earthengine-api 1.5.13rc0__py3-none-any.whl → 1.7.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of earthengine-api might be problematic. Click here for more details.

Files changed (102) hide show
  1. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/METADATA +3 -3
  2. earthengine_api-1.7.4.dist-info/RECORD +109 -0
  3. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/WHEEL +1 -1
  4. ee/__init__.py +29 -28
  5. ee/_arg_types.py +7 -6
  6. ee/_cloud_api_utils.py +95 -78
  7. ee/_helpers.py +17 -13
  8. ee/_state.py +105 -0
  9. ee/_utils.py +2 -1
  10. ee/apifunction.py +21 -19
  11. ee/apitestcase.py +33 -38
  12. ee/batch.py +87 -77
  13. ee/blob.py +10 -12
  14. ee/classifier.py +57 -59
  15. ee/cli/commands.py +178 -114
  16. ee/cli/eecli.py +1 -1
  17. ee/cli/utils.py +61 -42
  18. ee/clusterer.py +39 -41
  19. ee/collection.py +64 -54
  20. ee/computedobject.py +19 -16
  21. ee/confusionmatrix.py +9 -9
  22. ee/customfunction.py +13 -12
  23. ee/data.py +220 -322
  24. ee/daterange.py +10 -10
  25. ee/deprecation.py +21 -13
  26. ee/deserializer.py +25 -20
  27. ee/dictionary.py +11 -11
  28. ee/ee_array.py +22 -20
  29. ee/ee_date.py +23 -23
  30. ee/ee_list.py +15 -16
  31. ee/ee_number.py +11 -21
  32. ee/ee_string.py +24 -32
  33. ee/ee_types.py +4 -4
  34. ee/element.py +15 -15
  35. ee/encodable.py +7 -4
  36. ee/errormargin.py +4 -4
  37. ee/feature.py +68 -71
  38. ee/featurecollection.py +41 -40
  39. ee/filter.py +90 -92
  40. ee/function.py +8 -8
  41. ee/geometry.py +95 -93
  42. ee/image.py +238 -236
  43. ee/image_converter.py +4 -4
  44. ee/imagecollection.py +30 -27
  45. ee/join.py +13 -15
  46. ee/kernel.py +55 -57
  47. ee/mapclient.py +9 -9
  48. ee/model.py +29 -31
  49. ee/oauth.py +76 -63
  50. ee/pixeltype.py +6 -6
  51. ee/projection.py +5 -4
  52. ee/reducer.py +41 -41
  53. ee/serializer.py +14 -14
  54. ee/table_converter.py +7 -6
  55. ee/terrain.py +7 -9
  56. ee/tests/_cloud_api_utils_test.py +21 -6
  57. ee/tests/_helpers_test.py +57 -4
  58. ee/tests/_state_test.py +49 -0
  59. ee/tests/algorithms.json +85 -2
  60. ee/tests/apifunction_test.py +5 -5
  61. ee/tests/batch_test.py +135 -57
  62. ee/tests/blob_test.py +5 -5
  63. ee/tests/classifier_test.py +3 -3
  64. ee/tests/clusterer_test.py +3 -3
  65. ee/tests/collection_test.py +48 -13
  66. ee/tests/confusionmatrix_test.py +3 -3
  67. ee/tests/data_test.py +484 -55
  68. ee/tests/daterange_test.py +4 -4
  69. ee/tests/deprecation_test.py +6 -4
  70. ee/tests/deserializer_test.py +64 -5
  71. ee/tests/dictionary_test.py +12 -12
  72. ee/tests/ee_array_test.py +3 -3
  73. ee/tests/ee_date_test.py +4 -4
  74. ee/tests/ee_list_test.py +3 -3
  75. ee/tests/ee_number_test.py +75 -30
  76. ee/tests/ee_string_test.py +11 -3
  77. ee/tests/ee_test.py +40 -22
  78. ee/tests/element_test.py +2 -2
  79. ee/tests/errormargin_test.py +1 -1
  80. ee/tests/feature_test.py +10 -10
  81. ee/tests/featurecollection_test.py +3 -3
  82. ee/tests/filter_test.py +4 -4
  83. ee/tests/function_test.py +5 -5
  84. ee/tests/geometry_point_test.py +3 -3
  85. ee/tests/geometry_test.py +93 -52
  86. ee/tests/image_converter_test.py +1 -3
  87. ee/tests/image_test.py +3 -3
  88. ee/tests/imagecollection_test.py +3 -3
  89. ee/tests/join_test.py +3 -3
  90. ee/tests/kernel_test.py +7 -3
  91. ee/tests/model_test.py +17 -5
  92. ee/tests/oauth_test.py +189 -7
  93. ee/tests/pixeltype_test.py +6 -7
  94. ee/tests/projection_test.py +5 -6
  95. ee/tests/reducer_test.py +16 -3
  96. ee/tests/serializer_test.py +39 -12
  97. ee/tests/table_converter_test.py +51 -7
  98. ee/tests/terrain_test.py +11 -3
  99. earthengine_api-1.5.13rc0.dist-info/RECORD +0 -107
  100. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/entry_points.txt +0 -0
  101. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/licenses/LICENSE +0 -0
  102. {earthengine_api-1.5.13rc0.dist-info → earthengine_api-1.7.4.dist-info}/top_level.txt +0 -0
ee/tests/geometry_test.py CHANGED
@@ -87,13 +87,13 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
87
87
  (-10, -20, 10, math.inf),
88
88
  ),
89
89
  )
90
- def testBBox(self, expected, coords):
90
+ def test_bbox(self, expected, coords):
91
91
  self.assertEqual(
92
92
  self.epsg4326_rectangle(*expected),
93
93
  ee.Geometry.BBox(*coords),
94
94
  )
95
95
 
96
- def testBBox_computedArgs(self):
96
+ def test_bbox_computed_args(self):
97
97
  ten = ee.Number(5).add(5)
98
98
  box = ee.Geometry.BBox(-10, -20, ten, 20)
99
99
  func = ee.ApiFunction.lookup('GeometryConstructors.BBox')
@@ -164,11 +164,11 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
164
164
  r'Geometry\.BBox: north must be at least -90°, but was -inf°',
165
165
  ),
166
166
  )
167
- def testBBoxInvalid(self, coords, message):
167
+ def test_bbox_invalid(self, coords, message):
168
168
  with self.assertRaisesRegex(ee.EEException, message):
169
169
  ee.Geometry.BBox(*coords)
170
170
 
171
- def testLineString(self):
171
+ def test_line_string(self):
172
172
  coords = [1, 2, 3, 4]
173
173
  proj = 'EPSG:4326'
174
174
  max_error = 1000
@@ -186,7 +186,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
186
186
  geometry.args,
187
187
  )
188
188
 
189
- def testLineString_kwargs(self):
189
+ def test_line_string_kwargs(self):
190
190
  coords = [1, 2, 3, 4]
191
191
  func = ee.ApiFunction.lookup('GeometryConstructors.LineString')
192
192
 
@@ -197,7 +197,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
197
197
  geometry.args,
198
198
  )
199
199
 
200
- def testLineString_computedArgs(self):
200
+ def test_line_string_computed_args(self):
201
201
  """Verifies that a LineString with computed inputs can be constructed."""
202
202
  p1 = ee.Geometry.Point([1, 2])
203
203
  p2 = ee.Geometry.Point([3, 4])
@@ -215,11 +215,11 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
215
215
  ('_geometry', [[[1, 2], [3, 4], 5]], 'Invalid geometry'),
216
216
  ('_nesting', [[[[1, 2], [3, 4]]]], 'Invalid geometry'),
217
217
  )
218
- def testLineStringInvalid(self, coords, message):
218
+ def test_line_string_invalid(self, coords, message):
219
219
  with self.assertRaisesRegex(ee.EEException, message):
220
220
  ee.Geometry.LineString(*coords)
221
221
 
222
- def testLinearRing(self):
222
+ def test_linear_ring(self):
223
223
  coords = [1, 2, 3, 4]
224
224
  proj = 'EPSG:4326'
225
225
  geodesic = True
@@ -238,7 +238,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
238
238
  geometry.args,
239
239
  )
240
240
 
241
- def testLinearRing_kwargs(self):
241
+ def test_linear_ring_kwargs(self):
242
242
  coords = [1, 2, 3, 4]
243
243
  func = ee.ApiFunction.lookup('GeometryConstructors.LinearRing')
244
244
  geodesic = True
@@ -250,7 +250,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
250
250
  geometry.args,
251
251
  )
252
252
 
253
- def testLinearRing_computedArgs(self):
253
+ def test_linear_ring_computed_args(self):
254
254
  """Verifies that a LinearRing with computed inputs can be constructed."""
255
255
  p1 = ee.Geometry.Point([1, 2])
256
256
  p2 = ee.Geometry.Point([3, 4])
@@ -268,11 +268,11 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
268
268
  ('_geometry', [[[1, 2], [3, 4], 5]], 'Invalid geometry'),
269
269
  ('_nesting', [[[[1, 2], [3, 4]]]], 'Invalid geometry'),
270
270
  )
271
- def testLinearRingInvalid(self, coords, message):
271
+ def test_linear_ring_invalid(self, coords, message):
272
272
  with self.assertRaisesRegex(ee.EEException, message):
273
273
  ee.Geometry.LinearRing(*coords)
274
274
 
275
- def testMultiLineString(self):
275
+ def test_multi_line_string(self):
276
276
  coords = [1, 2, 3, 4]
277
277
  proj = 'EPSG:4326'
278
278
  geodesic = True
@@ -291,7 +291,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
291
291
  geometry.args,
292
292
  )
293
293
 
294
- def testMultiLineString_kwargs(self):
294
+ def test_multi_line_string_kwargs(self):
295
295
  coords = [1, 2, 3, 4]
296
296
  func = ee.ApiFunction.lookup('GeometryConstructors.MultiLineString')
297
297
  geodesic = True
@@ -303,7 +303,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
303
303
  geometry.args,
304
304
  )
305
305
 
306
- def testMultiLineString_computedArgs(self):
306
+ def test_multi_line_string_computed_args(self):
307
307
  """Verifies that a MultiLineString with computed inputs can be constructed."""
308
308
  p1 = ee.Geometry.Point([1, 2])
309
309
  p2 = ee.Geometry.Point([3, 4])
@@ -321,12 +321,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
321
321
  ('_geometry', [[[1, 2], [3, 4], 5]], 'Invalid geometry'),
322
322
  ('_nesting', [[[[[1, 2], [3, 4]]]]], 'Invalid geometry'),
323
323
  )
324
- def testMultiLineStringInvalid(self, coords, message):
324
+ def test_multi_line_string_invalid(self, coords, message):
325
325
  """Verifies MultiLineString constructor behavior with invalid arguments."""
326
326
  with self.assertRaisesRegex(ee.EEException, message):
327
327
  ee.Geometry.MultiLineString(*coords)
328
328
 
329
- def testMultiPoint(self):
329
+ def test_multi_point(self):
330
330
  coords = [1, 2, 3, 4]
331
331
  proj = 'EPSG:4326'
332
332
  func = ee.ApiFunction.lookup('GeometryConstructors.MultiPoint')
@@ -341,7 +341,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
341
341
  geometry.args,
342
342
  )
343
343
 
344
- def testMultiPoint_kwargs(self):
344
+ def test_multi_point_kwargs(self):
345
345
  coords = [1, 2, 3, 4]
346
346
  func = ee.ApiFunction.lookup('GeometryConstructors.MultiPoint')
347
347
  proj = 'EPSG:4326'
@@ -353,7 +353,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
353
353
  geometry.args,
354
354
  )
355
355
 
356
- def testMultiPoint_computedArgs(self):
356
+ def test_multi_point_computed_args(self):
357
357
  """Verifies that a MultiPoint with computed inputs can be constructed."""
358
358
  p1 = ee.Geometry.Point([1, 2])
359
359
  p2 = ee.Geometry.Point([3, 4])
@@ -371,12 +371,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
371
371
  ('_geometry', [[[1, 2], [3, 4], 5]], 'Invalid geometry'),
372
372
  ('_nesting', [[[[1, 2], [3, 4]]]], 'Invalid geometry'),
373
373
  )
374
- def testMultiPointInvalid(self, coords, message):
374
+ def test_multi_point_invalid(self, coords, message):
375
375
  """Verifies MultiPoint constructor behavior with invalid arguments."""
376
376
  with self.assertRaisesRegex(ee.EEException, message):
377
377
  ee.Geometry.MultiPoint(*coords)
378
378
 
379
- def testMultiPolygon(self):
379
+ def test_multi_polygon(self):
380
380
  coords = [1, 2, 3, 4]
381
381
  proj = 'EPSG:4326'
382
382
  geodesic = True
@@ -399,7 +399,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
399
399
  geometry.args,
400
400
  )
401
401
 
402
- def testMultiPolygon_kwargs(self):
402
+ def test_multi_polygon_kwargs(self):
403
403
  coords = [1, 2, 3, 4]
404
404
  func = ee.ApiFunction.lookup('GeometryConstructors.MultiPolygon')
405
405
  geodesic = True
@@ -411,7 +411,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
411
411
  geometry.args,
412
412
  )
413
413
 
414
- def testMultiPolygon_computedArgs(self):
414
+ def test_multi_polygon_computed_args(self):
415
415
  """Verifies that a MultiPolygon with computed inputs can be constructed."""
416
416
  p1 = ee.Geometry.Point([1, 2])
417
417
  p2 = ee.Geometry.Point([3, 4])
@@ -429,12 +429,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
429
429
  ('_geometry', [[[[[[1, 2], [3, 4], [5, 6]]]]]], 'Invalid geometry'),
430
430
  ('_nesting', [[[[[1, 2], [3, 4]], [1, 2]]]], 'Invalid geometry'),
431
431
  )
432
- def testMultiPolygonInvalid(self, coords, message):
432
+ def test_multi_polygon_invalid(self, coords, message):
433
433
  """Verifies MultiPolygon constructor behavior with invalid arguments."""
434
434
  with self.assertRaisesRegex(ee.EEException, message):
435
435
  ee.Geometry.MultiPolygon(*coords)
436
436
 
437
- def testPoint(self):
437
+ def test_point(self):
438
438
  coords = [1, 2, 3, 4]
439
439
  proj = 'EPSG:4326'
440
440
  func = ee.ApiFunction.lookup('GeometryConstructors.Point')
@@ -449,7 +449,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
449
449
  geometry.args,
450
450
  )
451
451
 
452
- def testPoint_kwargs(self):
452
+ def test_point_kwargs(self):
453
453
  coords = [1, 2, 3, 4]
454
454
  func = ee.ApiFunction.lookup('GeometryConstructors.Point')
455
455
  proj = 'EPSG:4326'
@@ -461,12 +461,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
461
461
  geometry.args,
462
462
  )
463
463
 
464
- def testPoint_oldKeywordArgs(self):
464
+ def test_point_old_keyword_args(self):
465
465
  """Verifies that Points still allow keyword lon/lat args."""
466
466
  self.assertEqual(ee.Geometry.Point(1, 2), ee.Geometry.Point(lon=1, lat=2))
467
467
  self.assertEqual(ee.Geometry.Point(1, 2), ee.Geometry.Point(1, lat=2))
468
468
 
469
- def testPoint_computedArgs(self):
469
+ def test_point_computed_args(self):
470
470
  """Verifies that a Point with computed inputs can be constructed."""
471
471
  v1 = ee.Number(1)
472
472
  v2 = ee.Number(2)
@@ -481,12 +481,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
481
481
  @parameterized.named_parameters(
482
482
  ('_geometry', [['-78.204948', '40.966539']], 'Invalid geometry'),
483
483
  )
484
- def testPointInvalid(self, coords, message):
484
+ def test_point_invalid(self, coords, message):
485
485
  """Verifies Point constructor behavior with invalid arguments."""
486
486
  with self.assertRaisesRegex(ee.EEException, message):
487
487
  ee.Geometry.Point(*coords)
488
488
 
489
- def testPolygon(self):
489
+ def test_polygon(self):
490
490
  coords = [1, 2, 3, 4]
491
491
  proj = 'EPSG:4326'
492
492
  geodesic = True
@@ -507,7 +507,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
507
507
  geometry.args,
508
508
  )
509
509
 
510
- def testPolygon_kwargs(self):
510
+ def test_polygon_kwargs(self):
511
511
  coords = [1, 2, 3, 4]
512
512
  func = ee.ApiFunction.lookup('GeometryConstructors.Polygon')
513
513
  geodesic = True
@@ -519,7 +519,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
519
519
  geometry.args,
520
520
  )
521
521
 
522
- def testPolygon_computedArgs(self):
522
+ def test_polygon_computed_args(self):
523
523
  """Verifies that a Polygon with computed inputs can be constructed."""
524
524
  p1 = ee.Geometry.Point([1, 2])
525
525
  p2 = ee.Geometry.Point([3, 4])
@@ -531,7 +531,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
531
531
  )
532
532
  self.assertEqual({'coordinates': ee.List([p1, p2])}, line.args)
533
533
 
534
- def testPolygon_evenOdd(self):
534
+ def test_polygon_even_odd(self):
535
535
  poly1 = ee.Geometry.Polygon([0, 0, 0, 5, 5, 0])
536
536
  self.assertTrue(poly1.toGeoJSON()['evenOdd'])
537
537
 
@@ -546,12 +546,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
546
546
  ('_tooMuchNesting', [[[[[1, 2], [3, 4], [5, 6]]]]], 'Invalid geometry'),
547
547
  ('_badNesting', [[[[1, 2], [3, 4]], [1, 2]]], 'Invalid geometry'),
548
548
  )
549
- def testPolygonInvalid(self, coords, message):
549
+ def test_polygon_invalid(self, coords, message):
550
550
  """Verifies Polygon constructor behavior with invalid arguments."""
551
551
  with self.assertRaisesRegex(ee.EEException, message):
552
552
  ee.Geometry.Polygon(*coords)
553
553
 
554
- def testRectangle(self):
554
+ def test_rectangle(self):
555
555
  coords = [1, 2, 3, 4]
556
556
  proj = 'EPSG:4326'
557
557
  geodesic = True
@@ -570,7 +570,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
570
570
  geometry.args,
571
571
  )
572
572
 
573
- def testRectangle_kwargs(self):
573
+ def test_rectangle_kwargs(self):
574
574
  coords = [1, 2, 3, 4]
575
575
  func = ee.ApiFunction.lookup('GeometryConstructors.Rectangle')
576
576
  geodesic = True
@@ -582,7 +582,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
582
582
  geometry.args,
583
583
  )
584
584
 
585
- def testRectangle_oldKeywordArgs(self):
585
+ def test_rectangle_old_keyword_args(self):
586
586
  """Verifies that Rectangles still allow keyword xlo/ylo/xhi/yhi args."""
587
587
  self.assertEqual(
588
588
  ee.Geometry.Rectangle(1, 2, 3, 4),
@@ -593,7 +593,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
593
593
  ee.Geometry.Rectangle(1, 2, xhi=3, yhi=4),
594
594
  )
595
595
 
596
- def testRectangle_computedArgs(self):
596
+ def test_rectangle_computed_args(self):
597
597
  """Verifies that a Rectangle with computed inputs can be constructed."""
598
598
  p1 = ee.Geometry.Point([1, 2])
599
599
  p2 = ee.Geometry.Point([3, 4])
@@ -611,12 +611,12 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
611
611
  ('_geometry', [[[1, 2], [3, 4], 5]], 'Invalid geometry'),
612
612
  ('_tooMuchNesting', [[[[1, 2], [3, 4]]]], 'Invalid geometry'),
613
613
  )
614
- def testRectangleInvalid(self, coords, message):
614
+ def test_rectangle_invalid(self, coords, message):
615
615
  """Verifies Rectangle constructor behavior with invalid arguments."""
616
616
  with self.assertRaisesRegex(ee.EEException, message):
617
617
  ee.Geometry.Rectangle(*coords)
618
618
 
619
- def testValid_GeometryCollection(self):
619
+ def test_valid_geometry_collection(self):
620
620
  """Verifies GeometryCollection constructor behavior with valid arguments."""
621
621
  geometry = ee.Geometry({
622
622
  'type': 'GeometryCollection',
@@ -640,7 +640,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
640
640
  })
641
641
  self.assertIsInstance(geometry, ee.Geometry)
642
642
 
643
- def testArrayConstructors(self):
643
+ def test_array_constructors(self):
644
644
  """Verifies that constructors that take arrays fix nesting."""
645
645
  get_coordinates_count = lambda g: len(g.toGeoJSON()['coordinates'])
646
646
 
@@ -669,7 +669,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
669
669
  )
670
670
  self.assertEqual(2, get_coordinates_count(mpolygon))
671
671
 
672
- def testGeodesicFlag(self):
672
+ def test_geodesic_flag(self):
673
673
  """Verifies that JSON parsing and generation preserves the geodesic flag."""
674
674
  geodesic = ee.Geometry({
675
675
  'type': 'LineString',
@@ -684,14 +684,14 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
684
684
  self.assertTrue(geodesic.toGeoJSON()['geodesic'])
685
685
  self.assertFalse(projected.toGeoJSON()['geodesic'])
686
686
 
687
- def testConstructor(self):
687
+ def test_constructor(self):
688
688
  """Check the behavior of the Geometry constructor.
689
689
 
690
690
  There are 5 options:
691
691
  1) A geoJSON object.
692
692
  2) A not-computed geometry.
693
693
  3) A not-computed geometry with overrides.
694
- 4) A computed geometry.
694
+ 4) A computed geometry with no overrides.
695
695
  5) something to cast to geometry.
696
696
  """
697
697
  line = ee.Geometry.LineString(1, 2, 3, 4)
@@ -729,7 +729,26 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
729
729
  self.assertEqual(computed.func, geom.func)
730
730
  self.assertEqual(computed.args, geom.args)
731
731
 
732
- def testComputedGeometries(self):
732
+ @parameterized.named_parameters(
733
+ ('_proj', {'proj': 'some-proj'}),
734
+ ('_geodesic', {'geodesic': False}),
735
+ ('_geodesic_true', {'geodesic': True}),
736
+ ('_evenOdd', {'evenOdd': False}),
737
+ ('_evenOdd_true', {'evenOdd': True}),
738
+ )
739
+ def test_constructor_error_for_computed_geometry_with_overrides(self, kwargs):
740
+ """Verifies that Geometry raises for computed geometries with overrides."""
741
+ computed_geometry = ee.Geometry.Polygon(
742
+ coords=[[[-35, -10], [-35, 10], [35, 10], [35, -10], [-35, -10]]],
743
+ geodesic=True,
744
+ )
745
+ with self.assertRaisesRegex(
746
+ ee.EEException,
747
+ 'Setting the CRS or geodesic on a computed Geometry is not supported.',
748
+ ):
749
+ ee.Geometry(computed_geometry, **kwargs)
750
+
751
+ def test_computed_geometries(self):
733
752
  """Verifies the computed object behavior of the Geometry constructor."""
734
753
  line = ee.Geometry.LineString(1, 2, 3, 4)
735
754
  bounds = line.bounds()
@@ -739,7 +758,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
739
758
  self.assertEqual(line, bounds.args['geometry'])
740
759
  self.assertTrue(hasattr(bounds, 'bounds'))
741
760
 
742
- def testComputedCoordinate(self):
761
+ def test_computed_coordinate(self):
743
762
  """Verifies that a computed coordinate produces a computed geometry."""
744
763
  coords = [1, ee.Number(1).add(1)]
745
764
  p = ee.Geometry.Point(coords)
@@ -750,7 +769,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
750
769
  )
751
770
  self.assertEqual({'coordinates': ee.List(coords)}, p.args)
752
771
 
753
- def testComputedList(self):
772
+ def test_computed_list(self):
754
773
  """Verifies that a computed coordinate produces a computed geometry."""
755
774
  lst = ee.List([1, 2, 3, 4]).slice(0, 2)
756
775
  p = ee.Geometry.Point(lst)
@@ -761,7 +780,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
761
780
  )
762
781
  self.assertEqual({'coordinates': lst}, p.args)
763
782
 
764
- def testComputedProjection(self):
783
+ def test_computed_projection(self):
765
784
  """Verifies that a geometry with a projection can be constructed."""
766
785
  p = ee.Geometry.Point([1, 2], 'epsg:4326')
767
786
 
@@ -775,13 +794,13 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
775
794
  }
776
795
  self.assertEqual(expected_args, p.args)
777
796
 
778
- def testInvalidCrs(self):
797
+ def test_invalid_crs(self):
779
798
  geo_json = ee.Geometry.LineString(1, 2, 3, 4).toGeoJSON()
780
799
  geo_json['crs'] = {'something': 'invalid-crs'}
781
800
  with self.assertRaisesRegex(ee.EEException, 'Invalid CRS declaration'):
782
801
  ee.Geometry(geo_json)
783
802
 
784
- def testInternals(self):
803
+ def test_internals(self):
785
804
  """Test eq(), ne() and hash()."""
786
805
  a = ee.Geometry.Point(1, 2)
787
806
  b = ee.Geometry.Point(2, 1)
@@ -793,7 +812,29 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
793
812
  self.assertNotEqual(b, c)
794
813
  self.assertNotEqual(hash(a), hash(b))
795
814
 
796
- def testInit_optParams(self):
815
+ def test_coordinates_to_line(self):
816
+ # pylint: disable=protected-access
817
+ self.assertEqual([], ee.Geometry._coordinatesToLine([]))
818
+ self.assertEqual([1, 2], ee.Geometry._coordinatesToLine([1, 2]))
819
+ # TODO: schwehr - Improve _coordinatesToLine typing.
820
+ self.assertEqual(
821
+ [[1, 2]],
822
+ ee.Geometry._coordinatesToLine([[1, 2]]), # pytype: disable=wrong-arg-types
823
+ )
824
+ self.assertEqual(
825
+ [[1, 2], [3, 4]], ee.Geometry._coordinatesToLine([1, 2, 3, 4])
826
+ )
827
+ self.assertEqual(
828
+ [[1, 2], [3, 4], [5, 6]],
829
+ ee.Geometry._coordinatesToLine([1, 2, 3, 4, 5, 6]),
830
+ )
831
+ with self.assertRaisesRegex(
832
+ ee.EEException, 'Invalid number of coordinates: 5'
833
+ ):
834
+ ee.Geometry._coordinatesToLine([1, 2, 3, 4, 5])
835
+ # pylint: enable=protected-access
836
+
837
+ def test_init_opt_params(self):
797
838
  result = ee.Geometry(
798
839
  geo_json={'type': 'Polygon', 'coordinates': [[[-2, 1]]]},
799
840
  opt_proj='abc',
@@ -882,7 +923,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
882
923
  ),
883
924
  ),
884
925
  )
885
- def testToGeoJSON(self, geometry_func, expected_geojson):
926
+ def test_to_geo_json(self, geometry_func, expected_geojson):
886
927
  self.assertEqual(expected_geojson, geometry_func().toGeoJSON())
887
928
 
888
929
  @parameterized.named_parameters(
@@ -896,7 +937,7 @@ class GeometryTest(apitestcase.ApiTestCase, parameterized.TestCase):
896
937
  ('Polygon', lambda: ee.Geometry.Polygon([], 'EPSG:4326')),
897
938
  ('Rectangle', lambda: ee.Geometry.Rectangle([], 'EPSG:4326')),
898
939
  )
899
- def testToGeoJSON_FailsOnComputed(self, geometry_func):
940
+ def test_to_geo_json_fails_on_computed(self, geometry_func):
900
941
  message = 'Cannot convert a computed geometry to GeoJSON'
901
942
  with self.assertRaisesRegex(ee.EEException, message):
902
943
  geometry_func().toGeoJSON()
@@ -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, Type
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: Optional[Type[image_converter.ImageConverter]],
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/image_test.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """Test for the ee.image module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
  from unittest import mock
7
7
 
8
8
  import unittest
@@ -37,8 +37,8 @@ IMAGE_C = {
37
37
 
38
38
 
39
39
  def make_expression_graph(
40
- function_invocation_value: Dict[str, Any],
41
- ) -> Dict[str, Any]:
40
+ function_invocation_value: dict[str, Any],
41
+ ) -> dict[str, Any]:
42
42
  return {
43
43
  'result': '0',
44
44
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -2,7 +2,7 @@
2
2
  """Test for the ee.imagecollection module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
  from unittest import mock
7
7
 
8
8
  import unittest
@@ -11,8 +11,8 @@ from ee import apitestcase
11
11
 
12
12
 
13
13
  def make_expression_graph(
14
- function_invocation_value: Dict[str, Any],
15
- ) -> Dict[str, Any]:
14
+ function_invocation_value: dict[str, Any],
15
+ ) -> dict[str, Any]:
16
16
  return {
17
17
  'result': '0',
18
18
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
ee/tests/join_test.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """Tests for the ee.Join module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
 
7
7
  import unittest
8
8
  import ee
@@ -13,8 +13,8 @@ SIMPLE = 'Join.simple'
13
13
 
14
14
 
15
15
  def make_expression_graph(
16
- function_invocation_value: Dict[str, Any],
17
- ) -> Dict[str, Any]:
16
+ function_invocation_value: dict[str, Any],
17
+ ) -> dict[str, Any]:
18
18
  return {
19
19
  'result': '0',
20
20
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
ee/tests/kernel_test.py CHANGED
@@ -3,7 +3,7 @@
3
3
 
4
4
  import json
5
5
  import sys
6
- from typing import Any, Dict
6
+ from typing import Any
7
7
  import unittest
8
8
 
9
9
  import unittest
@@ -30,8 +30,8 @@ _KERNEL_JSON = {
30
30
 
31
31
 
32
32
  def make_expression_graph(
33
- function_invocation_value: Dict[str, Any],
34
- ) -> Dict[str, Any]:
33
+ function_invocation_value: dict[str, Any],
34
+ ) -> dict[str, Any]:
35
35
  return {
36
36
  'result': '0',
37
37
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
@@ -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
ee/tests/model_test.py CHANGED
@@ -2,7 +2,7 @@
2
2
  """Tests for the ee.Model module."""
3
3
 
4
4
  import json
5
- from typing import Any, Dict
5
+ from typing import Any
6
6
 
7
7
  import unittest
8
8
  import ee
@@ -12,15 +12,15 @@ MODEL = 'Model'
12
12
 
13
13
 
14
14
  def make_expression_graph(
15
- function_invocation_value: Dict[str, Any],
16
- ) -> Dict[str, Any]:
15
+ function_invocation_value: dict[str, Any],
16
+ ) -> dict[str, Any]:
17
17
  return {
18
18
  'result': '0',
19
19
  'values': {'0': {'functionInvocationValue': function_invocation_value}},
20
20
  }
21
21
 
22
22
 
23
- def make_override_expression(key: str, pixel_type: str) -> Dict[str, Any]:
23
+ def make_override_expression(key: str, pixel_type: str) -> dict[str, Any]:
24
24
  return {
25
25
  'dictionaryValue': {
26
26
  'values': {
@@ -44,7 +44,7 @@ def make_override_expression(key: str, pixel_type: str) -> Dict[str, Any]:
44
44
 
45
45
  def make_type_expression(
46
46
  key: str, pixel_type: str, dimensions: int
47
- ) -> Dict[str, Any]:
47
+ ) -> dict[str, Any]:
48
48
  return {
49
49
  'dictionaryValue': {
50
50
  'values': {
@@ -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'