Skip to content

Commit 3b50432

Browse files
committed
Test xarray naming post conversion
1 parent d066ae7 commit 3b50432

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

tests/test_legacy.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import numpy as np
44
import pytest
55
import scyjava as sj
6+
import xarray
67

78
# -- Fixtures --
89

@@ -13,6 +14,11 @@ def arr():
1314
return empty_array
1415

1516

17+
@pytest.fixture(scope="module")
18+
def xarr(arr):
19+
return xarray.DataArray(arr, name="test_xarray")
20+
21+
1622
@pytest.fixture(scope="module")
1723
def results_table(ij):
1824
if ij.legacy and ij.legacy.isActive():
@@ -141,6 +147,19 @@ def test_window_to_numpy_converts_active_image_to_xarray(ij, arr):
141147
assert (arr == new_arr.values).all
142148

143149

150+
def test_linked_dataset_convertsion_to_xarray(ij, xarr):
151+
ensure_legacy_enabled(ij)
152+
ensure_gui_available(ij)
153+
154+
# get a dataset, linked to an ImagePlus
155+
dataset = ij.py.to_dataset(arr)
156+
ij.ui().show(dataset)
157+
158+
# convert the image data to xarray
159+
xarr_out = ij.py.to_xarray(dataset)
160+
assert xarr_out.name == "test_xarray"
161+
162+
144163
def test_functions_throw_warning_if_legacy_not_enabled(ij):
145164
ensure_legacy_disabled(ij)
146165

0 commit comments

Comments
 (0)