Commit edc5e76f authored by Philipp Arras's avatar Philipp Arras

More expressive error messages for domain checks.

parent bd249a5f
......@@ -260,4 +260,10 @@ class LinearOperator(Operator):
def _check_input(self, x, mode):
self._check_mode(mode)
if self._dom(mode) != x.domain:
raise ValueError("The operator's and field's domains don't match.")
s = "The operator's and field's domains don't match."
from ..domain_tuple import DomainTuple
from ..multi_domain import MultiDomain
if not (isinstance(self._dom(mode), DomainTuple)
or isinstance(x.domain, MultiDomain)):
s += " One of the domains is neither a `DomainTuple` nor a `MultiDomain`."
raise ValueError(s)
......@@ -67,7 +67,13 @@ class Operator(NiftyMetaBase()):
from ..linearization import Linearization
d = x.target if isinstance(x, Linearization) else x.domain
if self._domain != d:
raise ValueError("The operator's and field's domains don't match.")
s = "The operator's and field's domains don't match."
from ..domain_tuple import DomainTuple
from ..multi_domain import MultiDomain
if not (isinstance(self._domain, DomainTuple)
or isinstance(d, MultiDomain)):
s += " One of the domains is neither a `DomainTuple` nor a `MultiDomain`."
raise ValueError(s)
def __call__(self, x):
if isinstance(x, Operator):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment