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
e69914c0
Commit
e69914c0
authored
Jul 07, 2018
by
Martin Reinecke
Browse files
fixes
parent
d07a537e
Changes
2
Hide whitespace changes
Inline
Side-by-side
nifty5/multi/block_diagonal_operator.py
View file @
e69914c0
...
...
@@ -45,7 +45,7 @@ class BlockDiagonalOperator(EndomorphicOperator):
if
self
.
_domain
is
not
op
.
_domain
:
raise
ValueError
(
"domain mismatch"
)
res
=
{
key
:
v1
*
v2
for
key
,
v1
,
v2
in
zip
(
self
.
_domain
.
keys
(),
self
.
_ops
,
op
.
_ops
)}
return
BlockDiagonalOperator
(
res
)
return
BlockDiagonalOperator
(
self
.
_domain
,
res
)
def
_combine_sum
(
self
,
op
,
selfneg
,
opneg
):
from
..operators.sum_operator
import
SumOperator
...
...
@@ -54,4 +54,4 @@ class BlockDiagonalOperator(EndomorphicOperator):
res
=
{}
for
key
,
v1
,
v2
in
zip
(
self
.
_domain
.
keys
(),
self
.
_ops
,
op
.
_ops
):
res
[
key
]
=
SumOperator
.
make
([
v1
,
v2
],
[
selfneg
,
opneg
])
return
BlockDiagonalOperator
(
res
)
return
BlockDiagonalOperator
(
self
.
_domain
,
res
)
test/test_multi_field.py
View file @
e69914c0
...
...
@@ -39,8 +39,8 @@ class Test_Functionality(unittest.TestCase):
assert_equal
(
val
.
local_data
,
f2
[
key
].
local_data
)
def
test_blockdiagonal
(
self
):
op
=
ift
.
BlockDiagonalOperator
(
{
"d1"
:
ift
.
ScalingOperator
(
20.
,
dom
[
"d1"
])})
op
=
ift
.
BlockDiagonalOperator
(
dom
,
{
"d1"
:
ift
.
ScalingOperator
(
20.
,
dom
[
"d1"
])})
op2
=
op
*
op
ift
.
extra
.
consistency_check
(
op2
)
assert_equal
(
type
(
op2
),
ift
.
BlockDiagonalOperator
)
...
...
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