Skip to content

Commit

Permalink
Test case updated with np.testing.assert_equal.
Browse files Browse the repository at this point in the history
  • Loading branch information
dabhicusp committed Feb 15, 2024
1 parent 1929891 commit a0e3d56
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions xee/ext_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,28 +114,21 @@ def test_basic_indexing__nonzero(self):
def test_basic_indexing_multiple_images(self):
arr = xee.EarthEngineBackendArray('B4', self.store)
first_two = arr[indexing.BasicIndexer((slice(0, 2), 0, 0))]
self.assertTrue(np.allclose(first_two, np.full(2, np.nan), equal_nan=True))
np.testing.assert_equal(first_two, np.full(2, np.nan))
first_three = arr[indexing.BasicIndexer((slice(0, 3), 0, 0))]
self.assertTrue(
np.allclose(first_three, np.full(3, np.nan), equal_nan=True)
)
np.testing.assert_equal(first_three, np.full(3, np.nan))
last_two = arr[indexing.BasicIndexer((slice(-3, -1), 0, 0))]
self.assertTrue(np.allclose(last_two, np.full(2, np.nan), equal_nan=True))
np.testing.assert_equal(last_two, np.full(2, np.nan))
last_three = arr[indexing.BasicIndexer((slice(-4, -1), 0, 0))]
self.assertTrue(np.allclose(last_three, np.full(3, np.nan), equal_nan=True))
np.testing.assert_equal(last_three, np.full(3, np.nan))

def test_slice_indexing(self):
arr = xee.EarthEngineBackendArray('B5', self.store)
first_10 = indexing.BasicIndexer((0, slice(0, 10), slice(0, 10)))
self.assertTrue(
np.allclose(arr[first_10], np.full((10, 10), np.nan), equal_nan=True)
)
np.testing.assert_equal(arr[first_10], np.full((10, 10), np.nan))
last_5 = indexing.BasicIndexer((0, slice(-5, -1), slice(-5, -1)))
expected_last_5 = np.full((4, 4), np.nan)
self.assertTrue(
np.allclose(expected_last_5, arr[last_5], equal_nan=True),
f'Actual:\n{arr[last_5]}',
)
np.testing.assert_equal(expected_last_5, arr[last_5])

def test_slice_indexing__non_global(self):
arr = xee.EarthEngineBackendArray('spi2y', self.conus_store)
Expand Down Expand Up @@ -194,17 +187,12 @@ def test_keys_to_slices(self):
def test_slice_indexing_multiple_images(self):
arr = xee.EarthEngineBackendArray('B5', self.store)
first_10 = indexing.BasicIndexer((slice(0, 2), slice(0, 10), slice(0, 10)))
self.assertTrue(
np.allclose(arr[first_10], np.full((2, 10, 10), np.nan), equal_nan=True)
)
np.testing.assert_equal(arr[first_10], np.full((2, 10, 10), np.nan))
last_5 = indexing.BasicIndexer(
(slice(-3, -1), slice(-5, -1), slice(-5, -1))
)
expected_last_5 = np.full((2, 4, 4), np.nan)
self.assertTrue(
np.allclose(expected_last_5, arr[last_5], equal_nan=True),
f'Actual:\n{arr[last_5]}',
)
np.testing.assert_equal(expected_last_5, arr[last_5])

def test_slice_indexing__medium(self):
try:
Expand Down

0 comments on commit a0e3d56

Please sign in to comment.