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

Issue when import pyssht #206

Open
ASKabalan opened this issue Jul 29, 2024 · 4 comments · May be fixed by #210
Open

Issue when import pyssht #206

ASKabalan opened this issue Jul 29, 2024 · 4 comments · May be fixed by #210
Labels
blocker Blocking other or upcoming tasks

Comments

@ASKabalan
Copy link
Collaborator

Trying to finish up my PR #204
I ran to an issue

  File "<string>", line 1, in <module>
  File "/home/wassim/Projects/CMB/s2fft/s2fft/__init__.py", line 2, in <module>
    from .transforms import wigner
  File "/home/wassim/Projects/CMB/s2fft/s2fft/transforms/__init__.py", line 1, in <module>
    from . import spherical
  File "/home/wassim/Projects/CMB/s2fft/s2fft/transforms/spherical.py", line 16, in <module>
    from s2fft.transforms import c_backend_spherical as c_sph
  File "/home/wassim/Projects/CMB/s2fft/s2fft/transforms/c_backend_spherical.py", line 8, in <module>
    import pyssht
  File "/home/wassim/micromamba/envs/jax/lib/python3.10/site-packages/pyssht/__init__.py", line 11, in <module>
    from pyssht.cpyssht import *
  File "cpyssht.pyx", line 1, in init pyssht.cpyssht
ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use '<void>numpy._import_array' to disabl
e if you are certain you don't need it).

I think that there is an issue with pyssht and it prevents is from even importing s2fft

I commented it in three places

And I set c_sph to None

Just to be able to test my PR

I will look into it if you want, but the wise thing to do here is to wrap the import with a try catch et dynamically deactivate pyssht if it not working

@ASKabalan ASKabalan added the blocker Blocking other or upcoming tasks label Jul 29, 2024
@ASKabalan
Copy link
Collaborator Author

The issue is because of pyproject.toml I am gonna look into it

@as2875
Copy link

as2875 commented Sep 10, 2024

Firstly, thanks for your great work on S2FFT!

I ran into this issue while installing S2FFT using pip in a Conda environment. It seems the issue is that pyssht, which is imported by default by s2fft, is built against an old version of NumPy.

This is related to astro-informatics/ssht#74.

I tried to build pyssht from source. The build completes, but now I get

>>> import pyssht
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "[...]/pyssht/__init__.py", line 11, in <module>
    from pyssht.cpyssht import *
  File "cpyssht.pyx", line 1, in init pyssht.cpyssht
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

@as2875
Copy link

as2875 commented Sep 11, 2024

My workaround is to set numpy<2 in my package's pyproject.toml.

@CosmoMatt
Copy link
Collaborator

Hey @as2875 great to hear you're finding the code useful! So this conflict was introduced when NumPy incremented to v2.0 last month. Ultimately this broke the python wrappers of the SSHT C package, as you say, and we have it on our todo list to fix.

The current workaround we'd suggest is exactly what you found, just ensure that numpy<2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Blocking other or upcoming tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants