point

A point as a collection of coordinates in real space.

class parityos.utils.point.RealT

A constrained TypeVar representing a real number. Restricted to int, float and decimal.Decimal.

alias of TypeVar(‘RealT’, int, float, ~decimal.Decimal)

class parityos.utils.point.Point

Bases: Generic[RealT], ABC

Base class for Points in real space.

Coordinates can be of type float or decimal.Decimal.

property coordinates: tuple[RealT, ...]

Coordinates of the point as tuple.

abstractmethod classmethod from_coordinates(coordinates: Sequence[RealT], /) Self

Construct a Point from a sequence of its coordinates.

property squared_norm: RealT

The squared Euclidean norm of the point.

Returns:

The sum of squares of the coordinates.

property norm: float

The Euclidean norm of the point.

Returns:

The square root of the sum of squares of the coordinates.

__getitem__(index: int, /) RealT

Get coordinate at index.

Returns:

Coordinate at index.

Raises:

IndexError – If index is out of bounds.

__neg__() Self

The negative of the point.

Returns:

A Point with the same coordinates, but of opposite sign.

__add__(other: Self, /) Self

The addition operator +.

Addition is element-wise in the coordinates. Only supported between equal type Point instances.

Parameters:

other – Another Point.

Returns:

The sum of the two points as new Point.

Raises:
__sub__(other: Self, /) Self

Subtraction operator -.

Subtraction is element-wise in the coordinates. Only supported between equal type Point instances.

Parameters:

other – Another Point.

Returns:

The difference between the two points as new Point.

Raises:
__mul__(other: RealT, /) Self

Scalar multiplication operator *.

Type checking is only supported for multiplication with a scalar of same type as the coordinates of self.

Parameters:

other – Scalar factor to multiply self with.

Returns:

A new Point with the coordinates of self multiplied with other.

class parityos.utils.point.Point1D(x: RealT)

Bases: Point[RealT]

A one-dimensional Point on a line with a single coordinate x.

x: RealT

The x coordinate of this point.

coordinates: tuple[RealT]
classmethod from_coordinates(coordinates: Sequence[RealT]) Self

Construct a Point from a sequence of its coordinates.

class parityos.utils.point.Point2D(x: RealT, y: RealT)

Bases: Point[RealT]

A two-dimensional Point on a plane with coordinates x and y.

x: RealT

The x coordinate of this point.

y: RealT

The y coordinate of this point.

coordinates: tuple[RealT, RealT]
classmethod from_coordinates(coordinates: Sequence[RealT]) Self

Construct a Point from a sequence of its coordinates.

class parityos.utils.point.Point3D(x: RealT, y: RealT, z: RealT)

Bases: Point[RealT]

A three-dimensional Point in space with coordinates x, y and z.

x: RealT

The x coordinate of this point.

y: RealT

The y coordinate of this point.

z: RealT

The z coordinate of this point.

coordinates: tuple[RealT, RealT, RealT]
classmethod from_coordinates(coordinates: Sequence[RealT]) Self

Construct a Point from a sequence of its coordinates.

class parityos.utils.point.PointT

A TypeVar representing a Point.

alias of TypeVar(‘PointT’, bound=Point)

parityos.utils.point.get_point(x: RealT) Point1D[RealT]
parityos.utils.point.get_point(x: RealT, y: RealT) Point2D[RealT]
parityos.utils.point.get_point(x: RealT, y: RealT, z: RealT) Point3D[RealT]

Convenience function for creating points of arbitrary dimensionality.