Skip to content

Conversation

@thehrh
Copy link
Contributor

@thehrh thehrh commented Jan 9, 2026

All of the remaining dependencies are brought up to date (also see the linked issues). If I am not mistaken, none of these changes are expected to break existing PISA installations, and indeed don't seem to be doing so (as confirmed by successful unit and service tests in environments of mine without updated dependencies).

Note: Select "squash and merge" if and when this is merged to create a single commit.

@thehrh thehrh changed the title Update pint, numpy, scipy Update pint, numpy, scipy, python Jan 26, 2026
@thehrh thehrh changed the title Update pint, numpy, scipy, python Update numpy, pint, python, scipy, versioneer Jan 29, 2026
@thehrh thehrh marked this pull request as ready for review January 29, 2026 01:07
has_uncertainties = True
std_devs = obj.std_dev
obj = obj.nominal_value
elif isinstance(obj, np.ndarray) and np.issubsctype(obj, AffineScalarFunc):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I doubt this ever worked the way it was intended to, i.e., managed to only detect an ndarray that was created with uncertainties.

The reason is that np.issubsctype(obj, AffineScalarFunc) would determine the dtype of obj, but because AffineScalarFunc isn't a NumPy scalar subclass, the ndarray obj would have dtype=np.object_. Hence, the check couldn't detect whether the elements are AffineScalarFunc instances (and not, e.g., PISA Params, and would always return True. As shown below, np.issubsctype(np.object_, AffineScalarFunc) is True, as is np.issubdtype(np.object_, AffineScalarFunc)---probably because np.obj2sctype(AffineScalarFunc) yields np.object_.

Applying this check to an array with uncertainties created in two different ways:

>>> import numpy as np
>>> from pisa.core.param import Param
>>> from uncertainties import ufloat, unumpy
>>> from uncertainties.core import AffineScalarFunc
>>> arr1 = unumpy.uarray([1, 2], [0.01, 0.002])
>>> print(arr1.dtype)
object
>>> isinstance(arr1, np.ndarray)
True
>>> arr2 = np.array([ufloat(1, 0.1), ufloat(2, 0.002)])
>>> print(arr2.dtype)
object
>>> isinstance(arr2, np.ndarray)
True
>>> u1 = ufloat(1, 0.1)
>>> isinstance(u1, AffineScalarFunc)
True
>>> np.issubsctype(arr1, AffineScalarFunc)
True
>>> np.issubsctype(arr2, AffineScalarFunc)
True
>>> # but also:
>>> p = Param(name="x", value=0.1, prior=None, range=[0,1], is_fixed=True)
>>> arr3 = np.array([p, p])
>>> np.issubsctype(arr3, AffineScalarFunc)
True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On a related note, in old numpy (in my case 1.22.4), np.issubdtype(arr1.dtype, AffineScalarFunc) still worked, while now in numpy 2.3.5 it doesn't any longer (raises ValueError: dtype attribute is not a valid dtype instance for the second argument, AffineScalarFunc).

@thehrh thehrh added this to the 4.3 milestone Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants