pybop-team / PyBOP

A parameterisation and optimisation package for battery models.
https://pybop-docs.readthedocs.io
BSD 3-Clause "New" or "Revised" License
54 stars 13 forks source link

Running comparing_cost_functions.ipynb throws error #414

Closed Dibyendu-IITKGP closed 1 month ago

Dibyendu-IITKGP commented 1 month ago

Python Version

Python 3.10.12

Describe the bug

I was running the examples from the notebook folder. All of them run ok except one. comparing_cost_functions.ipynb is throwing error while calling rvs method.

Steps to reproduce the behaviour

In the example folder go to notebook and then run comparing_cost_functions.ipynb.

Relevant log output

No response

NicolaCourtier commented 1 month ago

Hi @Dibyendu-IITKGP, please refer to this discussion about notebooks: https://github.com/pybop-team/PyBOP/discussions/344 The develop version of the notebook should be run with the develop branch of PyBOP. Otherwise please use the main version.

BradyPlanden commented 1 month ago

Interestingly, @Dibyendu-IITKGP has installed from develop. I'm reopening this to confirm if the pip install from develop is causing problems on Linux machines, or a mismatch in virtual envs. I can confirm on MacOS that pip install git+https://github.com/pybop-team/PyBOP.git@develop in a new virtualenv allows the notebook in question to run correctly (after installing plotly).

@Dibyendu-IITKGP can you confirm you're jupyter instance is targetting the right virtualenv?

Dibyendu-IITKGP commented 1 month ago

@BradyPlanden yes, the virtual environment is rightly set up. I am using vs code to run in linux. In vs code, I have selected the same venv where I installed and re-installed (as per your suggestion) PyBOP. Used this earlier today (pip install git+https://github.com/pybop-team/PyBOP.git@develop --force-reinstall).

NicolaCourtier commented 1 month ago

The expected error when running the develop version of the notebook using the main version of PyBOP is:

TypeError                                 Traceback (most recent call last)
Cell In[10], [line 1](vscode-notebook-cell:?execution_count=10&line=1)
----> [1](vscode-notebook-cell:?execution_count=10&line=1) sample = parameters.rvs()
      [2](vscode-notebook-cell:?execution_count=10&line=2) print(sample)
      [3](vscode-notebook-cell:?execution_count=10&line=3) cost_SSE(sample)

TypeError: Parameters.rvs() missing 1 required positional argument: 'n_samples'

Is this the error that you see @Dibyendu-IITKGP?

Dibyendu-IITKGP commented 1 month ago

yes, it is.

Dibyendu-IITKGP commented 1 month ago

Working now as per @BradyPlanden 's suggestion, replace the %pip install pybop -q in the first cell of the notebook with: %pip install git+https://github.com/pybop-team/PyBOP.git@develop --force-reinstall