Skip to content

Commit 43d0a02

Browse files
committed
initial commit
0 parents  commit 43d0a02

File tree

9 files changed

+747
-0
lines changed

9 files changed

+747
-0
lines changed

.gitignore

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
# *.c
9+
10+
# backup files
11+
*~
12+
*.bak
13+
14+
# Distribution / packaging
15+
.Python
16+
build/
17+
develop-eggs/
18+
dist/
19+
downloads/
20+
eggs/
21+
.eggs/
22+
lib/
23+
lib64/
24+
parts/
25+
sdist/
26+
var/
27+
wheels/
28+
*.egg-info/
29+
.installed.cfg
30+
*.egg
31+
MANIFEST
32+
33+
# PyInstaller
34+
# Usually these files are written by a python script from a template
35+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
36+
*.manifest
37+
*.spec
38+
39+
# Installer logs
40+
pip-log.txt
41+
pip-delete-this-directory.txt
42+
43+
# Unit test / coverage reports
44+
htmlcov/
45+
.tox/
46+
.coverage
47+
.coverage.*
48+
.cache
49+
nosetests.xml
50+
coverage.xml
51+
*.cover
52+
.hypothesis/
53+
.pytest_cache/
54+
55+
# Translations
56+
*.mo
57+
*.pot
58+
59+
# Django stuff:
60+
*.log
61+
local_settings.py
62+
db.sqlite3
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
doc/_build/
73+
doc/source/_generated
74+
75+
76+
# PyBuilder
77+
target/
78+
79+
# Jupyter Notebook
80+
.ipynb_checkpoints
81+
82+
# pyenv
83+
.python-version
84+
85+
# celery beat schedule file
86+
celerybeat-schedule
87+
88+
# SageMath parsed files
89+
*.sage.py
90+
91+
# Environments
92+
.env
93+
.venv
94+
env/
95+
venv/
96+
ENV/
97+
env.bak/
98+
venv.bak/
99+
100+
# Spyder project settings
101+
.spyderproject
102+
.spyproject
103+
104+
# Rope project settings
105+
.ropeproject
106+
107+
# mkdocs documentation
108+
/site
109+
110+
# mypy
111+
.mypy_cache/
112+
113+
# PyCharm files/directories
114+
.idea/
115+
116+

LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2019, Marko Laine
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21+
22+
The views and conclusions contained in the software and documentation are those
23+
of the author and should not be interpreted as representing official policies,
24+
either expressed or implied, of his employer.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# EPPES

__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#
2+
3+
from .eppes import eppes
4+
from .eppes import config
5+
from .eppes.eppes import *
6+
from .eppes.data import EppesData
7+

eppes/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#__all__ = ['eppes','config','plots']
2+
__all__ = ['eppes','config']
3+
4+
from . import config
5+
from . import eppes
6+
from .data import EppesData
7+
from .eppes import *

eppes/config.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# Options configuration for eppes
2+
# -*- coding: utf-8; -*-
3+
4+
# order of options
5+
# 1. values given in the command line
6+
# 2. values read from config file 'eppes.cfg' or give as --config=myconfig.cfg
7+
# 3. defaults given in this file
8+
9+
import argparse
10+
import configparser
11+
12+
# default file options
13+
files = {
14+
'mufile': 'mufile.dat',
15+
'sigfile': 'sigfile.dat',
16+
'wfile': 'wfile.dat',
17+
'nfile': 'nfile.dat',
18+
'scorefile': 'scores.dat',
19+
'samplein': 'oldsample.dat',
20+
'sampleout': 'sampleout.dat',
21+
'boundsfile': '',
22+
'w00file': '',
23+
'winfofile': 'winfo.dat'
24+
}
25+
# other default values
26+
options_int = {
27+
'sampleonly': 1,
28+
'nsample': 10,
29+
'verbosity': 1,
30+
'maxn': -1,
31+
'lognor': 0,
32+
'useranks': 0
33+
}
34+
options_float = {'maxsteprel': 0.0}
35+
options_str = {'combine_method': 'amean'}
36+
37+
# combine options
38+
options = {**options_int, **options_float, **options_str}
39+
40+
# create config parser and add defaults
41+
config = configparser.ConfigParser()
42+
config['files'] = files
43+
config['options'] = options
44+
45+
# parser to read config file and command line args
46+
def parseargs(*cmdargs):
47+
parser = argparse.ArgumentParser(description="Eppes options", add_help=False)
48+
parser.add_argument("-c", "--config", dest='config_file', default='eppes.cfg', type=str)
49+
50+
args, remaining_argv = parser.parse_known_args(args = cmdargs)
51+
# read options from config file
52+
config.read(args.config_file)
53+
54+
# reload default options
55+
files = dict(config['files'])
56+
options = dict(config['options'])
57+
58+
for i in files.keys():
59+
parser.add_argument('--'+i, type=str)
60+
parser.set_defaults(**files)
61+
62+
for i in options_int.keys():
63+
parser.add_argument('--'+i, type=int)
64+
for i in options_float.keys():
65+
parser.add_argument('--'+i, type=float)
66+
for i in options_str.keys():
67+
parser.add_argument('--'+i, type=str)
68+
parser.set_defaults(**options)
69+
70+
# some extra arguments still
71+
parser.add_argument("-q", "--quiet", dest='verbosity', default=0, nargs='?', type=int)
72+
parser.add_argument("--showoptions", "-s", action='store_true')
73+
parser.add_argument("-h", "--help", action='help')
74+
75+
opts = parser.parse_args(remaining_argv)
76+
77+
if opts.showoptions:
78+
print('*Options values*')
79+
for k, v in vars(opts).items():
80+
print(k, ':', v)
81+
parser.exit(0)
82+
83+
return opts

0 commit comments

Comments
 (0)