mjhoptics / ray-optics

geometric ray tracing for optical systems
BSD 3-Clause "New" or "Revised" License
263 stars 54 forks source link

Numpy compatibility problem #150

Closed yatharthb97 closed 2 months ago

yatharthb97 commented 2 months ago

I did a fresh installation of the module from conda in a separate virtual environment, but couldn't import it:

>>> from rayoptics.environment import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/rayoptics/environment.py", line 28, in <module>
    import rayoptics.gui.appcmds as cmds
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/rayoptics/gui/appcmds.py", line 19, in <module>
    from rayoptics.codev import cmdproc
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/rayoptics/codev/cmdproc.py", line 16, in <module>
    from rayoptics.elem.surface import (DecenterData, Circular, Rectangular,
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/rayoptics/elem/surface.py", line 35, in <module>
    import transforms3d as t3d
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/transforms3d/__init__.py", line 10, in <module>
    from . import quaternions
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/transforms3d/quaternions.py", line 26, in <module>
    _MAX_FLOAT = np.maximum_sctype(np.float64)
                 ^^^^^^^^^^^^^^^^^
  File "/Users/byatharth/opt/miniconda3/envs/rayoptics/lib/python3.12/site-packages/numpy/__init__.py", line 397, in __getattr__
    raise AttributeError(
AttributeError: `np.maximum_sctype` was removed in the NumPy 2.0 release. Use a specific dtype instead. You should avoid relying on any implicit mechanism and select the largest dtype of a kind explicitly in the code.

Unfortunately, I have no experience with these things. Thanks for the help.

mjhoptics commented 2 months ago

Hello @yatharthb97, Sorry to hear of your difficulty. I had run into the problem on the conda release and fixed it there but apparently didn’t backport it to the pypi repo. The numpy version needs to be >=1.26.4 <2.0. I think this will work:

python -m pip install numpy==1.26.4

I’m on the road for several weeks and probably won’t be able to update a fix until I get back. Regards, Mike Hayford

mjhoptics commented 2 months ago

Fixed in version 0.9.1