-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adjusted estimation process, reorganized promotion section and the tr…
…avis test setup
- Loading branch information
Showing
123 changed files
with
3,713 additions
and
3,067 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
__pxcache__/ | ||
*.pyc | ||
.idea/ | ||
docs/_build | ||
docs/build | ||
promotion/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,22 @@ | ||
repos: | ||
- repo: https://github.com/ambv/black | ||
rev: stable | ||
rev: 19.3b0 | ||
hooks: | ||
- id: black | ||
language_version: python3.6 | ||
exclude: ^docs/ | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v1.2.3 | ||
hooks: | ||
- id: flake8 | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: v4.3.20 | ||
hooks: | ||
- repo: https://github.com/timothycrosley/isort | ||
rev: 4.3.20 | ||
hooks: | ||
- id: isort | ||
- name: isort | ||
- entry: isort | ||
- require_serial: true | ||
- language: python | ||
- types: [python] | ||
name: isort | ||
exclude: ^docs/ | ||
entry: isort | ||
require_serial: true | ||
language: python | ||
types: [python] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,27 @@ | ||
language: python | ||
|
||
python: | ||
- "3.6" | ||
|
||
install: | ||
- pip install -r requirements.txt | ||
- pip install pytest-cov | ||
- pip install codecov | ||
- sudo apt-get update | ||
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh | ||
- bash miniconda.sh -b -p $HOME/miniconda | ||
- PATH="$HOME/miniconda/bin:$PATH" | ||
- conda env create -f environment.yml | ||
- source activate grmpy | ||
|
||
before_script: | ||
- export PYTHONPATH=$PYTHONPATH:$(pwd) | ||
|
||
script: | ||
- py.test --cov=grmpy | ||
- py.test | ||
- bash utils/run_sphinx_build.sh | ||
- travis_wait python utils/travis_runner.py | ||
- python -c "import grmpy; grmpy.test()" | ||
|
||
after_success: | ||
- codecov | ||
|
||
notifications: | ||
email: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,61 @@ | ||
"""The test provides a regression test battery. In the first step it loops over 100 different seeds, | ||
generates a random init file for each seed, simulates the resulting dataframe, sums it up and saves | ||
the sum and the generated dictionary in /grmpy/test/resources/ as a json file. In the second step it | ||
reads the json file, and loops over all entries. For each element it prints an init file, simulates | ||
the dataframe, sums it up again and compares the sum from the first step with the one from the | ||
second step. | ||
"""The test provides a regression test battery. In the first step it loops over 100 | ||
different seeds, generates a random init file for each seed, simulates the resulting | ||
dataframe, sums it up and saves the sum and the generated dictionary in | ||
/grmpy/test/resources/ as a json file. In the second step it reads the json file, and | ||
loops over all entries. For each element it prints an init file, simulates the dataframe, | ||
sums it up again and compares the sum from the first step with the one from the second | ||
step. | ||
""" | ||
|
||
import json | ||
import os | ||
|
||
import numpy as np | ||
|
||
from grmpy.estimate.estimate_auxiliary import calculate_criteria | ||
from grmpy.estimate.estimate_auxiliary import start_values | ||
from grmpy.test.random_init import generate_random_dict | ||
from grmpy.test.random_init import print_dict | ||
from grmpy.estimate.estimate_auxiliary import ( | ||
calculate_criteria, | ||
process_data, | ||
start_values, | ||
) | ||
from grmpy.read.read import read | ||
from grmpy.simulate.simulate import simulate | ||
from grmpy.test.auxiliary import cleanup | ||
from grmpy.read.read import read | ||
from grmpy.test.random_init import generate_random_dict, print_dict | ||
|
||
NUM_TESTS = 100 | ||
|
||
np.random.seed(1234235) | ||
seeds = np.random.randint(0, 1000, size=NUM_TESTS) | ||
directory = os.path.dirname(__file__) | ||
file_dir = os.path.join(directory, 'old_regression_vault.grmpy.json') | ||
file_dir = os.path.join(directory, "old_regression_vault.grmpy.json") | ||
|
||
if True: | ||
tests = [] | ||
for seed in seeds: | ||
np.random.seed(seed) | ||
constr = dict() | ||
constr['DETERMINISTIC'], constr['CATEGORICAL'] = False, False | ||
constr["DETERMINISTIC"], constr["CATEGORICAL"] = False, False | ||
dict_ = generate_random_dict(constr) | ||
df = simulate('test.grmpy.ini') | ||
df = simulate("test.grmpy.yml") | ||
stat = np.sum(df.sum()) | ||
init_dict = read('test.grmpy.ini') | ||
start = start_values(init_dict, df, 'init') | ||
criteria = calculate_criteria(init_dict, df, start) | ||
init_dict = read("test.grmpy.yml") | ||
start = start_values(init_dict, df, "init") | ||
_, X1, X0, Z1, Z0, Y1, Y0 = process_data(df, init_dict) | ||
criteria = calculate_criteria(init_dict, X1, X0, Z1, Z0, Y1, Y0, start) | ||
tests += [(stat, dict_, criteria)] | ||
json.dump(tests, open(file_dir, 'w')) | ||
json.dump(tests, open(file_dir, "w")) | ||
|
||
if True: | ||
tests = json.load(open(file_dir, 'r')) | ||
tests = json.load(open(file_dir, "r")) | ||
|
||
for test in tests: | ||
stat, dict_, criteria = test | ||
print_dict(dict_) | ||
init_dict = read('test.grmpy.yml') | ||
df = simulate('test.grmpy.yml') | ||
start = start_values(init_dict, df, 'init') | ||
init_dict = read("test.grmpy.yml") | ||
df = simulate("test.grmpy.yml") | ||
start = start_values(init_dict, df, "init") | ||
criteria_ = calculate_criteria(init_dict, df, start) | ||
np.testing.assert_array_almost_equal(criteria, criteria_) | ||
np.testing.assert_almost_equal(np.sum(df.sum()), stat) | ||
|
||
cleanup('regression') | ||
cleanup("regression") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.