def test_scenario_risk_insured_losses(self): # This test exercises the 'mean-based' path through the Scenario Risk # calculator. There is no random sampling done here so the results are # 100% predictable. scen_cfg = helpers.qa_file('scenario_risk_insured_losses/config.gem') exp_mean_loss = 799.102578 exp_stddev_loss = 382.148808 expected_loss_map = [ dict(asset='a3', pos='15.48 38.25', mean=156.750910806, stddev=100.422061776), dict(asset='a2', pos='15.56 38.17', mean=314.859579324, stddev=293.976254984), dict(asset='a1', pos='15.48 38.09', mean=327.492087529, stddev=288.47906994), ] result = helpers.run_job(scen_cfg, ['--output-type=xml'], check_output=True) job = OqJob.objects.latest('id') self.assertEqual('succeeded', job.status) expected_loss_map_file = helpers.qa_file( 'scenario_risk_insured_losses/computed_output/insured-loss-map%s' '.xml' % job.id) self.assertTrue(os.path.exists(expected_loss_map_file)) helpers.verify_loss_map(self, expected_loss_map_file, expected_loss_map, self.LOSSMAP_PRECISION) actual_mean, actual_stddev = helpers.mean_stddev_from_result_line( result) self.assertAlmostEqual(exp_mean_loss, actual_mean, places=self.TOTAL_LOSS_PRECISION) self.assertAlmostEqual(exp_stddev_loss, actual_stddev, places=self.TOTAL_LOSS_PRECISION) # Cleaning generated results file. rmtree(QA_OUTPUT_DIR)
def test_scenario_risk(self): # This test exercises the 'mean-based' path through the Scenario Risk # calculator. There is no random sampling done here so the results are # 100% predictable. scen_cfg = helpers.demo_file('scenario_risk/config.gem') exp_mean_loss = 1053.09 exp_stddev_loss = 246.62 expected_loss_map = [ dict(asset='a3', pos='15.48 38.25', mean=180.717534009275, stddev=92.2122644809969), dict(asset='a2', pos='15.56 38.17', mean=432.225448142534, stddev=186.864456949986), dict(asset='a1', pos='15.48 38.09', mean=440.147078317589, stddev=182.615976701858), ] result = helpers.run_job(scen_cfg, ['--output-type=xml'], check_output=True) job = OqJob.objects.latest('id') self.assertEqual('succeeded', job.status) expected_loss_map_file = helpers.demo_file( 'scenario_risk/computed_output/loss-map-%s.xml' % job.id) self.assertTrue(os.path.exists(expected_loss_map_file)) helpers.verify_loss_map(self, expected_loss_map_file, expected_loss_map, self.LOSSMAP_PRECISION) actual_mean, actual_stddev = helpers.mean_stddev_from_result_line( result) self.assertAlmostEqual(exp_mean_loss, actual_mean, places=self.TOTAL_LOSS_PRECISION) self.assertAlmostEqual(exp_stddev_loss, actual_stddev, places=self.TOTAL_LOSS_PRECISION)
def test_scenario_risk_insured_losses(self): # This test exercises the 'mean-based' path through the Scenario Risk # calculator. There is no random sampling done here so the results are # 100% predictable. scen_cfg = helpers.qa_file('scenario_risk_insured_losses/config.gem') exp_mean_loss = 799.102578 exp_stddev_loss = 382.148808 expected_loss_map = [ dict(asset='a3', pos='15.48 38.25', mean=156.750910806, stddev=100.422061776), dict(asset='a2', pos='15.56 38.17', mean=314.859579324, stddev=293.976254984), dict(asset='a1', pos='15.48 38.09', mean=327.492087529, stddev=288.47906994), ] result = helpers.run_job(scen_cfg, ['--output-type=xml'], check_output=True) job = OqJob.objects.latest('id') self.assertEqual('succeeded', job.status) expected_loss_map_file = helpers.qa_file( 'scenario_risk_insured_losses/computed_output/insured-loss-map%s' '.xml' % job.id) self.assertTrue(os.path.exists(expected_loss_map_file)) helpers.verify_loss_map(self, expected_loss_map_file, expected_loss_map, self.LOSSMAP_PRECISION) actual_mean, actual_stddev = helpers.mean_stddev_from_result_line(result) self.assertAlmostEqual( exp_mean_loss, actual_mean, places=self.TOTAL_LOSS_PRECISION) self.assertAlmostEqual( exp_stddev_loss, actual_stddev, places=self.TOTAL_LOSS_PRECISION) # Cleaning generated results file. rmtree(QA_OUTPUT_DIR)
def test_scenario_risk(self): # This test exercises the 'mean-based' path through the Scenario Risk # calculator. There is no random sampling done here so the results are # 100% predictable. scen_cfg = helpers.demo_file('scenario_risk/config.gem') exp_mean_loss = 1053.09 exp_stddev_loss = 246.62 expected_loss_map = [ dict(asset='a3', pos='15.48 38.25', mean=180.717534009275, stddev=92.2122644809969), dict(asset='a2', pos='15.56 38.17', mean=432.225448142534, stddev=186.864456949986), dict(asset='a1', pos='15.48 38.09', mean=440.147078317589, stddev=182.615976701858), ] result = helpers.run_job(scen_cfg, ['--output-type=xml'], check_output=True) job = OqJob.objects.latest('id') self.assertEqual('succeeded', job.status) expected_loss_map_file = helpers.demo_file( 'scenario_risk/computed_output/loss-map-%s.xml' % job.id) self.assertTrue(os.path.exists(expected_loss_map_file)) helpers.verify_loss_map(self, expected_loss_map_file, expected_loss_map, self.LOSSMAP_PRECISION) actual_mean, actual_stddev = helpers.mean_stddev_from_result_line(result) self.assertAlmostEqual( exp_mean_loss, actual_mean, places=self.TOTAL_LOSS_PRECISION) self.assertAlmostEqual( exp_stddev_loss, actual_stddev, places=self.TOTAL_LOSS_PRECISION)