8000 Merge pull request #14991 from anntzer/tprop2 · matplotlib/matplotlib@fe7fa10 · GitHub
[go: up one dir, main page]

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)
0