Closed MichaelClerx closed 4 years ago
We could do a version that exposes the myokit internals to the user, or we could do one that just uses myokit to read & validate, and then exposes a sympy interface to the user (more like it is now). Personally I'd keep sympy out of the loop until the very last step: Only once units etc are no longer necessary convert it all to sympy, allow simplification and jacobians etc., and then pass on to cg
I can see the value of this BUT are we not a bit late in the day to be completely rewriting things (again !).
I'm currently concentrating on unit conversion but if the above is going to happen am I doing stuff that will just get over written ?
I don't think it's worth changing over at this stage! Also, I'm not convinced by the idea of having a separate maths representation and then changing to sympy for some manipulations. The design philosophy of cellmlmanip was to use best-of-breed libraries for each aspect of model manipulation (maths, units, rdf). (It was unfortunate that sympy's units support turned out to be very weak!) Myokit would be itself a large dependency for Web Lab/Chaste with many features we don't need, I believe.
Oh, and cellmlmanip only has 5 dependencies to Myokit's 6! (If you discount the GUI & optional stuff.)
Oh, and cellmlmanip only has 5 dependencies to Myokit's 6! (If you discount the GUI & optional stuff.)
OK
Myokit would be itself a large dependency for Web Lab/Chaste with many features we don't need, I believe.
Every dependency has lots of functionality you don't need. We only use 1 function from networkx for example. And sympy has lots of stuff we don't use.
The design philosophy of cellmlmanip was to use best-of-breed libraries for each aspect of model manipulation
But it doesn't hide any of those libraries! We're just making the user use them directly leading to this confused situation where they need to know about (1) sympy, (2) pint, (3) how our API ties them together, (4) networkx, (5) which bits of info go in networkx and which go in our sympy equations
Cellmlmanip doesn't wrap around these internals, it exposes them and makes users use bits of them - but not other bits. How is that user friendly?
But it's not trying to wrap around them! It's giving users an easy way of parsing CellML into sympy for manipulation etc. without losing the critical units & annotation information. Exposing sympy was a conscious design decision, to avoid writing our own less complete symbolic manipulation library (like pycml is).
The networkx dependency is the only one I think is marginal, as (lexicographic) topological sorting is pretty easy to implement. But equally, if you have a graph you want to do graph algorithms on, why not use the already written and well tested leading Python graph library?
Because it's one more thing for users, developers, and maintainers to learn about. And one more breakable thing that's outside our control.
We're doing this:
So we've got sympy-but-not-quite expressions in step 1 and 2, and then sympy expressions in step 3 and 4 (after user interaction is over). So why make the user interact with sympy-but-not-quite in the first 2 steps?
Equally, why make them learn another expression tree representation to do steps 1-2 from that used in steps 3-4?
They don't do 3 and 4, they only do 1 and 2. Steps 3 and 4 are under the hood. So all we give to users is the hacks-on-top-of-sympy bit. They never see the nice bit where all the cellml stuff is gone
Benefits
myokit.Plus(myokit.Name(x), myokit.Number(2, myokit.units.mV))
and a user-friendly parsing-based formy.set_rhs('x + 2 [mV]')
.A
touA/cm^2
https://myokit.readthedocs.io/api_core/units.html#myokit.Unit.conversion_factorSome downsides:
It can also do some of the things
cg
does, although I thinkcg
does them in a nicer way (with jinja templates)