Commit 1255a779 authored by Philipp Arras's avatar Philipp Arras
Browse files

Add type check to MultiField.from_dict()

parent edf428c9
......@@ -24,6 +24,7 @@ from . import utilities
from .compat import *
from .field import Field
from .multi_domain import MultiDomain
from .domain_tuple import DomainTuple
class MultiField(object):
......@@ -52,6 +53,9 @@ class MultiField(object):
def from_dict(dict, domain=None):
if domain is None:
for dd in dict.values():
if not isinstance(dd.domain, DomainTuple):
raise TypeError('Values of dictionary need to be Fields defined on DomainTuples.')
domain = MultiDomain.make({key: v._domain
for key, v in dict.items()})
res = tuple(dict[key] if key in dict else Field(dom, 0)
Supports Markdown
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