uvisbox.Core.BandDepths.curve_banddepth

Module Contents

uvisbox.Core.BandDepths.curve_banddepth.point_in_hull(point, hull_or_vertices, eps=1e-06)[source]

Check if a point is inside a convex hull.

Parameters:
  • point (array-like) – The coordinates of the point to check. Should be a 1D array or list of length equal to the dimension of the hull.

  • hull_or_vertices (scipy.spatial.ConvexHull or array-like) – Either a SciPy ConvexHull object, or an array/list of vertices that define the convex hull. If vertices are provided, a ConvexHull object will be constructed internally.

  • eps (float, optional) – Tolerance for numerical precision when checking if the point is inside the hull. Default is 1e-6.

Returns:

True if the point is inside the convex hull (within the specified tolerance), False otherwise.

Return type:

bool

Raises:

ValueError – If hull_or_vertices is not a ConvexHull object, ndarray, or list of vertices.

Notes

  • The function uses the hull’s half-space equations to determine if the point is inside.

  • Points on the boundary (within eps tolerance) are considered inside.

uvisbox.Core.BandDepths.curve_banddepth.points_in_hull(points, hull, eps=1e-06)[source]

Vectorized check if multiple points are inside a convex hull.

This function uses vectorized NumPy operations to efficiently test multiple points against a convex hull simultaneously, providing significant performance improvements over calling point_in_hull repeatedly.

Parameters:
  • points (numpy.ndarray) – Array of points to check, shape (n_points, n_dims). Can also be a single point of shape (n_dims,), which will be treated as (1, n_dims).

  • hull (scipy.spatial.ConvexHull) – A SciPy ConvexHull object defining the convex hull to test against.

  • eps (float, optional) – Tolerance for numerical precision when checking if points are inside the hull. Default is 1e-6.

Returns:

Boolean array of shape (n_points,) where True indicates the point is inside the hull (within the specified tolerance), False otherwise.

Return type:

numpy.ndarray

Notes

  • Uses vectorized matrix operations: equations[:, :-1] @ points.T + equations[:, -1]

  • Much faster than looping: O(1) matrix op vs O(n_points * n_equations) loop iterations

  • Points on the boundary (within eps tolerance) are considered inside.

  • For single point queries, consider using point_in_hull() for simplicity.

Examples

>>> hull = ConvexHull(np.array([[0, 0], [1, 0], [0, 1]]))
>>> points = np.array([[0.2, 0.2], [2.0, 2.0]])
>>> points_in_hull(points, hull)
array([ True, False])
uvisbox.Core.BandDepths.curve_banddepth.curve_banddepths(curves, indices=None, workers=12)[source]

Calculate band depth for curves based on how often each curve’s points lie within convex hulls formed by bands of other curves. M. Mirzargar, R. T. Whitaker and R. M. Kirby, “Curve Boxplot: Generalization of Boxplot for Ensembles of Curves,” in IEEE Transactions on Visualization and Computer Graphics, vol. 20, no. 12, pp. 2654-2663, 31 Dec. 2014, doi: 10.1109/TVCG.2014.2346455.

Parameters:
  • curves (numpy.ndarray) – 3D array of shape (n_curves, n_steps, n_dims) containing curve data

  • indices (list of lists, optional) – Each inner list contains indices of curves that form a band indices can be created by itertools.combinations(range(n_curves), k) for some k recommended caching for indices

  • workers (int, optional) – Number of worker processes for parallel computation. Default is 12. Set to 1 or None to use sequential processing (useful for debugging). Uses the operating system’s default multiprocessing context.

Returns:

1D array of normalized depth scores for each curve

Return type:

numpy.ndarray