here's the code
def energy_capacity_before_losses_for_tranche_gt_one_for_year(self, year, tranche, tranche_year_value):
print('tranche', tranche)
tranche_stack_quantity = self.tranches_stack_quantity[1] ----> Error here
print(tranche_stack_quantity)
if tranche_year_value in ["-", ""] or tranche_stack_quantity in ["-", ""]:
return D(0.0)
if int(tranche_year_value) <= year:
if tranche_stack_quantity and self.contracted_stack_capacity_tranche:
result = (
D(DEGRADATION_WITH_PG_MATRIX_TRANCHE_GREATER_THAN_ONE / 100) *
int(tranche_stack_quantity) *
D(self.contracted_stack_capacity_tranche / 1000)
)
return result
return D(0.0)
def energy_capacity_before_losses_for_tranche_gt_one(self, tranche, tranche_year_value):
return {
year: self.energy_capacity_before_losses_for_tranche_gt_one_for_year(year, tranche, tranche_year_value)
for year in self.years
}
def energy_capacity_before_losses_for_tranches(self):
result = {
1: self.energy_capacity_before_losses_for_tranche_one()
}
for tranche, tranche_value in enumerate(self.augmentation_before_start_of_year[1:], start=2):
result[tranche] = self.energy_capacity_before_losses_for_tranche_gt_one(
tranche=tranche, tranche_year_value=tranche_value
)
return result
i'm getting error in this line
line 63, in energy_capacity_before_losses_for_tranche_gt_one_for_year
tranche_stack_quantity = self.tranches_stack_quantity[1]
TypeError: 'NoneType' object is not subscriptable
and , values of self.tranches_stack_quantity are
["", "2", "", "", "", "", "", "", "", "", ""] and it's a django json field
i'm trying to assign tranche_stack_quantity = self.tranches_stack_quantity[1]
by printing
print(tranche_stack_quantity)
i got 2
for me it seems fine but i do not know why it's happening
Note: the rest of the values are coming from constants or formula calculations
and energy_capacity_before_losses_for_tranches() is parent functions and rest are sequentially dependent functions