FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fixed formatting to match our docstring conventions · matplotlib/matplotlib@1f0d625 · GitHub

Repository navigation

Commit 1f0d625

Browse files
committed
fixed formatting to match our docstring conventions
1 parent 5b8134f commit 1f0d625

1 file changed

Lines changed: 48 additions & 27 deletions

File tree

‎lib/matplotlib/transforms.py‎

Lines changed: 48 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -685,38 +685,59 @@ class Bbox(BboxBase):
685685
686686
Examples
687687
--------
688-
>>> # the default constructor takes the boundary "points" [[xmin, ymin],
689-
>>> # [xmax, ymax]]
690-
>>> unit_box = Bbox([[1, 1], [2, 2]])
688+
The default constructor takes the boundary "points" ``[[xmin, ymin],
689+
[xmax, ymax]]``.
691690
692-
>>> # the "zero" Bbox (i.e. "identity" object for Bbox.intersection), the
693-
>>> # null bbox has (min, max) = (np.inf, -np.inf) for each dimension
694-
>>> null = Bbox.null()
695-
>>> assert unit_box == Bbox.intersection(unit_box, null)
691+
>>> example_box = Bbox([[1, 1], [3, 7]])
692+
>>> example_box
693+
Bbox([[1.0, 1.0], [3.0, 7.0]])
696694
697-
>>> # and thus it overlaps with every bbox
698-
>>> assert unit_bbox.overlaps(null)
695+
Alternatively, a Bbox can be created from the flattened array, the
696+
so-called "extents" ``(xmin, ymin, xmax, ymax)``
699697
700-
>>> # a union containing null (the "zero" Bbox) will always return null
701-
>>> assert null == Bbox.union([unit_bbox, null])
698+
>>> Bbox.from_extents(1, 1, 3, 7)
699+
Bbox([[1.0, 1.0], [3.0, 7.0]])
702700
703-
>>> # a Bbox can be created from extents (xmin, ymin, xmax, ymax)
704-
>>> assert unit_bbox == Bbox.from_extents(1, 1, 2, 2)
701+
or from the "bounds" ``(xmin, ymin, width, height)``.
705702
706-
>>> # or from "bounds" (xmin, ymin, width, height)
707-
>>> assert unit_bbox == Bbox.from_bounds(1, 1, 1, 1)
703+
>>> Bbox.from_bounds(1, 1, 2, 6)
704+
Bbox([[1.0, 1.0], [3.0, 7.0]])
708705
709-
>>> # or from an arbitrary list of points (here, 10 random points)
710-
>>> random_bbox = Bbox.null()
711-
>>> random_bbox.update_from_data_xy(np.random.rand((10, 2)))
706+
The "empty" object for accumulating Bboxs is the null bbox, which has
707+
``(min, max) = (np.inf, -np.inf)`` for each dimension.
712708
713-
>>> # to quickly update a Bbox to include new point(s), simply use
714-
>>> # `ignore=False`, it's faster than using `union` directly
715-
>>> new_data = np.random.rand(10, 2) # 10 new points
716-
>>> new_bbox = Bbox.null()
717-
>>> new_bbox.update_from_data_xy(new_data)
718-
>>> assert random_bbox.update_from_data_xy(new_data, ignore=False) \
719-
>>> == Bbox.union([new_bbox, random_bbox])
709+
>>> Bbox.null()
710+
Bbox([[inf, inf], [-inf, -inf]])
711+
712+
Adding points to the null bbox will give you the bbox of those points.
713+
714+
>>> box = Bbox.null()
715+
>>> box.update_from_data_xy([[1, 1]])
716+
>>> box
717+
Bbox([[1.0, 1.0], [1.0, 1.0]])
718+
>>> box.update_from_data_xy([[2, 3], [3, 2]], ignore=False)
719+
>>> box
720+
Bbox([[1.0, 1.0], [3.0, 3.0]])
721+
722+
Setting ``ignore=True`` is equivalent to starting over from a null bbox.
723+
724+
>>> box.update_from_data_xy([[1, 1]], ignore=True)
725+
Bbox([[1.0, 1.0], [1.0, 1.0]])
726+
727+
The null bbox is also the identity for intersections
728+
729+
>>> Bbox.intersection(unit_box, null)
730+
Bbox([[1.0, 1.0], [2.0, 2.0]])
731+
732+
except with itself, where it returns the full space.
733+
734+
>>> Bbox.intersection(null, null)
735+
Bbox([[-inf, -inf], [inf, inf]])
736+
737+
A union containing null will always return the full space (not null!)
738+
739+
>>> Bbox.union([unit_bbox, null])
740+
Bbox([[-inf, -inf], [inf, inf]])
720741
"""
721742

722743
def __init__(self, points, **kwargs):
@@ -729,8 +750,8 @@ def __init__(self, points, **kwargs):
729750
Notes
730751
-----
731752
If you need to create a `Bbox` object from another form
732-
of data, consider the static methods :meth:`unit`,
733-
:meth:`from_bounds` and :meth:`from_extents`.
753+
of data, consider the static methods :meth:`from_bounds` and
754+
:meth:`from_extents`.
734755
"""
735756
BboxBase.__init__(self, **kwargs)
736757
points = np.asarray(points, float)

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL