Skip to content

Commit

Permalink
Test cases are added.
Browse files Browse the repository at this point in the history
  • Loading branch information
dabhicusp committed Mar 7, 2024
1 parent 7a4525e commit 16edfa0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion xee/ext.py
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ def __init__(self, variable_name: str, ee_store: EarthEngineStore):
# It looks like different bands have different dimensions & transforms!
# Can we get this into consistent dimensions?
self._info = ee_store._band_attrs(variable_name)
self.dtype = _parse_dtype(self._info['data_type'])
self.dtype = np.dtype(np.float32)

x_min, y_min, x_max, y_max = self.bounds

Expand Down
14 changes: 13 additions & 1 deletion xee/ext_integration_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ def setUp(self):
),
n_images=64,
)
self.store_with_neg_mask_value = xee.EarthEngineStore(
ee.ImageCollection('LANDSAT/LC08/C01/T1').filterDate(
'2017-01-01', '2017-01-03'
),
n_images=64,
mask_value=-9999
)
self.lnglat_store = xee.EarthEngineStore(
ee.ImageCollection.fromImages([ee.Image.pixelLonLat()]),
chunks={'index': 256, 'width': 512, 'height': 512},
Expand Down Expand Up @@ -97,14 +104,19 @@ def test_can_create_object(self):
self.assertIsNotNone(arr)

self.assertEqual((64, 360, 180), arr.shape)
self.assertEqual(np.int32, arr.dtype)
self.assertEqual(np.float32, arr.dtype)
self.assertEqual('B4', arr.variable_name)

def test_basic_indexing(self):
arr = xee.EarthEngineBackendArray('B4', self.store)
self.assertEqual(np.isnan(arr[indexing.BasicIndexer((0, 0, 0))]), True)
self.assertEqual(np.isnan(arr[indexing.BasicIndexer((-1, -1, -1))]), True)

def test_basic_indexing_on_int_ee_image(self):
arr = xee.EarthEngineBackendArray('B4', self.store_with_neg_mask_value)
self.assertEqual(np.isnan(arr[indexing.BasicIndexer((0, 0, 0))]), True)
self.assertEqual(np.isnan(arr[indexing.BasicIndexer((-1, -1, -1))]), True)

def test_basic_indexing__nonzero(self):
arr = xee.EarthEngineBackendArray('longitude', self.lnglat_store)

Expand Down

0 comments on commit 16edfa0

Please sign in to comment.