Skip to content

Commit

Permalink
Merge pull request #16 from dslosky-usgs/updates
Browse files Browse the repository at this point in the history
Add core tests and roll version
  • Loading branch information
dslosky-usgs authored Sep 9, 2018
2 parents a1773ed + f42bafb commit 9bcf071
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
# Versions should comply with PEP440. For a discussion on single-sourcing
# the version across setup.py and the project code, see
# https://packaging.python.org/en/latest/single_source_version.html
version='0.0a3',
version='0.0a4',

description='Potential impact calculation for well defined facilities due to an input earthquake hazard',
long_description=long_description,
Expand Down
1 change: 1 addition & 0 deletions shakecastaebm/capacity.py
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ def get_ultimate_point(ductility, d_y, a_y, post_yield):

def get_ultimate_period(d, a):
return math.sqrt(d / (a * 9.779738))

def get_elastic_damping(mbt):
lookup = {
'C1': .07,
Expand Down
2 changes: 1 addition & 1 deletion shakecastaebm/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def run(capacity, hazard, hazard_beta,
capacity: a capacity curve generated by the capacity module
hazard: spectral curve describing a natural hazard
[{'x': .01, 'y': .8}, {'x': .02, 'y': 1.1}, ...}]
[{'disp': .01, 'acc': .8}, {'disp': .02, 'acc': 1.1}, ...}]
hazard_beta: uncertainty in the hazard curve
pref_periods: a list of periods to interpolate
Expand Down
1 change: 1 addition & 0 deletions shakecastaebm/tests/bundle.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .core import *
from .damage import *
from .damping import *
from .spectrum import *
Expand Down
29 changes: 29 additions & 0 deletions shakecastaebm/tests/core.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import unittest

from shakecastaebm.capacity import get_capacity
from shakecastaebm.core import run

class TestRun(unittest.TestCase):
def test_Runs(self):
# run shakecast example
hazard = [
{'x': .03, 'y': 1.1377},
{'x': 1.0, 'y': .8302},
{'x': 3.0, 'y': .348}
]

hazard_beta = .5
mag = 6.7
r_rup = 20

capacity = get_capacity('C2', 'high', 1, 24, 2, 1990, 'very_poor', 'poor')

results = run(capacity,
hazard, hazard_beta, mag, r_rup)

for result in results:
self.assertIsNotNone(result)


if __name__ == '__main__':
unittest.main()
4 changes: 1 addition & 3 deletions shakecastaebm/tests/performance_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ def test_performancePoint(self):
self.assertTrue('acc' in pp.keys())
self.assertTrue('period' in pp.keys())

def main():
unittest.main()

if __name__ == '__main__':
main()
unittest.main()

0 comments on commit 9bcf071

Please sign in to comment.