Bidirectional map between entities in two topologies.
| 509 | |
| 510 | |
| 511 | class EntityMap: |
| 512 | """Bidirectional map between entities in two topologies.""" |
| 513 | |
| 514 | def __init__(self, entity_map): |
| 515 | """Initialise an entity map from a C++ `EntityMap` object. |
| 516 | |
| 517 | Note: |
| 518 | `EntityMap` objects should not usually be created using this |
| 519 | initializer directly. |
| 520 | |
| 521 | Args: |
| 522 | entity_map: A C++ `EntityMap` object. |
| 523 | """ |
| 524 | self._cpp_object = entity_map |
| 525 | self._topology = Topology(self._cpp_object.topology) |
| 526 | self._sub_topology = Topology(self._cpp_object.sub_topology) |
| 527 | |
| 528 | def sub_topology_to_topology(self, entities, inverse): |
| 529 | """Map entities between the sub-topology and the parent topology. |
| 530 | |
| 531 | If `inverse` is False, this function maps a list of |
| 532 | `self.dim()`-dimensional entities from `self.sub_topology()` to |
| 533 | the corresponding entities in `self.topology()`. If `inverse` is |
| 534 | True, it performs the inverse mapping from `self.topology()` to |
| 535 | `self.sub_topology()`. Entities that do not exist in the |
| 536 | sub-topology are marked as -1. |
| 537 | |
| 538 | Note: |
| 539 | If `inverse` is `True`, this function recomputes the inverse |
| 540 | map on every call (it is not cached), which may be expensive |
| 541 | if called repeatedly. |
| 542 | |
| 543 | Args: |
| 544 | entities: |
| 545 | A list of entity indices in the source topology. |
| 546 | inverse: |
| 547 | If False, maps from `self.sub_topology()` to |
| 548 | `self.topology()`. If True, maps from `self.topology()` |
| 549 | to `self.sub_topology()`. |
| 550 | |
| 551 | Returns: |
| 552 | A list of mapped entity indices. Entities that don't exist |
| 553 | in the target topology are marked as -1. |
| 554 | """ |
| 555 | return self._cpp_object.sub_topology_to_topology(entities, inverse) |
| 556 | |
| 557 | @property |
| 558 | def dim(self): |
| 559 | """Topological dimension of the entities.""" |
| 560 | return self._cpp_object.dim |
| 561 | |
| 562 | @property |
| 563 | def topology(self): |
| 564 | """The topology.""" |
| 565 | return self._topology |
| 566 | |
| 567 | @property |
| 568 | def sub_topology(self): |
no outgoing calls
no test coverage detected