The following works in numpy 1.23.5 but not in 1.24.3:
from astropy import units as u
import numpy as np
a = np.array([[1, 2], [3, 4]])
b = np.array([[5, 6], [7, 8]])
np.stack([a,b]*u.m)
With numpy 1.24.3, I get:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "<__array_function__ internals>", line 200, in stack
File "~/opt/anaconda3/lib/python3.9/site-packages/astropy/units/quantity.py", line 1683, in __array_function__
return super().__array_function__(function, types, args, kwargs)
File "~/opt/anaconda3/lib/python3.9/site-packages/numpy/core/shape_base.py", line 471, in stack
return _nx.concatenate(expanded_arrays, axis=axis, out=out,
File "<__array_function__ internals>", line 200, in concatenate
File "~/opt/anaconda3/lib/python3.9/site-packages/astropy/units/quantity.py", line 1688, in __array_function__
args, kwargs, unit, out = function_helper(*args, **kwargs)
TypeError: concatenate() got an unexpected keyword argument 'dtype'
While with numpy 1.23.5, I get:
<Quantity [[[1., 2.],
[3., 4.]],
[[5., 6.],
[7., 8.]]] m>
Am I doing something wrong or has been a bug introduced in numpy 1.24 or does astropy units have to be updated to work with the new numpy version?