is_compatible_space¶
-
odl.operator.tensor_ops.
is_compatible_space
(space, base_space)[source]¶ Check compatibility of a (power) space with a base space.
Compatibility here means that the spaces are equal or
space
is a non-empty power space ofbase_space
up to different data types.- Parameters
- space, base_space
LinearSpace
Spaces to check for compatibility.
base_space
cannot be aProductSpace
.
- space, base_space
- Returns
- is_compatiblebool
True
ifspace == base_space
orspace.astype(base_space.dtype) == base_space
, provided that these properties exist, orspace
is a power space of nonzero length and one of the three situations applies tospace[0]
(recursively).
Otherwise
False
.
Examples
Scalar spaces:
>>> base = odl.rn(2) >>> is_compatible_space(odl.rn(2), base) True >>> is_compatible_space(odl.rn(3), base) False >>> is_compatible_space(odl.rn(2, dtype='float32'), base) True
Power spaces:
>>> is_compatible_space(odl.rn(2) ** 2, base) True >>> is_compatible_space(odl.rn(2) * odl.rn(3), base) # no power space False >>> is_compatible_space(odl.rn(2, dtype='float32') ** 2, base) True