skspatial.objects.Point

class skspatial.objects.Point(array: Union[numpy.ndarray, Sequence])[source]

A point in space implemented as a 1D array.

The array is a subclass of numpy.ndarray.

Parameters
arrayarray_like

Input array.

Raises
ValueError

If the array is empty, the values are not finite, or the dimension is not one.

Examples

>>> from skspatial.objects import Point
>>> point = Point([1, 2, 3])
>>> point.dimension
3

The object inherits methods from numpy.ndarray.

>>> point.mean()
array(2.)
>>> Point([])
Traceback (most recent call last):
...
ValueError: The array must not be empty.
>>> import numpy as np
>>> Point([1, 2, np.nan])
Traceback (most recent call last):
...
ValueError: The values must all be finite.
>>> Point([[1, 2], [3, 4]])
Traceback (most recent call last):
...
ValueError: The array must be 1D.
Attributes
dimensionint

Dimension of the point.

Methods

distance_point(other)

Return the distance to another point.

plot_2d(ax_2d, **kwargs)

Plot the point on a 2D scatter plot.

plot_3d(ax_3d, **kwargs)

Plot the point on a 3D scatter plot.