@@ -131,11 +131,14 @@ def test_scale_range():
131131 )
132132 )
133133
134- exp_data = (np_data - np_data .min ()) / np_data .max ()
134+ eps = 1.0e-6
135+ mi , ma = np_data .min (), np_data .max ()
136+ exp_data = (np_data - mi ) / (ma - mi + eps )
135137 expected = xr .DataArray (exp_data , dims = ("x" , "y" ))
136138
137139 result = preprocessing (data )
138- xr .testing .assert_allclose (expected , result )
140+ # NOTE xarray.testing.assert_allclose compares irrelavant properties here and fails although the result is correct
141+ np .testing .assert_allclose (expected , result )
139142
140143
141144def test_scale_range_axes ():
@@ -156,13 +159,15 @@ def test_scale_range_axes():
156159 )
157160 )
158161
162+ eps = 1.0e-6
159163 p_low = np .percentile (np_data , min_percentile , axis = (1 , 2 ), keepdims = True )
160164 p_up = np .percentile (np_data , max_percentile , axis = (1 , 2 ), keepdims = True )
161- exp_data = (np_data - p_low ) / p_up
165+ exp_data = (np_data - p_low ) / ( p_up - p_low + eps )
162166 expected = xr .DataArray (exp_data , dims = ("c" , "x" , "y" ))
163167
164168 result = preprocessing (data )
165- xr .testing .assert_allclose (expected , result )
169+ # NOTE xarray.testing.assert_allclose compares irrelavant properties here and fails although the result is correct
170+ np .testing .assert_allclose (expected , result )
166171
167172
168173def test_sigmoid ():
0 commit comments