File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change 3
3
import numpy as np
4
4
import pytest
5
5
import scyjava as sj
6
+ import xarray
6
7
7
8
# -- Fixtures --
8
9
@@ -13,6 +14,11 @@ def arr():
13
14
return empty_array
14
15
15
16
17
+ @pytest .fixture (scope = "module" )
18
+ def xarr (arr ):
19
+ return xarray .DataArray (arr , name = "test_xarray" )
20
+
21
+
16
22
@pytest .fixture (scope = "module" )
17
23
def results_table (ij ):
18
24
if ij .legacy and ij .legacy .isActive ():
@@ -141,6 +147,19 @@ def test_window_to_numpy_converts_active_image_to_xarray(ij, arr):
141
147
assert (arr == new_arr .values ).all
142
148
143
149
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
+
144
163
def test_functions_throw_warning_if_legacy_not_enabled (ij ):
145
164
ensure_legacy_disabled (ij )
146
165
You can’t perform that action at this time.
0 commit comments