Skip to content

Commit 386c880

Browse files
committed
Revised test_notebooks.py
1 parent 81d699d commit 386c880

File tree

4 files changed

+146
-139
lines changed

4 files changed

+146
-139
lines changed

financepy/utils/date.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
from .error import FinError
1717
from .tenor import Tenor, TenorUnit
1818
from .date_format import DateFormatTypes, get_date_format
19-
from .date_arrays import *
19+
from .date_arrays import short_day_names, short_month_names
20+
from .date_arrays import month_days_leap_year, month_days_not_leap_year
2021

2122
########################################################################################
2223

@@ -177,10 +178,9 @@ def __init__(self, d, m, y, hh=0, mm=0, ss=0):
177178
global G_START_YEAR
178179
global G_END_YEAR
179180

180-
# If the date has been entered as y, m, d we flip it to d, m, y
181-
# This message should be removed after a few releases
182-
if d >= G_START_YEAR and d < G_END_YEAR and y > 0 and y <= 31:
183-
raise FinError("Date arguments must now be in the order Date(dd, mm, yyyy)")
181+
# Guard against mistaken order (yyyy, mm, dd)
182+
if G_START_YEAR <= d < G_END_YEAR and 1 <= y <= 31:
183+
raise FinError("Date arguments must be in order Date(day, month, year)")
184184

185185
if G_DT_COUNTER_LIST is None:
186186
calculate_list()
@@ -574,10 +574,10 @@ def add_years(self, yy: Union[np.ndarray, float]):
574574

575575
# If yyi is not a whole month I adjust for days using average
576576
# number of days in a month which is 365.242/12
577-
days_in_month = 365.242 / 12.0
577+
days_in_month_float = 365.242 / 12.0
578578

579579
mmi = int(yyi * 12.0)
580-
ddi = int((yyi * 12.0 - mmi) * days_in_month)
580+
ddi = int((yyi * 12.0 - mmi) * days_in_month_float)
581581
new_dt = self.add_months(mmi)
582582
new_dt = new_dt.add_days(ddi)
583583

financepy/utils/date_arrays.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@
2727
"NOV",
2828
"DEC",
2929
]
30-
longMonthNames = [
30+
31+
long_month_names = [
3132
"JANUARY",
3233
"FEBRUARY",
3334
"MARCH",

notebooks/products/bonds/FINANNUITY_Valuation.ipynb

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
"execution_count": 1,
2020
"metadata": {
2121
"execution": {
22-
"iopub.execute_input": "2025-08-27T22:23:05.703383Z",
23-
"iopub.status.busy": "2025-08-27T22:23:05.703192Z",
24-
"iopub.status.idle": "2025-08-27T22:23:06.674819Z",
25-
"shell.execute_reply": "2025-08-27T22:23:06.674422Z"
22+
"iopub.execute_input": "2025-09-05T11:16:17.089017Z",
23+
"iopub.status.busy": "2025-09-05T11:16:17.088731Z",
24+
"iopub.status.idle": "2025-09-05T11:16:17.952487Z",
25+
"shell.execute_reply": "2025-09-05T11:16:17.951780Z"
2626
},
2727
"scrolled": true,
2828
"tags": []
@@ -37,10 +37,10 @@
3737
"execution_count": 2,
3838
"metadata": {
3939
"execution": {
40-
"iopub.execute_input": "2025-08-27T22:23:06.676985Z",
41-
"iopub.status.busy": "2025-08-27T22:23:06.676731Z",
42-
"iopub.status.idle": "2025-08-27T22:23:07.932400Z",
43-
"shell.execute_reply": "2025-08-27T22:23:07.931932Z"
40+
"iopub.execute_input": "2025-09-05T11:16:17.955134Z",
41+
"iopub.status.busy": "2025-09-05T11:16:17.954750Z",
42+
"iopub.status.idle": "2025-09-05T11:16:19.131066Z",
43+
"shell.execute_reply": "2025-09-05T11:16:19.130512Z"
4444
}
4545
},
4646
"outputs": [],
@@ -69,10 +69,10 @@
6969
"execution_count": 3,
7070
"metadata": {
7171
"execution": {
72-
"iopub.execute_input": "2025-08-27T22:23:07.934878Z",
73-
"iopub.status.busy": "2025-08-27T22:23:07.934554Z",
74-
"iopub.status.idle": "2025-08-27T22:23:08.037922Z",
75-
"shell.execute_reply": "2025-08-27T22:23:08.037424Z"
72+
"iopub.execute_input": "2025-09-05T11:16:19.133008Z",
73+
"iopub.status.busy": "2025-09-05T11:16:19.132715Z",
74+
"iopub.status.idle": "2025-09-05T11:16:19.149500Z",
75+
"shell.execute_reply": "2025-09-05T11:16:19.148908Z"
7676
}
7777
},
7878
"outputs": [],
@@ -86,10 +86,10 @@
8686
"execution_count": 4,
8787
"metadata": {
8888
"execution": {
89-
"iopub.execute_input": "2025-08-27T22:23:08.039879Z",
90-
"iopub.status.busy": "2025-08-27T22:23:08.039626Z",
91-
"iopub.status.idle": "2025-08-27T22:23:08.042624Z",
92-
"shell.execute_reply": "2025-08-27T22:23:08.042277Z"
89+
"iopub.execute_input": "2025-09-05T11:16:19.151702Z",
90+
"iopub.status.busy": "2025-09-05T11:16:19.151415Z",
91+
"iopub.status.idle": "2025-09-05T11:16:19.154586Z",
92+
"shell.execute_reply": "2025-09-05T11:16:19.154060Z"
9393
},
9494
"scrolled": true
9595
},
@@ -110,10 +110,10 @@
110110
"execution_count": 5,
111111
"metadata": {
112112
"execution": {
113-
"iopub.execute_input": "2025-08-27T22:23:08.044279Z",
114-
"iopub.status.busy": "2025-08-27T22:23:08.044027Z",
115-
"iopub.status.idle": "2025-08-27T22:23:08.046298Z",
116-
"shell.execute_reply": "2025-08-27T22:23:08.045939Z"
113+
"iopub.execute_input": "2025-09-05T11:16:19.156542Z",
114+
"iopub.status.busy": "2025-09-05T11:16:19.156237Z",
115+
"iopub.status.idle": "2025-09-05T11:16:19.159362Z",
116+
"shell.execute_reply": "2025-09-05T11:16:19.158868Z"
117117
}
118118
},
119119
"outputs": [],
@@ -127,10 +127,10 @@
127127
"execution_count": 6,
128128
"metadata": {
129129
"execution": {
130-
"iopub.execute_input": "2025-08-27T22:23:08.048012Z",
131-
"iopub.status.busy": "2025-08-27T22:23:08.047711Z",
132-
"iopub.status.idle": "2025-08-27T22:23:08.051420Z",
133-
"shell.execute_reply": "2025-08-27T22:23:08.050975Z"
130+
"iopub.execute_input": "2025-09-05T11:16:19.161084Z",
131+
"iopub.status.busy": "2025-09-05T11:16:19.160817Z",
132+
"iopub.status.idle": "2025-09-05T11:16:19.165011Z",
133+
"shell.execute_reply": "2025-09-05T11:16:19.164378Z"
134134
},
135135
"scrolled": true,
136136
"tags": []
@@ -159,10 +159,10 @@
159159
"execution_count": 7,
160160
"metadata": {
161161
"execution": {
162-
"iopub.execute_input": "2025-08-27T22:23:08.079981Z",
163-
"iopub.status.busy": "2025-08-27T22:23:08.079706Z",
164-
"iopub.status.idle": "2025-08-27T22:23:08.082213Z",
165-
"shell.execute_reply": "2025-08-27T22:23:08.081879Z"
162+
"iopub.execute_input": "2025-09-05T11:16:19.166675Z",
163+
"iopub.status.busy": "2025-09-05T11:16:19.166484Z",
164+
"iopub.status.idle": "2025-09-05T11:16:19.168934Z",
165+
"shell.execute_reply": "2025-09-05T11:16:19.168460Z"
166166
}
167167
},
168168
"outputs": [],
@@ -175,10 +175,10 @@
175175
"execution_count": 8,
176176
"metadata": {
177177
"execution": {
178-
"iopub.execute_input": "2025-08-27T22:23:08.083965Z",
179-
"iopub.status.busy": "2025-08-27T22:23:08.083640Z",
180-
"iopub.status.idle": "2025-08-27T22:23:08.155176Z",
181-
"shell.execute_reply": "2025-08-27T22:23:08.154731Z"
178+
"iopub.execute_input": "2025-09-05T11:16:19.170749Z",
179+
"iopub.status.busy": "2025-09-05T11:16:19.170433Z",
180+
"iopub.status.idle": "2025-09-05T11:16:19.178280Z",
181+
"shell.execute_reply": "2025-09-05T11:16:19.177891Z"
182182
},
183183
"tags": []
184184
},
@@ -223,10 +223,10 @@
223223
"execution_count": 9,
224224
"metadata": {
225225
"execution": {
226-
"iopub.execute_input": "2025-08-27T22:23:08.156944Z",
227-
"iopub.status.busy": "2025-08-27T22:23:08.156735Z",
228-
"iopub.status.idle": "2025-08-27T22:23:08.170095Z",
229-
"shell.execute_reply": "2025-08-27T22:23:08.169564Z"
226+
"iopub.execute_input": "2025-09-05T11:16:19.180559Z",
227+
"iopub.status.busy": "2025-09-05T11:16:19.180195Z",
228+
"iopub.status.idle": "2025-09-05T11:16:19.194345Z",
229+
"shell.execute_reply": "2025-09-05T11:16:19.193733Z"
230230
}
231231
},
232232
"outputs": [],
@@ -250,10 +250,10 @@
250250
"execution_count": 10,
251251
"metadata": {
252252
"execution": {
253-
"iopub.execute_input": "2025-08-27T22:23:08.171953Z",
254-
"iopub.status.busy": "2025-08-27T22:23:08.171717Z",
255-
"iopub.status.idle": "2025-08-27T22:23:08.176937Z",
256-
"shell.execute_reply": "2025-08-27T22:23:08.176340Z"
253+
"iopub.execute_input": "2025-09-05T11:16:19.196403Z",
254+
"iopub.status.busy": "2025-09-05T11:16:19.196097Z",
255+
"iopub.status.idle": "2025-09-05T11:16:19.202093Z",
256+
"shell.execute_reply": "2025-09-05T11:16:19.201656Z"
257257
}
258258
},
259259
"outputs": [
@@ -277,10 +277,10 @@
277277
"execution_count": 11,
278278
"metadata": {
279279
"execution": {
280-
"iopub.execute_input": "2025-08-27T22:23:08.178930Z",
281-
"iopub.status.busy": "2025-08-27T22:23:08.178687Z",
282-
"iopub.status.idle": "2025-08-27T22:23:08.181590Z",
283-
"shell.execute_reply": "2025-08-27T22:23:08.181200Z"
280+
"iopub.execute_input": "2025-09-05T11:16:19.203801Z",
281+
"iopub.status.busy": "2025-09-05T11:16:19.203579Z",
282+
"iopub.status.idle": "2025-09-05T11:16:19.207334Z",
283+
"shell.execute_reply": "2025-09-05T11:16:19.206687Z"
284284
}
285285
},
286286
"outputs": [
@@ -326,10 +326,10 @@
326326
"execution_count": 12,
327327
"metadata": {
328328
"execution": {
329-
"iopub.execute_input": "2025-08-27T22:23:08.183251Z",
330-
"iopub.status.busy": "2025-08-27T22:23:08.183062Z",
331-
"iopub.status.idle": "2025-08-27T22:23:08.186018Z",
332-
"shell.execute_reply": "2025-08-27T22:23:08.185632Z"
329+
"iopub.execute_input": "2025-09-05T11:16:19.208873Z",
330+
"iopub.status.busy": "2025-09-05T11:16:19.208542Z",
331+
"iopub.status.idle": "2025-09-05T11:16:19.212257Z",
332+
"shell.execute_reply": "2025-09-05T11:16:19.211862Z"
333333
}
334334
},
335335
"outputs": [
@@ -378,10 +378,10 @@
378378
"execution_count": 13,
379379
"metadata": {
380380
"execution": {
381-
"iopub.execute_input": "2025-08-27T22:23:08.187583Z",
382-
"iopub.status.busy": "2025-08-27T22:23:08.187380Z",
383-
"iopub.status.idle": "2025-08-27T22:23:08.189715Z",
384-
"shell.execute_reply": "2025-08-27T22:23:08.189328Z"
381+
"iopub.execute_input": "2025-09-05T11:16:19.213974Z",
382+
"iopub.status.busy": "2025-09-05T11:16:19.213743Z",
383+
"iopub.status.idle": "2025-09-05T11:16:19.216188Z",
384+
"shell.execute_reply": "2025-09-05T11:16:19.215746Z"
385385
}
386386
},
387387
"outputs": [],
@@ -394,10 +394,10 @@
394394
"execution_count": 14,
395395
"metadata": {
396396
"execution": {
397-
"iopub.execute_input": "2025-08-27T22:23:08.191108Z",
398-
"iopub.status.busy": "2025-08-27T22:23:08.190932Z",
399-
"iopub.status.idle": "2025-08-27T22:23:08.193499Z",
400-
"shell.execute_reply": "2025-08-27T22:23:08.193080Z"
397+
"iopub.execute_input": "2025-09-05T11:16:19.217471Z",
398+
"iopub.status.busy": "2025-09-05T11:16:19.217306Z",
399+
"iopub.status.idle": "2025-09-05T11:16:19.219515Z",
400+
"shell.execute_reply": "2025-09-05T11:16:19.219074Z"
401401
}
402402
},
403403
"outputs": [],
@@ -417,10 +417,10 @@
417417
"execution_count": 15,
418418
"metadata": {
419419
"execution": {
420-
"iopub.execute_input": "2025-08-27T22:23:08.195124Z",
421-
"iopub.status.busy": "2025-08-27T22:23:08.194791Z",
422-
"iopub.status.idle": "2025-08-27T22:23:08.198050Z",
423-
"shell.execute_reply": "2025-08-27T22:23:08.197599Z"
420+
"iopub.execute_input": "2025-09-05T11:16:19.221152Z",
421+
"iopub.status.busy": "2025-09-05T11:16:19.220823Z",
422+
"iopub.status.idle": "2025-09-05T11:16:19.223960Z",
423+
"shell.execute_reply": "2025-09-05T11:16:19.223436Z"
424424
}
425425
},
426426
"outputs": [

0 commit comments

Comments
 (0)