Skip to content
Snippets Groups Projects

Stats

Merged
pmagrequested to merge
stats into master
2 files
+ 143
2
Compare changes
  • Side-by-side
  • Inline

Files

+ 31
3
@@ -134,8 +134,13 @@ class TimeFrame:
def consecutive_qpk(self, qpk_keyed_dict: dict) -> bool:
"Returns True if all (q,p,k) tuple keys are valid and consecutive."
# TODO: here
raise NotImplementedError
# all k intervals have to be consecutive for each (q,p) pair
set_qp = set(qpk[0:2] for qpk in qpk_keyed_dict.keys())
for qp in set_qp:
for k in range(self.number_time_intervals(qp[0])):
if (*qp,k) not in qpk_keyed_dict:
return False
return True
# *************************************************************************
# *************************************************************************
@@ -241,6 +246,29 @@ class TimeFrame:
# *************************************************************************
# *************************************************************************
def assessments_overlap(self) -> bool:
"Returns True if any period is covered by more than one assessment."
# if there is only one assessment, return False
if self.number_assessments() == 1:
return False
else:
# if there is more than one assessment, check whether two or more
# cover the same period
qs = tuple(self.assessments)
# for each assessment
for q1, q2 in zip(qs, qs[1:]):
# for each period in one assessment (q1)
for p in self.reporting_periods[q1]:
# check if it is covered by the other assessment (q2)
if p in self.reporting_periods[q2]:
# p is covered by at least two assessments (q1 and q2)
return True
# if no period is covered by more than one assessment, return False
return False
# *************************************************************************
# *************************************************************************
# *****************************************************************************
# *****************************************************************************
@@ -279,7 +307,7 @@ class EconomicTimeFrame(TimeFrame):
# dict: 1 value per p and q
self._discount_rates = dict(discount_rates_q)
else:
raise ValueError('Unrecognised inputs.')
raise TypeError('Unrecognised inputs.')
# TODO: validate the discount rate object
Loading