Example #1
0
    def test_computes_the_aggregate_loss_curve(self):
        vuln_functions = {"ID": self.vuln_function_2}

        # no epsilon_provided is needed because the vulnerability
        # function has all the covs equal to zero
        aggregate_curve = prob.AggregateLossCurve(vuln_functions, None)
        aggregate_curve.append(self.gmfs_1, self.asset_1)
        aggregate_curve.append(self.gmfs_2, self.asset_2)
        aggregate_curve.append(self.gmfs_3, self.asset_3)
        aggregate_curve.append(self.gmfs_4, self.asset_4)
        aggregate_curve.append(self.gmfs_5, self.asset_5)
        aggregate_curve.append(self.gmfs_6, self.asset_6)

        expected_losses = numpy.array((7.2636, 57.9264, 187.4893, 66.9082,
                47.0280, 248.7796, 23.2329, 121.3514, 177.4167, 259.2902,
                77.7080, 127.7417, 18.9470, 339.5774, 151.1763, 6.1881,
                71.9168, 97.9514, 56.4720, 11.6513))

        self.assertTrue(numpy.allclose(
                expected_losses, aggregate_curve.losses))

        expected_curve = shapes.Curve([(39.52702042, 0.99326205),
                (106.20489077, 0.917915), (172.88276113, 0.77686984),
                (239.56063147, 0.52763345), (306.23850182, 0.22119922)])

        self.assertEqual(expected_curve, aggregate_curve.compute(6))
Example #2
0
    def test_with_no_vuln_function_no_distribution_is_added(self):
        aggregate_curve = prob.AggregateLossCurve(
                {"ID": shapes.EMPTY_VULN_FUNCTION}, None)

        asset = {"vulnerabilityFunctionReference": "WRONG_ID",
                "assetValue": 1.0, "assetID": "ASSET_ID"}

        aggregate_curve.append({"TSES": 1, "TimeSpan": 1, "IMLs": ()}, asset)
        self.assertEqual(0, aggregate_curve.losses.size)
Example #3
0
    def test_time_span_parameter_must_be_congruent(self):
        aggregate_curve = prob.AggregateLossCurve(
                {"ID": shapes.EMPTY_VULN_FUNCTION}, None)

        asset = {"vulnerabilityFunctionReference": "ID", "assetValue": 1.0}

        aggregate_curve.append({"TSES": 1, "TimeSpan": 1, "IMLs": ()}, asset)

        self.assertRaises(AssertionError,
                aggregate_curve.append, {
                "TSES": 1, "TimeSpan": 2, "IMLs": ()}, asset)
Example #4
0
 def test_no_distribution_without_gmfs(self):
     aggregate_curve = prob.AggregateLossCurve({}, None)
     self.assertEqual(0, aggregate_curve.losses.size)
Example #5
0
 def test_an_empty_distribution_produces_an_empty_aggregate_curve(self):
     self.assertEqual(shapes.EMPTY_CURVE,
             prob.AggregateLossCurve({}, None).compute())