earthengine-api 1.6.15__py3-none-any.whl → 1.7.0__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.
- {earthengine_api-1.6.15.dist-info → earthengine_api-1.7.0.dist-info}/METADATA +2 -3
- {earthengine_api-1.6.15.dist-info → earthengine_api-1.7.0.dist-info}/RECORD +34 -34
- ee/__init__.py +13 -13
- ee/_cloud_api_utils.py +29 -28
- ee/_helpers.py +6 -6
- ee/_utils.py +2 -1
- ee/apitestcase.py +10 -10
- ee/cli/commands.py +2 -2
- ee/cli/utils.py +2 -2
- ee/collection.py +3 -2
- ee/computedobject.py +4 -1
- ee/customfunction.py +2 -1
- ee/data.py +31 -31
- ee/deprecation.py +3 -2
- ee/deserializer.py +4 -4
- ee/ee_number.py +6 -16
- ee/encodable.py +2 -1
- ee/image_converter.py +3 -3
- ee/imagecollection.py +2 -2
- ee/model.py +29 -31
- ee/oauth.py +35 -35
- ee/serializer.py +6 -6
- ee/table_converter.py +3 -3
- ee/tests/batch_test.py +3 -3
- ee/tests/collection_test.py +35 -0
- ee/tests/data_test.py +5 -3
- ee/tests/ee_number_test.py +40 -1
- ee/tests/image_converter_test.py +1 -3
- ee/tests/serializer_test.py +3 -2
- ee/tests/table_converter_test.py +2 -2
- {earthengine_api-1.6.15.dist-info → earthengine_api-1.7.0.dist-info}/WHEEL +0 -0
- {earthengine_api-1.6.15.dist-info → earthengine_api-1.7.0.dist-info}/entry_points.txt +0 -0
- {earthengine_api-1.6.15.dist-info → earthengine_api-1.7.0.dist-info}/licenses/LICENSE +0 -0
- {earthengine_api-1.6.15.dist-info → earthengine_api-1.7.0.dist-info}/top_level.txt +0 -0
ee/serializer.py
CHANGED
|
@@ -4,7 +4,7 @@ import collections
|
|
|
4
4
|
import datetime
|
|
5
5
|
import hashlib
|
|
6
6
|
import json
|
|
7
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
8
8
|
|
|
9
9
|
from ee import _cloud_api_utils
|
|
10
10
|
from ee import _utils
|
|
@@ -32,7 +32,7 @@ def DatetimeToMicroseconds(date: datetime.datetime) -> int:
|
|
|
32
32
|
|
|
33
33
|
class Serializer:
|
|
34
34
|
"""A serializer for EE object trees."""
|
|
35
|
-
unbound_name:
|
|
35
|
+
unbound_name: str | None
|
|
36
36
|
|
|
37
37
|
# Whether the encoding should factor out shared subtrees.
|
|
38
38
|
_is_compound: bool
|
|
@@ -48,7 +48,7 @@ class Serializer:
|
|
|
48
48
|
self,
|
|
49
49
|
is_compound: bool = True,
|
|
50
50
|
for_cloud_api: bool = False,
|
|
51
|
-
unbound_name:
|
|
51
|
+
unbound_name: str | None = None,
|
|
52
52
|
):
|
|
53
53
|
"""Constructs a serializer.
|
|
54
54
|
|
|
@@ -280,7 +280,7 @@ def encode(
|
|
|
280
280
|
obj: Any,
|
|
281
281
|
is_compound: bool = True,
|
|
282
282
|
for_cloud_api: bool = True,
|
|
283
|
-
unbound_name:
|
|
283
|
+
unbound_name: str | None = None,
|
|
284
284
|
) -> Any:
|
|
285
285
|
"""Serialize an object to a JSON-compatible structure for API calls.
|
|
286
286
|
|
|
@@ -358,7 +358,7 @@ class _ExpressionOptimizer:
|
|
|
358
358
|
- Collapse dicts and arrays of constants to constant dicts/arrays.
|
|
359
359
|
"""
|
|
360
360
|
|
|
361
|
-
def __init__(self, result: Any, values:
|
|
361
|
+
def __init__(self, result: Any, values: Any | None = None):
|
|
362
362
|
"""Builds an ExpressionOptimizer.
|
|
363
363
|
|
|
364
364
|
Args:
|
|
@@ -385,7 +385,7 @@ class _ExpressionOptimizer:
|
|
|
385
385
|
reference_counts = collections.defaultdict(int)
|
|
386
386
|
reference_counts[self._result] += 1
|
|
387
387
|
|
|
388
|
-
def _contained_reference(value: Any) ->
|
|
388
|
+
def _contained_reference(value: Any) -> Any | None:
|
|
389
389
|
"""Gets a contained reference from a ValueNode, if there is one."""
|
|
390
390
|
if 'functionDefinitionValue' in value:
|
|
391
391
|
return value['functionDefinitionValue']['body']
|
ee/table_converter.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Converters used in the table data fetching methods."""
|
|
2
2
|
|
|
3
3
|
from collections.abc import Iterator
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class TableConverter:
|
|
@@ -59,8 +59,8 @@ _TABLE_DATA_CONVERTERS: dict[str, type[TableConverter]] = {
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
def from_file_format(
|
|
62
|
-
file_format:
|
|
63
|
-
) ->
|
|
62
|
+
file_format: str | TableConverter
|
|
63
|
+
) -> TableConverter | None:
|
|
64
64
|
if isinstance(file_format, TableConverter):
|
|
65
65
|
return file_format
|
|
66
66
|
if file_format in _TABLE_DATA_CONVERTERS:
|
ee/tests/batch_test.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""Test for the ee.batch module."""
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
import unittest
|
|
7
7
|
from unittest import mock
|
|
8
8
|
|
|
@@ -201,8 +201,8 @@ class ExportTest(unittest.TestCase):
|
|
|
201
201
|
class BatchTestCase(apitestcase.ApiTestCase):
|
|
202
202
|
"""A test case for batch functionality."""
|
|
203
203
|
|
|
204
|
-
start_call_params:
|
|
205
|
-
update_call_params:
|
|
204
|
+
start_call_params: Any | None
|
|
205
|
+
update_call_params: Any | None
|
|
206
206
|
|
|
207
207
|
def setUp(self):
|
|
208
208
|
super().setUp()
|
ee/tests/collection_test.py
CHANGED
|
@@ -47,6 +47,10 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
47
47
|
|
|
48
48
|
# We don't allow empty filters.
|
|
49
49
|
self.assertRaises(Exception, collection.filter)
|
|
50
|
+
with self.assertRaisesRegex(ee.EEException, 'Empty filters.'):
|
|
51
|
+
collection.filter(None) # pytype: disable=wrong-arg-types
|
|
52
|
+
with self.assertRaisesRegex(ee.EEException, 'Empty filters.'):
|
|
53
|
+
collection.filter('')
|
|
50
54
|
|
|
51
55
|
filtered = collection.filter(ee.Filter.eq('foo', 1))
|
|
52
56
|
self.assertEqual(ee.ApiFunction.lookup('Collection.filter'), filtered.func)
|
|
@@ -75,6 +79,37 @@ class CollectionTestCase(apitestcase.ApiTestCase):
|
|
|
75
79
|
collection.filter(ee.Filter.eq('foo', 13)),
|
|
76
80
|
collection.filterMetadata('foo', 'equals', 13))
|
|
77
81
|
|
|
82
|
+
def test_load_table(self):
|
|
83
|
+
"""Verifies Collection.loadTable()."""
|
|
84
|
+
table_id = 'a/table/id'
|
|
85
|
+
geometry_column = 'geom'
|
|
86
|
+
version = 123
|
|
87
|
+
result = ee.Collection.loadTable(
|
|
88
|
+
tableId=table_id, geometryColumn=geometry_column, version=version
|
|
89
|
+
)
|
|
90
|
+
self.assertEqual(ee.ApiFunction.lookup('Collection.loadTable'), result.func)
|
|
91
|
+
self.assertEqual(
|
|
92
|
+
{
|
|
93
|
+
'tableId': ee.String(table_id),
|
|
94
|
+
'geometryColumn': ee.String(geometry_column),
|
|
95
|
+
'version': ee.Number(version),
|
|
96
|
+
},
|
|
97
|
+
result.args,
|
|
98
|
+
)
|
|
99
|
+
self.assertIsInstance(result, ee.FeatureCollection)
|
|
100
|
+
|
|
101
|
+
result2 = ee.Collection.loadTable(tableId=table_id)
|
|
102
|
+
self.assertEqual(ee.ApiFunction.lookup('Collection.loadTable'), result2.func)
|
|
103
|
+
self.assertEqual(
|
|
104
|
+
{
|
|
105
|
+
'tableId': ee.String(table_id),
|
|
106
|
+
'geometryColumn': None,
|
|
107
|
+
'version': None,
|
|
108
|
+
},
|
|
109
|
+
result2.args,
|
|
110
|
+
)
|
|
111
|
+
self.assertIsInstance(result2, ee.FeatureCollection)
|
|
112
|
+
|
|
78
113
|
def test_mapping(self):
|
|
79
114
|
"""Verifies the behavior of the map() method."""
|
|
80
115
|
collection = ee.ImageCollection('foo')
|
ee/tests/data_test.py
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"""Test for the ee.data module."""
|
|
3
3
|
|
|
4
4
|
import json
|
|
5
|
-
from typing import Any
|
|
5
|
+
from typing import Any
|
|
6
6
|
from unittest import mock
|
|
7
7
|
|
|
8
8
|
import googleapiclient
|
|
@@ -28,7 +28,7 @@ def NotFoundError() -> googleapiclient.errors.HttpError:
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def NewFolderAsset(
|
|
31
|
-
name: str, quota:
|
|
31
|
+
name: str, quota: dict[str, int] | None = None
|
|
32
32
|
) -> dict[str, Any]:
|
|
33
33
|
return {
|
|
34
34
|
'type': 'FOLDER',
|
|
@@ -66,7 +66,9 @@ class DataTest(unittest.TestCase):
|
|
|
66
66
|
mock_install_cloud_api_resource.assert_called_once()
|
|
67
67
|
|
|
68
68
|
@mock.patch.object(ee.data, '_install_cloud_api_resource', return_value=None)
|
|
69
|
-
def test_initialize_with_project(
|
|
69
|
+
def test_initialize_with_project(
|
|
70
|
+
self, unused_mock_install_cloud_api_resource
|
|
71
|
+
):
|
|
70
72
|
ee.data.initialize(project='my-project')
|
|
71
73
|
|
|
72
74
|
self.assertTrue(ee.data.is_initialized())
|
ee/tests/ee_number_test.py
CHANGED
|
@@ -396,6 +396,31 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
396
396
|
result = json.loads(expression.serialize())
|
|
397
397
|
self.assertEqual(expect, result)
|
|
398
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
|
+
|
|
399
424
|
def test_first(self):
|
|
400
425
|
expect = make_expression_graph({
|
|
401
426
|
'arguments': {
|
|
@@ -795,7 +820,21 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
795
820
|
result = json.loads(expression.serialize())
|
|
796
821
|
self.assertEqual(expect, result)
|
|
797
822
|
|
|
798
|
-
|
|
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)
|
|
799
838
|
|
|
800
839
|
def test_pow(self):
|
|
801
840
|
expect = make_expression_graph({
|
ee/tests/image_converter_test.py
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""Tests for the image_converter module."""
|
|
3
3
|
|
|
4
|
-
from typing import Optional
|
|
5
|
-
|
|
6
4
|
from absl.testing import parameterized
|
|
7
5
|
import numpy
|
|
8
6
|
|
|
@@ -20,7 +18,7 @@ class ImageConverterTest(parameterized.TestCase):
|
|
|
20
18
|
def test_from_file_format(
|
|
21
19
|
self,
|
|
22
20
|
data_format: str,
|
|
23
|
-
expected:
|
|
21
|
+
expected: type[image_converter.ImageConverter] | None,
|
|
24
22
|
) -> None:
|
|
25
23
|
"""Verifies `from_file_format` returns the correct converter class."""
|
|
26
24
|
if expected is None:
|
ee/tests/serializer_test.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""Test for the ee.serializer module."""
|
|
3
3
|
|
|
4
|
+
from collections.abc import Callable
|
|
4
5
|
import datetime
|
|
5
6
|
import json
|
|
6
|
-
from typing import Any
|
|
7
|
+
from typing import Any
|
|
7
8
|
|
|
8
9
|
import unittest
|
|
9
10
|
import ee
|
|
@@ -11,7 +12,7 @@ from ee import apitestcase
|
|
|
11
12
|
from ee import serializer
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
def _max_depth(x:
|
|
15
|
+
def _max_depth(x: dict[str, Any] | list[Any] | str) -> int:
|
|
15
16
|
"""Computes the maximum nesting level of some dict, list, or str."""
|
|
16
17
|
if isinstance(x, dict):
|
|
17
18
|
return 1 + max(_max_depth(v) for v in x.values())
|
ee/tests/table_converter_test.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""Tests for the table_converter module."""
|
|
3
3
|
|
|
4
|
-
from typing import Any
|
|
4
|
+
from typing import Any
|
|
5
5
|
|
|
6
6
|
from absl.testing import parameterized
|
|
7
7
|
import geopandas
|
|
@@ -28,7 +28,7 @@ class TableConverterTest(parameterized.TestCase):
|
|
|
28
28
|
def test_from_file_format(
|
|
29
29
|
self,
|
|
30
30
|
data_format: str,
|
|
31
|
-
expected:
|
|
31
|
+
expected: type[table_converter.TableConverter] | None,
|
|
32
32
|
) -> None:
|
|
33
33
|
"""Verifies `from_file_format` returns the correct converter class."""
|
|
34
34
|
if expected is None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|