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
606523c0
Commit
606523c0
authored
Dec 09, 2018
by
Philipp Arras
Committed by
Martin Reinecke
Dec 09, 2018
Browse files
Add some reprs
parent
30df8975
Changes
3
Hide whitespace changes
Inline
Side-by-side
nifty5/minimization/kl_energy.py
View file @
606523c0
...
...
@@ -73,3 +73,7 @@ class KL_Energy(Energy):
@
property
def
samples
(
self
):
return
self
.
_samples
def
__repr__
(
self
):
return
'KL ({} samples):
\n
'
.
format
(
len
(
self
.
_samples
))
+
utilities
.
indent
(
self
.
_ham
.
__repr__
())
nifty5/operators/energy_operators.py
View file @
606523c0
...
...
@@ -168,6 +168,11 @@ class Hamiltonian(EnergyOperator):
self
.
_ic_samp
,
prx
.
metric
.
inverse
)
return
(
lhx
+
prx
).
add_metric
(
mtr
)
def
__repr__
(
self
):
subs
=
'Likelihood:
\n
{}'
.
format
(
utilities
.
indent
(
self
.
_lh
.
__repr__
()))
subs
+=
'
\n
Prior: Quadratic{}'
.
format
(
self
.
_lh
.
domain
.
keys
())
return
'Hamiltonian:
\n
'
+
utilities
.
indent
(
subs
)
class
SampledKullbachLeiblerDivergence
(
EnergyOperator
):
def
__init__
(
self
,
h
,
res_samples
):
...
...
nifty5/operators/operator.py
View file @
606523c0
...
...
@@ -2,7 +2,7 @@ from __future__ import absolute_import, division, print_function
import
numpy
as
np
from
..compat
import
*
from
..utilities
import
NiftyMetaBase
from
..utilities
import
NiftyMetaBase
,
indent
class
Operator
(
NiftyMetaBase
()):
...
...
@@ -177,6 +177,11 @@ class _OpChain(_CombinedOperator):
return
x
def
__repr__
(
self
):
subs
=
"
\n
"
.
join
(
sub
.
__repr__
()
for
sub
in
self
.
_ops
)
return
"_OpChain:
\n
"
+
indent
(
subs
)
class
_OpProd
(
Operator
):
def
__init__
(
self
,
op1
,
op2
):
from
..sugar
import
domain_union
...
...
@@ -205,6 +210,11 @@ class _OpProd(Operator):
return
lin1
.
new
(
lin1
.
_val
*
lin2
.
_val
,
op
(
x
.
jac
))
def
__repr__
(
self
):
subs
=
"
\n
"
.
join
(
sub
.
__repr__
()
for
sub
in
(
self
.
_op1
,
self
.
_op2
))
return
"_OpProd:
\n
"
+
indent
(
subs
)
class
_OpSum
(
Operator
):
def
__init__
(
self
,
op1
,
op2
):
from
..sugar
import
domain_union
...
...
@@ -231,3 +241,7 @@ class _OpSum(Operator):
if
lin1
.
_metric
is
not
None
and
lin2
.
_metric
is
not
None
:
res
=
res
.
add_metric
(
lin1
.
_metric
+
lin2
.
_metric
)
return
res
def
__repr__
(
self
):
subs
=
"
\n
"
.
join
(
sub
.
__repr__
()
for
sub
in
(
self
.
_op1
,
self
.
_op2
))
return
"_OpSum:
\n
"
+
indent
(
subs
)
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