bounding_box#

Class for working with two-dimensional bounds.

Classes

BoundingBox(x_bounds, y_bounds[, inclusive])

Class representing 2-dimensional range of numeric values.

class data_morph.bounds.bounding_box.BoundingBox(x_bounds: Interval | Iterable[Number], y_bounds: Interval | Iterable[Number], inclusive: Iterable[bool] = False)[source]#

Bases: object

Class representing 2-dimensional range of numeric values.

Parameters:
  • x_bounds (Union[Interval, Iterable[numbers.Number]]) – A 2-dimensional numeric iterable or an Interval object.

  • y_bounds (Union[Interval, Iterable[numbers.Number]]) – A 2-dimensional numeric iterable or an Interval object.

  • inclusive (bool, default False) – Whether the bounds include the endpoints. Default is exclusive. If Interval objects are provided, their settings are used.

adjust_bounds(x: Number = None, y: Number = 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() None[source]#

Align the aspect ratio to 1:1.

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:

numbers.Number

clone() BoundingBox[source]#

Clone this instance.

Returns:

A new BoundingBox instance with the same bounds.

Return type:

BoundingBox

property range: Iterable[Number]#

Calculate the range (width) of the bounding box in each direction.

Returns:

The range covered by the x and y bounds, respectively.

Return type:

Iterable[numbers.Number]

x_bounds#

The bounds for the x direction.

Type:

Interval

y_bounds#

The bounds for the y direction.

Type:

Interval