Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ift
NIFTy
Commits
1255a779
Commit
1255a779
authored
Aug 31, 2018
by
Philipp Arras
Browse files
Add type check to MultiField.from_dict()
parent
edf428c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
nifty5/multi_field.py
View file @
1255a779
...
...
@@ -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):
@
staticmethod
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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment