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

Numpy 2.0.0 breaks things #1049

Closed
wd15 opened this issue Jun 17, 2024 · 2 comments · Fixed by #1050
Closed

Numpy 2.0.0 breaks things #1049

wd15 opened this issue Jun 17, 2024 · 2 comments · Fixed by #1050

Comments

@wd15
Copy link
Contributor

wd15 commented Jun 17, 2024

Running with Numpy 2.0.0 breaks things. See fipy.log.

Test failures like this:

   Traceback (most recent call last):                                                                                                                                                         
      File "/nix/store/ffy6s77zhixlwvzprz5j0zj4ma8n8h2q-python3-3.11.8/lib/python3.11/doctest.py", line 1355, in __run                                                                         
        exec(compile(example.source, filename, "single",                                                                                                                                       
...                                                                                             
      File "/nix/store/4xbcd56id9azry5srn5fwh83qlin9lgb-python3-3.11.8-env/lib/python3.11/site-packages/fipy/variables/meshVariable.py", line 99, in __init__                                  
        dtype = numerix.obj2sctype(value)                                                                                                                                                      
                ^^^^^^^^^^^^^^^^^^                                                                                                                                                             
    AttributeError: module 'fipy.tools.numerix' has no attribute 'obj2sctype'

Versions are as follows:

python 3.11.8 (main, Feb 6 2024, 21:21:21) [GCC 12.3.0]
fipy 3.4.4
numpy 2.0.0
pysparse not installed
scipy 1.13.1
matplotlib 3.9.0

@guyer
Copy link
Member

guyer commented Jun 17, 2024

numpy.obj2sctype was deprecated in numpy 2.0.0. It looks like its original usage of converting to numpy's internal data types was deprecated in numpy 1.20.0.

Unfortunately, the proposed replacement, np.dtype(obj).type, cannot be used as FiPy used numpy.obj2sctype, e.g., with numpy 1.24.3:

>>> np.obj2sctype(np.array([1.0, 2.0]))
numpy.float64

but, with numpy 1.24.3 or 2.0.0,

>>> np.dtype(np.array([1.0, 2.0])).type
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Cannot construct a dtype from an array
>>> np.array([1.0, 2.0]).dtype
dtype('float64')

works with either, but I'm not sure if that covers all the cases where we used it.

@guyer
Copy link
Member

guyer commented Jun 18, 2024

I think I've fixed these issues in #1050

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

Successfully merging a pull request may close this issue.

2 participants