Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit50d469d

Browse files
committed
Add ability to compose transforms of any dimension
1 parentf4de081 commit50d469d

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

‎lib/matplotlib/tests/test_transforms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ def test_str_transform():
853853
BlendedAffine(
854854
IdentityTransform(),
855855
IdentityTransform())),
856-
CompositeAffine2D(
856+
CompositeAffine(
857857
Affine2D().scale(1.0),
858858
Affine2D().scale(1.0))),
859859
PolarTransform(
@@ -876,7 +876,7 @@ def test_str_transform():
876876
(0.5, 0.5),
877877
TransformedBbox(
878878
Bbox(x0=0.0, y0=0.0, x1=6.283185307179586, y1=1.0),
879-
CompositeAffine2D(
879+
CompositeAffine(
880880
Affine2D().scale(1.0),
881881
Affine2D().scale(1.0))),
882882
LockableBbox(

‎lib/matplotlib/transforms.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2467,7 +2467,7 @@ def _invalidate_internal(self, level, invalidating_node):
24672467
super()._invalidate_internal(level,invalidating_node)
24682468

24692469
def__eq__(self,other):
2470-
ifisinstance(other, (CompositeGenericTransform,CompositeAffine2D)):
2470+
ifisinstance(other, (CompositeGenericTransform,CompositeAffine)):
24712471
returnselfisotheror (self._a==other._a
24722472
andself._b==other._b)
24732473
else:
@@ -2527,7 +2527,7 @@ def inverted(self):
25272527
self._b.inverted(),self._a.inverted())
25282528

25292529

2530-
classCompositeAffine2D(Affine2DBase):
2530+
classCompositeAffine(AffineImmutable):
25312531
"""
25322532
A composite transform formed by applying transform *a* then transform *b*.
25332533
@@ -2537,7 +2537,7 @@ class CompositeAffine2D(Affine2DBase):
25372537
def__init__(self,a,b,**kwargs):
25382538
"""
25392539
Create a new composite transform that is the result of
2540-
applying `Affine2DBase` *a* then `Affine2DBase` *b*.
2540+
applying `AffineImmutable` *a* then `AffineImmutable` *b*.
25412541
25422542
You will generally not call this constructor directly but write ``a +
25432543
b`` instead, which will automatically choose the best kind of composite
@@ -2548,10 +2548,8 @@ def __init__(self, a, b, **kwargs):
25482548
ifa.output_dims!=b.input_dims:
25492549
raiseValueError("The output dimension of 'a' must be equal to "
25502550
"the input dimensions of 'b'")
2551-
self.input_dims=a.input_dims
2552-
self.output_dims=b.output_dims
2551+
super().__init__(dims=a.output_dims,**kwargs)
25532552

2554-
super().__init__(**kwargs)
25552553
self._a=a
25562554
self._b=b
25572555
self.set_children(a,b)
@@ -2580,6 +2578,11 @@ def get_matrix(self):
25802578
returnself._mtx
25812579

25822580

2581+
@_api.deprecated("3.9",alternative="CompositeAffine")
2582+
classCompositeAffine2D(CompositeAffine):
2583+
pass
2584+
2585+
25832586
defcomposite_transform_factory(a,b):
25842587
"""
25852588
Create a new composite transform that is the result of applying
@@ -2603,7 +2606,7 @@ def composite_transform_factory(a, b):
26032606
elifisinstance(b,IdentityTransform):
26042607
returna
26052608
elifisinstance(a,Affine2D)andisinstance(b,Affine2D):
2606-
returnCompositeAffine2D(a,b)
2609+
returnCompositeAffine(a,b)
26072610
returnCompositeGenericTransform(a,b)
26082611

26092612

‎lib/matplotlib/transforms.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,11 +282,14 @@ class CompositeGenericTransform(Transform):
282282
pass_through:bool
283283
def__init__(self,a:Transform,b:Transform,**kwargs)->None: ...
284284

285-
classCompositeAffine2D(Affine2DBase):
286-
def__init__(self,a:Affine2DBase,b:Affine2DBase,**kwargs)->None: ...
285+
classCompositeAffine(AffineImmutable):
286+
def__init__(self,a:AffineImmutable,b:AffineImmutable,**kwargs)->None: ...
287287
@property
288288
defdepth(self)->int: ...
289289

290+
classCompositeAffine2D(CompositeAffine):
291+
pass
292+
290293
defcomposite_transform_factory(a:Transform,b:Transform)->Transform: ...
291294

292295
classBboxTransform(AffineImmutable):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp