From 51dc4a3a75be35cfa56f0a08b46a738755cace49 Mon Sep 17 00:00:00 2001
From: "Mads M. Pedersen" <mmpe@dtu.dk>
Date: Wed, 30 Oct 2024 08:59:55 +0000
Subject: [PATCH] Asarray copy

---
 py_wake/tests/test_sites/test_distances.py | 8 ++++----
 py_wake/utils/gradients.py                 | 5 +++--
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/py_wake/tests/test_sites/test_distances.py b/py_wake/tests/test_sites/test_distances.py
index bf5182a10..3e0f1429f 100644
--- a/py_wake/tests/test_sites/test_distances.py
+++ b/py_wake/tests/test_sites/test_distances.py
@@ -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(),
diff --git a/py_wake/utils/gradients.py b/py_wake/utils/gradients.py
index 563cbd248..23f04efcc 100644
--- a/py_wake/utils/gradients.py
+++ b/py_wake/utils/gradients.py
@@ -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):
-- 
GitLab