Reputation:
@property
def pmt_loaner_final(self):
return float(self.pmt_loaner_new) + float(self.debit_fee)
@property
def pmt_broker_final(self):
return float(self.pmt_broker_new) + float(self.debit_fee)
@property
def total_compounded_broker(self):
return self.compounded_amount(self.brokerage_fees)
@property
def total_compounded_loaner(self):
return self.compounded_amount(self.amount)
def compounded_amount(self, amount):
"""
Return the amount of interest pad for a given days amount
"""
interests_amount = math.pow(
(1 + self.daily_interest), self.padding_days)
total_post_daily_extra_interest = float(
amount) * float(interests_amount)
return total_post_daily_extra_interest
@property
def final_credit_rate(self):
return self.get_final_credit_rate(
self.final_pmt_without_withdrawal_fees,
self.total_compounded)
def get_final_credit_rate(self, pmt, interest):
pmt *= -1
final_rate = numpy.rate(self.debits_count, pmt, interest, 0, 1)
final_nominal_rate = final_rate * self.compounding_periods
return abs(math.pow((1 + (
final_nominal_rate / self.compounding_periods)),
self.compounding_periods) - 1)
I have a function discount
which give me the error :
TypeError: 'float' object is not callable
@property
def discount(self):
return self.final_credit_rate(
self.pmt_loaner_final + self.pmt_broker_final,
self.total_compounded_loaner + self.total_compounded_broker
)
Could any be able to help me at this point?
In [7]: a = computation.pmt_loaner_final
In [8]: computation.pmt_broker_final
Out[8]: 15.075747029391236
In [9]: b = computation.pmt_broker_final
In [10]: computation.total_compounded_loaner
Out[10]: 501.6459987947617
In [11]: c = computation.total_compounded_loaner
In [12]: computation.total_compounded_broker
Out[12]: 170.55963959021898
In [13]: d = computation.total_compounded_broker
In [14]: computation.final_credit_rate(a+b, c+d)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/home/jeremie/Projects/credit-24-django/loanwolf/products/tests.pyc in <module>()
----> 1 computation.final_credit_rate(a+b, c+d)
TypeError: 'float' object is not callable
Another point I have :
In [8]: a = computation.final_pmt_without_withdrawal_fees
In [9]: b = computation.total_compounded
In [10]: computation.get_final_credit_rate(a,b)
Out[10]: 0.3296931087692383
So the problem is really on final credit rate. Knowing that the additions a+b
and c+d
aren't a problem.
Upvotes: 1
Views: 793
Reputation: 19242
The "is not callable" in TypeError: 'float' object is not callable, probably means that you are trying to call property, which cannot be called, instead accessed. OR, you're calling a method, when a property with the same name is available in your scope. I think in your case it's the former.
In simple words - you have final_credit_rate
decorated as a property (@property
before above the def
). This means you cannot call it using the parenthesis at the end, but as a simple property access:
computation.final_credit_rate
Probable solutuion:
To use it as a method, remove the @property
decorator, and specify the 2 parameters in the definition, and then make the call
computation.final_credit_rate(a+b, c+d)
Upvotes: 3