***
Wartungsfenster jeden ersten Mittwoch vormittag im Monat
***
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jackknife
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
E138 Institute of Solid State Physics
E138-01 Computational Materials Science
Software
jackknife
Commits
02f5b570
Commit
02f5b570
authored
4 years ago
by
Kappl, Patrick
Browse files
Options
Downloads
Patches
Plain Diff
Use configparser's getboolean() instead of strtobool()
parent
6488c334
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
doc/source/getting_started.rst
+4
-4
4 additions, 4 deletions
doc/source/getting_started.rst
main.py
+10
-8
10 additions, 8 deletions
main.py
with
14 additions
and
12 deletions
doc/source/getting_started.rst
+
4
−
4
View file @
02f5b570
...
...
@@ -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.strto
bool()`_ for the possible
values of
boolean keys in the jackknife config file.
See the documentation of `
configparser.ConfigParser.get
bool
ean
()`_ for the possible
values of
boolean keys in the jackknife config file.
.. _
distutils.util.strto
bool():
https://docs.python.org/3
.8/distutils/apiref.html#distutils.util.strto
bool
.. _
configparser.ConfigParser.get
bool
ean
():
https://docs.python.org/3
/library/configparser.html#configparser.ConfigParser.get
bool
ean
Run
===
...
...
This diff is collapsed.
Click to expand it.
main.py
+
10
−
8
View file @
02f5b570
...
...
@@ -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.
"""
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment