Skip to content

Commit

Permalink
Merge pull request SDXorg#1 from sepiatone/my_tests
Browse files Browse the repository at this point in the history
My tests
  • Loading branch information
sepiatone authored Aug 13, 2018
2 parents 84fb948 + 0e35991 commit 97ddf09
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 1,847 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ build/
*.2mdl
pysd.egg*

.idea/*
.idea/*
docs/_build/*
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: python
python:
- "2.7"
- "3.5"
# - "2.7"
# - "3.5"
- "3.6"
# command to install dependencies
cache: pip
Expand All @@ -16,4 +16,4 @@ install:
script:
- cd tests
- nosetests --with-coverage --cover-package=pysd
- coveralls
- coveralls
18 changes: 13 additions & 5 deletions pysd/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,16 @@ def extreme_conditions_test(model, matrix=None, excel_file=None, errors='return'


def _get_bounds(unit_string):
parts = unit_string.split('[')
return parts[-1].strip(']').split(',') if len(parts) > 1 else ['?', '?']
return unit_string.strip('() ').split(',')


def _set_bounds(unit_string, type="Min"):
if unit_string.strip(' ') == "None" and type == "Min":
return float('-inf')
elif unit_string.strip(' ') == "None" and type == "Max":
return float('+inf')
else:
return float(unit_string)


def create_bounds_test_matrix(model, filename=None):
Expand All @@ -151,9 +159,9 @@ def create_bounds_test_matrix(model, filename=None):
"""

docs = model.doc()
docs['bounds'] = docs['Unit'].apply(_get_bounds)
docs['Min'] = docs['bounds'].apply(lambda x: float(x[0].replace('?', '-inf')))
docs['Max'] = docs['bounds'].apply(lambda x: float(x[1].replace('?', '+inf')))
docs['bounds'] = docs['Lims'].apply(_get_bounds)
docs['Min'] = docs['bounds'].apply(lambda x: float(_set_bounds(x[0], "Min")))
docs['Max'] = docs['bounds'].apply(lambda x: float(_set_bounds(x[1], "Max")))

output = docs[['Real Name', 'Comment',
'Unit', 'Min', 'Max']].sort_values(by='Real Name')
Expand Down
53 changes: 0 additions & 53 deletions tests/integration_test_factory.py

This file was deleted.

Loading

0 comments on commit 97ddf09

Please sign in to comment.