Commit f78346e3 authored by Lukas Platz's avatar Lukas Platz
Browse files

KL_Energy: add keyword argument to mirror samples

parent eaf710b7
......@@ -8,7 +8,8 @@ from .. import utilities
class KL_Energy(Energy):
def __init__(self, position, h, nsamp, constants=[],
constants_samples=None, _samples=None):
constants_samples=None, mirror_samples=False,
super(KL_Energy, self).__init__(position)
if h.domain is not position.domain:
raise TypeError
......@@ -17,11 +18,14 @@ class KL_Energy(Energy):
if constants_samples is None:
constants_samples = constants
self._constants_samples = constants_samples
self._mirror_samples = mirror_samples
if _samples is None:
met = h(Linearization.make_partial_var(
position, constants_samples, True)).metric
_samples = tuple(met.draw_sample(from_inverse=True)
for _ in range(nsamp))
if mirror_samples:
_samples += tuple(-s for s in _samples)
self._samples = _samples
self._lin = Linearization.make_partial_var(position, constants)
......@@ -40,7 +44,8 @@ class KL_Energy(Energy):
def at(self, position):
return KL_Energy(position, self._h, 0, self._constants,
self._constants_samples, self._samples)
self._constants_samples, self._mirror_samples,
def value(self):
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment