earthengine-api 1.6.11rc0__py3-none-any.whl → 1.6.12__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.
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/METADATA +1 -1
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/RECORD +48 -46
- ee/__init__.py +5 -5
- ee/_cloud_api_utils.py +33 -10
- ee/_state.py +105 -0
- ee/apifunction.py +1 -1
- ee/apitestcase.py +15 -21
- ee/batch.py +1 -1
- ee/cli/commands.py +153 -63
- ee/cli/eecli.py +1 -1
- ee/cli/utils.py +25 -15
- ee/collection.py +27 -18
- ee/computedobject.py +5 -5
- ee/customfunction.py +3 -3
- ee/data.py +104 -210
- ee/ee_array.py +4 -2
- ee/ee_number.py +1 -1
- ee/ee_string.py +18 -26
- ee/ee_types.py +2 -2
- ee/element.py +1 -1
- ee/featurecollection.py +10 -7
- ee/filter.py +2 -2
- ee/geometry.py +20 -21
- ee/image.py +7 -12
- ee/imagecollection.py +3 -3
- ee/mapclient.py +9 -9
- ee/oauth.py +13 -6
- ee/tests/_cloud_api_utils_test.py +16 -0
- ee/tests/_helpers_test.py +9 -9
- ee/tests/_state_test.py +49 -0
- ee/tests/apifunction_test.py +5 -5
- ee/tests/batch_test.py +61 -50
- ee/tests/collection_test.py +13 -13
- ee/tests/data_test.py +65 -60
- ee/tests/dictionary_test.py +9 -9
- ee/tests/ee_number_test.py +32 -26
- ee/tests/ee_string_test.py +8 -0
- ee/tests/ee_test.py +37 -19
- ee/tests/element_test.py +2 -2
- ee/tests/feature_test.py +6 -6
- ee/tests/function_test.py +5 -5
- ee/tests/geometry_test.py +73 -51
- ee/tests/oauth_test.py +21 -2
- ee/tests/serializer_test.py +8 -8
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/WHEEL +0 -0
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/entry_points.txt +0 -0
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/licenses/LICENSE +0 -0
- {earthengine_api-1.6.11rc0.dist-info → earthengine_api-1.6.12.dist-info}/top_level.txt +0 -0
ee/tests/ee_number_test.py
CHANGED
|
@@ -21,7 +21,7 @@ def make_expression_graph(
|
|
|
21
21
|
|
|
22
22
|
class NumberTest(apitestcase.ApiTestCase):
|
|
23
23
|
|
|
24
|
-
def
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
377
|
+
def test_erfc_inv(self):
|
|
372
378
|
expect = make_expression_graph({
|
|
373
379
|
'arguments': {
|
|
374
380
|
'input': {'constantValue': 1},
|
|
@@ -406,7 +412,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
406
412
|
result = json.loads(expression.serialize())
|
|
407
413
|
self.assertEqual(expect, result)
|
|
408
414
|
|
|
409
|
-
def
|
|
415
|
+
def test_first_non_zero(self):
|
|
410
416
|
expect = make_expression_graph({
|
|
411
417
|
'arguments': {
|
|
412
418
|
'left': {'constantValue': 1},
|
|
@@ -601,7 +607,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
601
607
|
result = json.loads(expression.serialize())
|
|
602
608
|
self.assertEqual(expect, result)
|
|
603
609
|
|
|
604
|
-
def
|
|
610
|
+
def test_left_shift(self):
|
|
605
611
|
expect = make_expression_graph({
|
|
606
612
|
'arguments': {
|
|
607
613
|
'left': {'constantValue': 1},
|
|
@@ -807,7 +813,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
807
813
|
result = json.loads(expression.serialize())
|
|
808
814
|
self.assertEqual(expect, result)
|
|
809
815
|
|
|
810
|
-
def
|
|
816
|
+
def test_right_shift(self):
|
|
811
817
|
expect = make_expression_graph({
|
|
812
818
|
'arguments': {
|
|
813
819
|
'left': {'constantValue': 1},
|
|
@@ -927,7 +933,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
927
933
|
result = json.loads(expression.serialize())
|
|
928
934
|
self.assertEqual(expect, result)
|
|
929
935
|
|
|
930
|
-
def
|
|
936
|
+
def test_to_byte(self):
|
|
931
937
|
expect = make_expression_graph({
|
|
932
938
|
'arguments': {
|
|
933
939
|
'input': {'constantValue': 1},
|
|
@@ -938,7 +944,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
938
944
|
result = json.loads(expression.serialize())
|
|
939
945
|
self.assertEqual(expect, result)
|
|
940
946
|
|
|
941
|
-
def
|
|
947
|
+
def test_to_double(self):
|
|
942
948
|
expect = make_expression_graph({
|
|
943
949
|
'arguments': {
|
|
944
950
|
'input': {'constantValue': 1},
|
|
@@ -949,7 +955,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
949
955
|
result = json.loads(expression.serialize())
|
|
950
956
|
self.assertEqual(expect, result)
|
|
951
957
|
|
|
952
|
-
def
|
|
958
|
+
def test_to_float(self):
|
|
953
959
|
expect = make_expression_graph({
|
|
954
960
|
'arguments': {
|
|
955
961
|
'input': {'constantValue': 1},
|
|
@@ -960,7 +966,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
960
966
|
result = json.loads(expression.serialize())
|
|
961
967
|
self.assertEqual(expect, result)
|
|
962
968
|
|
|
963
|
-
def
|
|
969
|
+
def test_to_int(self):
|
|
964
970
|
expect = make_expression_graph({
|
|
965
971
|
'arguments': {
|
|
966
972
|
'input': {'constantValue': 1},
|
|
@@ -971,7 +977,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
971
977
|
result = json.loads(expression.serialize())
|
|
972
978
|
self.assertEqual(expect, result)
|
|
973
979
|
|
|
974
|
-
def
|
|
980
|
+
def test_to_int16(self):
|
|
975
981
|
expect = make_expression_graph({
|
|
976
982
|
'arguments': {
|
|
977
983
|
'input': {'constantValue': 1},
|
|
@@ -982,7 +988,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
982
988
|
result = json.loads(expression.serialize())
|
|
983
989
|
self.assertEqual(expect, result)
|
|
984
990
|
|
|
985
|
-
def
|
|
991
|
+
def test_to_int32(self):
|
|
986
992
|
expect = make_expression_graph({
|
|
987
993
|
'arguments': {
|
|
988
994
|
'input': {'constantValue': 1},
|
|
@@ -993,7 +999,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
993
999
|
result = json.loads(expression.serialize())
|
|
994
1000
|
self.assertEqual(expect, result)
|
|
995
1001
|
|
|
996
|
-
def
|
|
1002
|
+
def test_to_int64(self):
|
|
997
1003
|
expect = make_expression_graph({
|
|
998
1004
|
'arguments': {
|
|
999
1005
|
'input': {'constantValue': 1},
|
|
@@ -1004,7 +1010,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1004
1010
|
result = json.loads(expression.serialize())
|
|
1005
1011
|
self.assertEqual(expect, result)
|
|
1006
1012
|
|
|
1007
|
-
def
|
|
1013
|
+
def test_to_int8(self):
|
|
1008
1014
|
expect = make_expression_graph({
|
|
1009
1015
|
'arguments': {
|
|
1010
1016
|
'input': {'constantValue': 1},
|
|
@@ -1015,7 +1021,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1015
1021
|
result = json.loads(expression.serialize())
|
|
1016
1022
|
self.assertEqual(expect, result)
|
|
1017
1023
|
|
|
1018
|
-
def
|
|
1024
|
+
def test_to_long(self):
|
|
1019
1025
|
expect = make_expression_graph({
|
|
1020
1026
|
'arguments': {
|
|
1021
1027
|
'input': {'constantValue': 1},
|
|
@@ -1026,7 +1032,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1026
1032
|
result = json.loads(expression.serialize())
|
|
1027
1033
|
self.assertEqual(expect, result)
|
|
1028
1034
|
|
|
1029
|
-
def
|
|
1035
|
+
def test_to_short(self):
|
|
1030
1036
|
expect = make_expression_graph({
|
|
1031
1037
|
'arguments': {
|
|
1032
1038
|
'input': {'constantValue': 1},
|
|
@@ -1037,7 +1043,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1037
1043
|
result = json.loads(expression.serialize())
|
|
1038
1044
|
self.assertEqual(expect, result)
|
|
1039
1045
|
|
|
1040
|
-
def
|
|
1046
|
+
def test_to_uint16(self):
|
|
1041
1047
|
expect = make_expression_graph({
|
|
1042
1048
|
'arguments': {
|
|
1043
1049
|
'input': {'constantValue': 1},
|
|
@@ -1048,7 +1054,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1048
1054
|
result = json.loads(expression.serialize())
|
|
1049
1055
|
self.assertEqual(expect, result)
|
|
1050
1056
|
|
|
1051
|
-
def
|
|
1057
|
+
def test_to_uint32(self):
|
|
1052
1058
|
expect = make_expression_graph({
|
|
1053
1059
|
'arguments': {
|
|
1054
1060
|
'input': {'constantValue': 1},
|
|
@@ -1059,7 +1065,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1059
1065
|
result = json.loads(expression.serialize())
|
|
1060
1066
|
self.assertEqual(expect, result)
|
|
1061
1067
|
|
|
1062
|
-
def
|
|
1068
|
+
def test_to_uint8(self):
|
|
1063
1069
|
expect = make_expression_graph({
|
|
1064
1070
|
'arguments': {
|
|
1065
1071
|
'input': {'constantValue': 1},
|
|
@@ -1114,7 +1120,7 @@ class NumberTest(apitestcase.ApiTestCase):
|
|
|
1114
1120
|
result = json.loads(expression.serialize())
|
|
1115
1121
|
self.assertEqual(expect, result)
|
|
1116
1122
|
|
|
1117
|
-
def
|
|
1123
|
+
def test_unit_scale(self):
|
|
1118
1124
|
expect = make_expression_graph({
|
|
1119
1125
|
'arguments': {
|
|
1120
1126
|
'number': {'constantValue': 1},
|
ee/tests/ee_string_test.py
CHANGED
|
@@ -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': {
|
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
|
|
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
|
-
|
|
31
|
-
self.
|
|
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
|
-
|
|
38
|
-
self.
|
|
39
|
-
self.assertEqual(
|
|
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
|
-
|
|
46
|
-
self.
|
|
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
|
-
|
|
51
|
-
self.
|
|
52
|
-
self.
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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,7 +476,7 @@ 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
|
|
479
|
+
def test_non_ascii_documentation(self):
|
|
462
480
|
"""Verifies that non-ASCII characters in documentation work."""
|
|
463
481
|
foo = '\uFB00\u00F6\u01EB'
|
|
464
482
|
bar = 'b\u00E4r'
|
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
|
|
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
|
|
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
|
|
ee/tests/feature_test.py
CHANGED
|
@@ -71,7 +71,7 @@ def make_expression_graph(
|
|
|
71
71
|
|
|
72
72
|
class FeatureTest(apitestcase.ApiTestCase):
|
|
73
73
|
|
|
74
|
-
def
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
649
|
+
def test_within_distance(self):
|
|
650
650
|
expect = {
|
|
651
651
|
'result': '0',
|
|
652
652
|
'values': {
|
ee/tests/function_test.py
CHANGED
|
@@ -34,7 +34,7 @@ Args:
|
|
|
34
34
|
|
|
35
35
|
class FunctionTest(unittest.TestCase):
|
|
36
36
|
|
|
37
|
-
def
|
|
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
|
|
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
|
|
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
|
|
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
|
|
98
|
+
def test_argument_failure_message(self):
|
|
99
99
|
"""Verifies properly formed function error message generation."""
|
|
100
100
|
self.assertRaisesRegex(
|
|
101
101
|
ee.EEException,
|