-
-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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
[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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Akhil-Sharma30
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Akhil-Sharma30, should be good to merge after Valentin's approval.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to take suggestions and do what is decided upon
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for taking too long to review, but the deprecation path sounds good to me!
pybamm/simulation.py
Outdated
@@ -177,6 +178,7 @@ def _set_random_seed(self): | |||
|
|||
def set_up_and_parameterise_experiment(self): | |||
""" | |||
This is a helper function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a helper function. |
CHANGELOG.md
Outdated
@@ -37,6 +37,7 @@ | |||
|
|||
## 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -11,6 +11,7 @@ | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -185,6 +187,8 @@ def set_up_and_parameterise_experiment(self): | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -209,12 +213,15 @@ def set_up_and_parameterise_experiment(self): | |||
|
|||
def set_up_and_parameterise_model_for_experiment(self): | |||
""" | |||
This is a helper function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a helper function. |
pybamm/simulation.py
Outdated
Set up self._model to be able to run the experiment (new version). | ||
In this version, a new model is created for each step. | ||
|
||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
@@ -325,7 +332,8 @@ def set_parameters(self): | |||
""" | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_experiment
andpybamm.Simulation.set_up_and_parameterise_model_for_experiment
made private inpybamm/simulation.py
Fixes #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: