Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FragilityFunctionDiscrete can not handle list properly #3113

Closed
dynaryu opened this issue Oct 10, 2017 · 0 comments · Fixed by #3114
Closed

FragilityFunctionDiscrete can not handle list properly #3113

dynaryu opened this issue Oct 10, 2017 · 0 comments · Fixed by #3114
Assignees
Milestone

Comments

@dynaryu
Copy link

dynaryu commented Oct 10, 2017

Noticed that FragilityFunctionDiscrete can not handle list or array properly as below:
a = FragilityFunctionDiscrete(limit_state='slight', imls= [0.0, 0.2, 0.4, 0.6, 0.8, 1, 1.2, 1.4], poes = [0.0, 0.771, 0.95, 0.989, 0.997, 0.999, 1., 1.], no_damage_limit=0.05)
It works okay when it takes a single value, but it fails when it takes array and yields a wrong value if it takes a list:

a(0.4)
a([0.2, 0.4])
a(numpy.array([0.2, 0.4]))

I changed the code as below to fix the error:
`class FragilityFunctionDiscrete(object):

def __call__(self, iml):
    """
    Compute the Probability of Exceedance (PoE) for the given
    Intensity Measure Level (IML).
    """
    highest_iml = self.imls[-1]

    # when the intensity measure level is above
    # the range, we use the highest one
    try:
        iml = [highest_iml if x > highest_iml else x for x in iml]
    except TypeError:
        temp = self.interp(highest_iml if iml > highest_iml else iml)
    else:
        temp = self.interp(iml)

    if self.no_damage_limit:
         temp[iml < self.no_damage_limit] = 0.0
    return temp

`

@dynaryu dynaryu changed the title FragilityFunctionDiscrete can not handle list correclty FragilityFunctionDiscrete can not handle list properly Oct 10, 2017
@micheles micheles added this to the Engine 2.7.0 milestone Oct 19, 2017
@micheles micheles self-assigned this Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants