earthengine-api 1.5.13rc0__py3-none-any.whl → 1.7.4__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.

Files changed (102) hide show
  1. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/METADATA +3 -3
  2. earthengine_api-1.7.4.dist-info/RECORD +109 -0
  3. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/WHEEL +1 -1
  4. ee/__init__.py +29 -28
  5. ee/_arg_types.py +7 -6
  6. ee/_cloud_api_utils.py +95 -78
  7. ee/_helpers.py +17 -13
  8. ee/_state.py +105 -0
  9. ee/_utils.py +2 -1
  10. ee/apifunction.py +21 -19
  11. ee/apitestcase.py +33 -38
  12. ee/batch.py +87 -77
  13. ee/blob.py +10 -12
  14. ee/classifier.py +57 -59
  15. ee/cli/commands.py +178 -114
  16. ee/cli/eecli.py +1 -1
  17. ee/cli/utils.py +61 -42
  18. ee/clusterer.py +39 -41
  19. ee/collection.py +64 -54
  20. ee/computedobject.py +19 -16
  21. ee/confusionmatrix.py +9 -9
  22. ee/customfunction.py +13 -12
  23. ee/data.py +220 -322
  24. ee/daterange.py +10 -10
  25. ee/deprecation.py +21 -13
  26. ee/deserializer.py +25 -20
  27. ee/dictionary.py +11 -11
  28. ee/ee_array.py +22 -20
  29. ee/ee_date.py +23 -23
  30. ee/ee_list.py +15 -16
  31. ee/ee_number.py +11 -21
  32. ee/ee_string.py +24 -32
  33. ee/ee_types.py +4 -4
  34. ee/element.py +15 -15
  35. ee/encodable.py +7 -4
  36. ee/errormargin.py +4 -4
  37. ee/feature.py +68 -71
  38. ee/featurecollection.py +41 -40
  39. ee/filter.py +90 -92
  40. ee/function.py +8 -8
  41. ee/geometry.py +95 -93
  42. ee/image.py +238 -236
  43. ee/image_converter.py +4 -4
  44. ee/imagecollection.py +30 -27
  45. ee/join.py +13 -15
  46. ee/kernel.py +55 -57
  47. ee/mapclient.py +9 -9
  48. ee/model.py +29 -31
  49. ee/oauth.py +76 -63
  50. ee/pixeltype.py +6 -6
  51. ee/projection.py +5 -4
  52. ee/reducer.py +41 -41
  53. ee/serializer.py +14 -14
  54. ee/table_converter.py +7 -6
  55. ee/terrain.py +7 -9
  56. ee/tests/_cloud_api_utils_test.py +21 -6
  57. ee/tests/_helpers_test.py +57 -4
  58. ee/tests/_state_test.py +49 -0
  59. ee/tests/algorithms.json +85 -2
  60. ee/tests/apifunction_test.py +5 -5
  61. ee/tests/batch_test.py +135 -57
  62. ee/tests/blob_test.py +5 -5
  63. ee/tests/classifier_test.py +3 -3
  64. ee/tests/clusterer_test.py +3 -3
  65. ee/tests/collection_test.py +48 -13
  66. ee/tests/confusionmatrix_test.py +3 -3
  67. ee/tests/data_test.py +484 -55
  68. ee/tests/daterange_test.py +4 -4
  69. ee/tests/deprecation_test.py +6 -4
  70. ee/tests/deserializer_test.py +64 -5
  71. ee/tests/dictionary_test.py +12 -12
  72. ee/tests/ee_array_test.py +3 -3
  73. ee/tests/ee_date_test.py +4 -4
  74. ee/tests/ee_list_test.py +3 -3
  75. ee/tests/ee_number_test.py +75 -30
  76. ee/tests/ee_string_test.py +11 -3
  77. ee/tests/ee_test.py +40 -22
  78. ee/tests/element_test.py +2 -2
  79. ee/tests/errormargin_test.py +1 -1
  80. ee/tests/feature_test.py +10 -10
  81. ee/tests/featurecollection_test.py +3 -3
  82. ee/tests/filter_test.py +4 -4
  83. ee/tests/function_test.py +5 -5
  84. ee/tests/geometry_point_test.py +3 -3
  85. ee/tests/geometry_test.py +93 -52
  86. ee/tests/image_converter_test.py +1 -3
  87. ee/tests/image_test.py +3 -3
  88. ee/tests/imagecollection_test.py +3 -3
  89. ee/tests/join_test.py +3 -3
  90. ee/tests/kernel_test.py +7 -3
  91. ee/tests/model_test.py +17 -5
  92. ee/tests/oauth_test.py +189 -7
  93. ee/tests/pixeltype_test.py +6 -7
  94. ee/tests/projection_test.py +5 -6
  95. ee/tests/reducer_test.py +16 -3
  96. ee/tests/serializer_test.py +39 -12
  97. ee/tests/table_converter_test.py +51 -7
  98. ee/tests/terrain_test.py +11 -3
  99. earthengine_api-1.5.13rc0.dist-info/RECORD +0 -107
  100. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/entry_points.txt +0 -0
  101. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/licenses/LICENSE +0 -0
  102. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/top_level.txt +0 -0
@@ -6,7 +6,7 @@ DateRange is currently 100% dynamically generated.
6
6
 
7
7
  import datetime
8
8
  import json
9
- from typing import Any, Dict
9
+ from typing import Any
10
10
 
11
11
  import unittest
12
12
  import ee
@@ -22,15 +22,15 @@ DATERANGE = 'DateRange'
22
22
 
23
23
 
24
24
  def make_expression_graph(
25
- function_invocation_value: Dict[str, Any]
26
- ) -> Dict[str, Any]:
25
+ function_invocation_value: dict[str, Any]
26
+ ) -> dict[str, Any]:
27
27
  return {
28
28
  'result': '0',
29
29
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
30
30
  }
31
31
 
32
32
 
33
- def daterange_function_expr(value: int) -> Dict[str, Any]:
33
+ def daterange_function_expr(value: int) -> dict[str, Any]:
34
34
  return {
35
35
  'functionInvocationValue': {
36
36
  'functionName': 'DateRange',
@@ -3,7 +3,7 @@
3
3
 
4
4
  import contextlib
5
5
  import datetime
6
- from typing import Any, Dict
6
+ from typing import Any
7
7
  from unittest import mock
8
8
  import warnings
9
9
 
@@ -100,7 +100,8 @@ _EXPECTED_WARNINGS = {
100
100
  r'Attention required for date_and_learn_more! You are using a'
101
101
  r' deprecated asset.\nTo make sure your code keeps working, please'
102
102
  r' update'
103
- r' it by July 1, 2024.\nLearn more: learn_more_url'
103
+ r' it by July 1, 2024.\nThis dataset has been superseded by'
104
+ r' replacement_id\n\nLearn more: learn_more_url'
104
105
  ),
105
106
  'date_only': (
106
107
  r'Attention required for date_only! You are using a deprecated asset.\n'
@@ -124,7 +125,8 @@ _EXPECTED_WARNINGS = {
124
125
  r'Attention required for learn_more_url_only! You are using a'
125
126
  r' deprecated asset.\nTo make sure your code keeps working, please'
126
127
  r' update'
127
- r' it.\nLearn more: learn_more_url'
128
+ r' it.\nThis dataset has been superseded by replacement_id\n\nLearn'
129
+ r' more: learn_more_url'
128
130
  ),
129
131
  }
130
132
 
@@ -173,7 +175,7 @@ class DeprecationTest(apitestcase.ApiTestCase, parameterized.TestCase):
173
175
  yield
174
176
 
175
177
  # Overridden from apitestcase.ApiTestCase.
176
- def _MockFetchDataCatalogStac(self) -> Dict[str, Any]:
178
+ def _MockFetchDataCatalogStac(self) -> dict[str, Any]:
177
179
  return _STAC_JSON
178
180
 
179
181
  def test_no_warnings_thrown(self):
@@ -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,64 @@ 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
+ def test_duplicate_scope_key(self):
84
+ """Verifies raising duplicate scope key in decode()."""
85
+ encoded = {
86
+ 'type': 'CompoundValue',
87
+ 'scope': [['a', 1], ['a', 2]],
88
+ 'value': 3,
89
+ }
90
+ with self.assertRaisesRegex(
91
+ ee.EEException, 'Duplicate scope key "a" in scope #1.'
92
+ ):
93
+ deserializer.decode(encoded)
94
+
95
+ def test_cannot_decode_object(self):
96
+ """Verifies raising EEException for non-dict objects in _decodeValue()."""
97
+ with self.assertRaisesRegex(
98
+ ee.EEException, r'Cannot decode object: \(1\+1j\)'
99
+ ):
100
+ deserializer.decode([1 + 1j])
101
+
102
+ def test_invalid_date_value(self):
103
+ """Verifies EEException for invalid date values in _decodeValue()."""
104
+ with self.assertRaisesRegex(
105
+ ee.EEException, r'Invalid date value: not-a-number'
106
+ ):
107
+ deserializer.decode({'type': 'Date', 'value': 'not-a-number'})
108
+
109
+ def test_invocation_of_custom_function(self):
110
+ """Verifies decoding of an Invocation of a CustomFunction."""
111
+ encoded = {
112
+ 'type': 'Invocation',
113
+ 'function': {
114
+ 'type': 'Function',
115
+ 'argumentNames': ['foo'],
116
+ 'body': {'type': 'ArgumentRef', 'value': 'foo'},
117
+ },
118
+ 'arguments': {'foo': 1},
119
+ }
120
+ decoded = deserializer.decode(encoded)
121
+ self.assertIsInstance(decoded, ee.ComputedObject)
122
+
123
+ def test_date_decode(self):
124
+ """Verifies decoding of a Date."""
125
+ encoded = {'type': 'Date', 'value': 1609459200000000}
126
+ decoded = deserializer.decode(encoded)
127
+ self.assertIsInstance(decoded, ee.Date)
128
+ self.assertEqual({'value': 1609459200000}, decoded.args)
129
+
130
+
72
131
  if __name__ == '__main__':
73
132
  unittest.main()
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  """Test for the ee.dictionary module."""
3
3
  import json
4
- from typing import Any, Dict
4
+ from typing import Any
5
5
  import unittest
6
6
 
7
7
  import unittest
@@ -10,8 +10,8 @@ from ee import apitestcase
10
10
 
11
11
 
12
12
  def make_expression_graph(
13
- function_invocation_value: Dict[str, Any],
14
- ) -> Dict[str, Any]:
13
+ function_invocation_value: dict[str, Any],
14
+ ) -> dict[str, Any]:
15
15
  return {
16
16
  'result': '0',
17
17
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -20,7 +20,7 @@ def make_expression_graph(
20
20
 
21
21
  class DictionaryTest(apitestcase.ApiTestCase):
22
22
 
23
- def testDictionary(self):
23
+ def test_dictionary(self):
24
24
  """Verifies basic behavior of ee.Dictionary."""
25
25
  src = {'a': 1, 'b': 2, 'c': 'three'}
26
26
  dictionary = ee.Dictionary(src)
@@ -46,7 +46,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
46
46
  for d in cons:
47
47
  self.assertIsInstance(d, ee.ComputedObject)
48
48
 
49
- def testInternals(self):
49
+ def test_internals(self):
50
50
  """Test eq(), ne() and hash()."""
51
51
  a = ee.Dictionary({'one': 1})
52
52
  b = ee.Dictionary({'two': 2})
@@ -93,7 +93,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
93
93
  result = json.loads(expression.serialize())
94
94
  self.assertEqual(expect, result)
95
95
 
96
- def test_fromLists(self):
96
+ def test_from_lists(self):
97
97
  expect = make_expression_graph({
98
98
  'arguments': {
99
99
  'keys': {'constantValue': ['a']},
@@ -126,7 +126,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
126
126
  result = json.loads(expression.serialize())
127
127
  self.assertEqual(expect, result)
128
128
 
129
- def test_getArray(self):
129
+ def test_get_array(self):
130
130
  expect = make_expression_graph({
131
131
  'arguments': {
132
132
  'dictionary': {'constantValue': {'a': 1}},
@@ -142,7 +142,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
142
142
  result = json.loads(expression.serialize())
143
143
  self.assertEqual(expect, result)
144
144
 
145
- def test_getGeometry(self):
145
+ def test_get_geometry(self):
146
146
  expect = make_expression_graph({
147
147
  'arguments': {
148
148
  'dictionary': {'constantValue': {'a': 1}},
@@ -158,7 +158,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
158
158
  result = json.loads(expression.serialize())
159
159
  self.assertEqual(expect, result)
160
160
 
161
- def test_getNumber(self):
161
+ def test_get_number(self):
162
162
  expect = make_expression_graph({
163
163
  'arguments': {
164
164
  'dictionary': {'constantValue': {'a': 1}},
@@ -174,7 +174,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
174
174
  result = json.loads(expression.serialize())
175
175
  self.assertEqual(expect, result)
176
176
 
177
- def test_getString(self):
177
+ def test_get_string(self):
178
178
  expect = make_expression_graph({
179
179
  'arguments': {
180
180
  'dictionary': {'constantValue': {'a': 1}},
@@ -292,7 +292,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
292
292
  result = json.loads(expression.serialize())
293
293
  self.assertEqual(expect, result)
294
294
 
295
- def test_toArray(self):
295
+ def test_to_array(self):
296
296
  expect = make_expression_graph({
297
297
  'arguments': {
298
298
  'dictionary': {'constantValue': {'a': 1}},
@@ -325,7 +325,7 @@ class DictionaryTest(apitestcase.ApiTestCase):
325
325
  result = json.loads(expression.serialize())
326
326
  self.assertEqual(expect, result)
327
327
 
328
- def test_toImage(self):
328
+ def test_to_image(self):
329
329
  expect = make_expression_graph({
330
330
  'arguments': {
331
331
  'dictionary': {'constantValue': {'a': 1}},
ee/tests/ee_array_test.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """Tests for the ee.Array module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
 
7
7
  import unittest
8
8
  import ee
@@ -24,8 +24,8 @@ ARRAY_TWO = {
24
24
 
25
25
 
26
26
  def make_expression_graph(
27
- function_invocation_value: Dict[str, Any],
28
- ) -> Dict[str, Any]:
27
+ function_invocation_value: dict[str, Any],
28
+ ) -> dict[str, Any]:
29
29
  return {
30
30
  'result': '0',
31
31
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
ee/tests/ee_date_test.py CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  import datetime
5
5
  import json
6
- from typing import Any, Dict
6
+ from typing import Any
7
7
 
8
8
  import unittest
9
9
  import ee
@@ -16,15 +16,15 @@ UTC = 'UTC'
16
16
 
17
17
 
18
18
  def make_expression_graph(
19
- function_invocation_value: Dict[str, Any]
20
- ) -> Dict[str, Any]:
19
+ function_invocation_value: dict[str, Any]
20
+ ) -> dict[str, Any]:
21
21
  return {
22
22
  'result': '0',
23
23
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
24
24
  }
25
25
 
26
26
 
27
- def date_function_expr(value: int) -> Dict[str, Any]:
27
+ def date_function_expr(value: int) -> dict[str, Any]:
28
28
  return {
29
29
  'functionInvocationValue': {
30
30
  'functionName': 'Date',
ee/tests/ee_list_test.py CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  """Test for the ee.list module."""
3
3
  import json
4
- from typing import Any, Dict
4
+ from typing import Any
5
5
 
6
6
  import unittest
7
7
  import ee
@@ -9,8 +9,8 @@ from ee import apitestcase
9
9
 
10
10
 
11
11
  def make_expression_graph(
12
- function_invocation_value: Dict[str, Any]
13
- ) -> Dict[str, Any]:
12
+ function_invocation_value: dict[str, Any]
13
+ ) -> dict[str, Any]:
14
14
  return {
15
15
  'result': '0',
16
16
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -2,7 +2,7 @@
2
2
  """Test for the ee.number module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
  import unittest
7
7
 
8
8
  import unittest
@@ -11,8 +11,8 @@ from ee import apitestcase
11
11
 
12
12
 
13
13
  def make_expression_graph(
14
- function_invocation_value: Dict[str, Any],
15
- ) -> Dict[str, Any]:
14
+ function_invocation_value: dict[str, Any],
15
+ ) -> dict[str, Any]:
16
16
  return {
17
17
  'result': '0',
18
18
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -21,7 +21,7 @@ def make_expression_graph(
21
21
 
22
22
  class NumberTest(apitestcase.ApiTestCase):
23
23
 
24
- def testNumber(self):
24
+ def test_number(self):
25
25
  """Verifies basic behavior of ee.Number."""
26
26
  num = ee.Number(1)
27
27
  self.assertEqual(1, num.encode())
@@ -34,7 +34,7 @@ class NumberTest(apitestcase.ApiTestCase):
34
34
  'right': ee.Number(2)
35
35
  }, computed.args)
36
36
 
37
- def testInternals(self):
37
+ def test_internals(self):
38
38
  """Test eq(), ne() and hash()."""
39
39
  a = ee.Number(1)
40
40
  b = ee.Number(2.1)
@@ -46,6 +46,12 @@ class NumberTest(apitestcase.ApiTestCase):
46
46
  self.assertNotEqual(b, c)
47
47
  self.assertNotEqual(hash(a), hash(b))
48
48
 
49
+ def test_init_invalid_arg(self):
50
+ with self.assertRaisesRegex(
51
+ ee.EEException, 'Invalid argument specified for ee.Number'
52
+ ):
53
+ ee.Number('not a number') # pytype: disable=wrong-arg-types
54
+
49
55
  def test_abs(self):
50
56
  expect = make_expression_graph({
51
57
  'arguments': {
@@ -139,7 +145,7 @@ class NumberTest(apitestcase.ApiTestCase):
139
145
  result = json.loads(expression.serialize())
140
146
  self.assertEqual(expect, result)
141
147
 
142
- def test_bitCount(self):
148
+ def test_bit_count(self):
143
149
  expect = make_expression_graph({
144
150
  'arguments': {
145
151
  'input': {'constantValue': 1},
@@ -150,7 +156,7 @@ class NumberTest(apitestcase.ApiTestCase):
150
156
  result = json.loads(expression.serialize())
151
157
  self.assertEqual(expect, result)
152
158
 
153
- def test_bitwiseAnd(self):
159
+ def test_bitwise_and(self):
154
160
  expect = make_expression_graph({
155
161
  'arguments': {
156
162
  'left': {'constantValue': 1},
@@ -166,7 +172,7 @@ class NumberTest(apitestcase.ApiTestCase):
166
172
  result = json.loads(expression.serialize())
167
173
  self.assertEqual(expect, result)
168
174
 
169
- def test_bitwiseNot(self):
175
+ def test_bitwise_not(self):
170
176
  expect = make_expression_graph({
171
177
  'arguments': {
172
178
  'input': {'constantValue': 1},
@@ -177,7 +183,7 @@ class NumberTest(apitestcase.ApiTestCase):
177
183
  result = json.loads(expression.serialize())
178
184
  self.assertEqual(expect, result)
179
185
 
180
- def test_bitwiseOr(self):
186
+ def test_bitwise_or(self):
181
187
  expect = make_expression_graph({
182
188
  'arguments': {
183
189
  'left': {'constantValue': 1},
@@ -193,7 +199,7 @@ class NumberTest(apitestcase.ApiTestCase):
193
199
  result = json.loads(expression.serialize())
194
200
  self.assertEqual(expect, result)
195
201
 
196
- def test_bitwiseXor(self):
202
+ def test_bitwise_xor(self):
197
203
  expect = make_expression_graph({
198
204
  'arguments': {
199
205
  'left': {'constantValue': 1},
@@ -346,7 +352,7 @@ class NumberTest(apitestcase.ApiTestCase):
346
352
  result = json.loads(expression.serialize())
347
353
  self.assertEqual(expect, result)
348
354
 
349
- def test_erfInv(self):
355
+ def test_erf_inv(self):
350
356
  expect = make_expression_graph({
351
357
  'arguments': {
352
358
  'input': {'constantValue': 1},
@@ -368,7 +374,7 @@ class NumberTest(apitestcase.ApiTestCase):
368
374
  result = json.loads(expression.serialize())
369
375
  self.assertEqual(expect, result)
370
376
 
371
- def test_erfcInv(self):
377
+ def test_erfc_inv(self):
372
378
  expect = make_expression_graph({
373
379
  'arguments': {
374
380
  'input': {'constantValue': 1},
@@ -390,6 +396,31 @@ class NumberTest(apitestcase.ApiTestCase):
390
396
  result = json.loads(expression.serialize())
391
397
  self.assertEqual(expect, result)
392
398
 
399
+ def test_expression(self):
400
+ expression = ee.Number.expression('1 + 2')
401
+ self.assertIsInstance(expression, ee.Number)
402
+ self.assertEqual(
403
+ ee.ApiFunction.lookup('Number.expression'), expression.func
404
+ )
405
+
406
+ expect = make_expression_graph({
407
+ 'arguments': {'expression': {'constantValue': '1 + 2'}},
408
+ 'functionName': 'Number.expression',
409
+ })
410
+ result = json.loads(expression.serialize())
411
+ self.assertEqual(expect, result)
412
+
413
+ expression_vars = ee.Number.expression('a + b', {'a': 1, 'b': 2})
414
+ expect_vars = make_expression_graph({
415
+ 'arguments': {
416
+ 'expression': {'constantValue': 'a + b'},
417
+ 'vars': {'constantValue': {'a': 1, 'b': 2}},
418
+ },
419
+ 'functionName': 'Number.expression',
420
+ })
421
+ result_vars = json.loads(expression_vars.serialize())
422
+ self.assertEqual(expect_vars, result_vars)
423
+
393
424
  def test_first(self):
394
425
  expect = make_expression_graph({
395
426
  'arguments': {
@@ -406,7 +437,7 @@ class NumberTest(apitestcase.ApiTestCase):
406
437
  result = json.loads(expression.serialize())
407
438
  self.assertEqual(expect, result)
408
439
 
409
- def test_firstNonZero(self):
440
+ def test_first_non_zero(self):
410
441
  expect = make_expression_graph({
411
442
  'arguments': {
412
443
  'left': {'constantValue': 1},
@@ -601,7 +632,7 @@ class NumberTest(apitestcase.ApiTestCase):
601
632
  result = json.loads(expression.serialize())
602
633
  self.assertEqual(expect, result)
603
634
 
604
- def test_leftShift(self):
635
+ def test_left_shift(self):
605
636
  expect = make_expression_graph({
606
637
  'arguments': {
607
638
  'left': {'constantValue': 1},
@@ -789,7 +820,21 @@ class NumberTest(apitestcase.ApiTestCase):
789
820
  result = json.loads(expression.serialize())
790
821
  self.assertEqual(expect, result)
791
822
 
792
- # TODO: test_parse.
823
+ def test_parse(self):
824
+ expect = make_expression_graph({
825
+ 'arguments': {
826
+ 'input': {'constantValue': '1'},
827
+ 'radix': {'constantValue': 2},
828
+ },
829
+ 'functionName': 'Number.parse',
830
+ })
831
+ expression = ee.Number.parse('1', 2)
832
+ result = json.loads(expression.serialize())
833
+ self.assertEqual(expect, result)
834
+
835
+ expression = ee.Number.parse(input='1', radix=2)
836
+ result = json.loads(expression.serialize())
837
+ self.assertEqual(expect, result)
793
838
 
794
839
  def test_pow(self):
795
840
  expect = make_expression_graph({
@@ -807,7 +852,7 @@ class NumberTest(apitestcase.ApiTestCase):
807
852
  result = json.loads(expression.serialize())
808
853
  self.assertEqual(expect, result)
809
854
 
810
- def test_rightShift(self):
855
+ def test_right_shift(self):
811
856
  expect = make_expression_graph({
812
857
  'arguments': {
813
858
  'left': {'constantValue': 1},
@@ -927,7 +972,7 @@ class NumberTest(apitestcase.ApiTestCase):
927
972
  result = json.loads(expression.serialize())
928
973
  self.assertEqual(expect, result)
929
974
 
930
- def test_toByte(self):
975
+ def test_to_byte(self):
931
976
  expect = make_expression_graph({
932
977
  'arguments': {
933
978
  'input': {'constantValue': 1},
@@ -938,7 +983,7 @@ class NumberTest(apitestcase.ApiTestCase):
938
983
  result = json.loads(expression.serialize())
939
984
  self.assertEqual(expect, result)
940
985
 
941
- def test_toDouble(self):
986
+ def test_to_double(self):
942
987
  expect = make_expression_graph({
943
988
  'arguments': {
944
989
  'input': {'constantValue': 1},
@@ -949,7 +994,7 @@ class NumberTest(apitestcase.ApiTestCase):
949
994
  result = json.loads(expression.serialize())
950
995
  self.assertEqual(expect, result)
951
996
 
952
- def test_toFloat(self):
997
+ def test_to_float(self):
953
998
  expect = make_expression_graph({
954
999
  'arguments': {
955
1000
  'input': {'constantValue': 1},
@@ -960,7 +1005,7 @@ class NumberTest(apitestcase.ApiTestCase):
960
1005
  result = json.loads(expression.serialize())
961
1006
  self.assertEqual(expect, result)
962
1007
 
963
- def test_toInt(self):
1008
+ def test_to_int(self):
964
1009
  expect = make_expression_graph({
965
1010
  'arguments': {
966
1011
  'input': {'constantValue': 1},
@@ -971,7 +1016,7 @@ class NumberTest(apitestcase.ApiTestCase):
971
1016
  result = json.loads(expression.serialize())
972
1017
  self.assertEqual(expect, result)
973
1018
 
974
- def test_toInt16(self):
1019
+ def test_to_int16(self):
975
1020
  expect = make_expression_graph({
976
1021
  'arguments': {
977
1022
  'input': {'constantValue': 1},
@@ -982,7 +1027,7 @@ class NumberTest(apitestcase.ApiTestCase):
982
1027
  result = json.loads(expression.serialize())
983
1028
  self.assertEqual(expect, result)
984
1029
 
985
- def test_toInt32(self):
1030
+ def test_to_int32(self):
986
1031
  expect = make_expression_graph({
987
1032
  'arguments': {
988
1033
  'input': {'constantValue': 1},
@@ -993,7 +1038,7 @@ class NumberTest(apitestcase.ApiTestCase):
993
1038
  result = json.loads(expression.serialize())
994
1039
  self.assertEqual(expect, result)
995
1040
 
996
- def test_toInt64(self):
1041
+ def test_to_int64(self):
997
1042
  expect = make_expression_graph({
998
1043
  'arguments': {
999
1044
  'input': {'constantValue': 1},
@@ -1004,7 +1049,7 @@ class NumberTest(apitestcase.ApiTestCase):
1004
1049
  result = json.loads(expression.serialize())
1005
1050
  self.assertEqual(expect, result)
1006
1051
 
1007
- def test_toInt8(self):
1052
+ def test_to_int8(self):
1008
1053
  expect = make_expression_graph({
1009
1054
  'arguments': {
1010
1055
  'input': {'constantValue': 1},
@@ -1015,7 +1060,7 @@ class NumberTest(apitestcase.ApiTestCase):
1015
1060
  result = json.loads(expression.serialize())
1016
1061
  self.assertEqual(expect, result)
1017
1062
 
1018
- def test_toLong(self):
1063
+ def test_to_long(self):
1019
1064
  expect = make_expression_graph({
1020
1065
  'arguments': {
1021
1066
  'input': {'constantValue': 1},
@@ -1026,7 +1071,7 @@ class NumberTest(apitestcase.ApiTestCase):
1026
1071
  result = json.loads(expression.serialize())
1027
1072
  self.assertEqual(expect, result)
1028
1073
 
1029
- def test_toShort(self):
1074
+ def test_to_short(self):
1030
1075
  expect = make_expression_graph({
1031
1076
  'arguments': {
1032
1077
  'input': {'constantValue': 1},
@@ -1037,7 +1082,7 @@ class NumberTest(apitestcase.ApiTestCase):
1037
1082
  result = json.loads(expression.serialize())
1038
1083
  self.assertEqual(expect, result)
1039
1084
 
1040
- def test_toUint16(self):
1085
+ def test_to_uint16(self):
1041
1086
  expect = make_expression_graph({
1042
1087
  'arguments': {
1043
1088
  'input': {'constantValue': 1},
@@ -1048,7 +1093,7 @@ class NumberTest(apitestcase.ApiTestCase):
1048
1093
  result = json.loads(expression.serialize())
1049
1094
  self.assertEqual(expect, result)
1050
1095
 
1051
- def test_toUint32(self):
1096
+ def test_to_uint32(self):
1052
1097
  expect = make_expression_graph({
1053
1098
  'arguments': {
1054
1099
  'input': {'constantValue': 1},
@@ -1059,7 +1104,7 @@ class NumberTest(apitestcase.ApiTestCase):
1059
1104
  result = json.loads(expression.serialize())
1060
1105
  self.assertEqual(expect, result)
1061
1106
 
1062
- def test_toUint8(self):
1107
+ def test_to_uint8(self):
1063
1108
  expect = make_expression_graph({
1064
1109
  'arguments': {
1065
1110
  'input': {'constantValue': 1},
@@ -1114,7 +1159,7 @@ class NumberTest(apitestcase.ApiTestCase):
1114
1159
  result = json.loads(expression.serialize())
1115
1160
  self.assertEqual(expect, result)
1116
1161
 
1117
- def test_unitScale(self):
1162
+ def test_unit_scale(self):
1118
1163
  expect = make_expression_graph({
1119
1164
  'arguments': {
1120
1165
  'number': {'constantValue': 1},
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  """Test for the ee.string module."""
3
3
  import json
4
- from typing import Any, Dict
4
+ from typing import Any
5
5
  import unittest
6
6
 
7
7
  import unittest
@@ -10,8 +10,8 @@ from ee import apitestcase
10
10
 
11
11
 
12
12
  def make_expression_graph(
13
- function_invocation_value: Dict[str, Any]
14
- ) -> Dict[str, Any]:
13
+ function_invocation_value: dict[str, Any]
14
+ ) -> dict[str, Any]:
15
15
  return {
16
16
  'result': '0',
17
17
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -107,6 +107,14 @@ class StringTest(apitestcase.ApiTestCase):
107
107
  result = json.loads(expression.serialize())
108
108
  self.assertEqual(expect, result)
109
109
 
110
+ expect = make_expression_graph({
111
+ 'arguments': {'object': {'constantValue': [1]}},
112
+ 'functionName': 'String.encodeJSON',
113
+ })
114
+ expression = ee.String.encodeJSON([1])
115
+ result = json.loads(expression.serialize())
116
+ self.assertEqual(expect, result)
117
+
110
118
  def test_equals(self):
111
119
  expect = make_expression_graph({
112
120
  'arguments': {