3
3
from tempfile import TemporaryDirectory
4
4
5
5
import numpy as np
6
+ import xarray
6
7
7
8
from depiction .misc .integration_test_utils import IntegrationTestUtils
8
9
from depiction .persistence import ImzmlReadFile , ImzmlModeEnum , ImzmlWriteFile
@@ -39,12 +40,14 @@ def test_merge_continuous(self) -> None:
39
40
40
41
with ImzmlReadFile (self .mock_output_file_path ).reader () as reader :
41
42
spectra = reader .get_spectra ([0 , 1 , 2 ])
42
- coordinates = reader .coordinates
43
+ coordinates = reader .coordinates_array_2d
43
44
self .assertEqual (ImzmlModeEnum .CONTINUOUS , reader .imzml_mode )
44
45
45
46
np .testing .assert_array_equal (np .array ([[100 , 200 , 300 ], [100 , 200 , 300 ], [100 , 200 , 300 ]]), spectra [0 ])
46
47
np .testing .assert_array_equal (np .array ([[1 , 2 , 3 ], [2 , 2 , 2 ], [4 , 5 , 6 ]]), spectra [1 ])
47
- np .testing .assert_array_equal (np .array ([[0 , 0 , 1 ], [0 , 1 , 1 ], [5 , 1 , 1 ]]), coordinates )
48
+ xarray .testing .assert_equal (
49
+ xarray .DataArray ([[0 , 0 ], [0 , 1 ], [5 , 1 ]], dims = ("i" , "d" ), coords = {"d" : ["x" , "y" ]}), coordinates
50
+ )
48
51
49
52
def test_merge_processed (self ) -> None :
50
53
IntegrationTestUtils .populate_test_file (
@@ -69,7 +72,7 @@ def test_merge_processed(self) -> None:
69
72
70
73
with ImzmlReadFile (self .mock_output_file_path ).reader () as reader :
71
74
spectra = reader .get_spectra ([0 , 1 , 2 ])
72
- coordinates = reader .coordinates
75
+ coordinates = reader .coordinates_array_2d
73
76
self .assertEqual (ImzmlModeEnum .PROCESSED , reader .imzml_mode )
74
77
75
78
self .assertEqual (3 , len (spectra [0 ]))
@@ -80,8 +83,9 @@ def test_merge_processed(self) -> None:
80
83
np .testing .assert_array_equal (np .array ([1 , 2 , 3 ]), spectra [1 ][0 ])
81
84
np .testing .assert_array_equal (np .array ([2 , 2 ]), spectra [1 ][1 ])
82
85
np .testing .assert_array_equal (np .array ([3 , 3 , 3 , 3 ]), spectra [1 ][2 ])
83
-
84
- np .testing .assert_array_equal (np .array ([[0 , 0 , 1 ], [0 , 1 , 1 ], [5 , 1 , 1 ]]), coordinates )
86
+ xarray .testing .assert_equal (
87
+ xarray .DataArray ([[0 , 0 ], [0 , 1 ], [5 , 1 ]], dims = ("i" , "d" ), coords = {"d" : ["x" , "y" ]}), coordinates
88
+ )
85
89
86
90
87
91
if __name__ == "__main__" :
0 commit comments