Added tally arithmetic cross-scores

This commit is contained in:
Will Boyd 2015-05-31 13:26:10 -07:00
parent a430cd7fd0
commit fe7ba99816

View file

@ -145,6 +145,22 @@ class Tally(object):
if self.num_realizations == other.num_realizations:
new_tally.num_realizations = self.num_realizations
# Generate "cross" scores
# NOTE: This only needs to cross the scores if the
if self.scores != other.scores:
for self_score in self.scores:
for other_score in other.scores:
new_score = '({0} + {1})'.format(self_score, other_score)
new_tally.add_score(new_score)
else:
for score in self.scores:
new_score = '({0} + {1})'.format(score, score)
new_tally.add_score(new_score)
elif is_integer(other) or is_float(other):
new_tally._mean = self._mean + other
@ -206,6 +222,21 @@ class Tally(object):
if self.num_realizations == other.num_realizations:
new_tally.num_realizations = self.num_realizations
# Generate "cross" scores
# NOTE: This only needs to cross the scores if the
if self.scores != other.scores:
for self_score in self.scores:
for other_score in other.scores:
new_score = '({0} - {1})'.format(self_score, other_score)
new_tally.add_score(new_score)
else:
for score in self.scores:
new_score = '({0} - {1})'.format(score, score)
new_tally.add_score(new_score)
elif is_integer(other) or is_float(other):
new_tally._mean = self._mean - other
@ -270,6 +301,21 @@ class Tally(object):
if self.num_realizations == other.num_realizations:
new_tally.num_realizations = self.num_realizations
# Generate "cross" scores
# NOTE: This only needs to cross the scores if the
if self.scores != other.scores:
for self_score in self.scores:
for other_score in other.scores:
new_score = '({0} * {1})'.format(self_score, other_score)
new_tally.add_score(new_score)
else:
for score in self.scores:
new_score = '({0} * {1})'.format(score, score)
new_tally.add_score(new_score)
elif is_integer(other) or is_float(other):
new_tally._mean = self._mean * other
@ -334,6 +380,21 @@ class Tally(object):
if self.num_realizations == other.num_realizations:
new_tally.num_realizations = self.num_realizations
# Generate "cross" scores
# NOTE: This only needs to cross the scores if the
if self.scores != other.scores:
for self_score in self.scores:
for other_score in other.scores:
new_score = '({0} / {1})'.format(self_score, other_score)
new_tally.add_score(new_score)
else:
for score in self.scores:
new_score = '({0} / {1})'.format(score, score)
new_tally.add_score(new_score)
elif is_integer(other) or is_float(other):
new_tally._mean = self._mean / other
@ -399,6 +460,21 @@ class Tally(object):
if self.num_realizations == power.num_realizations:
new_tally.num_realizations = self.num_realizations
# Generate "cross" scores
# NOTE: This only needs to cross the scores if the
if self.scores != power.scores:
for self_score in self.scores:
for power_score in power.scores:
new_score = '({0} ^ {1})'.format(self_score, power_score)
new_tally.add_score(new_score)
else:
for score in self.scores:
new_score = '({0} ^ {1})'.format(score, score)
new_tally.add_score(new_score)
elif is_integer(power) or is_float(power):
new_tally._mean = self._mean ** power