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

New python bindings using pybind11- many of function not exposed #418

Open
hrani opened this issue Aug 25, 2020 · 4 comments
Open

New python bindings using pybind11- many of function not exposed #418

hrani opened this issue Aug 25, 2020 · 4 comments
Assignees

Comments

@hrani
Copy link
Contributor

hrani commented Aug 25, 2020

function like
getId(), getDataIndex(),
mooseWriteSBML,mooseReadSBML
mooseWriteKkit
is not available at python binding level.

@hrani
Copy link
Contributor Author

hrani commented Aug 25, 2020

moose.Neutral('/m')
moose.CubeMesh('/m/c')
f = moose.Function('/m/c/f')
moose.showfield(f)
Not sure what does "derivative" hold in case of function, earlier it use to be
derivative = 0.0 now its saying Nan
derivative = nan

@dilawar
Copy link
Contributor

dilawar commented Aug 26, 2020

function like
getId(), getDataIndex(),
mooseWriteSBML,mooseReadSBML
mooseWriteKkit
is not available at python binding level.

getId and getDataIndex are avaiable as a field.

In [7]: b = moose.Neutral('/a')                                                                                                                                 

In [8]: a.getId()                                                                                                                                               
Out[8]: <moose.vec: class=Neutral, id=448, path=/a>

In [9]: a.getDataIndex()                                                                                                                                        
Out[9]: 0
  • mooseWriteSBML is changed to [writeSBML](https://github.com/BhallaLab/moose-core/blob/b4aac15bf9e696c442f8d4c972f329d16ff97f7f/python/moose/__init__.py#L766). Similarly mooseReadSBML, and mooseWriteKkit are renamed to readSBML and writeKkit. You can create an alias in python/__init__.py file.

You may want to check pybind11/module.cpp as well.

When a value is assigned to a moose element, derivative does not make sense. For computing derivative, you need at least 2 values (f(x+h) - f(x)/h). In old API, it was initialized to 0.0. It doesn't break any existing code.

@hrani
Copy link
Contributor Author

hrani commented Aug 31, 2020

In [7]: b = moose.Neutral('/a')                                                                                                                                 

In [8]: a.getId()                                                                                                                                               
Out[8]: <moose.vec: class=Neutral, id=448, path=/a>

In [9]: a.getDataIndex()                                                                                                                                        
Out[9]: 0

ipython3
Python 3.8.2 (default, Jul 16 2020, 14:00:26)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.13.0 -- An enhanced Interactive Python. Type '?' for help.

moose.about()
Out[1]:
{'path': '/home/harsha/moose/moose-core/python/moose',
'version': '3.2.0.dev20200826',
'docs': 'https://moose.readthedocs.io/en/latest/',
'development': 'https://github.com/BhallaLab/moose-core'}

b = moose.Neutral('/a')
b.getDataIndex()
KeyError Traceback (most recent call last)
in
----> 1 b.getDataIndex()
KeyError: "getDataIndex is not found on '/a[0]'."

b.getId()
KeyError Traceback (most recent call last)
in
----> 1 b.getId()
KeyError: "getId is not found on '/a[0]'."

* `mooseWriteSBML` is changed to `[writeSBML](https://github.com/BhallaLab/moose-core/blob/b4aac15bf9e696c442f8d4c972f329d16ff97f7f/python/moose/__init__.py#L766)`. Similarly `mooseReadSBML`, and `mooseWriteKkit` are renamed to `readSBML` and `writeKkit`. You can create an alias in `python/__init__.py` file.

I know writeSBML,readSBML,writeKkit works and this makes more sense which I always preferred but in the documentation it still says as mooseWriteSBML and snippets also failing due to this.

You may want to check pybind11/module.cpp as well.

When a value is assigned to a moose element, derivative does not make sense. For computing derivative, you need at least 2 >values (f(x+h) - f(x)/h). In old API, it was initialized to 0.0. It doesn't break any existing code.

Yes its not breaking any existing code, but warning as in earlier API it was initialized 0.0 which is better than Nan

Also in documentation, specially cookbook
https://moose.readthedocs.io/en/latest/user/py/cookbook/
https://moose.ncbs.res.in/readthedocs/user/py/cookbook/
has different version, the one which is on moose.ncbs.res.in is the latest

@dilawar
Copy link
Contributor

dilawar commented Aug 31, 2020

#422 fixes the missing getFieldIndex, getDataIndex functions. I miswrote in the previous update: they were available as dataIndex, fieldIndex. Sorry about that! Only one script in the moose-examples, still uses getDataIndex. If they have made into the published code, I'd suggest to deprecate them in favor of fieldIndex and dataIndex.

About missing mooseReadSBML etc., it's up to you and @upibhalla to either tweak the API or change the docs. It's a one-line change in the __init__.py. As far as I can recall, mooseReadSBML etc. were introduced because C++ had the name-clash with this readSBML etc. function which is no longer the case.

About derivative set to nan in the beginning, it is mathematically correct now and does not break any code. There is no need to make it wrong.

Many other PRs I've opened are diverging and getting stale and I hardly hear about them for 2-3 months. I am feeling a little less motivated to work on this project.

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

3 participants