Points have zero volume and are determined by a single location. An instance of `Point` represents a single n-dimensional point or a batch of points.
| 656 | @sliceable(keepdims='vector') |
| 657 | @dataclass(frozen=True, eq=False) |
| 658 | class Point(Geometry): |
| 659 | """ |
| 660 | Points have zero volume and are determined by a single location. |
| 661 | An instance of `Point` represents a single n-dimensional point or a batch of points. |
| 662 | """ |
| 663 | |
| 664 | location: Tensor |
| 665 | |
| 666 | variable_attrs = ('location',) |
| 667 | value_attrs = ('location',) |
| 668 | |
| 669 | def __post_init__(self): |
| 670 | assert 'vector' in self.location.shape, "location must have a vector dimension" |
| 671 | assert self.location.shape.get_item_names('vector') is not None, "Vector dimension needs to list spatial dimension as item names." |
| 672 | |
| 673 | @property |
| 674 | def center(self) -> Tensor: |
| 675 | return self.location |
| 676 | |
| 677 | @property |
| 678 | def shape(self) -> Shape: |
| 679 | return self.location.shape |
| 680 | |
| 681 | @property |
| 682 | def faces(self) -> 'Geometry': |
| 683 | return self |
| 684 | |
| 685 | def unstack(self, dimension: str) -> tuple: |
| 686 | return tuple(Point(loc) for loc in math.unstack(self.location, dimension)) |
| 687 | |
| 688 | def lies_inside(self, location: Tensor) -> Tensor: |
| 689 | return expand(math.wrap(False), shape(location).without('vector')) |
| 690 | |
| 691 | def approximate_signed_distance(self, location: Union[Tensor, tuple]) -> Tensor: |
| 692 | return math.norm(location - self.location) |
| 693 | |
| 694 | def bounding_radius(self) -> Tensor: |
| 695 | return math.zeros() |
| 696 | |
| 697 | def bounding_half_extent(self) -> Tensor: |
| 698 | return wrap(0) |
| 699 | |
| 700 | def at(self, center: Tensor) -> 'Geometry': |
| 701 | return Point(center) |
| 702 | |
| 703 | def rotated(self, angle) -> 'Geometry': |
| 704 | return self |
| 705 | |
| 706 | @property |
| 707 | def volume(self) -> Tensor: |
| 708 | return math.wrap(0) |
| 709 | |
| 710 | def sample_uniform(self, *shape: math.Shape) -> Tensor: |
| 711 | raise NotImplementedError |
| 712 | |
| 713 | def scaled(self, factor: Union[float, Tensor]) -> 'Geometry': |
| 714 | return self |
| 715 |
no outgoing calls
no test coverage detected