earthengine-api 1.5.20rc0__py3-none-any.whl → 1.5.21rc0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of earthengine-api might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: earthengine-api
3
- Version: 1.5.20rc0
3
+ Version: 1.5.21rc0
4
4
  Summary: Earth Engine Python API
5
5
  Author-email: Google LLC <noreply@google.com>
6
6
  License: Apache-2.0
@@ -1,5 +1,5 @@
1
- earthengine_api-1.5.20rc0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
2
- ee/__init__.py,sha256=qPcRFNQNq5dD59LAjW-KiTHgnBU0-9aTJIF6fXCPHTc,16867
1
+ earthengine_api-1.5.21rc0.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
2
+ ee/__init__.py,sha256=VuJ2nCg0wUazK8D1HKTDyu3rTGy1nGOxccoBVnz8VAY,16867
3
3
  ee/_arg_types.py,sha256=iKWKK4KjkgIv6s4hZDCakHLdBxVp3jcoBsbaJYjtIe4,2674
4
4
  ee/_cloud_api_utils.py,sha256=ABvZ6h80GHndnoDVM6Q0i8xsFe4z5gD6K1sGpU4T8TA,32485
5
5
  ee/_helpers.py,sha256=roBMok5ZvoWmQx2Pd4F26uTFN1q-SNeoFiHo-aGuE0A,4684
@@ -17,7 +17,7 @@ ee/customfunction.py,sha256=fc-c0FuhX2En6iCMparExnn2gl592MV5_09D8lXDIME,7403
17
17
  ee/data.py,sha256=Jntk9lXyHUrhzxhfPmdh3ygaAE3Pgef4LpILoBqL96c,88678
18
18
  ee/daterange.py,sha256=5HArg4214QKmEj6ZQR3ZTLwMtVW5DUCVGjdz1wbdeyc,5009
19
19
  ee/deprecation.py,sha256=DCSrDE5kVxOJLiuZXKw1rSreRVFlVOt8HXRKN1VUQ4o,6068
20
- ee/deserializer.py,sha256=D6y0Td_LVsG82YnGKYvKHkF1PRM9Nu7_887VhLDhO9I,8168
20
+ ee/deserializer.py,sha256=sIQB-4jcZFmG40jMfxTFc1Eq9RaMxsH4WbYqhvaKSO0,8432
21
21
  ee/dictionary.py,sha256=x_NR18NoCuGVEq0hM6jnjiJte2BzFIkD6iR3tRES--0,10554
22
22
  ee/ee_array.py,sha256=eWGkxxn8rELf_xI9JKXFkx3Xp1YXDyD86sbRaFn1bNg,36375
23
23
  ee/ee_date.py,sha256=C6tv5VyLB5O-0zon9GbwcyfQ2ika3puZRYe52ffCd2E,10839
@@ -27,7 +27,7 @@ ee/ee_number.py,sha256=zb5LyiA4j24ml-B8ib4DTFne0Dzry2K4bSYhEdturtI,22615
27
27
  ee/ee_string.py,sha256=gNMEJIWxRGiAa-FQrHYeAtEqdU9vJgXv4zyas3DHRZQ,7761
28
28
  ee/ee_types.py,sha256=MWfXc0h3KgT8bLraI6qw-b0D3ogVkY5aDZKM3eoTsJA,3089
29
29
  ee/element.py,sha256=awb1ufzfC9YwzonH0V3KKkTRbM-sFc2yPoSDjFsHjLE,6305
30
- ee/encodable.py,sha256=vifFNsZt6WxZA3qpJR9Lg94YdLQEOj2Bh0CffrINcL8,1734
30
+ ee/encodable.py,sha256=ZzZBOVOEwc8a8Dby3oHwIhW-5za-4tvLDE0Q2oVaNwQ,1884
31
31
  ee/errormargin.py,sha256=worYjc36VNP_M76NxlCFpXtq1HBfHThug1sOKUkaV8Q,3061
32
32
  ee/feature.py,sha256=TwXn_uwvjBOremgoow-dbykFL59h6ortI1I7UDLdM-8,30543
33
33
  ee/featurecollection.py,sha256=BZbhXhpSJD87RrilBVVJZb3pH-_w7ZuNd4tdSSPr620,14510
@@ -70,7 +70,7 @@ ee/tests/confusionmatrix_test.py,sha256=L7-yXE1XkWmw-n890Vra9WrjgoxP3R1qwtq2mDtc
70
70
  ee/tests/data_test.py,sha256=HNHI2RDL9oFzA_-dG48zYtpc10I9HeCdFa5vtyndInY,35299
71
71
  ee/tests/daterange_test.py,sha256=CFVCIrfGz7ZqZCjAbyrP-j3tsd4auDdS-Pu8xvqEc5A,8589
72
72
  ee/tests/deprecation_test.py,sha256=P3_Rn8-7QqfQ9ztvxrTlqF9-oL3Y-brCmxgMVbc75Qc,8358
73
- ee/tests/deserializer_test.py,sha256=0zWOJS5AQwpdm4RGFu0navyOKMOAutEh94ELY1kyCjg,3041
73
+ ee/tests/deserializer_test.py,sha256=-tbrL0cjrXdSLF7M3wl-QQuj6TjXJdkjp7RZvVErUy4,3427
74
74
  ee/tests/dictionary_test.py,sha256=k8iVRCtWZ6_uvGZy7L40z3ZG0AJnhlwqowf1TCKQKoQ,11815
75
75
  ee/tests/ee_array_test.py,sha256=9AFv0_d12fWmG84bMNVyLBPne3cc0KVO4KvnzEdTkpI,50274
76
76
  ee/tests/ee_date_test.py,sha256=csMDTfBf-F_vkpnP6C8wvvfKBgoHFyUqn1rFZ2kAORQ,11112
@@ -100,8 +100,8 @@ ee/tests/reducer_test.py,sha256=wzwESob1ZPtC2IfkmDYFkL631Ph9VtmCl2UhQQOzZBc,3152
100
100
  ee/tests/serializer_test.py,sha256=5aApenGb9_tOTM4J8zFcT0JFzAOO_Av6dYGFz93COP8,8814
101
101
  ee/tests/table_converter_test.py,sha256=HSZpEvDG-H1RATnQXcZNR8O3kEJdJ3rHc-46KTiOWpY,3385
102
102
  ee/tests/terrain_test.py,sha256=kV901v89SBKzgSNqG6k3wxh3IdDfQeNdxmD5f9ouV18,4334
103
- earthengine_api-1.5.20rc0.dist-info/METADATA,sha256=BjYtzu53xUsN-3FtyZX6aiW29kCtw9-oHpHpIJ3db_c,2146
104
- earthengine_api-1.5.20rc0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
105
- earthengine_api-1.5.20rc0.dist-info/entry_points.txt,sha256=-Ax4SCU-S474r8OD2LIxata6PRmkZoDrppQ4fP_exNc,50
106
- earthengine_api-1.5.20rc0.dist-info/top_level.txt,sha256=go5zOwCgm5lIS3yTR-Vsxp1gNI4qdS-MP5eY-7zMxVY,3
107
- earthengine_api-1.5.20rc0.dist-info/RECORD,,
103
+ earthengine_api-1.5.21rc0.dist-info/METADATA,sha256=gVy3TYUbVtEpP2t4ebS2XWPf1FzyZO1jeRs0sLHLejo,2146
104
+ earthengine_api-1.5.21rc0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
105
+ earthengine_api-1.5.21rc0.dist-info/entry_points.txt,sha256=-Ax4SCU-S474r8OD2LIxata6PRmkZoDrppQ4fP_exNc,50
106
+ earthengine_api-1.5.21rc0.dist-info/top_level.txt,sha256=go5zOwCgm5lIS3yTR-Vsxp1gNI4qdS-MP5eY-7zMxVY,3
107
+ earthengine_api-1.5.21rc0.dist-info/RECORD,,
ee/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
  """The EE Python library."""
2
2
 
3
- __version__ = '1.5.20rc0'
3
+ __version__ = '1.5.21rc0'
4
4
 
5
5
  # Using lowercase function naming to match the JavaScript names.
6
6
  # pylint: disable=g-bad-name
ee/deserializer.py CHANGED
@@ -1,6 +1,7 @@
1
1
  """A deserializer that decodes EE object trees from JSON DAGs."""
2
2
 
3
3
  import json
4
+ from typing import Any, Union
4
5
 
5
6
  from ee import apifunction
6
7
  from ee import computedobject
@@ -12,7 +13,7 @@ from ee import function
12
13
  from ee import geometry
13
14
 
14
15
 
15
- def fromJSON(json_obj): # pylint: disable=g-bad-name
16
+ def fromJSON(json_obj: Union[bytes, str]) -> Any: # pylint: disable=g-bad-name
16
17
  """Deserialize an object from a JSON string appropriate for API calls.
17
18
 
18
19
  Args:
@@ -24,7 +25,7 @@ def fromJSON(json_obj): # pylint: disable=g-bad-name
24
25
  return decode(json.loads(json_obj))
25
26
 
26
27
 
27
- def decode(json_obj):
28
+ def decode(json_obj: Any) -> Any:
28
29
  """Decodes an object previously encoded using the EE API v2 (DAG) format.
29
30
 
30
31
  Args:
@@ -50,7 +51,8 @@ def decode(json_obj):
50
51
  return _decodeValue(json_obj, named_values)
51
52
 
52
53
 
53
- def _decodeValue(json_obj, named_values): # pylint: disable=g-bad-name
54
+ # pylint: disable-next=g-bad-name
55
+ def _decodeValue(json_obj: Any, named_values: dict[str, Any]) -> Any:
54
56
  """Decodes an object previously encoded using the EE API v2 (DAG) format.
55
57
 
56
58
  This uses a provided scope for ValueRef lookup and does not allow the
@@ -82,7 +84,7 @@ def _decodeValue(json_obj, named_values): # pylint: disable=g-bad-name
82
84
  if json_obj['value'] in named_values:
83
85
  return named_values[json_obj['value']]
84
86
  else:
85
- raise ee_exception.EEException('Unknown ValueRef: ' + json_obj)
87
+ raise ee_exception.EEException(f'Unknown ValueRef: {json_obj}')
86
88
  elif type_name == 'ArgumentRef':
87
89
  var_name = json_obj['value']
88
90
  if not isinstance(var_name, str):
@@ -132,7 +134,7 @@ def _decodeValue(json_obj, named_values): # pylint: disable=g-bad-name
132
134
  raise ee_exception.EEException('Unknown encoded object type: ' + type_name)
133
135
 
134
136
 
135
- def _invocation(func, args):
137
+ def _invocation(func: Any, args: dict[str, Any]) -> Any:
136
138
  """Creates an EE object representing the application of `func` to `args`."""
137
139
  if isinstance(func, function.Function):
138
140
  return func.apply(args)
@@ -151,7 +153,7 @@ def _invocation(func, args):
151
153
  raise ee_exception.EEException('Invalid function value: %s' % func)
152
154
 
153
155
 
154
- def fromCloudApiJSON(json_obj): # pylint: disable=g-bad-name
156
+ def fromCloudApiJSON(json_obj: Union[str, bytes]) -> Any: # pylint: disable=g-bad-name
155
157
  """Deserializes an object from the JSON string used in Cloud API calls.
156
158
 
157
159
  Args:
@@ -163,7 +165,8 @@ def fromCloudApiJSON(json_obj): # pylint: disable=g-bad-name
163
165
  return decodeCloudApi(json.loads(json_obj))
164
166
 
165
167
 
166
- def decodeCloudApi(json_obj): # pylint: disable=g-bad-name
168
+ # pylint: disable-next=g-bad-name
169
+ def decodeCloudApi(json_obj: dict[str, Any]) -> Any:
167
170
  """Decodes an object previously encoded using the EE Cloud API format.
168
171
 
169
172
  Args:
@@ -206,14 +209,16 @@ def decodeCloudApi(json_obj): # pylint: disable=g-bad-name
206
209
  return lookup(node['valueReference'], 'reference')
207
210
  return None
208
211
 
209
- def decode_function_definition(defined):
212
+ def decode_function_definition(
213
+ defined: dict[str, Any],
214
+ ) -> customfunction.CustomFunction:
210
215
  body = lookup(defined['body'], 'function body')
211
216
  signature_args = [{'name': name, 'type': 'Object', 'optional': False}
212
217
  for name in defined['argumentNames']]
213
218
  signature = {'args': signature_args, 'name': '', 'returns': 'Object'}
214
219
  return customfunction.CustomFunction(signature, lambda *args: body)
215
220
 
216
- def decode_function_invocation(invoked):
221
+ def decode_function_invocation(invoked: dict[str, Any]) -> Any:
217
222
  if 'functionReference' in invoked:
218
223
  func = lookup(invoked['functionReference'], 'function')
219
224
  else:
ee/encodable.py CHANGED
@@ -1,10 +1,12 @@
1
1
  """Interfaces implemented by serializable objects."""
2
2
 
3
+ from typing import Any, Callable
4
+
3
5
 
4
6
  class Encodable:
5
7
  """An interface implemented by objects that can serialize themselves."""
6
8
 
7
- def encode(self, encoder):
9
+ def encode(self, encoder: Callable[[Any], Any]) -> Any:
8
10
  """Encodes the object in a format compatible with Serializer.
9
11
 
10
12
  Args:
@@ -16,7 +18,7 @@ class Encodable:
16
18
  """
17
19
  raise NotImplementedError('Encodable classes must implement encode().')
18
20
 
19
- def encode_cloud_value(self, encoder):
21
+ def encode_cloud_value(self, encoder: Callable[[Any], Any]) -> Any:
20
22
  """Encodes the object as a ValueNode.
21
23
 
22
24
  Args:
@@ -33,7 +35,7 @@ class Encodable:
33
35
  class EncodableFunction:
34
36
  """An interface implemented by functions that can serialize themselves."""
35
37
 
36
- def encode_invocation(self, encoder):
38
+ def encode_invocation(self, encoder: Callable[[Any], Any]) -> Any:
37
39
  """Encodes the function in a format compatible with Serializer.
38
40
 
39
41
  Args:
@@ -46,7 +48,7 @@ class EncodableFunction:
46
48
  raise NotImplementedError(
47
49
  'EncodableFunction classes must implement encode_invocation().')
48
50
 
49
- def encode_cloud_invocation(self, encoder):
51
+ def encode_cloud_invocation(self, encoder: Callable[[Any], Any]) -> Any:
50
52
  """Encodes the function as a FunctionInvocation.
51
53
 
52
54
  Args:
@@ -12,7 +12,7 @@ from ee import serializer
12
12
 
13
13
  class DeserializerTest(apitestcase.ApiTestCase):
14
14
 
15
- def testLegacyRoundTrip(self):
15
+ def test_legacy_roundtrip(self):
16
16
  """Verifies a round trip of a comprehensive serialization case."""
17
17
  encoded = apitestcase.ENCODED_JSON_SAMPLE
18
18
  decoded = deserializer.decode(encoded)
@@ -25,7 +25,7 @@ class DeserializerTest(apitestcase.ApiTestCase):
25
25
  serializer.toJSON(cloud_decoded, for_cloud_api=True))
26
26
  self.assertEqual(cloud_encoded, cloud_re_encoded)
27
27
 
28
- def testCloudRoundTrip(self):
28
+ def test_cloud_roundtrip(self):
29
29
  """Verifies a round trip of a comprehensive serialization case."""
30
30
  cloud_encoded = apitestcase.ENCODED_CLOUD_API_JSON_SAMPLE
31
31
  cloud_decoded = deserializer.decode(cloud_encoded) # Supports both formats
@@ -38,7 +38,7 @@ class DeserializerTest(apitestcase.ApiTestCase):
38
38
  re_encoded = json.loads(serializer.toJSON(decoded, for_cloud_api=False))
39
39
  self.assertEqual(encoded, re_encoded)
40
40
 
41
- def testCast(self):
41
+ def test_cast(self):
42
42
  """Verifies that decoding casts the result to the right class."""
43
43
  input_image = ee.Image(13).addBands(42)
44
44
  output = deserializer.fromJSON(serializer.toJSON(input_image))
@@ -47,7 +47,7 @@ class DeserializerTest(apitestcase.ApiTestCase):
47
47
  serializer.toJSON(input_image, for_cloud_api=True))
48
48
  self.assertIsInstance(cloud_output, ee.Image)
49
49
 
50
- def testReuse(self):
50
+ def test_reuse(self):
51
51
  """Verifies that decoding results can be used and re-encoded."""
52
52
  input_image = ee.Image(13)
53
53
  output = deserializer.fromJSON(serializer.toJSON(input_image))
@@ -60,7 +60,7 @@ class DeserializerTest(apitestcase.ApiTestCase):
60
60
  cloud_output.addBands(42).serialize(),
61
61
  input_image.addBands(42).serialize())
62
62
 
63
- def testImageExpression(self):
63
+ def test_image_expression(self):
64
64
  """Verifies that ee.Image.expression results can be re-encoded."""
65
65
  image = ee.Image(13)
66
66
  expression = image.expression('x', {'x': image})
@@ -69,5 +69,17 @@ class DeserializerTest(apitestcase.ApiTestCase):
69
69
  expression_re_encoded = serializer.toJSON(expression_decoded)
70
70
  self.assertEqual(expression_encoded, expression_re_encoded)
71
71
 
72
+ def test_unknown_value_ref(self):
73
+ """Verifies raising Unknown ValueRef in _decodeValue()."""
74
+ encoded = {
75
+ 'type': 'CompoundValue',
76
+ 'scope': [['key', {'type': 'ValueRef', 'value': 'bar'}]],
77
+ }
78
+ with self.assertRaisesRegex(
79
+ ee.EEException, "Unknown ValueRef: {'type': 'ValueRef', 'value': 'bar'}"
80
+ ):
81
+ deserializer.decode(encoded)
82
+
83
+
72
84
  if __name__ == '__main__':
73
85
  unittest.main()