MCPcopy
hub / github.com/google/earthengine-api / test_mapping

Method test_mapping

python/ee/tests/collection_test.py:113–132  ·  view source on GitHub ↗

Verifies the behavior of the map() method.

(self)

Source from the content-addressed store, hash-verified

111 self.assertIsInstance(result2, ee.FeatureCollection)
112
113 def test_mapping(self):
114 """Verifies the behavior of the map() method."""
115 collection = ee.ImageCollection('foo')
116 algorithm = lambda img: img.select('bar')
117 mapped = collection.map(algorithm)
118
119 self.assertIsInstance(mapped, ee.ImageCollection)
120 self.assertEqual(ee.ApiFunction.lookup('Collection.map'), mapped.func)
121 self.assertEqual(collection, mapped.args['collection'])
122
123 # Need to do a serialized comparison for the function body because
124 # variables returned from CustomFunction.variable() do not implement
125 # __eq__.
126 sig = {
127 'returns': 'Image',
128 'args': [{'name': '_MAPPING_VAR_0_0', 'type': 'Image'}]
129 }
130 expected_function = ee.CustomFunction(sig, algorithm)
131 self.assertEqual(expected_function.serialize(),
132 mapped.args['baseAlgorithm'].serialize())
133
134 def test_nested_mapping(self):
135 """Verifies that nested map() calls produce distinct variables."""

Callers

nothing calls this directly

Calls 4

lookupMethod · 0.80
selectMethod · 0.45
mapMethod · 0.45
serializeMethod · 0.45

Tested by

no test coverage detected