BhallaLab / moose-core

C++ basecode and python scripting interface
https://moose.ncbs.res.in
GNU General Public License v3.0
15 stars 26 forks source link

setting stoich.path to stoich.ReacSystemPath for cross compartment model gives seg fault #426

Open hrani opened 4 years ago

hrani commented 4 years ago

https://github.com/BhallaLab/moose-examples/blob/master/snippets/crossComptSimpleReacGSSA.py.BROKEN line no 100-102 Stoich.path says DeprecationWarning:: Use Soitch::readSystemPath instead

  1. Stoich.cpp @ line no 44: reacSystemPath, but @ line no 281: message says readSystemPath, it should be reacSystemPath right?

  2. In new python binding this field reacSystemPath might not be exposed ( if try to print dir(stoich) this field is not showing)

  3. replacing in (100-102) crossComptSimpleReacGSSA.py.BROKEN from Stoich.path to Stoich.reacSystemPath gives a seg fault with Stoich::innerInstallReaction 3.a This happens for GSL and GSSA solvers for multiCompartment/crosscompartment model ( may be durning buildXreacs some reactions are not zombified or other way round) For single compartment model, I have set stoich.reacSystemPath and it works (scriptKineticSolver.py)

dilawar commented 4 years ago
  1. the fixes are in #427.getFieldNames is available on every moose.element. See the example in the PR for more details.

  2. dir(stoich) does not return C++ fields. To get them use getFieldNames. It is for two reasons: first, performance reason because python objects don't have to carry copies. Second, this behavior required odd hacks in the API (can't recall which one and can't find a note or commit.).

This is also the reason why isinstance does not work (#425, #423) as before in the new API. Use getFieldNames, getFieldDicts etc. and showfields to see the C++ level attributes. The generic attributes which are common to all moose elements (think moose.Neutral) are available in dir command.

There is probably a neat way to extend dir to include the output of getFieldNames as well (e.g. https://stackoverflow.com/questions/15507848/what-is-the-correct-way-to-override-the-dir-method). Not sure if it is worth the cost of making API a bit more convoluted.