pyglow icon indicating copy to clipboard operation
pyglow copied to clipboard

Compatibility with numpy 1.21

Open Luca-ggmb opened this issue 3 years ago • 11 comments

I have managed to install pyglow with all the .so files appearing in the respective dl_models folders. After installing the python package I have tried to import into a Jupyter notebook and get the following error message:

cannot import name 'iri_sub' from 'iri12py' (/home/s1637615/.local/lib/python3.8/site-packages/iri12py.cpython-38-x86_64-linux-gnu.so)

Is this an issue with installation?

Also, when i executed the python2 setup.py install --user command hundreds of the following warnings came up:

`Warning: Array reference at (1) is out of bounds (68 > 1) in dimension 1 src/pyglow/models/dl_models/hwm93/hwm93_modified.f:715:27:

715 | $ (PB(53)*BT(3,2)+PB(99)*BT(5,2)+PB(68)*BT(7,2))`

Is the best option to reinstall?

Thanks, Luca

Luca-ggmb avatar Jun 25 '21 16:06 Luca-ggmb

I often get a ton of those warnings. These come from compiling the underlying Fortran code (IRI, MSIS, etc.) so it's not something we can control unfortunately.

The first issue regarding iri_sub is more critical and likely implies that IRI did not install correctly.

It looks like you used python2 to install but your local Python is running 3.8. Maybe that's (part of) the issue?

bharding512 avatar Jul 02 '21 16:07 bharding512

I have the same issue, can't get pyglow running.

ImportError: cannot import name 'iri_sub' from 'iri12py' (/home/mag-proc/.local/lib/python3.8/site-packages/iri12py.cpython-38-x86_64-linux-gnu.so

It's definitely installed in the correct Python 3.8 path. So what happened?

jarau-de avatar Jan 31 '22 08:01 jarau-de

Does anything in the long installation output look like a fatal error during the IRI install? If the .so was created, it seems like it installed. If you can attach the log here I could see if anything pops out to me.

Did IRI16 install ok?

bharding512 avatar Jan 31 '22 17:01 bharding512

Ok, I found the reason. I was using Numpy 1.21. It seems something has changed from 1.20 to 1.21. f2py_rout_iri12py_iri_sub is missing in the new f2py compilation. Obviously the f2py interface is not included in the library and that's the reason why it's not being seen during Python import of pyglow. It is reproducible and concerns also IRI16. Maybe you could check that. I don't see errors during compilation and libraries are created and installed as expected. Maybe I have overseen something. Only the f2py interface is absent. It would be nice to use Pyglow also with most recent Numpy versions.

jarau-de avatar Jan 31 '22 17:01 jarau-de

It would be nice to use Pyglow also with most recent Numpy versions.

I think this is actually critical. I'm changing the name of this issue to reflect this. Thanks for tracking this down. (And open to PRs or any tips)

bharding512 avatar Jan 31 '22 17:01 bharding512

Is there any progress on that issue?

It would be nice to use Pyglow also with most recent Numpy versions.

I think this is actually critical. I'm changing the name of this issue to reflect this. Thanks for tracking this down. (And open to PRs or any tips)

Is there any progress on that topic?

jarau-de avatar Mar 28 '22 13:03 jarau-de

No progress yet. I'm very open to ideas and PRs.

bharding512 avatar Mar 28 '22 16:03 bharding512

@Vaylyn reports that pyglow is also incompatible with numpy 1.22, so it appears this problem will not solve itself. This is probably pyglow's most critical issue at this time.

bharding512 avatar Jun 01 '22 17:06 bharding512

Same issue encountered: can be fixed temporarily by including a version constraint in numpy in the requirement.txt file

danielk333 avatar Sep 14 '22 13:09 danielk333

Confirmed pyglow works on python 3.9 but not on 3.10 since numpy 1.20 is only compatible up to python 3.9

danielk333 avatar Sep 14 '22 13:09 danielk333

The cause are the COMMON blocks in the signature file sig_file_patched.pyf. Obviously f2py (>v1.20, exactly crackfortran.py) has some trouble with compiling that. If one comment out the COMMONs compilation runs smoothly. What also seems to work is to modify the end of the enclosing data block: END BLOCK DATA -> END BLOCKDATA. Just simply remove the space between BLOCK and DATA and f2py is happy. ENDBLOCKDATA works too. Maybe one could add a patch for Pyglow until Numpy gets fixed. I also reported an issue to Numpy bug tracker.

jarau-de avatar Nov 22 '22 15:11 jarau-de