Skip to content

Commit

Permalink
Added method error_contribution_from.
Browse files Browse the repository at this point in the history
The function error_contribution_from allows developers to discover the complete
contribution from a set of tags specified by a predicate function.
  • Loading branch information
Nathanael Farley committed Aug 24, 2017
1 parent b5dc04e commit d235894
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions uncertainties/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1758,6 +1758,24 @@ def error_components(self):

return error_components

def error_contribution_from(self, filter_tag):
"""
Provides contribution from given error components.
Provides the error contribution from error components for
which filter_tag(tag) returns True.
"""

errors_that_contribute = []
for variable, derivative in self.error_components().iteritems():
if filter_tag(variable.tag):
errors_that_contribute.append(derivative**2)

# Since error components already does the heavy lifting of separating
# errors into a linear combination, we select only the ones we are
# interested in.
return sqrt(sum(errors_that_contribute))

@property
def std_dev(self):
"""
Expand Down

0 comments on commit d235894

Please sign in to comment.