From 4b84a531f53c4e1a3085e18ed3787ba82416a700 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Tue, 6 Aug 2019 10:56:36 +0200 Subject: [PATCH] Handle inherited is_separable, has_inverse in transform props detection. Using `__init_subclass__` is more subtle than directly overriding with `@property`... --- lib/matplotlib/transforms.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/transforms.py b/lib/matplotlib/transforms.py index 112b867abb22..51182616b8a0 100644 --- a/lib/matplotlib/transforms.py +++ b/lib/matplotlib/transforms.py @@ -1227,14 +1227,16 @@ class Transform(TransformNode): def __init_subclass__(cls): # 1d transforms are always separable; we assume higher-dimensional ones - # are not but subclasses can also directly set is_separable. - if ("is_separable" not in vars(cls) # Was it overridden explicitly? + # are not but subclasses can also directly set is_separable -- this is + # verified by checking whether "is_separable" appears more than once in + # the class's MRO (it appears once in Transform). + if (sum("is_separable" in vars(parent) for parent in cls.__mro__) == 1 and cls.input_dims == cls.output_dims == 1): cls.is_separable = True # Transform.inverted raises NotImplementedError; we assume that if this # is overridden then the transform is invertible but subclass can also # directly set has_inverse. - if ("has_inverse" not in vars(cls) # Was it overridden explicitly? + if (sum("has_inverse" in vars(parent) for parent in cls.__mro__) == 1 and hasattr(cls, "inverted") and cls.inverted is not Transform.inverted): cls.has_inverse = True 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