*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 02f5b570 authored by Kappl, Patrick's avatar Kappl, Patrick
Browse files

Use configparser's getboolean() instead of strtobool()

parent 6488c334
No related branches found
No related tags found
No related merge requests found
......@@ -106,11 +106,11 @@ output file must be given. The keys of this section will be used as the names of
observables in the :ref:`jackknife output file <Output>`.
.. note::
See the documentation of `distutils.util.strtobool()`_ for the possible values of
boolean keys in the jackknife config file.
See the documentation of `configparser.ConfigParser.getboolean()`_ for the possible
values of boolean keys in the jackknife config file.
.. _distutils.util.strtobool():
https://docs.python.org/3.8/distutils/apiref.html#distutils.util.strtobool
.. _configparser.ConfigParser.getboolean():
https://docs.python.org/3/library/configparser.html#configparser.ConfigParser.getboolean
Run
===
......
......@@ -11,7 +11,6 @@ import numpy as np
import sys
import h5py
import configparser
from distutils.util import strtobool
def main():
......@@ -54,15 +53,18 @@ def main():
"adga_config_file": None,
"two_particle_file": None,
"output_file_prefix": "jackknife",
"store_output_samples": "no"}
"store_output_samples": False}
# Read config file and check if obligatory keys are missing
config = configparser.ConfigParser()
config.read(config_file_name)
for key in config["General"]:
if key in general:
general[key] = config["General"][key]
else:
try:
if isinstance(general[key], bool):
general[key] = config["General"].getboolean(key)
else:
general[key] = config["General"][key]
except KeyError:
print("Warning: unsupported key \"{}\" found in".format(key)
+ " config file will be ignored.")
for key in general:
......@@ -90,8 +92,8 @@ def main():
# Do the Jackknife estimation
jackknife = jk.Jackknife(x_generator, n, f, -1,
general["output_file_prefix"],
strtobool(general["store_output_samples"]))
general["output_file_prefix"],
general.getboolean("store_output_samples"))
jackknife.do_estimation()
jackknife.write_results_to_file()
......@@ -109,7 +111,7 @@ def main():
np.string_(general["two_particle_file"]))
config.create("n_processes", n_processes)
config.create("store_output_samples",
bool(strtobool(general["store_output_samples"])))
general.getboolean("store_output_samples"))
except:
print("""-- Something went wrong when adding metadata to the output
file.""")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment