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
a7325040
Commit
a7325040
authored
May 02, 2019
by
Martin Reinecke
Browse files
slightly less invasive fix
parent
bfd678e9
Pipeline
#47569
passed with stages
in 8 minutes and 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
nifty5/operators/energy_operators.py
View file @
a7325040
...
...
@@ -191,21 +191,15 @@ class PoissonianEnergy(EnergyOperator):
def
apply
(
self
,
x
):
self
.
_check_input
(
x
)
if
isinstance
(
x
,
Linearization
):
inp_vals
=
x
.
val
.
local_data
else
:
inp_vals
=
x
.
local_data
fix_inf
=
False
if
np
.
any
(
inp_vals
==
np
.
inf
):
if
not
np
.
any
(
np
.
isnan
(
inp_vals
)):
fix_inf
=
True
#Note: This will break for MPI if there are NaNs in some threads but not others
res
=
x
.
sum
()
tmp
=
(
res
.
val
.
local_data
if
isinstance
(
res
,
Linearization
)
else
res
.
local_data
)
# if we have no infinity here, we can continue with the calculation;
# otherwise we know that the result must also be infinity
if
not
np
.
any
(
np
.
isinf
(
tmp
)):
res
=
res
-
x
.
log
().
vdot
(
self
.
_d
)
if
not
isinstance
(
x
,
Linearization
):
if
fix_inf
:
res
=
np
.
inf
return
Field
.
scalar
(
res
)
res
=
x
.
sum
()
-
x
.
log
().
vdot
(
self
.
_d
)
if
fix_inf
:
res
=
Linearization
(
Field
.
scalar
(
np
.
inf
),
res
.
jac
)
if
not
x
.
want_metric
:
return
res
metric
=
SandwichOperator
.
make
(
x
.
jac
,
makeOp
(
1.
/
x
.
val
))
...
...
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