(self, other, binary_fn)
| 509 | return self |
| 510 | |
| 511 | def _binary_functor(self, other, binary_fn): |
| 512 | assert isinstance(other, (self.__class__, torch.Tensor)) |
| 513 | if isinstance(other, self.__class__): |
| 514 | assert self._manager == other._manager, COORDINATE_MANAGER_DIFFERENT_ERROR |
| 515 | |
| 516 | if self.coordinate_map_key == other.coordinate_map_key: |
| 517 | return self.__class__( |
| 518 | binary_fn(self._F, other.F), |
| 519 | coordinate_map_key=self.coordinate_map_key, |
| 520 | coordinate_manager=self._manager, |
| 521 | ) |
| 522 | else: |
| 523 | # Generate union maps |
| 524 | out_key = CoordinateMapKey( |
| 525 | self.coordinate_map_key.get_coordinate_size() |
| 526 | ) |
| 527 | union_maps = self.coordinate_manager.union_map( |
| 528 | [self.coordinate_map_key, other.coordinate_map_key], out_key |
| 529 | ) |
| 530 | N_out = self.coordinate_manager.size(out_key) |
| 531 | out_F = torch.zeros( |
| 532 | (N_out, self._F.size(1)), dtype=self.dtype, device=self.device |
| 533 | ) |
| 534 | out_F[union_maps[0][1]] = self._F[union_maps[0][0]] |
| 535 | out_F[union_maps[1][1]] = binary_fn( |
| 536 | out_F[union_maps[1][1]], other._F[union_maps[1][0]] |
| 537 | ) |
| 538 | return self.__class__( |
| 539 | out_F, coordinate_map_key=out_key, coordinate_manager=self._manager |
| 540 | ) |
| 541 | else: # when it is a torch.Tensor |
| 542 | return self.__class__( |
| 543 | binary_fn(self._F, other), |
| 544 | coordinate_map_key=self.coordinate_map_key, |
| 545 | coordinate_manager=self._manager, |
| 546 | ) |
| 547 | |
| 548 | def __add__(self, other): |
| 549 | r""" |
no test coverage detected