Commit 564aca36 authored by Gordian Edenhofer's avatar Gordian Edenhofer
Browse files

Fix usage of print to logging

parent 4ca56a07
Pipeline #65019 passed with stages
in 8 minutes and 58 seconds
......@@ -18,6 +18,7 @@
import numpy as np
from ..logger import logger
from ..domain_tuple import DomainTuple
from ..domains.power_space import PowerSpace
from ..domains.unstructured_domain import UnstructuredDomain
......@@ -501,7 +502,7 @@ class CorrelatedFieldMaker:
mean = sc.mean.to_global_data()
stddev = sc.var.sqrt().to_global_data()
for m, s in zip(mean.flatten(), stddev.flatten()):
print('{}: {:.02E} ± {:.02E}'.format(kk, m, s))
logger.info('{}: {:.02E} ± {:.02E}'.format(kk, m, s))
def moment_slice_to_average(self, fluctuations_slice_mean, nsamples=1000):
fluctuations_slice_mean = float(fluctuations_slice_mean)
......
......@@ -20,6 +20,7 @@ from time import time
import numpy as np
from .logger import logger
from . import dobj, utilities
from .domain_tuple import DomainTuple
from .domains.power_space import PowerSpace
......@@ -462,46 +463,46 @@ def exec_time(obj, want_metric=True):
if isinstance(obj, Energy):
t0 = time()
obj.at(0.99*obj.position)
print('Energy.at():', time() - t0)
logger.info('Energy.at(): {}'.format(time() - t0))
t0 = time()
obj.value
print('Energy.value:', time() - t0)
logger.info('Energy.value: {}'.format(time() - t0))
t0 = time()
obj.gradient
print('Energy.gradient:', time() - t0)
logger.info('Energy.gradient: {}'.format(time() - t0))
t0 = time()
obj.metric
print('Energy.metric:', time() - t0)
logger.info('Energy.metric: {}'.format(time() - t0))
t0 = time()
obj.apply_metric(obj.position)
print('Energy.apply_metric:', time() - t0)
logger.info('Energy.apply_metric: {}'.format(time() - t0))
t0 = time()
obj.metric(obj.position)
print('Energy.metric(position):', time() - t0)
logger.info('Energy.metric(position): {}'.format(time() - t0))
elif isinstance(obj, Operator):
want_metric = bool(want_metric)
pos = from_random('normal', obj.domain)
t0 = time()
obj(pos)
print('Operator call with field:', time() - t0)
logger.info('Operator call with field: {}'.format(time() - t0))
lin = Linearization.make_var(pos, want_metric=want_metric)
t0 = time()
res = obj(lin)
print('Operator call with linearization:', time() - t0)
logger.info('Operator call with linearization: {}'.format(time() - t0))
if isinstance(obj, EnergyOperator):
t0 = time()
res.gradient
print('Gradient evaluation:', time() - t0)
logger.info('Gradient evaluation: {}'.format(time() - t0))
if want_metric:
t0 = time()
res.metric(pos)
print('Metric apply:', time() - t0)
logger.info('Metric apply: {}'.format(time() - t0))
else:
raise TypeError
......
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