Skip to content

Commit a625672

Browse files
committed
black
1 parent 35604bb commit a625672

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

autoarray/structures/grids/irregular_2d.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,13 @@ def __init__(self, values: Union[np.ndarray, List]):
4545
if type(values) is list:
4646
if isinstance(values[0], Grid2DIrregular):
4747
values = values
48+
elif isinstance(values[0], jnp.ndarray):
49+
values = jnp.asarray(values)
4850
else:
49-
values = np.asarray(values)
51+
try:
52+
values = np.asarray(values)
53+
except ValueError:
54+
pass
5055

5156
super().__init__(values)
5257

test_autoarray/structures/grids/test_irregular_2d.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ def test__furthest_distances_to_other_coordinates():
9595
def test__grid_of_closest_from():
9696
grid = aa.Grid2DIrregular(values=[(0.0, 0.0), (0.0, 1.0)])
9797

98-
grid_of_closest = grid.grid_of_closest_from(grid_pair=aa.Grid2DIrregular(np.array([[0.0, 0.1]])))
98+
grid_of_closest = grid.grid_of_closest_from(
99+
grid_pair=aa.Grid2DIrregular(np.array([[0.0, 0.1]]))
100+
)
99101

100102
assert (grid_of_closest == np.array([[0.0, 0.0]])).all()
101103

@@ -106,7 +108,9 @@ def test__grid_of_closest_from():
106108
assert (grid_of_closest == np.array([[0.0, 0.0], [0.0, 0.0], [0.0, 0.0]])).all()
107109

108110
grid_of_closest = grid.grid_of_closest_from(
109-
grid_pair=aa.Grid2DIrregular(np.array([[0.0, 0.1], [0.0, 0.2], [0.0, 0.9], [0.0, -0.1]]))
111+
grid_pair=aa.Grid2DIrregular(
112+
np.array([[0.0, 0.1], [0.0, 0.2], [0.0, 0.9], [0.0, -0.1]])
113+
)
110114
)
111115

112116
assert (

0 commit comments

Comments
 (0)