Skip to content

Commit fe7fa10

Browse files
authored
Merge pull request #14991 from anntzer/tprop2
MNT: Handle inherited is_separable, has_inverse in transform props detection.
2 parents 724f9a2 + 4b84a53 commit fe7fa10

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/matplotlib/transforms.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,14 +1227,16 @@ class Transform(TransformNode):
12271227

12281228
def __init_subclass__(cls):
12291229
# 1d transforms are always separable; we assume higher-dimensional ones
1230-
# are not but subclasses can also directly set is_separable.
1231-
if ("is_separable" not in vars(cls) # Was it overridden explicitly?
1230+
# are not but subclasses can also directly set is_separable -- this is
1231+
# verified by checking whether "is_separable" appears more than once in
1232+
# the class's MRO (it appears once in Transform).
1233+
if (sum("is_separable" in vars(parent) for parent in cls.__mro__) == 1
12321234
and cls.input_dims == cls.output_dims == 1):
12331235
cls.is_separable = True
12341236
# Transform.inverted raises NotImplementedError; we assume that if this
12351237
# is overridden then the transform is invertible but subclass can also
12361238
# directly set has_inverse.
1237-
if ("has_inverse" not in vars(cls) # Was it overridden explicitly?
1239+
if (sum("has_inverse" in vars(parent) for parent in cls.__mro__) == 1
12381240
and hasattr(cls, "inverted")
12391241
and cls.inverted is not Transform.inverted):
12401242
cls.has_inverse = True

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy