Solve numpy/scipy dependency issues - #389
Conversation
|
The issue was that coeff_iterpol in the N3LO interpolator sometimes returns a scalar, sometimes an array. Scalarizing the output seems to do the trick. I explicitly checked it under numpy 2.4.6 |
"sometimes" makes me nervous 🙈 is there no clear reason? e.g. based on the argument types? you still have |
|
Sometimes is indeed a scary word, but I will have to look into what the interpolator does exactly and what’s inside the N3LO grids before verifying this🙈 we do really have to think about putting in soms proper benchmarks… And the test that I modified in the last dependency pr |
Radonirinaunimi
left a comment
There was a problem hiding this comment.
We should implement the fix at the core so that all calls (not only f2_nc and fl_nc here) get the correct behavior. See the following patch:
diff --git a/src/yadism/coefficient_functions/heavy/n3lo/__init__.py b/src/yadism/coefficient_functions/heavy/n3lo/__init__.py
index 7f095724..9dbe1180 100644
--- a/src/yadism/coefficient_functions/heavy/n3lo/__init__.py
+++ b/src/yadism/coefficient_functions/heavy/n3lo/__init__.py
@@ -22,7 +22,10 @@ def interpolator(coeff, nf, variation):
coeff = np.load(grid_path / grid_name)
grid_interpolator = RectBivariateSpline(xi_grid, eta_grid, coeff)
- # store result
- interpolators[grid_name] = grid_interpolator
+ def evaluate(xi, eta):
+ # `grid=False`: point evaluation. `.item()` avoids array->scalar `TypeError`.
+ return grid_interpolator(xi, eta, grid=False).item()
- return grid_interpolator
+ interpolators[grid_name] = evaluate
+
+ return evaluateWith this, we do not also need to lock numpy.
PS: I updated the description of the PR so that the root cause is explained for future reference.
|
Amazing, thank you @Radonirinaunimi |
In the end #383 (comment) comes to bite us in the .... .
A newer version of numpy introduces a matching issue between the scipy integration, and the numpy output.
An example error log is the following, when running with the FFNS scheme:
For now in this PR I have locked the numpy version to 2.2.4, but the purpose of this PR is to fix the matching for good.
Root Cause
In src/yadism/coefficient_functions/heavy/n3lo/init.py,
interpolator()returns a rawRectBivariateSplineandRectBivariateSpline.__call__withgrid=True(default if unspecified) always returns a 2D (1,1) array, never a bare scalar. Older numpy silently coerced that to afloatbut numpy >= 2.4 turned that into a hardTypeError.