astro-informatics / ssht

Fast and exact spin spherical harmonic transforms
http://astro-informatics.github.io/ssht/
GNU General Public License v3.0
11 stars 2 forks source link

Support `numpy>=2` #74

Closed paddyroddy closed 2 months ago

paddyroddy commented 2 months ago

Following the release of numpy v2 importing pyssht in an environment with numpy==2.0.0 installed results in the following error

A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last):  File "/private/tmp/.venv/bin/ipython", line 8, in <module>
    sys.exit(start_ipython())
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/__init__.py", line 130, in start_ipython
    return launch_new_instance(argv=argv, **kwargs)
  File "/private/tmp/.venv/lib/python3.12/site-packages/traitlets/config/application.py", line 1075, in launch_instance
    app.start()
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/terminal/ipapp.py", line 317, in start
    self.shell.mainloop()
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/terminal/interactiveshell.py", line 917, in mainloop
    self.interact()
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/terminal/interactiveshell.py", line 910, in interact
    self.run_cell(code, store_history=True)
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3075, in run_cell
    result = self._run_cell(
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3130, in _run_cell
    result = runner(coro)
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/core/async_helpers.py", line 129, in _pseudo_sync_runner
    coro.send(None)
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3334, in run_cell_async
    has_raised = await self.run_ast_nodes(code_ast.body, cell_name,
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3517, in run_ast_nodes
    if await self.run_code(code, result, async_=asy):
  File "/private/tmp/.venv/lib/python3.12/site-packages/IPython/core/interactiveshell.py", line 3577, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-1-7fab22e9eefd>", line 1, in <module>
    import pyssht
  File "/private/tmp/.venv/lib/python3.12/site-packages/pyssht/__init__.py", line 11, in <module>
    from pyssht.cpyssht import *
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 1
----> 1 import pyssht

File /private/tmp/.venv/lib/python3.12/site-packages/pyssht/__init__.py:11
      5 __doc__ = (Path(__file__).parent / "SSHT_Python_Documentation.md").read_text()
      7 from pyssht.exceptions import (
      8     ssht_spin_error as ssht_spin_error,
      9     ssht_input_error as ssht_input_error,
     10 )
---> 11 from pyssht.cpyssht import *

File cpyssht.pyx: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 disable if you are certain you don't need it).