@@ -682,6 +682,42 @@ def intersection(bbox1, bbox2):
682
682
class Bbox (BboxBase ):
683
683
"""
684
684
A mutable bounding box.
685
+
686
+
687
+ Examples
688
+ --------
689
+ >>> # the default constructor takes the boundary "points" [[xmin, ymin],
690
+ >>> # [xmax, ymax]]
691
+ >>> unit_box = Bbox([[1, 1], [2, 2]])
692
+
693
+ >>> # the "zero" Bbox (i.e. "identity" object for Bbox.intersection), the
694
+ >>> # null bbox has (min, max) = (np.inf, -np.inf) for each dimension
695
+ >>> null = Bbox.null()
696
+ >>> assert unit_box == Bbox.intersection(unit_box, null)
697
+
698
+ >>> # and thus it overlaps with every bbox
699
+ >>> assert unit_bbox.overlaps(null)
700
+
701
+ >>> # a union containing null (the "zero" Bbox) will always return null
702
+ >>> assert null == Bbox.union([unit_bbox, null])
703
+
704
+ >>> # a Bbox can be created from extents (xmin, ymin, xmax, ymax)
705
+ >>> assert unit_bbox == Bbox.from_extents(1, 1, 2, 2)
706
+
707
+ >>> # or from "bounds" (xmin, ymin, width, height)
708
+ >>> assert unit_bbox == Bbox.from_bounds(1, 1, 1, 1)
709
+
710
+ >>> # or from an arbitrary list of points (here, 10 random points)
711
+ >>> random_bbox = Bbox.null()
712
+ >>> random_bbox.update_from_data_xy(np.random.rand((10, 2)))
713
+
714
+ >>> # to quickly update a Bbox to include new point(s), simply use
715
+ >>> # `ignore=False`, it's faster than using `union` directly
716
+ >>> new_data = np.random.rand(10, 2) # 10 new points
717
+ >>> new_bbox = Bbox.null()
718
+ >>> new_bbox.update_from_data_xy(new_data)
719
+ >>> assert random_bbox.update_from_data_xy(new_data, ignore=False) \
720
+ >>> == Bbox.union([new_bbox, random_bbox])
685
721
"""
686
722
687
723
def __init__ (self , points , ** kwargs ):
0 commit comments