def test_dda_iml_above_range(self):
        # corner case where we have a ground motion value
        # (that corresponds to the intensity measure level in the
        # fragility function) that is higher than the highest
        # intensity measure level defined in the model (in this
        # particular case 0.7). Given this condition, to compute
        # the fractions of buildings we use the highest intensity
        # measure level defined in the model (0.7 in this case)

        fm = input.FragilityModel(
            "discrete", [0.1, 0.3, 0.5, 0.7], LIMIT_STATES)

        func = input.FragilityFunctionDiscrete(
            fm, [0.05, 0.20, 0.50, 1.00], 1)

        self._close_to(_ground_motion_value_fractions((fm, [func]), 0.7),
                       _ground_motion_value_fractions((fm, [func]), 0.8))
    def test_dda_iml_below_range_damage_limit_defined(self):
        # corner case where we have a ground motion value
        # (that corresponds to the intensity measure level in the
        # fragility function) that is lower than the lowest
        # intensity measure level defined in the model (in this
        # particular case 0.1) and lower than the no_damage_limit
        # attribute defined in the model. Given this condition, the
        # fractions of buildings is 100% no_damage and 0% for the
        # remaining limit states defined in the model.

        fm = input.FragilityModel("discrete", [0.1, 0.3, 0.5, 0.7],
            LIMIT_STATES, no_damage_limit=0.05)

        func = input.FragilityFunctionDiscrete(
            fm, [0.05, 0.20, 0.50, 1.00], 1)

        self._close_to([1.0, 0.0, 0.0],
            _ground_motion_value_fractions((fm, [func]), 0.02))
    def test_gmv_between_no_damage_limit_and_first_iml(self):
        # corner case where we have a ground motion value
        # (that corresponds to the intensity measure level in the
        # fragility function) that is lower than the lowest
        # intensity measure level defined in the model (in this
        # particular case 0.1) but bigger than the no_damage_limit
        # attribute defined in the model. Given this condition, the
        # fractions of buildings is 97.5% no_damage and 2.5% for the
        # remaining limit states defined in the model.

        fm = input.FragilityModel("discrete", [0.1, 0.3, 0.5, 0.7],
            LIMIT_STATES, no_damage_limit=0.05)

        func1 = input.FragilityFunctionDiscrete(
            fm, [0.05, 0.20, 0.50, 1.00], 1)

        func2 = input.FragilityFunctionDiscrete(
            fm, [0.00, 0.05, 0.20, 0.50], 2)

        self._close_to([0.975, 0.025, 0.],
            _ground_motion_value_fractions((fm, [func1, func2]), 0.075))