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
Neel Shah
NIFTy
Commits
93b3fdd9
Commit
93b3fdd9
authored
Nov 06, 2019
by
Philipp Arras
Browse files
Fix PartialExtractor
parent
441e854e
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/simple_linear_operators.py
View file @
93b3fdd9
...
@@ -338,12 +338,17 @@ class PartialExtractor(LinearOperator):
...
@@ -338,12 +338,17 @@ class PartialExtractor(LinearOperator):
if
self
.
_domain
[
key
]
is
not
self
.
_target
[
key
]:
if
self
.
_domain
[
key
]
is
not
self
.
_target
[
key
]:
raise
ValueError
(
"domain mismatch"
)
raise
ValueError
(
"domain mismatch"
)
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
self
.
_capability
=
self
.
TIMES
|
self
.
ADJOINT_TIMES
self
.
_compldomain
=
MultiDomain
.
make
({
kk
:
self
.
_domain
[
kk
]
for
kk
in
self
.
_domain
.
keys
()
if
kk
not
in
self
.
_target
.
keys
()})
def
apply
(
self
,
x
,
mode
):
def
apply
(
self
,
x
,
mode
):
self
.
_check_input
(
x
,
mode
)
self
.
_check_input
(
x
,
mode
)
if
mode
==
self
.
TIMES
:
if
mode
==
self
.
TIMES
:
return
x
.
extract
(
self
.
_target
)
return
x
.
extract
(
self
.
_target
)
return
MultiField
.
from_dict
({
key
:
x
[
key
]
for
key
in
x
.
domain
.
keys
()})
res0
=
MultiField
.
from_dict
({
key
:
x
[
key
]
for
key
in
x
.
domain
.
keys
()})
res1
=
MultiField
.
full
(
self
.
_compldomain
,
0.
)
return
res0
.
unite
(
res1
)
class
MatrixProductOperator
(
EndomorphicOperator
):
class
MatrixProductOperator
(
EndomorphicOperator
):
...
...
test/test_operators/test_adjoint.py
View file @
93b3fdd9
...
@@ -295,3 +295,15 @@ def testValueInserter(sp, seed):
...
@@ -295,3 +295,15 @@ def testValueInserter(sp, seed):
ind
.
append
(
np
.
random
.
randint
(
0
,
ss
-
1
))
ind
.
append
(
np
.
random
.
randint
(
0
,
ss
-
1
))
op
=
ift
.
ValueInserter
(
sp
,
ind
)
op
=
ift
.
ValueInserter
(
sp
,
ind
)
ift
.
extra
.
consistency_check
(
op
)
ift
.
extra
.
consistency_check
(
op
)
@
pmp
(
'seed'
,
[
12
,
3
])
def
testPartialExtractor
(
seed
):
np
.
random
.
seed
(
seed
)
tgt
=
{
'a'
:
ift
.
RGSpace
(
1
),
'b'
:
ift
.
RGSpace
(
2
)}
dom
=
tgt
.
copy
()
dom
[
'c'
]
=
ift
.
RGSpace
(
3
)
dom
=
ift
.
MultiDomain
.
make
(
dom
)
tgt
=
ift
.
MultiDomain
.
make
(
tgt
)
op
=
ift
.
PartialExtractor
(
dom
,
tgt
)
ift
.
extra
.
consistency_check
(
op
)
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