numpy / numpy/numpy-financial

MAINT: Avoid ``ZeroDivisionError``s in ``nper_inner_loop``

Open
#119 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Cython maintenance
Dominant language
Python
Stars
409
Forks
98
Avg merge
10h 43m
Merged PRs (30d)
12

Description

Proposed new feature or change:

I've just merged #118, this PR reproduced the behaviour of nper in Cython as closely as possible. However there are several ZeroDivisionErrors that are currently handled poorly (they return NANs).

https://github.com/numpy/numpy-financial/blob/858358697fce8fb96530f9c299d285286e5192e5/numpy_financial/_cfinancial.pyx#L21-L22

In each case, we should carefully evaluate each code path and return a financially sensible result.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in numpy_financial/_cfinancial.pyx at lines 21-22 and trace each nper_inner_loop code path that can raise ZeroDivisionError. Determine the financially sensible result for each case, then verify that the affected paths no longer produce NaNs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
fintech-quant
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.