numpy / numpy/numpy-financial

BUG: irr function inconsistent behavior on different cpu architecture

Open
#131 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Describe the issue:

Hi, I noticed that npf.irr function could return different results on different cpus in some cases. The results would match if i run irr function more than once. Please see example below.

Reproduce the code example:
python -c "import numpy_financial as npf; amount = 37155; month_count = 144; monthly_payment = 560; npf.irr([-amount] + [monthly_payment] * int(month_count));  print(npf.irr([-amount] + [monthly_payment] * int(month_count)))"

python -c "import numpy_financial as npf; amount = 37155; month_count = 144; monthly_payment = 560; print(npf.irr([-amount] + [monthly_payment] * int(month_count)))"
Error message:
On aws ec2 6i instance with Intel Ice Lake, I got the following:
0.01258179635558565
0.01258179635558565

On aws ec2 7i instance with Intel Sapphire Rapids, I got the following:
0.01258179635558565
0.006850691458678115
Runtime information:

1.23.5
3.10.14 | packaged by conda-forge | (main, Mar 20 2024, 12:45:18) [GCC 12.3.0]

Context for the issue:

No response

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 by running the two provided npf.irr command lines on the reported CPU architectures and inspect the irr entry point. The fix is complete when repeated calls produce the same result across architectures, with coverage for the reproduced case.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data, performance, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.