Skip to content

Commit 5f52428

Browse files
authored
Merge pull request #27513 from oscargus/transformtestdoc
Fix docs and add tests for transform and deprecate `BboxTransformToMaxOnly`
2 parents e90058d + 7d98270 commit 5f52428

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``BboxTransformToMaxOnly``
2+
~~~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
... is deprecated without replacement. If you rely on this, please make a copy of the
5+
code.

lib/matplotlib/tests/test_transforms.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,3 +1054,21 @@ def test_transformedbbox_contains():
10541054
assert bb.contains(1.25, 1.5)
10551055
assert not bb.fully_contains(1.25, 1.5)
10561056
assert not bb.fully_contains(.1, .1)
1057+
1058+
1059+
def test_interval_contains():
1060+
assert mtransforms.interval_contains((0, 1), 0.5)
1061+
assert mtransforms.interval_contains((0, 1), 0)
1062+
assert mtransforms.interval_contains((0, 1), 1)
1063+
assert not mtransforms.interval_contains((0, 1), -1)
1064+
assert not mtransforms.interval_contains((0, 1), 2)
1065+
assert mtransforms.interval_contains((1, 0), 0.5)
1066+
1067+
1068+
def test_interval_contains_open():
1069+
assert mtransforms.interval_contains_open((0, 1), 0.5)
1070+
assert not mtransforms.interval_contains_open((0, 1), 0)
1071+
assert not mtransforms.interval_contains_open((0, 1), 1)
1072+
assert not mtransforms.interval_contains_open((0, 1), -1)
1073+
assert not mtransforms.interval_contains_open((0, 1), 2)
1074+
assert mtransforms.interval_contains_open((1, 0), 0.5)

lib/matplotlib/transforms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2617,9 +2617,10 @@ def get_matrix(self):
26172617
return self._mtx
26182618

26192619

2620+
@_api.deprecated("3.9")
26202621
class BboxTransformToMaxOnly(BboxTransformTo):
26212622
"""
2622-
`BboxTransformTo` is a transformation that linearly transforms points from
2623+
`BboxTransformToMaxOnly` is a transformation that linearly transforms points from
26232624
the unit bounding box to a given `Bbox` with a fixed upper left of (0, 0).
26242625
"""
26252626
def get_matrix(self):

0 commit comments

Comments
 (0)