[Bug]: pybamm.Simulation.set_parameters, pybamm.Simulation.set_up_and_parameterise_experiment and pybamm.Simulation.set_up_and_parameterise_model_for_experiment made private in simulation.py#3752
Conversation
valentinsulzer
left a comment
There was a problem hiding this comment.
Thanks @Akhil-Sharma30
valentinsulzer
left a comment
There was a problem hiding this comment.
You will need to also update the method names wherever they are called (which should only be inside the Simulation class)
There was a problem hiding this comment.
Thanks @Akhil-Sharma30 for the fix!
Edit: yes, I missed Valentin's note. Please update the methods too
This pull request needs extra changes, which I overlooked
Done. |
|
@all-contributors please add @Akhil-Sharma30 for docs |
|
I've put up a pull request to add @Akhil-Sharma30! 🎉 |
arjxn-py
left a comment
There was a problem hiding this comment.
Thanks @Akhil-Sharma30, should be good to merge after Valentin's approval.
Saransh-cpp
left a comment
There was a problem hiding this comment.
Ideally, we should deprecate these functions before making them private, given that they are visible in the API docs, but this might be fine if not a lot of users are using them. However, this should be documented in the CHANGELOG (as a breaking change) and the tests should be fixed (you can look at the logs in GH Actions to see where these functions are being used).
Added a deprecated warning inside the function and made them public and also mentioned this in the CHANGELOG.md |
a2baa6b to
4672625
Compare
…ent` in simulation
63f499a to
ad30142
Compare
pybamm/simulation.py
Outdated
| msg = "pybamm.simulation.set_up_and_parameterise_experiment is not meant to be accessed directly." | ||
| warn(msg, DeprecationWarning) |
There was a problem hiding this comment.
Given that not a lot of users are using these methods and we want to make them private in the next release - we could create dummy public methods that throw NameError on being invoked -
def set_up_and_parameterise_experiment(self):
"""
A note here for users that this should not be used and is not private
with the name _set_up_and_parameterise_experiment
"""
raise NameError(...)Just suggestions. We should go ahead with the strategy that most maintainers agree with.
There was a problem hiding this comment.
happy to take suggestions and do what is decided upon
There was a problem hiding this comment.
I don't think it's a good idea to make them private right in the next release, since it doesn't conform to our policy of three releases – even if the popularity of this API not being relatively high is the question. Keeping them public plus raising a DeprecationWarning should be enough, a NameError sounds a bit odd IMO (I don't think we have used this before).
Saransh-cpp
left a comment
There was a problem hiding this comment.
Sorry for taking too long to review, but the deprecation path sounds good to me!
pybamm/simulation.py
Outdated
|
|
||
| def set_up_and_parameterise_experiment(self): | ||
| """ | ||
| This is a helper function. |
There was a problem hiding this comment.
| This is a helper function. |
CHANGELOG.md
Outdated
|
|
||
| ## Breaking changes | ||
|
|
||
| - Added a deprecated warning for `pybamm.Simulation.set_parameters`, `pybamm.Simulation.set_up_and_parameterise_experiment` and `pybamm.Simulation.set_up_and_parameterise_model_for_experiment` functions in `pybamm.simulation.py`. ([#3752](https://github.com/pybamm-team/PyBaMM/pull/3752)) |
There was a problem hiding this comment.
You'll also need to shift it to the unreleased section
| - Added a deprecated warning for `pybamm.Simulation.set_parameters`, `pybamm.Simulation.set_up_and_parameterise_experiment` and `pybamm.Simulation.set_up_and_parameterise_model_for_experiment` functions in `pybamm.simulation.py`. ([#3752](https://github.com/pybamm-team/PyBaMM/pull/3752)) | |
| - Deprecated `pybamm.Simulation.set_parameters`, `pybamm.Simulation.set_up_and_parameterise_experiment` and `pybamm.Simulation.set_up_and_parameterise_model_for_experiment` functions in `pybamm.simulation.py`. ([#3752](https://github.com/pybamm-team/PyBaMM/pull/3752)) |
pybamm/simulation.py
Outdated
| from datetime import timedelta | ||
| from pybamm.util import have_optional_dependency | ||
| from typing import Optional | ||
| from warnings import warn |
There was a problem hiding this comment.
Nitpicking here, but we should keep this uniform throughout the codebase -
| from warnings import warn | |
| import warnings |
and then warnings.warn everywhere
pybamm/simulation.py
Outdated
| This needs to be done here and not in the Experiment class because the nominal | ||
| cell capacity (from the parameters) is used to convert C-rate to current. | ||
| """ | ||
| msg = "pybamm.simulation.set_up_and_parameterise_experiment is not meant to be accessed directly." |
There was a problem hiding this comment.
| msg = "pybamm.simulation.set_up_and_parameterise_experiment is not meant to be accessed directly." | |
| msg = "pybamm.simulation.set_up_and_parameterise_experiment is deprecated and not meant to be accessed by users" |
pybamm/simulation.py
Outdated
|
|
||
| def set_up_and_parameterise_model_for_experiment(self): | ||
| """ | ||
| This is a helper function. |
There was a problem hiding this comment.
| This is a helper function. |
pybamm/simulation.py
Outdated
| This increases set-up time since several models to be processed, but | ||
| reduces simulation time since the model formulation is efficient. | ||
| """ | ||
| msg = "pybamm.simulation.set_up_and_parameterise_model_for_experiment is not meant to be accessed directly." |
There was a problem hiding this comment.
| msg = "pybamm.simulation.set_up_and_parameterise_model_for_experiment is not meant to be accessed directly." | |
| msg = "pybamm.simulation.set_up_and_parameterise_model_for_experiment is deprecated not meant to be accessed by users" |
pybamm/simulation.py
Outdated
| A method to set the parameters in the model and the associated geometry. | ||
| """ | ||
|
|
||
| msg = "pybamm.set_paramters is meant to be accessed directly." |
There was a problem hiding this comment.
| msg = "pybamm.set_paramters is meant to be accessed directly." | |
| msg = "pybamm.set_paramters is deprecated and not meant to be accessed by users" |
|
I am not able to reset my branch I made a mess of it. Could someone provide me instruction on how to fix this issue? |
Can you provide some logs while you're trying to reset your branch? Although assuming that you might be getting merge conflicts while trying to reset to your branch i.e. :
|
Thanks for the help. I by mistake deleted the branch but when I was trying to bring the branch locally it was causing issue so I tried the If possible could you suggest me any method to bring that branch locally again so that I can do the changes. |
|
I am not very familiar with the GitHub CLI, but with git you should be able to do something like this - |
|
Hi @Akhil-Sharma30, any updates on this? |
40d152d
|
@Akhil-Sharma30 This has been open for quite a while are you working on this still? If not we should close it because there have been a lot of changes to PyBaMM since this was opened |
Apologize for the delay, I was busy with some work I will fix the changes in 1-2 days maximum. |
|
Could you also resolve the merge conflicts, @Akhil-Sharma30? |
If possible could you guide me from where can I solve these conflict? |
@Akhil-Sharma30 Honestly, your change is ~10 lines. It is probably easier to just redo this in a fresh PR. Just check out develop and redo the small changes |
Okay I have created a fresh PR for this. Just wanted to know if this |
|
Hi, it would be easier to open a new PR and request a review / ask your queries there. We'll be able to help you better in a fresh space. This PR is a bit too tangled now. |
|
I have created a new PR for this fix #4489 |
Description
pybamm.Simulation.set_parameters,pybamm.Simulation.set_up_and_parameterise_experimentandpybamm.Simulation.set_up_and_parameterise_model_for_experimentmade private inpybamm/simulation.pyFixes #3751
Type of change
Please add a line in the relevant section of CHANGELOG.md to document the change (include PR #) - note reverse order of PR #s. If necessary, also add to the list of breaking changes.
Key checklist:
$ pre-commit run(or$ nox -s pre-commit) (see CONTRIBUTING.md for how to set this up to run automatically when committing locally, in just two lines of code)$ python run-tests.py --all(or$ nox -s tests)$ python run-tests.py --doctest(or$ nox -s doctests)You can run integration tests, unit tests, and doctests together at once, using
$ python run-tests.py --quick(or$ nox -s quick).Further checks: