Get function args - #881
Conversation
There was a problem hiding this comment.
There's something a bit jarring about having to pass in two lists that both refer to the same things but one is the object and the other is the string. It might be neater to do something like
pybamm.FunctionParameter("Voltage function [V]", dict_input={"Time [s]": pybamm.t})Then the FunctionParameter can work out what the input objects and strings are based on the dictionary keys and values
(edit: I wouldn't be against changing FunctionParameter to always have to take in a dictionary input of the above form. I think in general we should strive to only allow one way of doing things)
|
this is very useful. do we need the string description of the inputs? or can we just get them from symbol.name? then FunctionParameter can just take the function name and a list of symbols? i think it feels a bit clunky to pass in both the string and symbol. also, not a huge issue, but do people expect to call this from model to get info on the parameters? maybe in the future model.info could be used in a more general way |
|
@tinosulzer I am happy to change to a dict if we feel this is less messy. However, I opted for an optional list as it was the minimal change and definitely wouldn't interfere with any existing functionality (i.e. to_python or casadi and back etc which I didn't want to deal with but maybe this isn't a problem?). I think if we do go for the dict though, that we should enforce it consistently. Thoughts? @rtimms |
|
It should be fine because |
Codecov Report
@@ Coverage Diff @@
## develop #881 +/- ##
===========================================
+ Coverage 98% 98.03% +0.03%
===========================================
Files 208 208
Lines 10936 11016 +80
===========================================
+ Hits 10718 10800 +82
+ Misses 218 216 -2
Continue to review full report at Codecov.
|
valentinsulzer
left a comment
There was a problem hiding this comment.
looks good now, thanks, can you fix the coverage?
| V | ||
| + I | ||
| - pybamm.FunctionParameter( | ||
| "Current plus voltage function", {"Time [s]": pybamm.t} |
There was a problem hiding this comment.
nb: time isn't in seconds here, will open separate issue
There was a problem hiding this comment.
Happy to remove the seconds if want it to be dimensionless? Or thinking of changing input to be in seconds?
There was a problem hiding this comment.
I think we should do pybamm.t * self.param.timescale so that it is a dimensional time (that is how people will define it externally)
rtimms
left a comment
There was a problem hiding this comment.
great, thanks @Scottmar93 ! just a few minor points
valentinsulzer
left a comment
There was a problem hiding this comment.
Looks good to me but @rtimms might have more comments
Description
A helper function to get information on symbols in a model. Accessed by doing model.info("Negative electrode diffusivity [m2.s-1]"). This then displays class of the symbol associated with that name. If it is a functionparameter it lists the parameters it requires in this model.
Fixes #880
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:
$ flake8$ python run-tests.py --unit$ cd docsand then$ make clean; make htmlYou can run all three at once, using
$ python run-tests.py --quick.Further checks: