Skip to content
Snippets Groups Projects
Commit 51dc4a3a authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

Asarray copy

parent f0d2b219
No related branches found
No related tags found
1 merge request!611Asarray copy
Pipeline #66345 failed
......@@ -55,7 +55,7 @@ def test_flat_distances(distance):
y = [100, 100, 100, 0, 0]
h = [0, 10, 20, 30, 0]
z = [0, 0, 0, 0]
wdirs = [0, 30, 90]
wdirs = [-1e-10, 30, 90 + 1e-10]
site = FlatSite(distance=distance)
site.distance.setup(src_x_ilk=x, src_y_ilk=y, src_h_ilk=h, src_z_ilk=z)
......@@ -78,9 +78,9 @@ def test_flat_distances(distance):
[[-10, -10, -10]],
[[-20, -20, -20]],
[[-30, -30, -30]]])
npt.assert_array_equal(dw_indices_lkd[:, 0, :4], [[2, 1, 0, 3],
[2, 1, 0, 3],
[2, 3, 1, 0]])
npt.assert_array_equal(dw_indices_lkd[:, 0, :], [[0, 1, 2, 4, 3],
[2, 1, 0, 3, 4],
[3, 2, 1, 4, 0]])
@pytest.mark.parametrize('distance', [StraightDistance(),
......
......@@ -24,13 +24,14 @@ from scipy.special import gamma as sgamma
from autograd.scipy.special import gamma as agamma
def asarray(x, dtype=None, order=None):
def asarray(x, dtype=None, order=None, **kwargs):
# kwargs: copy, like, etc introduced in numpy >=2
if isinstance(x, (ArrayBox)):
return x
elif isinstance(x, DataArray) and isinstance(x.values, ArrayBox): # pragma: no cover
# only needed or called with some versions of xarray
return x.values
return np_asarray(x, dtype, order)
return np_asarray(x, dtype, order, **kwargs)
# def asanyarray(x, dtype=None, order=None):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment