Commit a198e78a authored by Martin Reinecke's avatar Martin Reinecke
Browse files

small cleanups

parent 58d4b593
Pipeline #31303 passed with stages
in 2 minutes and 6 seconds
...@@ -57,4 +57,4 @@ pages: ...@@ -57,4 +57,4 @@ pages:
paths: paths:
- public - public
only: only:
- NIFTy_4 - NIFTy_5
...@@ -40,14 +40,16 @@ N_iter = 100 ...@@ -40,14 +40,16 @@ N_iter = 100
tol = 1e-3 tol = 1e-3
IC = ift.GradientNormController(tol_abs_gradnorm=tol, iteration_limit=N_iter) IC = ift.GradientNormController(tol_abs_gradnorm=tol, iteration_limit=N_iter)
inverter = ift.ConjugateGradient(IC) inverter = ift.ConjugateGradient(IC)
curv = ift.library.WienerFilterCurvature(S=S, N=N, R=R_p, inverter=inverter, sampling_inverter=inverter) curv = ift.library.WienerFilterCurvature(S=S, N=N, R=R_p, inverter=inverter,
sampling_inverter=inverter)
m_xi = curv.inverse_times(j) m_xi = curv.inverse_times(j)
samps_long = [curv.draw_sample(from_inverse=True) for i in range(N_samps)] samps_long = [curv.draw_sample(from_inverse=True) for i in range(N_samps)]
tol = 1e2 tol = 1e2
IC = ift.GradientNormController(tol_abs_gradnorm=tol, iteration_limit=N_iter) IC = ift.GradientNormController(tol_abs_gradnorm=tol, iteration_limit=N_iter)
inverter = ift.ConjugateGradient(IC) inverter = ift.ConjugateGradient(IC)
curv = ift.library.WienerFilterCurvature(S=S, N=N, R=R_p, inverter=inverter, sampling_inverter=inverter) curv = ift.library.WienerFilterCurvature(S=S, N=N, R=R_p, inverter=inverter,
sampling_inverter=inverter)
samps_short = [curv.draw_sample(from_inverse=True) for i in range(N_samps)] samps_short = [curv.draw_sample(from_inverse=True) for i in range(N_samps)]
# Compute mean # Compute mean
......
...@@ -215,7 +215,7 @@ Further operator classes provided by NIFTy are ...@@ -215,7 +215,7 @@ Further operator classes provided by NIFTy are
Syntactic sugar Syntactic sugar
--------------- ---------------
Nifty4 allows simple and intuitive construction of altered and combined Nifty5 allows simple and intuitive construction of altered and combined
operators. operators.
As an example, if ``A``, ``B`` and ``C`` are of type :class:`LinearOperator` As an example, if ``A``, ``B`` and ``C`` are of type :class:`LinearOperator`
and ``f1`` and ``f2`` are of type :class:`Field`, writing:: and ``f1`` and ``f2`` are of type :class:`Field`, writing::
......
...@@ -138,14 +138,16 @@ class Energy(NiftyMetaBase()): ...@@ -138,14 +138,16 @@ class Energy(NiftyMetaBase()):
def Add(energy1, energy2): def Add(energy1, energy2):
if isinstance(energy1.position, MultiField) and isinstance(energy2.position, MultiField): if (isinstance(energy1.position, MultiField) and
isinstance(energy2.position, MultiField)):
a = energy1.position._val a = energy1.position._val
b = energy2.position._val b = energy2.position._val
# Note: In python >3.5 one could do {**a, **b} # Note: In python >3.5 one could do {**a, **b}
ab = a.copy() ab = a.copy()
ab.update(b) ab.update(b)
position = MultiField(ab) position = MultiField(ab)
elif isinstance(energy1.position, Field) and isinstance(energy2.position, Field): elif (isinstance(energy1.position, Field) and
isinstance(energy2.position, Field)):
position = energy1.position position = energy1.position
else: else:
raise TypeError raise TypeError
......
...@@ -49,7 +49,8 @@ class MultiDomain(frozendict): ...@@ -49,7 +49,8 @@ class MultiDomain(frozendict):
def __init__(self, domain, _callingfrommake=False): def __init__(self, domain, _callingfrommake=False):
if not _callingfrommake: if not _callingfrommake:
raise NotImplementedError('To create a MultiDomain call `MultiDomain.make()`.') raise NotImplementedError(
'To create a MultiDomain call `MultiDomain.make()`.')
super(MultiDomain, self).__init__(domain) super(MultiDomain, self).__init__(domain)
@staticmethod @staticmethod
......
Supports Markdown
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