Skip to content

Install NumPy < 2.0 along with Assess#402

Merged
benfulton merged 1 commit into
mainfrom
use_numpy_one
Jul 9, 2026
Merged

Install NumPy < 2.0 along with Assess#402
benfulton merged 1 commit into
mainfrom
use_numpy_one

Conversation

@benfulton

Copy link
Copy Markdown
Contributor

Apparently the Assess install in the CI Dockerfile has started to bring in NumPy 2.0. This should work in the general case, but many tests rely on earlier versions of NumPy and will fail under NumPy 2.0. Additionally, since we compile the application under Numpy 1.0, updating it to 2.0 at the end will cause problems. The solution is to install NumPy<2.0 alongside Assess at the end of the dockerfiles.

@benfulton benfulton requested a review from stephankramer July 6, 2026 07:54

@stephankramer stephankramer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, makes sense. Any idea why some tests fail with numpy 2? We should probably fix that as it's more and more likely to be what users have

@benfulton benfulton merged commit d2331b2 into main Jul 9, 2026
197 checks passed
@benfulton benfulton deleted the use_numpy_one branch July 9, 2026 05:39
@benfulton

Copy link
Copy Markdown
Contributor Author

NumPy 2 introduced a lot of breaking changes, e.g. size-1 arrays like np.array([3.14]) are no longer implicitly convertible to Python scalars. A lot of the tests rely on this - particle_dt_test is an example:

import numpy as np
import h5py
from fluidity_tools import stat_parser

f = h5py.File('particle_attributes.particles.DtMeasure.h5part', 'r')
z = stat_parser("particle_attributes.stat")
dt_errors = np.zeros(10,float)

for i in range(10):
    d = f['/Step#{}'.format(len(f)-(10-i))]
    val = d['DtVal'][:]
    dt_errors[i] =  val- z['dt']['value'][i+1]
dt_error=abs(dt_errors).max()
print ("max error",dt_error)
Variable computation raised an exception
--------------------------------------------------------------------------------
  1  import numpy as np
  2  import h5py
  3  from fluidity_tools import stat_parser
  4  
  5  f = h5py.File('particle_attributes.particles.DtMeasure.h5part', 'r')
  6  z = stat_parser("particle_attributes.stat")
  7  dt_errors = np.zeros(10,float)
  8  
  9  for i in range(10):
 10      d = f['/Step#{}'.format(len(f)-(10-i))]
 11      val = d['DtVal'][:]
 12      dt_errors[i] =  val- z['dt']['value'][i+1]
 13  dt_error=abs(dt_errors).max()
 14  print ("max error",dt_error)
--------------------------------------------------------------------------------
TypeError: only 0-dimensional arrays can be converted to Python scalars

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/bfulton/GIT/fluidity/python/fluidity/regressiontest.py", line 363, in run_python
    exec(self.code, varsdict)
    ~~~~^^^^^^^^^^^^^^^^^^^^^
  File "<string>", line 12, in <module>
ValueError: setting an array element with a sequence.
--------------------------------------------------------------------------------
particle_dt_test: failure.

Summary of test problems with failures or warnings:
particle_dt_test.xml: F

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 this pull request may close these issues.

2 participants