File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1227,14 +1227,16 @@ class Transform(TransformNode):
1227
1227
1228
1228
def __init_subclass__ (cls ):
1229
1229
# 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
1232
1234
and cls .input_dims == cls .output_dims == 1 ):
1233
1235
cls .is_separable = True
1234
1236
# Transform.inverted raises NotImplementedError; we assume that if this
1235
1237
# is overridden then the transform is invertible but subclass can also
1236
1238
# 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
1238
1240
and hasattr (cls , "inverted" )
1239
1241
and cls .inverted is not Transform .inverted ):
1240
1242
cls .has_inverse = True
You can’t perform that action at this time.
0 commit comments