(self, value, map_function)
| 275 | return self._execute_mapping(args_to_map, map_function) |
| 276 | |
| 277 | def _execute_mapping(self, value, map_function): |
| 278 | if _is_raw_type(value, tuple) or _is_raw_type(value, list): |
| 279 | mapped_value = value.__class__( |
| 280 | map(lambda x: self._execute_mapping(x, map_function), value) |
| 281 | ) |
| 282 | elif _is_raw_type(value, dict) or _is_raw_type(value, OrderedDict): |
| 283 | mapped_value = value.__class__( |
| 284 | map( |
| 285 | lambda x: (x[0], self._execute_mapping(x[1], map_function)), |
| 286 | value.items(), |
| 287 | ) |
| 288 | ) |
| 289 | elif _is_raw_type(value, NamedArg): |
| 290 | if value.is_leaf(): # only map the leaf: TENSOR/NONE/OPAQUE |
| 291 | mapped_value = map_function(value) |
| 292 | else: |
| 293 | mapped_value = self._execute_mapping(value.value(), map_function) |
| 294 | else: |
| 295 | mapped_value = map_function(value) |
| 296 | |
| 297 | return mapped_value |
| 298 | |
| 299 | def __repr__(self): |
| 300 | if self._named_io_args: |
no test coverage detected