Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
aleeciu committed Nov 8, 2023
1 parent 6cc431a commit dbbd713
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions climada/hazard/test/test_tc_cc.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class TestKnutson(unittest.TestCase):

def test_get_knutson_scaling_pass(self):
"""Test get_knutson_criterion function."""
criterion = tc_cc.get_knutson_scaling_factor()
criterion = tc_cc.get_knutson_scaling_factor(
percentile='5/10',
baseline=(1950, 2018))
self.assertEqual(criterion.shape, (21, 4))

self.assertEqual(criterion.columns[0], '2.6')
Expand All @@ -43,15 +45,19 @@ def test_get_knutson_scaling_pass(self):

def test_get_gmst_pass(self):
"""Test get_gmst_info function."""
gmst_data, gmst_start_year, gmst_end_year, rcps = tc_cc.get_gmst_info()

self.assertAlmostEqual(gmst_data.shape,
(len(rcps),
gmst_end_year-gmst_start_year+1))
self.assertAlmostEqual(gmst_data[0,0], -0.16)
self.assertAlmostEqual(gmst_data[0,-1], 1.27641, 4)
self.assertAlmostEqual(gmst_data[-1,0], -0.16)
self.assertAlmostEqual(gmst_data[-1,-1], 4.477764, 4)
gmst_info = tc_cc.get_gmst_info()

self.assertAlmostEqual(gmst_info['gmst_start_year'], 1880)
self.assertAlmostEqual(gmst_info['gmst_end_year'], 2100)
self.assertAlmostEqual(len(gmst_info['rcps']), 4)

self.assertAlmostEqual(gmst_info['gmst_data'].shape,
(len(gmst_info['rcps']),
gmst_info['gmst_end_year']-gmst_info['gmst_start_year']+1))
self.assertAlmostEqual(gmst_info['gmst_data'][0,0], -0.16)
self.assertAlmostEqual(gmst_info['gmst_data'][0,-1], 1.27641, 4)
self.assertAlmostEqual(gmst_info['gmst_data'][-1,0], -0.16)
self.assertAlmostEqual(gmst_info['gmst_data'][-1,-1], 4.477764, 4)

def test_get_knutson_data_pass(self):
"""Test get_knutson_data function."""
Expand Down

0 comments on commit dbbd713

Please sign in to comment.