Skip to content

Commit b74859f

Browse files
numpy-financial NPV test in test_economics
1 parent 4577bcf commit b74859f

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/geophires_x_tests/test_economics.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
import sys
33
from pathlib import Path
44

5-
from geophires_x.Economics import CalculateFinancialPerformance
5+
import numpy_financial as npf
6+
7+
# ruff: noqa: I001 # Successful module initialization is dependent on this specific import order.
68
from geophires_x.Model import Model
9+
from geophires_x.Economics import CalculateFinancialPerformance
710
from tests.base_test_case import BaseTestCase
811

912

@@ -33,6 +36,19 @@ def calc_irr(total_revenue):
3336
self.assertAlmostEqual(6.21, calc_irr([-100, 100, 0, 7]), places=2)
3437
self.assertAlmostEqual(8.86, calc_irr([-5, 10.5, 1, -8, 1]), places=2)
3538

39+
def test_numpy_financial_npv(self):
40+
# https://www.nrel.gov/docs/legosti/old/5173.pdf, p. 41
41+
rate = 0.12
42+
cashflow_series = [-10000, 7274, 6558, 6223, 6087, 6259]
43+
npv = npf.npv(rate, cashflow_series)
44+
self.assertEqual(13572, round(npv))
45+
46+
# https://support.microsoft.com/en-us/office/npv-function-8672cb67-2576-4d07-b67b-ac28acf2a568
47+
rate = 0.1
48+
cashflow_series = [-10000, 3000, 4200, 6800]
49+
excel_npv = npf.npv(rate, [0, *cashflow_series])
50+
self.assertEqual(1188.44, round(excel_npv, 2))
51+
3652
def test_well_drilling_cost_correlation_tooltiptext(self):
3753
ec = self._new_model().economics
3854
self.assertEqual(

0 commit comments

Comments
 (0)