Skip to content

Commit e456c8a

Browse files
BUG: Fix bug related to inclusive keyword in pandas.date_range and warning related to line_terminator keyword (#45)
1 parent b284e61 commit e456c8a

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

fourinsight/engineroom/utils/_core.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,10 @@ def collect(self, **results):
397397
current_index = self._dataframe.index[-1]
398398

399399
try:
400-
row_update = pd.DataFrame(data=results, index=[current_index],).astype(
400+
row_update = pd.DataFrame(
401+
data=results,
402+
index=[current_index],
403+
).astype(
401404
{
402405
header: dtype_
403406
for header, dtype_ in self._headers.items()
@@ -476,7 +479,14 @@ def push(self):
476479
"""
477480
self._handler.seek(0)
478481
self._handler.truncate()
479-
self._dataframe.to_csv(self._handler, sep=",", index=True, line_terminator="\n")
482+
try:
483+
self._dataframe.to_csv(
484+
self._handler, sep=",", index=True, lineterminator="\n"
485+
)
486+
except TypeError: # for backward compatibility (remove after 2024-06-01)
487+
self._dataframe.to_csv(
488+
self._handler, sep=",", index=True, line_terminator="\n"
489+
)
480490
self._handler.push()
481491

482492
@property

fourinsight/engineroom/utils/iter_index/_iter_index.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ def date_range(
66
end=None,
77
periods=None,
88
freq=None,
9-
inclusive=None,
9+
inclusive="both",
1010
**kwargs,
1111
):
1212
"""
@@ -37,6 +37,9 @@ def date_range(
3737
if periods:
3838
periods += 1
3939

40+
if inclusive is None:
41+
inclusive = "both"
42+
4043
start_end = pd.date_range(
4144
start=start, end=end, periods=periods, freq=freq, inclusive=inclusive, **kwargs
4245
)

tests/test_core.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,6 @@ def test__setitem__(self, persistent_dict):
287287

288288
def test__setitem_jsonencode(self, persistent_dict):
289289
with patch.object(persistent_dict, "_jsonencoder") as mock_jsonencoder:
290-
291290
persistent_dict["a"] = 1
292291
mock_jsonencoder.assert_called_once_with(1)
293292

0 commit comments

Comments
 (0)