usnistgov / fipy

FiPy is a Finite Volume PDE solver written in Python
http://pages.nist.gov/fipy/en/latest
Other
504 stars 148 forks source link

FiPY not working with numpy 1.25 #931

Closed MD-11F-RR closed 1 year ago

MD-11F-RR commented 1 year ago

This is a fresh install of fipy using anaconda, and all dependency is on default. Therefore, numpy 1.25 (released on 17 June) is installed.

However, issue occur when trying to create a grid, for example Grid1D. The following error message will come up on my computer. If I downgrade numpy to 1.24.0, everything seems to be fine. I assume downgrade numpy to 1.24.3 will also work, but I have not tried it yet.

I used a CLI to trigger this, using Grid1D. The error message is as followed:

(FIFI) C:\Users\(USERNAME)>python
Python 3.10.11 | packaged by Anaconda, Inc. | (main, May 16 2023, 00:55:32) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from fipy import *
>>> mesh=Grid1D(dx=1,Lx=100)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\meshes\factoryMeshes.py", line 192, in Grid1D
    return UniformGrid1D(dx=dx, nx=nx, overlap=overlap, communicator=communicator)
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\meshes\uniformGrid1D.py", line 76, in __init__
    self._setTopology()
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\meshes\uniformGrid1D.py", line 83, in _setTopology
    self._exteriorFaces = self.facesLeft | self.facesRight
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\meshes\abstractMesh.py", line 788, in facesLeft
    x = self.faceCenters[0]
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\meshes\abstractMesh.py", line 95, in faceCenters
    return FaceVariable(mesh=self, value=self._faceCenters,
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\variables\meshVariable.py", line 51, in __init__
    value = self._globalToLocalValue(value)
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\variables\meshVariable.py", line 121, in _globalToLocalValue
    value = value[..., self._globalOverlappingIDs]
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\variables\variable.py", line 1466, in __getitem__
    opShape=numerix._indexShape(index=index, arrayShape=self.shape),
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\tools\numerix.py", line 862, in _indexShape
    broadcastshape, skip = _compressIndexSubspaces(index=expanded, i=i)
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\tools\numerix.py", line 694, in _compressIndexSubspaces
    broadcastshape = _broadcastShape(broadcastshape, element.shape)
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\tools\numerix.py", line 933, in _broadcastShape
    shape1, shape2, broadcastshape = _broadcastShapes(shape1, shape2)
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\tools\numerix.py", line 920, in _broadcastShapes
    broadcastshape = tuple([maxzero(s, o) for s, o in zip(shape1, shape2)])
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\tools\numerix.py", line 920, in <listcomp>
    broadcastshape = tuple([maxzero(s, o) for s, o in zip(shape1, shape2)])
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\fipy\tools\numerix.py", line 917, in maxzero
    return max(s, o)
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\numpy\core\fromnumeric.py", line 2810, in max
    return _wrapreduction(a, np.maximum, 'max', axis, None, out,
  File "C:\Users\(USERNAME)\anaconda3\envs\FIFI\lib\site-packages\numpy\core\fromnumeric.py", line 88, in _wrapreduction
    return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
numpy.exceptions.AxisError: axis 101 is out of bounds for array of dimension 0
>>>
guyer commented 1 year ago

Thank you for reporting this. Our nightly CI started complaining about this on the 17th, but I didn't get a chance to start work on it until last night. I hope to push a fix out soon.