Skip to content
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

issues with "New python bindings using pybind11" #423

Closed
hrani opened this issue Sep 6, 2020 · 2 comments
Closed

issues with "New python bindings using pybind11" #423

hrani opened this issue Sep 6, 2020 · 2 comments

Comments

@hrani
Copy link
Contributor

hrani commented Sep 6, 2020

moose.le('/') works but

  1. moose.le('/r') which is not defined or created it gives
    moose.element: /r does not exist!
    Segmentation fault (core dumped)

  2. isinstance of super class gives False
    n = moose.Neutral('/n')
    c = moose.CubeMesh('/n/cube')
    isinstance(c,moose.ChemCompt)
    returns False should be True as CubeMesh is inherited from ChemCompt which was the True before new python bindings

dilawar pushed a commit to dilawar/pymoose-community that referenced this issue Sep 7, 2020
moose.le('/elmenent_that_does_not_exists') now raises ValueError like
version 3.1.x and does not fail with a seg-fault.
@dilawar
Copy link
Contributor

dilawar commented Sep 7, 2020

The PR #424 fixes the seg-fault issue with moose.le.

isinstance does not work as before in new binding. Have a look at #410 (comment) which summaries the changes.

Also see #404 (comment) and https://labnotes.ncbs.res.in/comment/2322#comment-2322 and follow-up discussion on issue #404 on why isA and not isinstance is not a good way to check the base class.

The current recommendation is to use isA as you have also mentioned in #404 (comment) that you are aware of https://labnotes.ncbs.res.in/comment/2322#comment-2322 (though not sure though what you meant here).

Nonetheless, to summarise, following is the behavious of new bindings:

n = moose.Neutral('/n')
c = moose.CubeMesh('/n/cube')
print(isinstance(c, moose.CubeMesh))        # True
print(isinstance(c, moose.ChemCompt))     # False 
print(c.isA['ChemCompt'])                       # True

The line isinstance(c, moose.ChemCompt) is no longer True in new bindings. You must use c.isA['ChemCompt'] (notice the square bracket, though () also works).

@hrani
Copy link
Contributor Author

hrani commented Sep 7, 2020

Yes my mistake, I had changed this in the moose-gui, will do for SBML reader and writer also.

@hrani hrani closed this as completed Sep 7, 2020
hrani pushed a commit that referenced this issue Sep 7, 2020
moose.le('/elmenent_that_does_not_exists') now raises ValueError like
version 3.1.x and does not fail with a seg-fault.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants