earthengine-api 1.7.6rc0__tar.gz → 1.7.8rc0__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.

Files changed (118) hide show
  1. {earthengine_api-1.7.6rc0/earthengine_api.egg-info → earthengine_api-1.7.8rc0}/PKG-INFO +1 -1
  2. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0/earthengine_api.egg-info}/PKG-INFO +1 -1
  3. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/earthengine_api.egg-info/SOURCES.txt +1 -0
  4. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/__init__.py +1 -1
  5. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/data.py +15 -12
  6. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_list.py +3 -1
  7. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_types.py +1 -0
  8. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/encodable.py +4 -1
  9. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/feature.py +5 -4
  10. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/featurecollection.py +6 -6
  11. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/algorithms.json +2 -2
  12. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/data_test.py +133 -0
  13. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/daterange_test.py +25 -0
  14. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/ee_list_test.py +31 -1
  15. earthengine_api-1.7.8rc0/ee/tests/ee_types_test.py +58 -0
  16. earthengine_api-1.7.8rc0/ee/tests/element_test.py +138 -0
  17. earthengine_api-1.7.8rc0/ee/tests/encodable_test.py +29 -0
  18. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/feature_test.py +24 -0
  19. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/featurecollection_test.py +20 -0
  20. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/pyproject.toml +1 -1
  21. earthengine_api-1.7.6rc0/ee/tests/ee_types_test.py +0 -32
  22. earthengine_api-1.7.6rc0/ee/tests/element_test.py +0 -57
  23. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/LICENSE +0 -0
  24. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/MANIFEST.in +0 -0
  25. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/README.md +0 -0
  26. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/earthengine_api.egg-info/dependency_links.txt +0 -0
  27. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/earthengine_api.egg-info/entry_points.txt +0 -0
  28. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/earthengine_api.egg-info/requires.txt +0 -0
  29. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/earthengine_api.egg-info/top_level.txt +0 -0
  30. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/_arg_types.py +0 -0
  31. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/_cloud_api_utils.py +0 -0
  32. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/_helpers.py +0 -0
  33. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/_state.py +0 -0
  34. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/_utils.py +0 -0
  35. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/apifunction.py +0 -0
  36. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/apitestcase.py +0 -0
  37. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/batch.py +0 -0
  38. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/blob.py +0 -0
  39. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/classifier.py +0 -0
  40. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/cli/__init__.py +0 -0
  41. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/cli/commands.py +0 -0
  42. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/cli/eecli.py +0 -0
  43. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/cli/eecli_wrapper.py +0 -0
  44. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/cli/utils.py +0 -0
  45. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/clusterer.py +0 -0
  46. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/collection.py +0 -0
  47. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/computedobject.py +0 -0
  48. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/confusionmatrix.py +0 -0
  49. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/customfunction.py +0 -0
  50. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/daterange.py +0 -0
  51. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/deprecation.py +0 -0
  52. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/deserializer.py +0 -0
  53. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/dictionary.py +0 -0
  54. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_array.py +0 -0
  55. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_date.py +0 -0
  56. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_exception.py +0 -0
  57. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_number.py +0 -0
  58. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/ee_string.py +0 -0
  59. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/element.py +0 -0
  60. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/errormargin.py +0 -0
  61. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/filter.py +0 -0
  62. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/function.py +0 -0
  63. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/geometry.py +0 -0
  64. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/image.py +0 -0
  65. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/image_converter.py +0 -0
  66. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/imagecollection.py +0 -0
  67. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/join.py +0 -0
  68. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/kernel.py +0 -0
  69. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/mapclient.py +0 -0
  70. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/model.py +0 -0
  71. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/oauth.py +0 -0
  72. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/pixeltype.py +0 -0
  73. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/projection.py +0 -0
  74. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/py.typed +0 -0
  75. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/reducer.py +0 -0
  76. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/serializer.py +0 -0
  77. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/table_converter.py +0 -0
  78. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/terrain.py +0 -0
  79. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/_cloud_api_utils_test.py +0 -0
  80. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/_helpers_test.py +0 -0
  81. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/_state_test.py +0 -0
  82. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/_utils_test.py +0 -0
  83. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/apifunction_test.py +0 -0
  84. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/batch_test.py +0 -0
  85. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/blob_test.py +0 -0
  86. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/classifier_test.py +0 -0
  87. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/cloud_api_discovery_document.json +0 -0
  88. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/clusterer_test.py +0 -0
  89. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/collection_test.py +0 -0
  90. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/computedobject_test.py +0 -0
  91. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/confusionmatrix_test.py +0 -0
  92. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/deprecation_test.py +0 -0
  93. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/deserializer_test.py +0 -0
  94. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/dictionary_test.py +0 -0
  95. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/ee_array_test.py +0 -0
  96. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/ee_date_test.py +0 -0
  97. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/ee_number_test.py +0 -0
  98. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/ee_string_test.py +0 -0
  99. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/ee_test.py +0 -0
  100. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/errormargin_test.py +0 -0
  101. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/filter_test.py +0 -0
  102. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/function_test.py +0 -0
  103. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/geometry_point_test.py +0 -0
  104. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/geometry_test.py +0 -0
  105. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/image_converter_test.py +0 -0
  106. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/image_test.py +0 -0
  107. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/imagecollection_test.py +0 -0
  108. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/join_test.py +0 -0
  109. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/kernel_test.py +0 -0
  110. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/model_test.py +0 -0
  111. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/oauth_test.py +0 -0
  112. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/pixeltype_test.py +0 -0
  113. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/projection_test.py +0 -0
  114. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/reducer_test.py +0 -0
  115. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/serializer_test.py +0 -0
  116. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/table_converter_test.py +0 -0
  117. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/ee/tests/terrain_test.py +0 -0
  118. {earthengine_api-1.7.6rc0 → earthengine_api-1.7.8rc0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: earthengine-api
3
- Version: 1.7.6rc0
3
+ Version: 1.7.8rc0
4
4
  Summary: Earth Engine Python API
5
5
  Author-email: Google LLC <noreply@google.com>
6
6
  License: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: earthengine-api
3
- Version: 1.7.6rc0
3
+ Version: 1.7.8rc0
4
4
  Summary: Earth Engine Python API
5
5
  Author-email: Google LLC <noreply@google.com>
6
6
  License: Apache-2.0
@@ -91,6 +91,7 @@ ee/tests/ee_string_test.py
91
91
  ee/tests/ee_test.py
92
92
  ee/tests/ee_types_test.py
93
93
  ee/tests/element_test.py
94
+ ee/tests/encodable_test.py
94
95
  ee/tests/errormargin_test.py
95
96
  ee/tests/feature_test.py
96
97
  ee/tests/featurecollection_test.py
@@ -1,6 +1,6 @@
1
1
  """The EE Python library."""
2
2
 
3
- __version__ = '1.7.6rc0'
3
+ __version__ = '1.7.8rc0'
4
4
 
5
5
  # Using lowercase function naming to match the JavaScript names.
6
6
  # pylint: disable=g-bad-name
@@ -689,8 +689,10 @@ def getMapId(params: dict[str, Any]) -> dict[str, Any]:
689
689
  )
690
690
  state = _get_state()
691
691
  map_name = result['name']
692
- url_format = '{}/{}/{}/tiles/{{z}}/{{x}}/{{y}}'.format(
693
- state.tile_base_url, _cloud_api_utils.VERSION, map_name)
692
+ version = _cloud_api_utils.VERSION
693
+ url_format = (
694
+ '{state.tile_base_url}/{version}/{map_name)}/tiles/{{z}}/{{x}}/{{y}}'
695
+ )
694
696
  if state.cloud_api_key:
695
697
  url_format += f'?key={state.cloud_api_key}'
696
698
 
@@ -1199,9 +1201,9 @@ def makeThumbUrl(thumbId: dict[str, str]) -> str:
1199
1201
  A URL from which the thumbnail can be obtained.
1200
1202
  """
1201
1203
  state = _get_state()
1202
- url = '{}/{}/{}:getPixels'.format(
1203
- state.tile_base_url, _cloud_api_utils.VERSION, thumbId['thumbid']
1204
- )
1204
+ version = _cloud_api_utils.VERSION
1205
+ thumb_id = thumbId['thumbid']
1206
+ url = f'{state.tile_base_url}/{version}/{thumb_id}:getPixels'
1205
1207
  if state.cloud_api_key:
1206
1208
  url += f'?key={state.cloud_api_key}'
1207
1209
  return url
@@ -1332,9 +1334,10 @@ def makeDownloadUrl(downloadId: dict[str, str]) -> str:
1332
1334
  Returns:
1333
1335
  A URL from which the download can be obtained.
1334
1336
  """
1335
- return '{}/{}/{}:getPixels'.format(
1336
- _get_state().tile_base_url, _cloud_api_utils.VERSION, downloadId['docid']
1337
- )
1337
+ title_base_url = _get_state().tile_base_url
1338
+ version = _cloud_api_utils.VERSION
1339
+ docid = downloadId['docid']
1340
+ return f'{title_base_url}/{version}/{docid}:getPixels'
1338
1341
 
1339
1342
 
1340
1343
  def getTableDownloadId(params: dict[str, Any]) -> dict[str, str]:
@@ -1395,10 +1398,10 @@ def makeTableDownloadUrl(downloadId: dict[str, str]) -> str:
1395
1398
  Returns:
1396
1399
  A Url from which the download can be obtained.
1397
1400
  """
1398
- return '{}/{}/{}:getFeatures'.format(
1399
- _get_state().tile_base_url, _cloud_api_utils.VERSION, downloadId['docid']
1400
- )
1401
-
1401
+ title_base_url = _get_state().tile_base_url
1402
+ version = _cloud_api_utils.VERSION
1403
+ docid = downloadId['docid']
1404
+ return f'{title_base_url}/{version}/{docid}:getFeatures'
1402
1405
 
1403
1406
  def getAlgorithms() -> Any:
1404
1407
  """Get the list of algorithms.
@@ -422,8 +422,10 @@ class List(computedobject.ComputedObject):
422
422
  # TODO: Improve the type of `baseAlgorithm`.
423
423
  def map(
424
424
  self,
425
- baseAlgorithm: _arg_types.Any, # pylint: disable=invalid-name
425
+ # pylint: disable=invalid-name
426
+ baseAlgorithm: _arg_types.Any,
426
427
  dropNulls: _arg_types.Bool = False,
428
+ # pylint: enable=invalid-name
427
429
  ) -> List:
428
430
  """Map an algorithm over a list.
429
431
 
@@ -77,6 +77,7 @@ def isSubtype(firstType: str, secondType: str) -> bool:
77
77
  'Collection', 'ImageCollection', 'FeatureCollection')
78
78
  elif firstType in ('FeatureCollection', 'Collection'):
79
79
  return secondType in ('Collection', 'ImageCollection', 'FeatureCollection')
80
+ # TODO: elif firstType == 'Object':
80
81
  elif firstType == object:
81
82
  return True
82
83
  else:
@@ -1,4 +1,7 @@
1
- """Interfaces implemented by serializable objects."""
1
+ """Interfaces implemented by serializable objects.
2
+
3
+ This file has no implementation, only interfaces.
4
+ """
2
5
 
3
6
  from collections.abc import Callable
4
7
  from typing import Any
@@ -28,10 +28,10 @@ class Feature(element.Element):
28
28
  def __init__(
29
29
  self,
30
30
  geom: None | (
31
- Feature |
32
- geometry.Geometry |
33
- dict[str, Any] |
34
- computedobject.ComputedObject
31
+ Feature |
32
+ geometry.Geometry |
33
+ dict[str, Any] |
34
+ computedobject.ComputedObject
35
35
  ),
36
36
  properties: None | (
37
37
  dict[str, Any] | computedobject.ComputedObject
@@ -682,6 +682,7 @@ class Feature(element.Element):
682
682
  )
683
683
 
684
684
  def setGeometry(
685
+ # pylint: disable-next=redefined-outer-name
685
686
  self, geometry: _arg_types.Geometry | None = None
686
687
  ) -> Feature:
687
688
  """Returns the feature with the geometry replaced by the specified geometry.
@@ -35,12 +35,12 @@ class FeatureCollection(collection.Collection[feature.Feature]):
35
35
  def __init__(
36
36
  self,
37
37
  args: None | (
38
- dict[str, Any] |
39
- list[Any] |
40
- str |
41
- feature.Feature |
42
- geometry.Geometry |
43
- computedobject.ComputedObject
38
+ dict[str, Any] |
39
+ list[Any] |
40
+ str |
41
+ feature.Feature |
42
+ geometry.Geometry |
43
+ computedobject.ComputedObject
44
44
  ),
45
45
  column: Any | None = None,
46
46
  ):
@@ -5894,7 +5894,7 @@
5894
5894
  "type": "Long",
5895
5895
  "description": "The version of the asset. -1 signifies the latest version. Ignored unless tableId is an asset ID.",
5896
5896
  "optional": true,
5897
- "defaultValue": null
5897
+ "defaultValue": -1.0
5898
5898
  }]
5899
5899
  }, {
5900
5900
  "name": "algorithms/Collection.merge",
@@ -9404,7 +9404,7 @@
9404
9404
  }, {
9405
9405
  "argumentName": "size",
9406
9406
  "type": "Integer",
9407
- "description": "The size of the neighborhood to include in each GLCM.",
9407
+ "description": "The size of the neighborhood to include in each GLCM. For example, the size of 1 corresponds to a 3x3 square, the size of 2 corresponds to a 5x5 square, the size of 3 corresponds to a 7x7 square, etc.",
9408
9408
  "optional": true,
9409
9409
  "defaultValue": 1.0
9410
9410
  }, {
@@ -848,6 +848,131 @@ class DataTest(unittest.TestCase):
848
848
  cloud_api_resource.projects().maps().create.call_args_list[1]
849
849
  .kwargs['workloadTag'])
850
850
 
851
+ def test_get_map_id_with_string_image(self):
852
+ cloud_api_resource = mock.MagicMock()
853
+ with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
854
+ with self.assertRaisesRegex(
855
+ ee.ee_exception.EEException, '^Image as JSON string not supported.'
856
+ ):
857
+ ee.data.getMapId({'image': 'my-image'})
858
+
859
+ def test_get_map_id_with_version(self):
860
+ cloud_api_resource = mock.MagicMock()
861
+ with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
862
+ with self.assertRaisesRegex(
863
+ ee.ee_exception.EEException,
864
+ '^Image version specification not supported.',
865
+ ):
866
+ ee.data.getMapId({
867
+ 'image': image.Image('my-image'),
868
+ 'version': '123',
869
+ })
870
+
871
+ def test_get_map_id_with_vis_params(self):
872
+ cloud_api_resource = mock.MagicMock()
873
+ with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
874
+ mock_result = {
875
+ 'name': 'projects/earthengine-legacy/maps/DOCID',
876
+ }
877
+ cloud_api_resource.projects().maps().create().execute.return_value = (
878
+ mock_result
879
+ )
880
+ vis_params = {'paletteColors': ['FF0000']}
881
+ ee.data.getMapId({
882
+ 'image': image.Image('my-image'),
883
+ 'palette': 'FF0000',
884
+ })
885
+ self.assertEqual(
886
+ 2, cloud_api_resource.projects().maps().create.call_count
887
+ )
888
+ kwargs = (
889
+ cloud_api_resource.projects().maps().create.call_args_list[1].kwargs
890
+ )
891
+ self.assertIn('body', kwargs)
892
+ self.assertIn('visualizationOptions', kwargs['body'])
893
+ self.assertEqual(vis_params, kwargs['body']['visualizationOptions'])
894
+
895
+ def test_get_map_id_with_cloud_api_key(self):
896
+ cloud_api_resource = mock.MagicMock()
897
+ with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
898
+ ee.data._get_state().cloud_api_key = 'my-api-key'
899
+ mock_result = {
900
+ 'name': 'projects/earthengine-legacy/maps/DOCID',
901
+ }
902
+ cloud_api_resource.projects().maps().create().execute.return_value = (
903
+ mock_result
904
+ )
905
+ actual_result = ee.data.getMapId({
906
+ 'image': image.Image('my-image'),
907
+ })
908
+ self.assertIn('?key=my-api-key', actual_result['tile_fetcher'].url_format)
909
+
910
+ def test_get_thumbnail_default(self):
911
+ cloud_api_resource_raw = mock.MagicMock()
912
+ with apitestcase.UsingCloudApi(
913
+ cloud_api_resource_raw=cloud_api_resource_raw
914
+ ):
915
+ thumb_id = 'projects/earthengine-legacy/thumbnails/some-id'
916
+ thumb_id_result = {'thumbid': thumb_id}
917
+ img = image.Image('my-image')
918
+ img.getThumbId = mock.Mock(return_value=thumb_id_result)
919
+ params = {'image': img}
920
+ (
921
+ cloud_api_resource_raw.projects()
922
+ .thumbnails()
923
+ .getPixels.return_value.execute.return_value
924
+ ) = b'pixel data'
925
+ result = ee.data.getThumbnail(params)
926
+ self.assertEqual(b'pixel data', result)
927
+ img.getThumbId.assert_called_once_with(params)
928
+ cloud_api_resource_raw.projects().thumbnails().getPixels.assert_called_once_with(
929
+ name=thumb_id
930
+ )
931
+
932
+ def test_get_thumbnail_video(self):
933
+ cloud_api_resource_raw = mock.MagicMock()
934
+ with apitestcase.UsingCloudApi(
935
+ cloud_api_resource_raw=cloud_api_resource_raw
936
+ ):
937
+ thumb_id = 'projects/earthengine-legacy/videoThumbnails/some-id'
938
+ thumb_id_result = {'thumbid': thumb_id}
939
+ img = image.Image('my-image')
940
+ img.getThumbId = mock.Mock(return_value=thumb_id_result)
941
+ params = {'image': img}
942
+ (
943
+ cloud_api_resource_raw.projects()
944
+ .videoThumbnails()
945
+ .getPixels.return_value.execute.return_value
946
+ ) = b'video data'
947
+ result = ee.data.getThumbnail(params, thumbType='video')
948
+ self.assertEqual(b'video data', result)
949
+ img.getThumbId.assert_called_once_with(params)
950
+ cloud_api_resource_raw.projects().videoThumbnails().getPixels.assert_called_once_with(
951
+ name=thumb_id
952
+ )
953
+
954
+ def test_get_thumbnail_filmstrip(self):
955
+ cloud_api_resource_raw = mock.MagicMock()
956
+ with apitestcase.UsingCloudApi(
957
+ cloud_api_resource_raw=cloud_api_resource_raw
958
+ ):
959
+ thumb_id = 'projects/earthengine-legacy/filmstripThumbnails/some-id'
960
+ thumb_id_result = {'thumbid': thumb_id}
961
+ img = image.Image('my-image')
962
+ img.getThumbId = mock.Mock(return_value=thumb_id_result)
963
+ params = {'image': img}
964
+ (
965
+ cloud_api_resource_raw.projects()
966
+ .filmstripThumbnails()
967
+ .getPixels.return_value.execute.return_value
968
+ ) = b'filmstrip data'
969
+ result = ee.data.getThumbnail(params, thumbType='filmstrip')
970
+ self.assertEqual(b'filmstrip data', result)
971
+ img.getThumbId.assert_called_once_with(params)
972
+ cloud_api_resource_raw.projects().filmstripThumbnails().getPixels.assert_called_once_with(
973
+ name=thumb_id
974
+ )
975
+
851
976
  def test_get_download_id(self):
852
977
  cloud_api_resource = mock.MagicMock()
853
978
  with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
@@ -949,6 +1074,14 @@ class DataTest(unittest.TestCase):
949
1074
  cloud_api_resource.projects().thumbnails().create.call_args
950
1075
  .kwargs['workloadTag'])
951
1076
 
1077
+ def test_make_thumb_url_with_api_key(self):
1078
+ cloud_api_resource = mock.MagicMock()
1079
+ with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
1080
+ ee.data._get_state().cloud_api_key = 'my-api-key'
1081
+ thumb_id = {'thumbid': 'projects/earthengine-legacy/thumbnails/some-id'}
1082
+ url = ee.data.makeThumbUrl(thumb_id)
1083
+ self.assertIn('?key=my-api-key', url)
1084
+
952
1085
  def test_get_table_download_id(self):
953
1086
  cloud_api_resource = mock.MagicMock()
954
1087
  with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
@@ -272,6 +272,31 @@ class DateRangeTest(apitestcase.ApiTestCase):
272
272
  result = json.loads(expression.serialize())
273
273
  self.assertEqual(expect, result)
274
274
 
275
+ def test_unbounded(self):
276
+ expect = make_expression_graph({
277
+ 'functionName': 'DateRange.unbounded',
278
+ 'arguments': {},
279
+ })
280
+ expression = ee.DateRange.unbounded()
281
+ result = json.loads(expression.serialize())
282
+ self.assertEqual(expect, result)
283
+
284
+ is_unbounded_expect = make_expression_graph({
285
+ 'arguments': {
286
+ 'dateRange': {
287
+ 'functionInvocationValue': {
288
+ 'functionName': 'DateRange.unbounded',
289
+ 'arguments': {},
290
+ }
291
+ }
292
+ },
293
+ 'functionName': 'DateRange.isUnbounded',
294
+ })
295
+
296
+ is_unbounded_expression = expression.isUnbounded()
297
+ is_unbounded_result = json.loads(is_unbounded_expression.serialize())
298
+ self.assertEqual(is_unbounded_expect, is_unbounded_result)
299
+
275
300
  def test_union(self):
276
301
  expect = make_expression_graph({
277
302
  'arguments': {
@@ -47,6 +47,12 @@ class ListTest(apitestcase.ApiTestCase):
47
47
  self.assertEqual(expect, json.loads(ee.List(tuple([42])).serialize()))
48
48
  self.assertEqual(expect, json.loads(ee.List([42]).serialize()))
49
49
 
50
+ def test_bad_list(self):
51
+ with self.assertRaisesRegex(
52
+ ee.EEException, 'Invalid argument specified for ee.List'
53
+ ):
54
+ ee.List('not a list') # pytype: disable=wrong-arg-types
55
+
50
56
  def test_mapping(self):
51
57
  lst = ee.List(['foo', 'bar'])
52
58
  body = lambda s: ee.String(s).cat('bar')
@@ -359,7 +365,31 @@ class ListTest(apitestcase.ApiTestCase):
359
365
  result = json.loads(expression.serialize())
360
366
  self.assertEqual(expect, result)
361
367
 
362
- # TODO: test_iterate
368
+ def test_iterate(self):
369
+ lst = ee.List([1, 2, 3])
370
+ body = lambda n, p: ee.Number(p).add(n)
371
+ iterated = lst.iterate(body, 0)
372
+
373
+ self.assertIsInstance(iterated, ee.ComputedObject)
374
+ self.assertEqual(ee.ApiFunction.lookup('List.iterate'), iterated.func)
375
+ self.assertEqual(lst, iterated.args['list'])
376
+ self.assertEqual(0, iterated.args['first'])
377
+
378
+ sig = {
379
+ 'returns': 'Object',
380
+ 'args': [
381
+ {'name': '_MAPPING_VAR_0_0', 'type': 'Object'},
382
+ {'name': '_MAPPING_VAR_0_1', 'type': 'Object'},
383
+ ],
384
+ }
385
+ expected_function = ee.CustomFunction(sig, body)
386
+ self.assertEqual(
387
+ expected_function.serialize(), iterated.args['function'].serialize()
388
+ )
389
+ self.assertEqual(
390
+ expected_function.serialize(for_cloud_api=True),
391
+ iterated.args['function'].serialize(for_cloud_api=True),
392
+ )
363
393
 
364
394
  def test_join(self):
365
395
  expect = make_expression_graph({
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env python3
2
+ """Tests for ee_types.py."""
3
+
4
+ import datetime
5
+
6
+ import unittest
7
+ from ee import apitestcase
8
+ from ee import ee_list
9
+ from ee import ee_number
10
+ from ee import ee_types
11
+
12
+
13
+ class EeTypesTest(apitestcase.ApiTestCase):
14
+
15
+ def test_class_to_name(self):
16
+ self.assertEqual('List', ee_types.classToName(ee_list.List))
17
+ self.assertEqual('Number', ee_types.classToName(ee_number.Number))
18
+ self.assertEqual('Number', ee_types.classToName(int))
19
+ self.assertEqual('Number', ee_types.classToName(float))
20
+ self.assertEqual('String', ee_types.classToName(str))
21
+ self.assertEqual('Array', ee_types.classToName(tuple))
22
+ self.assertEqual('Array', ee_types.classToName(list))
23
+ self.assertEqual('Array', ee_types.classToName(list))
24
+ self.assertEqual('Date', ee_types.classToName(datetime.datetime))
25
+
26
+ class Foo:
27
+ pass
28
+
29
+ self.assertEqual('Object', ee_types.classToName(Foo))
30
+
31
+ def test_is_subtype(self):
32
+ self.assertTrue(ee_types.isSubtype('Image', 'Image'))
33
+ self.assertTrue(ee_types.isSubtype('Element', 'Image'))
34
+ self.assertFalse(ee_types.isSubtype('Image', 'Element'))
35
+
36
+ self.assertTrue(ee_types.isSubtype('Collection', 'ImageCollection'))
37
+ self.assertTrue(ee_types.isSubtype('Collection', 'FeatureCollection'))
38
+
39
+ self.assertFalse(ee_types.isSubtype('ImageCollection', 'Collection'))
40
+
41
+ self.assertFalse(ee_types.isSubtype('Image', 'Collection'))
42
+ self.assertFalse(ee_types.isSubtype('ImageCollection', 'FeatureCollection'))
43
+
44
+ # TODO: Theses should be false.
45
+ self.assertTrue(ee_types.isSubtype('FeatureCollection', 'Collection'))
46
+ self.assertTrue(ee_types.isSubtype('FeatureCollection', 'ImageCollection'))
47
+
48
+ def test_is_array(self):
49
+ self.assertTrue(ee_types.isArray([]))
50
+ self.assertTrue(ee_types.isArray(()))
51
+ self.assertTrue(ee_types.isArray(ee_list.List([1, 2])))
52
+ self.assertFalse(ee_types.isArray(1))
53
+ self.assertFalse(ee_types.isArray('string'))
54
+ self.assertFalse(ee_types.isArray(ee_number.Number(1)))
55
+
56
+
57
+ if __name__ == '__main__':
58
+ unittest.main()
@@ -0,0 +1,138 @@
1
+ #!/usr/bin/env python3
2
+ """Test for the ee.element module."""
3
+
4
+ import datetime
5
+
6
+ import unittest
7
+ import ee
8
+ from ee import apitestcase
9
+
10
+
11
+ class ElementTestCase(apitestcase.ApiTestCase):
12
+
13
+ def test_set(self):
14
+ """Verifies Element.set() keyword argument interpretation."""
15
+ image = ee.Image(1)
16
+
17
+ # Constant dictionary.
18
+ def AssertProperties(expected, image):
19
+ properties = {}
20
+ while image.func == ee.ApiFunction.lookup('Element.set'):
21
+ key = image.args['key']
22
+ if not isinstance(key, str):
23
+ key = key.encode()
24
+ properties[key] = image.args['value']
25
+ image = image.args['object']
26
+ self.assertEqual(ee.Image(1), image)
27
+ self.assertEqual(expected, properties)
28
+
29
+ AssertProperties({'foo': 'bar'}, image.set({'foo': 'bar'}))
30
+ AssertProperties({'foo': 'bar'}, image.set({'properties': {'foo': 'bar'}}))
31
+ AssertProperties({'properties': 5}, image.set({'properties': 5}))
32
+ AssertProperties({'properties': {'foo': 'bar'}, 'baz': 'quux'},
33
+ image.set({'properties': {'foo': 'bar'}, 'baz': 'quux'}))
34
+ AssertProperties({'foo': 'bar', 'baz': 'quux'},
35
+ image.set('foo', 'bar', 'baz', 'quux'))
36
+ dt = datetime.datetime.fromtimestamp(12345)
37
+ AssertProperties({'foo': dt}, image.set('foo', dt))
38
+
39
+ # Computed dictionary.
40
+ computed_arg = ee.ComputedObject(None, None, 'foo')
41
+
42
+ def CheckMultiProperties(result):
43
+ self.assertEqual(ee.ApiFunction.lookup('Element.setMulti'), result.func)
44
+ self.assertEqual({
45
+ 'object': image,
46
+ 'properties': ee.Dictionary(computed_arg)
47
+ }, result.args)
48
+ CheckMultiProperties(image.set(computed_arg))
49
+ CheckMultiProperties(image.set({'properties': computed_arg}))
50
+
51
+ def test_set_one_arg_exception(self):
52
+ with self.assertRaisesRegex(
53
+ ee.EEException,
54
+ r'When Element\.set\(\) is passed one argument, '
55
+ r'it must be a dictionary\.',
56
+ ):
57
+ ee.Image(1).set('not a dictionary')
58
+
59
+ def test_set_odd_args_exception(self):
60
+ with self.assertRaisesRegex(
61
+ ee.EEException,
62
+ r'When Element\.set\(\) is passed multiple arguments, there '
63
+ r'must be an even number of them\.',
64
+ ):
65
+ ee.Image(1).set('key1', 'value1', 'key2')
66
+
67
+ def test_get_array(self):
68
+ image = ee.Image(1)
69
+ array_property = image.getArray('array_prop')
70
+ self.assertIsInstance(array_property, ee.Array)
71
+ self.assertEqual(
72
+ ee.ApiFunction.lookup('Element.getArray'), array_property.func
73
+ )
74
+ self.assertEqual(
75
+ {'object': image, 'property': ee.String('array_prop')},
76
+ array_property.args,
77
+ )
78
+
79
+ def test_get_number(self):
80
+ image = ee.Image(1)
81
+ number_property = image.getNumber('number_prop')
82
+ self.assertIsInstance(number_property, ee.Number)
83
+ self.assertEqual(
84
+ ee.ApiFunction.lookup('Element.getNumber'), number_property.func
85
+ )
86
+ self.assertEqual(
87
+ {'object': image, 'property': ee.String('number_prop')},
88
+ number_property.args,
89
+ )
90
+
91
+ def test_get_string(self):
92
+ image = ee.Image(1)
93
+ string_property = image.getString('string_prop')
94
+ self.assertIsInstance(string_property, ee.String)
95
+ self.assertEqual(
96
+ ee.ApiFunction.lookup('Element.getString'), string_property.func
97
+ )
98
+ self.assertEqual(
99
+ {'object': image, 'property': ee.String('string_prop')},
100
+ string_property.args,
101
+ )
102
+
103
+ def test_property_names(self):
104
+ image = ee.Image(1)
105
+ property_names = image.propertyNames()
106
+ self.assertIsInstance(property_names, ee.List)
107
+ self.assertEqual(
108
+ ee.ApiFunction.lookup('Element.propertyNames'), property_names.func
109
+ )
110
+ self.assertEqual({'element': image}, property_names.args)
111
+
112
+ def test_to_dictionary(self):
113
+ image = ee.Image(1)
114
+ dictionary = image.toDictionary()
115
+ self.assertIsInstance(dictionary, ee.Dictionary)
116
+ self.assertEqual(
117
+ ee.ApiFunction.lookup('Element.toDictionary'), dictionary.func
118
+ )
119
+ self.assertEqual({'element': image, 'properties': None}, dictionary.args)
120
+
121
+ dictionary_with_props = image.toDictionary(['a', 'b'])
122
+ self.assertIsInstance(dictionary_with_props, ee.Dictionary)
123
+ self.assertEqual(
124
+ ee.ApiFunction.lookup('Element.toDictionary'),
125
+ dictionary_with_props.func,
126
+ )
127
+ self.assertEqual(
128
+ {'element': image, 'properties': ee.List(['a', 'b'])},
129
+ dictionary_with_props.args,
130
+ )
131
+
132
+ def test_init_opt_params(self):
133
+ result = ee.Element(func=None, args=None, opt_varName='test').serialize()
134
+ self.assertIn('"0": {"argumentReference": "test"}', result)
135
+
136
+
137
+ if __name__ == '__main__':
138
+ unittest.main()
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env python3
2
+ """Tests for ee.encodable."""
3
+
4
+ from collections.abc import Callable
5
+ from typing import Any
6
+ import unittest
7
+
8
+ from ee import encodable
9
+
10
+
11
+ class EncodableTest(unittest.TestCase):
12
+
13
+ def test_encodable(self):
14
+ encoder: Callable[[Any], Any] = lambda x: x
15
+ with self.assertRaises(NotImplementedError):
16
+ encodable.Encodable().encode(encoder)
17
+ with self.assertRaises(NotImplementedError):
18
+ encodable.Encodable().encode_cloud_value(encoder)
19
+
20
+ def test_encodable_function(self):
21
+ encoder: Callable[[Any], Any] = lambda x: x
22
+ with self.assertRaises(NotImplementedError):
23
+ encodable.EncodableFunction().encode_invocation(encoder)
24
+ with self.assertRaises(NotImplementedError):
25
+ encodable.EncodableFunction().encode_cloud_invocation(encoder)
26
+
27
+
28
+ if __name__ == '__main__':
29
+ unittest.main()
@@ -121,6 +121,30 @@ class FeatureTest(apitestcase.ApiTestCase):
121
121
  'system:index': 'bar'
122
122
  }, from_geo_json_feature.args['metadata'])
123
123
 
124
+ def test_feature_copy(self):
125
+ feature = ee.Feature(ee.Geometry.Point(1, 2), {'x': 1})
126
+ feature_copy = ee.Feature(feature)
127
+ self.assertEqual(feature.func, feature_copy.func)
128
+ self.assertEqual(feature.args, feature_copy.args)
129
+
130
+ def test_feature_with_properties_exception(self):
131
+ with self.assertRaisesRegex(
132
+ ee.EEException, 'Cannot create Feature out of a Feature and properties'
133
+ ):
134
+ ee.Feature(ee.Feature(None), {'x': 2})
135
+
136
+ def test_id_and_system_index_exception(self):
137
+ point = ee.Geometry.Point(1, 2)
138
+ with self.assertRaisesRegex(
139
+ ee.EEException, 'Cannot specify both "id" and "system:index"'
140
+ ):
141
+ ee.Feature({
142
+ 'type': 'Feature',
143
+ 'id': 'bar',
144
+ 'geometry': point.toGeoJSON(),
145
+ 'properties': {'system:index': 'bar'},
146
+ })
147
+
124
148
  def test_get_map(self):
125
149
  """Verifies that getMap() uses Collection.draw to rasterize Features."""
126
150
  feature = ee.Feature(None)
@@ -96,6 +96,19 @@ class FeatureCollectionTest(apitestcase.ApiTestCase):
96
96
  ee.ComputedObject(None, {'x': 'y'}))
97
97
  self.assertEqual({'x': 'y'}, from_computed_object.args)
98
98
 
99
+ def test_invalid_constructor_args(self):
100
+ with self.assertRaisesRegex(
101
+ ee.EEException,
102
+ 'Unrecognized argument type to convert to a FeatureCollection: 1',
103
+ ):
104
+ ee.FeatureCollection(1)
105
+
106
+ with self.assertRaisesRegex(
107
+ ee.EEException,
108
+ 'Unrecognized argument type to convert to a FeatureCollection: None',
109
+ ):
110
+ ee.FeatureCollection(None)
111
+
99
112
  def test_get_map_id(self):
100
113
  """Verifies that getMap() uses Collection.draw to draw."""
101
114
  collection = ee.FeatureCollection('test5')
@@ -126,6 +139,13 @@ class FeatureCollectionTest(apitestcase.ApiTestCase):
126
139
  ee.FeatureCollection('test7').getDownloadUrl('csv'),
127
140
  ee.FeatureCollection('test7').getDownloadURL('csv'))
128
141
 
142
+ ee.FeatureCollection('test9').getDownloadURL(selectors=['bar', 'baz'])
143
+ self.assertEqual(
144
+ ee.FeatureCollection('test9').serialize(),
145
+ self.last_table_call['data']['table'].serialize(),
146
+ )
147
+ self.assertEqual('bar,baz', self.last_table_call['data']['selectors'])
148
+
129
149
  def test_download_table_with_cloud_api(self):
130
150
  cloud_api_resource = mock.MagicMock()
131
151
  with apitestcase.UsingCloudApi(cloud_api_resource=cloud_api_resource):
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "earthengine-api"
3
- version = "1.7.6rc0"
3
+ version = "1.7.8rc0"
4
4
  description = "Earth Engine Python API"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,32 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Tests for ee_types.py."""
3
-
4
- import datetime
5
-
6
- import unittest
7
- from ee import ee_list
8
- from ee import ee_number
9
- from ee import ee_types
10
-
11
-
12
- class EeTypesTest(unittest.TestCase):
13
-
14
- def test_class_to_name(self):
15
- self.assertEqual('List', ee_types.classToName(ee_list.List))
16
- self.assertEqual('Number', ee_types.classToName(ee_number.Number))
17
- self.assertEqual('Number', ee_types.classToName(int))
18
- self.assertEqual('Number', ee_types.classToName(float))
19
- self.assertEqual('String', ee_types.classToName(str))
20
- self.assertEqual('Array', ee_types.classToName(tuple))
21
- self.assertEqual('Array', ee_types.classToName(list))
22
- self.assertEqual('Array', ee_types.classToName(list))
23
- self.assertEqual('Date', ee_types.classToName(datetime.datetime))
24
-
25
- class Foo:
26
- pass
27
-
28
- self.assertEqual('Object', ee_types.classToName(Foo))
29
-
30
-
31
- if __name__ == '__main__':
32
- unittest.main()
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env python3
2
- """Test for the ee.element module."""
3
-
4
- import datetime
5
-
6
- import unittest
7
- import ee
8
- from ee import apitestcase
9
-
10
-
11
- class ElementTestCase(apitestcase.ApiTestCase):
12
-
13
- def test_set(self):
14
- """Verifies Element.set() keyword argument interpretation."""
15
- image = ee.Image(1)
16
-
17
- # Constant dictionary.
18
- def AssertProperties(expected, image):
19
- properties = {}
20
- while image.func == ee.ApiFunction.lookup('Element.set'):
21
- key = image.args['key']
22
- if not isinstance(key, str):
23
- key = key.encode()
24
- properties[key] = image.args['value']
25
- image = image.args['object']
26
- self.assertEqual(ee.Image(1), image)
27
- self.assertEqual(expected, properties)
28
-
29
- AssertProperties({'foo': 'bar'}, image.set({'foo': 'bar'}))
30
- AssertProperties({'foo': 'bar'}, image.set({'properties': {'foo': 'bar'}}))
31
- AssertProperties({'properties': 5}, image.set({'properties': 5}))
32
- AssertProperties({'properties': {'foo': 'bar'}, 'baz': 'quux'},
33
- image.set({'properties': {'foo': 'bar'}, 'baz': 'quux'}))
34
- AssertProperties({'foo': 'bar', 'baz': 'quux'},
35
- image.set('foo', 'bar', 'baz', 'quux'))
36
- dt = datetime.datetime.fromtimestamp(12345)
37
- AssertProperties({'foo': dt}, image.set('foo', dt))
38
-
39
- # Computed dictionary.
40
- computed_arg = ee.ComputedObject(None, None, 'foo')
41
-
42
- def CheckMultiProperties(result):
43
- self.assertEqual(ee.ApiFunction.lookup('Element.setMulti'), result.func)
44
- self.assertEqual({
45
- 'object': image,
46
- 'properties': ee.Dictionary(computed_arg)
47
- }, result.args)
48
- CheckMultiProperties(image.set(computed_arg))
49
- CheckMultiProperties(image.set({'properties': computed_arg}))
50
-
51
- def test_init_opt_params(self):
52
- result = ee.Element(func=None, args=None, opt_varName='test').serialize()
53
- self.assertIn('"0": {"argumentReference": "test"}', result)
54
-
55
-
56
- if __name__ == '__main__':
57
- unittest.main()