Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

rem_to_be_paid.pyx 1.4 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
  1. cimport numpy as np
  2. import numpy as np
  3. cpdef rem_to_be_paid(double out_prncp,
  4. double install,
  5. double int_rate):
  6. cdef double m_rate
  7. cdef double to_be_paid
  8. m_rate = int_rate/12
  9. to_be_paid = 0.0
  10. k = 0
  11. while out_prncp > 0:
  12. k += 1
  13. out_prncp = (1+m_rate) * out_prncp
  14. out_prncp -= install
  15. to_be_paid += install
  16. # the break was added to figure out what was wrong with infinite while; it was due to installment funded
  17. # being INCORRECTLY REPORTED by lending club
  18. if k >= 100:
  19. print(to_be_paid)
  20. break
  21. if out_prncp < 0:
  22. to_be_paid -= abs(out_prncp)
  23. return to_be_paid
  24. cpdef np.ndarray[double] apply_rem_to_be_paid(np.ndarray col_out_prncp,
  25. np.ndarray col_install,
  26. np.ndarray col_int_rate):
  27. assert (col_out_prncp.dtype == np.float32 and col_install.dtype == np.float32 and col_int_rate.dtype == np.float32)
  28. cdef Py_ssize_t i, n = len(col_out_prncp)
  29. assert (len(col_out_prncp) == len(col_install) == n)
  30. cdef np.ndarray[double] res = np.empty(n)
  31. for i in xrange(n):
  32. res[i] = rem_to_be_paid(col_out_prncp[i],
  33. col_install[i],
  34. col_int_rate[i])
  35. return res
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...