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 Apr 26, 2018
1 parent 8c7a833 commit 842a45b
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 @@ -1755,6 +1755,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 842a45b

Please sign in to comment.