BoundingBox#
- class data_morph.bounds.bounding_box.BoundingBox(x_bounds: Interval | Iterable[Number], y_bounds: Interval | Iterable[Number], inclusive: Iterable[bool] = False)[source]#
Bases:
objectClass representing 2-dimensional range of numeric values.
- Parameters:
x_bounds (Interval | Iterable[numbers.Number]) – A 2-dimensional numeric iterable or an
Intervalobject.y_bounds (Interval | Iterable[numbers.Number]) – A 2-dimensional numeric iterable or an
Intervalobject.inclusive (bool, default
False) – Whether the bounds include the endpoints. Default is exclusive. IfIntervalobjects are provided, their settings are used.
- adjust_bounds(x: Number | None = None, y: Number | None = None) None[source]#
Adjust bounding box range.
- Parameters:
x (numbers.Number, optional) – The amount to change the x bound range by (half will be applied to each end).
y (numbers.Number, optional) – The amount to change the y bound range by (half will be applied to each end).
See also
Interval.adjust_bounds()Method that performs the adjustment.
- align_aspect_ratio(shrink: bool = False) None[source]#
Align the aspect ratio to 1:1.
- Parameters:
shrink (bool, default
False) – Whether to shrink the larger bound (True), or expand the smaller bound (False).
- property aspect_ratio: Number#
Calculate the aspect ratio of the bounding box.
- Returns:
The range in the x direction divided by the range in the y direction.
- Return type:
- property center: tuple[Number, Number]#
Calculate the center of the bounding box.
- Returns:
The center of the x and y bounds, respectively.
- Return type:
tuple[Number, Number]
- clone() BoundingBox[source]#
Clone this instance.
- Returns:
A new
BoundingBoxinstance with the same bounds.- Return type: