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
ee/tests/ee_test.py CHANGED
@@ -8,6 +8,7 @@ from google.oauth2 import credentials
8
8
 
9
9
  import unittest
10
10
  import ee
11
+ from ee import _state
11
12
  from ee import apitestcase
12
13
 
13
14
 
@@ -18,7 +19,7 @@ class EETestCase(apitestcase.ApiTestCase):
18
19
  ee.Reset()
19
20
  ee.data._install_cloud_api_resource = lambda: None
20
21
 
21
- def testInitialization(self):
22
+ def test_initialization(self):
22
23
  """Verifies library initialization."""
23
24
 
24
25
  def MockAlgorithms():
@@ -27,33 +28,50 @@ class EETestCase(apitestcase.ApiTestCase):
27
28
  ee.data.getAlgorithms = MockAlgorithms
28
29
 
29
30
  # Verify that the base state is uninitialized.
30
- self.assertFalse(ee.data._initialized)
31
- self.assertIsNone(ee.data._api_base_url)
31
+ state = _state.get_state()
32
+ self.assertFalse(state.initialized)
33
+ self.assertIsNone(state.credentials)
34
+ self.assertIsNone(state.api_base_url)
35
+ self.assertIsNone(state.tile_base_url)
36
+ self.assertIsNone(state.cloud_api_base_url)
37
+ self.assertIsNone(state.cloud_api_key)
38
+ self.assertIsNone(state.requests_session)
39
+ self.assertIsNone(state.cloud_api_resource)
40
+ self.assertIsNone(state.cloud_api_resource_raw)
41
+ self.assertEqual(state.cloud_api_user_project, 'earthengine-legacy')
42
+ self.assertIsNone(state.cloud_api_client_version)
43
+ self.assertIsNone(state.http_transport)
44
+ self.assertEqual(state.deadline_ms, 0)
45
+ self.assertEqual(state.max_retries, 5)
46
+ self.assertIsNone(state.user_agent)
32
47
  self.assertEqual(ee.ApiFunction._api, {})
33
48
  self.assertFalse(ee.Image._initialized)
34
49
 
35
50
  # Verify that ee.Initialize() sets the URL and initializes classes.
36
51
  ee.Initialize(None, 'foo', project='my-project')
37
- self.assertTrue(ee.data._initialized)
38
- self.assertEqual(ee.data._api_base_url, 'foo/api')
39
- self.assertEqual(ee.data._cloud_api_user_project, 'my-project')
52
+ state = _state.get_state()
53
+ self.assertTrue(state.initialized)
54
+ self.assertEqual(state.api_base_url, 'foo/api')
55
+ self.assertEqual(state.cloud_api_user_project, 'my-project')
40
56
  self.assertEqual(ee.ApiFunction._api, {})
41
57
  self.assertTrue(ee.Image._initialized)
42
58
 
43
59
  # Verify that ee.Initialize() without a URL does not override custom URLs.
44
60
  ee.Initialize(None, project='my-project')
45
- self.assertTrue(ee.data._initialized)
46
- self.assertEqual(ee.data._api_base_url, 'foo/api')
61
+ state = _state.get_state()
62
+ self.assertTrue(state.initialized)
63
+ self.assertEqual(state.api_base_url, 'foo/api')
47
64
 
48
65
  # Verify that ee.Reset() reverts everything to the base state.
49
66
  ee.Reset()
50
- self.assertFalse(ee.data._initialized)
51
- self.assertIsNone(ee.data._api_base_url)
52
- self.assertIsNone(ee.data._cloud_api_user_project)
67
+ state = _state.get_state()
68
+ self.assertFalse(state.initialized)
69
+ self.assertIsNone(state.api_base_url)
70
+ self.assertEqual(state.cloud_api_user_project, 'earthengine-legacy')
53
71
  self.assertEqual(ee.ApiFunction._api, {})
54
72
  self.assertFalse(ee.Image._initialized)
55
73
 
56
- def testProjectInitialization(self):
74
+ def test_project_initialization(self):
57
75
  """Verifies that we can fetch the client project from many locations.
58
76
 
59
77
  This also exercises the logic in data.get_persistent_credentials.
@@ -118,7 +136,7 @@ class EETestCase(apitestcase.ApiTestCase):
118
136
  ee.Initialize()
119
137
  self.assertEqual(6, inits.call_count)
120
138
 
121
- def testCallAndApply(self):
139
+ def test_call_and_apply(self):
122
140
  """Verifies library initialization."""
123
141
 
124
142
  # Use a custom set of known functions.
@@ -174,7 +192,7 @@ class EETestCase(apitestcase.ApiTestCase):
174
192
  called_with_null = ee.call('fakeFunction', None, 1)
175
193
  self.assertIsNone(called_with_null.args['image1'])
176
194
 
177
- def testDynamicClasses(self):
195
+ def test_dynamic_classes(self):
178
196
  """Verifies dynamic class initialization."""
179
197
 
180
198
  # Use a custom set of known functions.
@@ -280,7 +298,7 @@ class EETestCase(apitestcase.ApiTestCase):
280
298
  ee.EEException, 'Unknown algorithm: Reducer.moo'):
281
299
  ee.call('fakeFunction', 'moo')
282
300
 
283
- def testDynamicConstructor(self):
301
+ def test_dynamic_constructor(self):
284
302
  # Test the behavior of the dynamic class constructor.
285
303
 
286
304
  # Use a custom set of known functions for classes Foo and Bar.
@@ -389,7 +407,7 @@ class EETestCase(apitestcase.ApiTestCase):
389
407
  with self.assertRaisesRegex(ee.EEException, 'Must be a ComputedObject'):
390
408
  ee.Bar(1)
391
409
 
392
- def testDynamicConstructorCasting(self):
410
+ def test_dynamic_constructor_casting(self):
393
411
  """Test the behavior of casting with dynamic classes."""
394
412
  self.InitializeApi()
395
413
  result = ee.Geometry.Rectangle(1, 1, 2, 2).bounds(0, 'EPSG:4326')
@@ -398,7 +416,7 @@ class EETestCase(apitestcase.ApiTestCase):
398
416
  ee.ErrorMargin(0), ee.Projection('EPSG:4326')))
399
417
  self.assertEqual(expected, result)
400
418
 
401
- def testPromotion(self):
419
+ def test_promotion(self):
402
420
  """Verifies object promotion rules."""
403
421
  self.InitializeApi()
404
422
 
@@ -415,7 +433,7 @@ class EETestCase(apitestcase.ApiTestCase):
415
433
  self.assertIsInstance(ee._Promote(untyped, 'Element'), ee.Element)
416
434
  self.assertEqual('foo', ee._Promote(untyped, 'Element').varName)
417
435
 
418
- def testUnboundMethods(self):
436
+ def test_unbound_methods(self):
419
437
  """Verifies unbound method attachment to ee.Algorithms."""
420
438
 
421
439
  # Use a custom set of known functions.
@@ -458,11 +476,11 @@ class EETestCase(apitestcase.ApiTestCase):
458
476
  self.assertEqual(ee.call('Foo.bar'), ee.Algorithms.Foo.bar())
459
477
  self.assertNotEqual(ee.Algorithms.Foo.bar(), ee.Algorithms.last())
460
478
 
461
- def testNonAsciiDocumentation(self):
479
+ def test_non_ascii_documentation(self):
462
480
  """Verifies that non-ASCII characters in documentation work."""
463
- foo = u'\uFB00\u00F6\u01EB'
464
- bar = u'b\u00E4r'
465
- baz = u'b\u00E2\u00DF'
481
+ foo = '\uFB00\u00F6\u01EB'
482
+ bar = 'b\u00E4r'
483
+ baz = 'b\u00E2\u00DF'
466
484
 
467
485
  def MockAlgorithms():
468
486
  return {
ee/tests/element_test.py CHANGED
@@ -10,7 +10,7 @@ from ee import apitestcase
10
10
 
11
11
  class ElementTestCase(apitestcase.ApiTestCase):
12
12
 
13
- def testSet(self):
13
+ def test_set(self):
14
14
  """Verifies Element.set() keyword argument interpretation."""
15
15
  image = ee.Image(1)
16
16
 
@@ -48,7 +48,7 @@ class ElementTestCase(apitestcase.ApiTestCase):
48
48
  CheckMultiProperties(image.set(computed_arg))
49
49
  CheckMultiProperties(image.set({'properties': computed_arg}))
50
50
 
51
- def testInitOptParams(self):
51
+ def test_init_opt_params(self):
52
52
  result = ee.Element(func=None, args=None, opt_varName='test').serialize()
53
53
  self.assertIn('"0": {"argumentReference": "test"}', result)
54
54
 
@@ -26,7 +26,7 @@ class ErrorMarginTest(apitestcase.ApiTestCase):
26
26
  self.assertEqual(errormargin_func, errormargin.func)
27
27
 
28
28
  self.assertFalse(errormargin.isVariable())
29
- self.assertEqual(set([UNIT, VALUE]), set(errormargin.args))
29
+ self.assertEqual({UNIT, VALUE}, set(errormargin.args))
30
30
  expected_unit = {
31
31
  'result': '0',
32
32
  'values': {'0': {'constantValue': 'projected'}},
ee/tests/feature_test.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """Test for the ee.feature module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
  from unittest import mock
7
7
 
8
8
  import unittest
@@ -40,7 +40,7 @@ FEATURE_A_GRAPH = {
40
40
  }
41
41
 
42
42
 
43
- def right_maxerror_proj(function_name: str) -> Dict[str, Any]:
43
+ def right_maxerror_proj(function_name: str) -> dict[str, Any]:
44
44
  return {
45
45
  'result': '0',
46
46
  'values': {
@@ -61,8 +61,8 @@ def right_maxerror_proj(function_name: str) -> Dict[str, Any]:
61
61
 
62
62
 
63
63
  def make_expression_graph(
64
- function_invocation_value: Dict[str, Any],
65
- ) -> Dict[str, Any]:
64
+ function_invocation_value: dict[str, Any],
65
+ ) -> dict[str, Any]:
66
66
  return {
67
67
  'result': '0',
68
68
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -71,7 +71,7 @@ def make_expression_graph(
71
71
 
72
72
  class FeatureTest(apitestcase.ApiTestCase):
73
73
 
74
- def testConstructors(self):
74
+ def test_constructors(self):
75
75
  """Verifies that constructors understand valid parameters."""
76
76
  point = ee.Geometry.Point(1, 2)
77
77
  from_geometry = ee.Feature(point)
@@ -121,7 +121,7 @@ class FeatureTest(apitestcase.ApiTestCase):
121
121
  'system:index': 'bar'
122
122
  }, from_geo_json_feature.args['metadata'])
123
123
 
124
- def testGetMap(self):
124
+ def test_get_map(self):
125
125
  """Verifies that getMap() uses Collection.draw to rasterize Features."""
126
126
  feature = ee.Feature(None)
127
127
  mapid = feature.getMapId({'color': 'ABCDEF'})
@@ -132,7 +132,7 @@ class FeatureTest(apitestcase.ApiTestCase):
132
132
  self.assertEqual('fakeMapId', mapid['mapid'])
133
133
  self.assertEqual(manual.serialize(), mapid['image'].serialize())
134
134
 
135
- def testInitOptParams(self):
135
+ def test_init_opt_params(self):
136
136
  result = ee.Feature(
137
137
  geom=ee.Geometry.Point(1, 2), opt_properties=dict(prop='a')
138
138
  ).serialize()
@@ -328,7 +328,7 @@ class FeatureTest(apitestcase.ApiTestCase):
328
328
  result = json.loads(expression.serialize())
329
329
  self.assertEqual(expect, result)
330
330
 
331
- def test_cutLines(self):
331
+ def test_cut_lines(self):
332
332
  expect = make_expression_graph({
333
333
  'arguments': {
334
334
  'feature': FEATURE_NONE_GRAPH,
@@ -546,7 +546,7 @@ class FeatureTest(apitestcase.ApiTestCase):
546
546
  result = json.loads(expression.serialize())
547
547
  self.assertEqual(expect, result)
548
548
 
549
- def test_setGeometry(self):
549
+ def test_set_geometry(self):
550
550
  expect = make_expression_graph({
551
551
  'arguments': {
552
552
  'feature': FEATURE_NONE_GRAPH,
@@ -646,7 +646,7 @@ class FeatureTest(apitestcase.ApiTestCase):
646
646
  result = json.loads(expression.serialize())
647
647
  self.assertEqual(expect, result)
648
648
 
649
- def test_withinDistance(self):
649
+ def test_within_distance(self):
650
650
  expect = {
651
651
  'result': '0',
652
652
  'values': {
@@ -2,7 +2,7 @@
2
2
  """Test for the ee.featurecollection module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
  from unittest import mock
7
7
 
8
8
  import unittest
@@ -12,8 +12,8 @@ from ee import apitestcase
12
12
 
13
13
 
14
14
  def make_expression_graph(
15
- function_invocation_value: Dict[str, Any],
16
- ) -> Dict[str, Any]:
15
+ function_invocation_value: dict[str, Any],
16
+ ) -> dict[str, Any]:
17
17
  return {
18
18
  'result': '0',
19
19
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
ee/tests/filter_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
@@ -11,15 +11,15 @@ 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}},
19
19
  }
20
20
 
21
21
 
22
- def max_error_expression(max_error: float) -> Dict[str, Any]:
22
+ def max_error_expression(max_error: float) -> dict[str, Any]:
23
23
  return {
24
24
  'functionInvocationValue': {
25
25
  'functionName': 'ErrorMargin',
ee/tests/function_test.py CHANGED
@@ -34,7 +34,7 @@ Args:
34
34
 
35
35
  class FunctionTest(unittest.TestCase):
36
36
 
37
- def testNameArgs(self):
37
+ def test_name_args(self):
38
38
  """Verifies that Functions can convert positional to named arguments."""
39
39
  self.assertEqual({}, TEST_FUNC.nameArgs([]))
40
40
  self.assertEqual({'a': 42}, TEST_FUNC.nameArgs([42]))
@@ -44,7 +44,7 @@ class FunctionTest(unittest.TestCase):
44
44
  self.assertRaisesRegex(ee.EEException, 'Too many', TEST_FUNC.nameArgs,
45
45
  [1, 2, 3])
46
46
 
47
- def testPromoteArgs(self):
47
+ def test_promote_args(self):
48
48
  """Verifies that Functions can promote and verify their arguments."""
49
49
  old_promoter = ee.Function._promoter
50
50
  ee.Function._registerPromoter(lambda obj, type_name: [type_name, obj])
@@ -75,7 +75,7 @@ class FunctionTest(unittest.TestCase):
75
75
  # Clean up.
76
76
  ee.Function._registerPromoter(old_promoter)
77
77
 
78
- def testCall(self):
78
+ def test_call(self):
79
79
  """Verifies the full function invocation flow."""
80
80
  old_promoter = ee.Function._promoter
81
81
  ee.Function._registerPromoter(lambda obj, type_name: [type_name, obj])
@@ -91,11 +91,11 @@ class FunctionTest(unittest.TestCase):
91
91
  # Clean up.
92
92
  ee.Function._registerPromoter(old_promoter)
93
93
 
94
- def testToString(self):
94
+ def test_to_string(self):
95
95
  """Verifies function docstring generation."""
96
96
  self.assertEqual(EXPECTED_DOC, str(TEST_FUNC))
97
97
 
98
- def testArgumentFailureMessage(self):
98
+ def test_argument_failure_message(self):
99
99
  """Verifies properly formed function error message generation."""
100
100
  self.assertRaisesRegex(
101
101
  ee.EEException,
@@ -2,7 +2,7 @@
2
2
  """Test for the ee.geometry module Point methods."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
  from unittest import mock
7
7
 
8
8
  import unittest
@@ -45,8 +45,8 @@ PROJ = {
45
45
 
46
46
 
47
47
  def make_expression_graph_geom(
48
- function_name: str, args: Dict[str, Any]
49
- ) -> Dict[str, Any]:
48
+ function_name: str, args: dict[str, Any]
49
+ ) -> dict[str, Any]:
50
50
  return {
51
51
  'result': '0',
52
52
  'values': {