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
d3114d0e
Commit
d3114d0e
authored
Jun 11, 2021
by
Martin Reinecke
Browse files
more paranoia
parent
a81e79a3
Pipeline
#103377
passed with stages
in 17 minutes and 6 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/operators/multifield2vector.py
View file @
d3114d0e
...
...
@@ -17,6 +17,7 @@
import
numpy
as
np
from
..multi_domain
import
MultiDomain
from
..domain_tuple
import
DomainTuple
from
..domains.unstructured_domain
import
UnstructuredDomain
from
..sugar
import
makeField
...
...
@@ -38,6 +39,8 @@ class Multifield2Vector(LinearOperator):
"""
def
__init__
(
self
,
domain
):
if
not
isinstance
(
domain
,
MultiDomain
):
raise
NotImplementedError
(
"This operator only works on MultiDomains"
)
self
.
_dof
=
domain
.
size
self
.
_domain
=
domain
self
.
_target
=
DomainTuple
.
make
(
UnstructuredDomain
(
self
.
_dof
))
...
...
@@ -50,13 +53,13 @@ class Multifield2Vector(LinearOperator):
if
mode
==
self
.
TIMES
:
res
=
np
.
empty
(
self
.
target
.
shape
)
for
key
in
self
.
domain
.
keys
():
if
not
(
np
.
issubdtype
(
x
[
key
].
dtype
,
np
.
floating
)
)
:
if
not
np
.
issubdtype
(
x
[
key
].
dtype
,
np
.
floating
):
raise
NotImplementedError
(
"only real fields are allowed"
)
arr
=
x
[
key
].
flatten
()
res
[
ii
:
ii
+
arr
.
size
]
=
arr
ii
+=
arr
.
size
else
:
if
not
(
np
.
issubdtype
(
x
.
dtype
,
np
.
floating
)
)
:
if
not
np
.
issubdtype
(
x
.
dtype
,
np
.
floating
):
raise
NotImplementedError
(
"only real fields are allowed"
)
res
=
{}
for
key
in
self
.
domain
.
keys
():
...
...
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