locan.data.region.Region#
- class locan.data.region.Region[source]#
Bases:
ABC
Abstract Region class to define the interface for Region-derived classes that specify geometric objects to represent regions of interest.
Methods
__init__
()buffer
(distance, **kwargs)Extend the region perpendicular by a distance.
contains
(points)Return list of indices for all points that are inside the region of interest.
from_intervals
(intervals)Constructor for instantiating axis-oriented, box-like Region from list of (min, max) bounds.
intersection
(other)Returns a region representing the intersection of this region with
other
.symmetric_difference
(other)Returns the union of the two regions minus any areas contained in the intersection of the two regions.
union
(other)Returns a region representing the union of this region with
other
.Attributes
A region describing the minimum axis-aligned bounding box that encloses the original region.
Region bounds min_x, min_y, ..., max_x, max_y, .
Point coordinates for region centroid.
The region dimension.
The extent (max_x - min_x), (max_y - min_y), .
The maximum distance between any two points within the region.
Point coordinates.
Region measure, i.e. area (for 2d) or volume (for 3d).
Measure of the sub-dimensional region, i.e. circumference (for 2d) or surface (for 3d).
- abstract property bounding_box: Region#
A region describing the minimum axis-aligned bounding box that encloses the original region.
- Return type:
- abstract property bounds: ndarray[Any, dtype[float64]] | None#
Region bounds min_x, min_y, …, max_x, max_y, … for each dimension.
- Returns:
of shape (2 * dimension,)
- Return type:
npt.NDArray[np.float64] | None
- abstract buffer(distance, **kwargs)[source]#
Extend the region perpendicular by a distance.
- Parameters:
distance (
float
) – Distance by which the region is extended.- Returns:
The extended region.
- Return type:
- abstract property centroid: ndarray[Any, dtype[float64]] | None#
Point coordinates for region centroid.
- Returns:
of shape (dimension,)
- Return type:
npt.NDArray[np.float64] | None
- abstract contains(points)[source]#
Return list of indices for all points that are inside the region of interest.
- Parameters:
points (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – Coordinates of points that are tested for being inside the specified region.- Returns:
Array with indices for all points in original point array that are within the region.
- Return type:
npt.NDArray[np.int64]
- abstract property dimension: int | None#
The region dimension.
- Return type:
int | None
- abstract property extent: ndarray[Any, dtype[float64]] | None#
The extent (max_x - min_x), (max_y - min_y), … for each dimension.
- Returns:
of shape (dimension,)
- Return type:
npt.NDArray[np.float64] | None
- static from_intervals(intervals)[source]#
Constructor for instantiating axis-oriented, box-like Region from list of (min, max) bounds. Takes array-like intervals instead of interval to be consistent with Rectangle.from_intervals.
- Parameters:
intervals (
Union
[_SupportsArray
[dtype
[Any
]],_NestedSequence
[_SupportsArray
[dtype
[Any
]]],bool
,int
,float
,complex
,str
,bytes
,_NestedSequence
[Union
[bool
,int
,float
,complex
,str
,bytes
]]]) – The region bounds for each dimension of shape (dimension, 2).- Return type:
Interval | Rectangle | AxisOrientedCuboid | AxisOrientedHypercuboid
- abstract intersection(other)[source]#
Returns a region representing the intersection of this region with
other
.
- abstract property max_distance: float#
The maximum distance between any two points within the region.
- Return type:
float
- abstract property points: ndarray[Any, dtype[float64]] | list[ndarray[Any, dtype[float64]]]#
Point coordinates.
- Returns:
of shape (n_points, dimension)
- Return type:
npt.NDArray[np.float64] | list[npt.NDArray[np.float64]]
- abstract property region_measure: float#
Region measure, i.e. area (for 2d) or volume (for 3d).
- Return type:
float
- abstract property subregion_measure: float#
Measure of the sub-dimensional region, i.e. circumference (for 2d) or surface (for 3d).
- Return type:
float