Skip to content
GitLab
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
c8018d8e
Commit
c8018d8e
authored
May 01, 2018
by
Martin Reinecke
Browse files
experiment with dtypes
parent
585414a4
Pipeline
#28419
passed with stages
in 2 minutes and 42 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
nifty4/multi/multi_field.py
View file @
c8018d8e
...
...
@@ -47,19 +47,30 @@ class MultiField(object):
def
copy
(
self
):
return
MultiField
({
key
:
val
.
copy
()
for
key
,
val
in
self
.
items
()})
@
staticmethod
def
build_dtype
(
dtype
,
domain
):
if
isinstance
(
dtype
,
dict
):
return
dtype
if
dtype
is
None
:
dtype
=
np
.
float64
return
{
key
:
dtype
for
key
in
domain
.
keys
()}
@
staticmethod
def
zeros
(
domain
,
dtype
=
None
):
return
MultiField
({
key
:
Field
.
zeros
(
dom
,
dtype
=
dtype
)
dtype
=
self
.
build_dtype
(
dtype
,
domain
)
return
MultiField
({
key
:
Field
.
zeros
(
dom
,
dtype
=
dtype
[
key
])
for
key
,
dom
in
domain
.
items
()})
@
staticmethod
def
ones
(
domain
,
dtype
=
None
):
return
MultiField
({
key
:
Field
.
ones
(
dom
,
dtype
=
dtype
)
dtype
=
self
.
build_dtype
(
dtype
,
domain
)
return
MultiField
({
key
:
Field
.
ones
(
dom
,
dtype
=
dtype
[
key
])
for
key
,
dom
in
domain
.
items
()})
@
staticmethod
def
empty
(
domain
,
dtype
=
None
):
return
MultiField
({
key
:
Field
.
empty
(
dom
,
dtype
=
dtype
)
dtype
=
self
.
build_dtype
(
dtype
,
domain
)
return
MultiField
({
key
:
Field
.
empty
(
dom
,
dtype
=
dtype
[
key
])
for
key
,
dom
in
domain
.
items
()})
def
norm
(
self
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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