Skip to content

Commit 15a98b1

Browse files
authored
Merge pull request #135 from jorenham/ruff/B905
CI: Fix CI errors
2 parents 9ad0bc2 + dab283b commit 15a98b1

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

environment.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ dependencies:
2626
- numpydoc
2727
- pydata-sphinx-theme>=0.15.0
2828
# Lint
29-
- ruff>=0.3.0
29+
- ruff>=0.11.5
3030
# Benchmarks
3131
- asv>=0.6.0
3232
# Misc tools
33-
- ipython
33+
- ipython

numpy_financial/_financial.py

+13-11
Original file line numberDiff line numberDiff line change
@@ -756,7 +756,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
756756
User may insert their own customised function for selection
757757
of IRR values.The function should accept a one-dimensional array
758758
of numbers and return a number.
759-
759+
760760
761761
Returns
762762
-------
@@ -803,7 +803,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
803803
0.0886
804804
>>> npf.irr([[-100, 0, 0, 74], [-100, 100, 0, 7]]).round(5)
805805
array([-0.0955 , 0.06206])
806-
806+
807807
"""
808808
values = np.atleast_2d(values)
809809
if values.ndim != 2:
@@ -852,7 +852,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
852852
# If only one real solution
853853
elif len(eirr) == 1:
854854
irr_results[i] = eirr[0]
855-
else:
855+
else:
856856
irr_results[i] = selection_logic(eirr)
857857

858858
return _ufunc_like(irr_results)
@@ -986,7 +986,7 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
986986
987987
.. math::
988988
989-
MIRR =
989+
MIRR =
990990
\\left( \\frac{{FV_{positive}}}{{PV_{negative}}} \\right)^{\\frac{{1}}{{n-1}}}
991991
* (1+r) - 1
992992
@@ -1000,8 +1000,8 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
10001000
--------
10011001
>>> import numpy_financial as npf
10021002
1003-
Consider a project with an initial investment of -$100
1004-
and projected cash flows of $50, -$60, and $70 at the end of each period.
1003+
Consider a project with an initial investment of -$100
1004+
and projected cash flows of $50, -$60, and $70 at the end of each period.
10051005
The project has a finance rate of 10% and a reinvestment rate of 12%.
10061006
10071007
>>> npf.mirr([-100, 50, -60, 70], 0.10, 0.12)
@@ -1028,17 +1028,17 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
10281028
>>> npf.mirr([-100, -50, -60, -70], 0.10, 0.12)
10291029
nan
10301030
1031-
Finally, let's explore the situation where all cash flows are positive,
1031+
Finally, let's explore the situation where all cash flows are positive,
10321032
and the `raise_exceptions` parameter is set to True.
10331033
10341034
>>> npf.mirr([
1035-
... 100, 50, 60, 70],
1036-
... 0.10, 0.12,
1035+
... 100, 50, 60, 70],
1036+
... 0.10, 0.12,
10371037
... raise_exceptions=True
10381038
... ) #doctest: +NORMALIZE_WHITESPACE
10391039
Traceback (most recent call last):
10401040
...
1041-
numpy_financial._financial.NoRealSolutionError:
1041+
numpy_financial._financial.NoRealSolutionError:
10421042
No real solution exists for MIRR since all cashflows are of the same sign.
10431043
"""
10441044
values_inner = np.atleast_2d(values).astype(np.float64)
@@ -1055,7 +1055,9 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
10551055
out = np.empty(out_shape)
10561056

10571057
for i, v in enumerate(values_inner):
1058-
for j, (rr, fr) in enumerate(zip(reinvest_rate_inner, finance_rate_inner)):
1058+
for j, (rr, fr) in enumerate(
1059+
zip(reinvest_rate_inner, finance_rate_inner, strict=True)
1060+
):
10591061
pos = v > 0
10601062
neg = v < 0
10611063

numpy_financial/tests/test_financial.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
def assert_decimal_close(actual, expected, tol=Decimal("1e-7")):
2727
# Check if both actual and expected are iterable (like arrays)
2828
if hasattr(actual, "__iter__") and hasattr(expected, "__iter__"):
29-
for a, e in zip(actual, expected):
29+
for a, e in zip(actual, expected, strict=True):
3030
assert abs(a - e) <= tol
3131
else:
3232
# For single value comparisons
@@ -760,7 +760,7 @@ def test_npv_irr_congruence(self):
760760
assert_allclose(
761761
npf.npv(npf.irr(cashflows), cashflows),
762762
0,
763-
atol=1e-10,
763+
atol=1e-9,
764764
rtol=0,
765765
)
766766

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ doc = [
5252
"myst-parser>=2.0.0",
5353
]
5454
dev = [
55-
"ruff>=0.3.0",
55+
"ruff>=0.11.5",
5656
"asv>=0.6.0",
5757
]
5858

0 commit comments

Comments
 (0)