earthengine-api 1.6.14rc0__tar.gz → 1.6.15rc0__tar.gz
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.14rc0/earthengine_api.egg-info → earthengine_api-1.6.15rc0}/PKG-INFO +1 -1
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0/earthengine_api.egg-info}/PKG-INFO +1 -1
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/__init__.py +1 -1
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/cli/commands.py +4 -8
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/cli/utils.py +26 -21
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/deserializer.py +6 -6
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/reducer.py +2 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/deserializer_test.py +47 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/kernel_test.py +4 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/model_test.py +12 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/reducer_test.py +13 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/pyproject.toml +1 -1
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/LICENSE +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/MANIFEST.in +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/README.md +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/SOURCES.txt +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/dependency_links.txt +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/entry_points.txt +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/requires.txt +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/top_level.txt +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/_arg_types.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/_cloud_api_utils.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/_helpers.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/_state.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/_utils.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/apifunction.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/apitestcase.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/batch.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/blob.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/classifier.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/cli/__init__.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/cli/eecli.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/cli/eecli_wrapper.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/clusterer.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/collection.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/computedobject.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/confusionmatrix.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/customfunction.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/data.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/daterange.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/deprecation.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/dictionary.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_array.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_date.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_exception.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_list.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_number.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_string.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/ee_types.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/element.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/encodable.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/errormargin.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/feature.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/featurecollection.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/filter.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/function.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/geometry.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/image.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/image_converter.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/imagecollection.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/join.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/kernel.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/mapclient.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/model.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/oauth.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/pixeltype.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/projection.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/py.typed +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/serializer.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/table_converter.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/terrain.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/_cloud_api_utils_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/_helpers_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/_state_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/_utils_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/algorithms.json +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/apifunction_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/batch_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/blob_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/classifier_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/cloud_api_discovery_document.json +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/clusterer_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/collection_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/computedobject_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/confusionmatrix_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/data_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/daterange_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/deprecation_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/dictionary_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_array_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_date_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_list_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_number_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_string_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/ee_types_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/element_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/errormargin_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/feature_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/featurecollection_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/filter_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/function_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/geometry_point_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/geometry_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/image_converter_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/image_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/imagecollection_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/join_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/oauth_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/pixeltype_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/projection_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/serializer_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/table_converter_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/terrain_test.py +0 -0
- {earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/setup.cfg +0 -0
|
@@ -128,7 +128,7 @@ def _comma_separated_strings(string: str) -> list[str]:
|
|
|
128
128
|
"""Parses an input consisting of comma-separated strings."""
|
|
129
129
|
error_msg = 'Argument should be a comma-separated list of strings: {}'
|
|
130
130
|
values = string.split(',')
|
|
131
|
-
if not values:
|
|
131
|
+
if not all(values):
|
|
132
132
|
raise argparse.ArgumentTypeError(error_msg.format(string))
|
|
133
133
|
return values
|
|
134
134
|
|
|
@@ -137,7 +137,7 @@ def _comma_separated_numbers(string: str) -> list[float]:
|
|
|
137
137
|
"""Parses an input consisting of comma-separated numbers."""
|
|
138
138
|
error_msg = 'Argument should be a comma-separated list of numbers: {}'
|
|
139
139
|
values = string.split(',')
|
|
140
|
-
if not values:
|
|
140
|
+
if not all(values):
|
|
141
141
|
raise argparse.ArgumentTypeError(error_msg.format(string))
|
|
142
142
|
numbervalues = []
|
|
143
143
|
for value in values:
|
|
@@ -155,9 +155,9 @@ def _comma_separated_numbers(string: str) -> list[float]:
|
|
|
155
155
|
def _comma_separated_pyramiding_policies(string: str) -> list[str]:
|
|
156
156
|
"""Parses an input consisting of comma-separated pyramiding policies."""
|
|
157
157
|
error_msg = ('Argument should be a comma-separated list of: '
|
|
158
|
-
'{{"mean", "sample", "min", "max", "mode"}}: {}')
|
|
158
|
+
'{{"mean", "median", "sample", "min", "max", "mode"}}: {}')
|
|
159
159
|
values = string.split(',')
|
|
160
|
-
if not values:
|
|
160
|
+
if not all(values):
|
|
161
161
|
raise argparse.ArgumentTypeError(error_msg.format(string))
|
|
162
162
|
redvalues = []
|
|
163
163
|
for value in values:
|
|
@@ -226,10 +226,6 @@ def _format_cloud_timestamp(timestamp: str | None) -> str:
|
|
|
226
226
|
return _datetime_from_cloud_timestamp(timestamp).strftime('%Y-%m-%d %H:%M:%S')
|
|
227
227
|
|
|
228
228
|
|
|
229
|
-
def _parse_millis(millis: float) -> datetime.datetime:
|
|
230
|
-
return datetime.datetime.fromtimestamp(millis / 1000)
|
|
231
|
-
|
|
232
|
-
|
|
233
229
|
def _decode_date(string: str) -> Union[float, str]:
|
|
234
230
|
"""Decodes a date from a command line argument, returning msec since epoch".
|
|
235
231
|
|
|
@@ -145,7 +145,10 @@ class CommandLineConfig:
|
|
|
145
145
|
|
|
146
146
|
|
|
147
147
|
def _split_gcs_path(path):
|
|
148
|
-
|
|
148
|
+
# This only catches some troubles. For complete details on naming, see:
|
|
149
|
+
# https://cloud.google.com/storage/docs/buckets
|
|
150
|
+
# https://cloud.google.com/storage/docs/objects#naming
|
|
151
|
+
m = re.search('gs://([a-z0-9][a-z0-9-_.]*)/(.*)', path, re.IGNORECASE)
|
|
149
152
|
if not m:
|
|
150
153
|
raise ValueError(f"'{path}' is not a valid GCS path")
|
|
151
154
|
|
|
@@ -197,7 +200,7 @@ class GcsHelper:
|
|
|
197
200
|
if not os.path.exists(dir_path):
|
|
198
201
|
os.makedirs(dir_path)
|
|
199
202
|
|
|
200
|
-
if output_path
|
|
203
|
+
if not output_path.endswith('/'):
|
|
201
204
|
blob.download_to_filename(output_path)
|
|
202
205
|
|
|
203
206
|
return temp_dir
|
|
@@ -206,7 +209,7 @@ class GcsHelper:
|
|
|
206
209
|
"""Uploads a directory to cloud storage."""
|
|
207
210
|
canonical_path = _canonicalize_dir_path(source_path)
|
|
208
211
|
|
|
209
|
-
files =
|
|
212
|
+
files = []
|
|
210
213
|
for dirpath, _, filenames in os.walk(canonical_path):
|
|
211
214
|
files += [os.path.join(dirpath, f) for f in filenames]
|
|
212
215
|
|
|
@@ -224,7 +227,7 @@ def is_gcs_path(path: str) -> bool:
|
|
|
224
227
|
|
|
225
228
|
|
|
226
229
|
def query_yes_no(msg: str) -> bool:
|
|
227
|
-
print('
|
|
230
|
+
print(f'{msg} (y/n)')
|
|
228
231
|
while True:
|
|
229
232
|
confirm = input().lower()
|
|
230
233
|
if confirm == 'y':
|
|
@@ -264,10 +267,9 @@ def wait_for_task(
|
|
|
264
267
|
state = status['metadata']['state']
|
|
265
268
|
if status.get('done', False):
|
|
266
269
|
error_message = status.get('error', {}).get('message')
|
|
267
|
-
print('Task
|
|
268
|
-
% (task_id, state, elapsed))
|
|
270
|
+
print(f'Task {task_id} ended at state: {state} after {elapsed:.2f} seconds')
|
|
269
271
|
if error_message:
|
|
270
|
-
raise ee.ee_exception.EEException('Error:
|
|
272
|
+
raise ee.ee_exception.EEException(f'Error: {error_message}')
|
|
271
273
|
return
|
|
272
274
|
if log_progress and elapsed - last_check >= 30:
|
|
273
275
|
print('[{:%H:%M:%S}] Current state for task {}: {}'
|
|
@@ -309,17 +311,20 @@ def wait_for_tasks(
|
|
|
309
311
|
status_counts = collections.defaultdict(int)
|
|
310
312
|
for status in status_list:
|
|
311
313
|
status_counts[status] += 1
|
|
314
|
+
succeeded = status_counts['SUCCEEDED']
|
|
315
|
+
failed = status_counts['FAILED']
|
|
316
|
+
cancelled = status_counts['CANCELLED']
|
|
312
317
|
num_incomplete = (
|
|
313
318
|
len(status_list)
|
|
314
|
-
-
|
|
315
|
-
-
|
|
316
|
-
-
|
|
319
|
+
- succeeded
|
|
320
|
+
- failed
|
|
321
|
+
- cancelled
|
|
317
322
|
)
|
|
318
323
|
print('Finished waiting for tasks.\n Status summary:')
|
|
319
|
-
print('
|
|
320
|
-
print('
|
|
321
|
-
print('
|
|
322
|
-
print('
|
|
324
|
+
print(f' {succeeded} tasks completed successfully.')
|
|
325
|
+
print(f' {failed} tasks failed.')
|
|
326
|
+
print(f' {cancelled} tasks cancelled.')
|
|
327
|
+
print(f' {num_incomplete} tasks are still incomplete (timed-out)')
|
|
323
328
|
|
|
324
329
|
|
|
325
330
|
def expand_gcs_wildcards(source_files: list[str]) -> Iterable[str]:
|
|
@@ -351,7 +356,7 @@ def expand_gcs_wildcards(source_files: list[str]) -> Iterable[str]:
|
|
|
351
356
|
bucket, rest = bucket_match.group(1, 2)
|
|
352
357
|
else:
|
|
353
358
|
raise ee.ee_exception.EEException(
|
|
354
|
-
'Badly formatted source file or bucket:
|
|
359
|
+
f'Badly formatted source file or bucket: {source}')
|
|
355
360
|
prefix = rest[:rest.find('*')] # Everything before the first wildcard
|
|
356
361
|
|
|
357
362
|
bucket_files = _gcs_ls(bucket, prefix)
|
|
@@ -395,23 +400,23 @@ def _gcs_ls(bucket: str, prefix: str = '') -> Iterable[str]:
|
|
|
395
400
|
try:
|
|
396
401
|
response, content = http.request(url, method=method)
|
|
397
402
|
except httplib2.HttpLib2Error as e:
|
|
398
|
-
raise ee.ee_exception.EEException('Unexpected HTTP error:
|
|
403
|
+
raise ee.ee_exception.EEException(f'Unexpected HTTP error: {e}') from e
|
|
399
404
|
|
|
400
405
|
if response.status < 100 or response.status >= 300:
|
|
401
406
|
raise ee.ee_exception.EEException(
|
|
402
|
-
'Error retrieving bucket
|
|
403
|
-
|
|
407
|
+
f'Error retrieving bucket {bucket}; '
|
|
408
|
+
f'Server returned HTTP code: {response.status}'
|
|
404
409
|
)
|
|
405
410
|
|
|
406
411
|
json_content = json.loads(content)
|
|
407
412
|
if 'error' in json_content:
|
|
408
413
|
json_error = json_content['error']['message']
|
|
409
|
-
raise ee.ee_exception.EEException(
|
|
410
|
-
|
|
414
|
+
raise ee.ee_exception.EEException(
|
|
415
|
+
f'Error retrieving bucket {bucket}: {json_error}')
|
|
411
416
|
|
|
412
417
|
if 'items' not in json_content:
|
|
413
418
|
raise ee.ee_exception.EEException(
|
|
414
|
-
'Cannot find items list in the response from GCS:
|
|
419
|
+
f'Cannot find items list in the response from GCS: {json_content}')
|
|
415
420
|
objects = json_content['items']
|
|
416
421
|
object_names = [str(gc_object['name']) for gc_object in objects]
|
|
417
422
|
|
|
@@ -76,7 +76,7 @@ def _decodeValue(json_obj: Any, named_values: dict[str, Any]) -> Any:
|
|
|
76
76
|
|
|
77
77
|
# Ensure that we've got a proper object at this point.
|
|
78
78
|
if not isinstance(json_obj, dict):
|
|
79
|
-
raise ee_exception.EEException('Cannot decode object: '
|
|
79
|
+
raise ee_exception.EEException(f'Cannot decode object: {json_obj}')
|
|
80
80
|
|
|
81
81
|
# Check for explicitly typed values.
|
|
82
82
|
type_name = json_obj['type']
|
|
@@ -88,12 +88,12 @@ def _decodeValue(json_obj: Any, named_values: dict[str, Any]) -> Any:
|
|
|
88
88
|
elif type_name == 'ArgumentRef':
|
|
89
89
|
var_name = json_obj['value']
|
|
90
90
|
if not isinstance(var_name, str):
|
|
91
|
-
raise ee_exception.EEException('Invalid variable name: '
|
|
92
|
-
return customfunction.CustomFunction.variable(None, var_name)
|
|
91
|
+
raise ee_exception.EEException(f'Invalid variable name: {var_name}')
|
|
92
|
+
return customfunction.CustomFunction.variable(None, var_name)
|
|
93
93
|
elif type_name == 'Date':
|
|
94
94
|
microseconds = json_obj['value']
|
|
95
95
|
if not isinstance(microseconds, (float, int)):
|
|
96
|
-
raise ee_exception.EEException('Invalid date value: '
|
|
96
|
+
raise ee_exception.EEException(f'Invalid date value: {microseconds}')
|
|
97
97
|
return ee_date.Date(microseconds / 1e3)
|
|
98
98
|
elif type_name == 'Bytes':
|
|
99
99
|
result = encodable.Encodable()
|
|
@@ -131,7 +131,7 @@ def _decodeValue(json_obj: Any, named_values: dict[str, Any]) -> Any:
|
|
|
131
131
|
elif type_name == 'CompoundValue':
|
|
132
132
|
raise ee_exception.EEException('Nested CompoundValues are disallowed.')
|
|
133
133
|
else:
|
|
134
|
-
raise ee_exception.EEException('Unknown encoded object type: '
|
|
134
|
+
raise ee_exception.EEException(f'Unknown encoded object type: {type_name}')
|
|
135
135
|
|
|
136
136
|
|
|
137
137
|
def _invocation(func: Any, args: dict[str, Any]) -> Any:
|
|
@@ -150,7 +150,7 @@ def _invocation(func: Any, args: dict[str, Any]) -> Any:
|
|
|
150
150
|
'returns': 'ComputedObject'
|
|
151
151
|
}
|
|
152
152
|
return function.SecondOrderFunction(func, signature).apply(args)
|
|
153
|
-
raise ee_exception.EEException('Invalid function value:
|
|
153
|
+
raise ee_exception.EEException(f'Invalid function value: {func}')
|
|
154
154
|
|
|
155
155
|
|
|
156
156
|
def fromCloudApiJSON(json_obj: Union[str, bytes]) -> Any: # pylint: disable=g-bad-name
|
|
@@ -465,8 +465,10 @@ class Reducer(computedobject.ComputedObject):
|
|
|
465
465
|
|
|
466
466
|
def group(
|
|
467
467
|
self,
|
|
468
|
+
# pylint: disable=invalid-name
|
|
468
469
|
groupField: _arg_types.Integer | None = None,
|
|
469
470
|
groupName: _arg_types.String | None = None,
|
|
471
|
+
# pylint: enable=invalid-name
|
|
470
472
|
) -> Reducer:
|
|
471
473
|
"""Returns a reducer groups reducer records by the value of a given input.
|
|
472
474
|
|
|
@@ -80,6 +80,53 @@ class DeserializerTest(apitestcase.ApiTestCase):
|
|
|
80
80
|
):
|
|
81
81
|
deserializer.decode(encoded)
|
|
82
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
|
+
|
|
83
130
|
|
|
84
131
|
if __name__ == '__main__':
|
|
85
132
|
unittest.main()
|
|
@@ -287,6 +287,10 @@ class KernelTest(apitestcase.ApiTestCase):
|
|
|
287
287
|
result = json.loads(expression.serialize())
|
|
288
288
|
self.assertEqual(expect, result)
|
|
289
289
|
|
|
290
|
+
def test_fixed_no_weights(self):
|
|
291
|
+
with self.assertRaisesRegex(ValueError, 'weights is required.'):
|
|
292
|
+
ee.Kernel.fixed()
|
|
293
|
+
|
|
290
294
|
def test_gaussian(self):
|
|
291
295
|
radius = 1.1
|
|
292
296
|
sigma = 2.2
|
|
@@ -115,6 +115,18 @@ class ModelTest(apitestcase.ApiTestCase):
|
|
|
115
115
|
}
|
|
116
116
|
self.assertEqual(expect, result)
|
|
117
117
|
|
|
118
|
+
def test_model_constructor_invalid(self):
|
|
119
|
+
with self.assertRaisesRegex(
|
|
120
|
+
TypeError, 'Model constructor can only cast to Model.'
|
|
121
|
+
):
|
|
122
|
+
ee.Model('not a computed object') # pytype: disable=wrong-arg-types
|
|
123
|
+
|
|
124
|
+
def test_model_constructor_invalid_int(self):
|
|
125
|
+
with self.assertRaisesRegex(
|
|
126
|
+
TypeError, 'Model constructor can only cast to Model.'
|
|
127
|
+
):
|
|
128
|
+
ee.Model(123) # pytype: disable=wrong-arg-types
|
|
129
|
+
|
|
118
130
|
def test_from_ai_platform_predictor(self):
|
|
119
131
|
project_name = 'some project'
|
|
120
132
|
project_id = 'a project id'
|
|
@@ -809,6 +809,19 @@ class ReducerTest(apitestcase.ApiTestCase):
|
|
|
809
809
|
result = json.loads(expression.serialize())
|
|
810
810
|
self.assertEqual(expect, result)
|
|
811
811
|
|
|
812
|
+
def test_ridge_regression_kwargs_with_lambda(self):
|
|
813
|
+
with self.assertRaisesRegex(
|
|
814
|
+
ValueError, 'lambda_ cannot be set when providing kwargs.'
|
|
815
|
+
):
|
|
816
|
+
ee.Reducer.ridgeRegression(1, lambda_=3, **{'lambda': 4})
|
|
817
|
+
|
|
818
|
+
def test_ridge_regression_unexpected_kwargs(self):
|
|
819
|
+
with self.assertRaisesRegex(
|
|
820
|
+
ValueError,
|
|
821
|
+
r"Unexpected arguments: \['unexpected'\]\. Expected: lambda.",
|
|
822
|
+
):
|
|
823
|
+
ee.Reducer.ridgeRegression(1, unexpected=4)
|
|
824
|
+
|
|
812
825
|
def test_robust_linear_regression(self):
|
|
813
826
|
num_x = 1
|
|
814
827
|
num_y = 2
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/entry_points.txt
RENAMED
|
File without changes
|
{earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/requires.txt
RENAMED
|
File without changes
|
{earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/earthengine_api.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{earthengine_api-1.6.14rc0 → earthengine_api-1.6.15rc0}/ee/tests/cloud_api_discovery_document.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|