pybamm-team / PyBaMM

Fast and flexible physics-based battery models in Python
https://www.pybamm.org/
BSD 3-Clause "New" or "Revised" License
1.12k stars 547 forks source link

Updating parameters without default values #4578

Closed isaacbasil closed 1 week ago

isaacbasil commented 1 week ago

Hi,

As per my previous issue posted today, I want to start contributing to Pybamm, but I have never contributed to an open-source project before, so I am looking for an easy entry point to understand the process.

A second point came up in some work I was doing today: when trying to update a parameter that doesn't have a default value, the following error is given: "Cannot update parameter '{name}' as it does not have a default value. ({err.args[0]}). If you are sure you want to update this parameter, use param.update({{name: value}}, check_already_exists=False)"

However, if I follow this advice and use param.update({{name: value}} where param is a ParameterValues object, I get the following error, TypeError: unhashable type: 'dict'

Perhaps this is just a typo? If I remove one set of curly brackets it works fine - param.update({name: value}, check_already_exists=False)

Again, just looking for a simple fix to make my first pull request. Please let me know what you think of this and if I have missed something.

kratman commented 1 week ago

@isaacbasil Yes, this is likely just a string parsing error. I will investigate it and make a fix

isaacbasil commented 1 week ago

Ah ok. If it's as simple as what I described in the issue, could I try to make the fix? So that I can get experience contributing.

kratman commented 1 week ago

Ah ok. If it's as simple as what I described in the issue, could I try to make the fix? So that I can get experience contributing.

Sorry, I already had the fix done in another branch before I saw your comment

isaacbasil commented 1 week ago

No problem