Verifies the behavior of the map() method.
(self)
| 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.""" |