@@ -13,32 +13,32 @@ class EEStoreStandardDatatypesTest(parameterized.TestCase):
1313 dict (
1414 testcase_name = 'int8' ,
1515 dtype = np .dtype ('int8' ),
16- expected_chunks = {'index' : 48 , 'width' : 1024 , 'height' : 1024 },
16+ expected_chunks = {'index' : 48 , 'width' : 1024 , 'height' : 512 },
1717 ),
1818 dict (
1919 testcase_name = 'int32' ,
2020 dtype = np .dtype ('int32' ),
21- expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 512 },
21+ expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 256 },
2222 ),
2323 dict (
2424 testcase_name = 'int64' ,
2525 dtype = np .dtype ('int64' ),
26- expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 256 },
26+ expected_chunks = {'index' : 48 , 'width' : 256 , 'height' : 256 },
2727 ),
2828 dict (
2929 testcase_name = 'float32' ,
3030 dtype = np .dtype ('float32' ),
31- expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 512 },
31+ expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 256 },
3232 ),
3333 dict (
3434 testcase_name = 'float64' ,
3535 dtype = np .dtype ('float64' ),
36- expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 256 },
36+ expected_chunks = {'index' : 48 , 'width' : 256 , 'height' : 256 },
3737 ),
3838 dict (
3939 testcase_name = 'complex64' ,
4040 dtype = np .dtype ('complex64' ),
41- expected_chunks = {'index' : 48 , 'width' : 512 , 'height' : 256 },
41+ expected_chunks = {'index' : 48 , 'width' : 256 , 'height' : 256 },
4242 ),
4343 )
4444 def test_auto_chunks__handles_standard_dtypes (self , dtype , expected_chunks ):
@@ -49,7 +49,7 @@ def test_auto_chunks__handles_standard_dtypes(self, dtype, expected_chunks):
4949 )
5050
5151
52- class EEStoreTest (absltest .TestCase ):
52+ class EEStoreTest (parameterized .TestCase ):
5353
5454 def test_auto_chunks__handles_range_of_dtype_sizes (self ):
5555 dt = 0
@@ -59,18 +59,36 @@ def test_auto_chunks__handles_range_of_dtype_sizes(self):
5959 except ValueError :
6060 self .fail (f'Could not handle data type size { dt } .' )
6161
62- def test_auto_chunks__is_optimal_for_powers_of_two (self ):
63- for p in range (10 ):
64- dt = 2 ** p
65- chunks = xee .EarthEngineStore ._auto_chunks (dt )
62+ def test_auto_chunks__matches_observed_values (self ):
63+ observed_results = {
64+ 1 : 50331648 ,
65+ 2 : 37748736 ,
66+ 4 : 31457280 ,
67+ 8 : 28311552 ,
68+ 16 : 26738688 ,
69+ 32 : 25952256 ,
70+ 64 : 25559040 ,
71+ 128 : 25362432 ,
72+ 256 : 25264128 ,
73+ 512 : 25214976 ,
74+ }
75+
76+ for dtype_bytes , expected_bytes in observed_results .items ():
77+ chunks = xee .EarthEngineStore ._auto_chunks (dtype_bytes )
78+ actual_bytes = np .prod (list (chunks .values ())) * (
79+ dtype_bytes + 1
80+ ) # added +1 to account for the mask byte
6681 self .assertEqual (
67- xee .REQUEST_BYTE_LIMIT , np .prod (list (chunks .values ())) * dt
82+ expected_bytes ,
83+ actual_bytes ,
84+ f'dtype_bytes: { dtype_bytes } , Expected: { expected_bytes } , '
85+ f'Actual: { actual_bytes } , Chunks: { chunks } ' ,
6886 )
6987
7088 def test_exceeding_byte_limit__raises_error (self ):
7189 dtype_size = 8
7290 # does not fail
73- chunks = {'index' : 48 , 'width' : 512 , 'height' : 256 }
91+ chunks = {'index' : 48 , 'width' : 256 , 'height' : 256 }
7492 ext ._check_request_limit (chunks , dtype_size , xee .REQUEST_BYTE_LIMIT )
7593
7694 # fails
0 commit comments