Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Commit 5f408ba

Browse files
authored
change isinstance (#792)
1 parent aa6898b commit 5f408ba

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

sdc/datatypes/hpat_pandas_dataframe_functions.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1954,7 +1954,7 @@ def pct_change_overload(df, periods=1, fill_method='pad', limit=None, freq=None)
19541954
19551955
Limitations
19561956
-----------
1957-
Parameters ``limit`` and ``freq`` are unsupported.
1957+
Parameters ``limit`` and ``freq`` are supported only with default value ``None``.
19581958
19591959
Examples
19601960
--------
@@ -1995,16 +1995,16 @@ def pct_change_overload(df, periods=1, fill_method='pad', limit=None, freq=None)
19951995
ty_checker = TypeChecker('Method {}().'.format(name))
19961996
ty_checker.check(df, DataFrameType)
19971997

1998-
if not isinstance(periods, (types.Integer, types.Omitted)):
1998+
if not isinstance(periods, (types.Integer, types.Omitted)) and periods != 1:
19991999
ty_checker.raise_exc(periods, 'int64', 'periods')
20002000

20012001
if not isinstance(fill_method, (str, types.UnicodeType, types.StringLiteral, types.NoneType, types.Omitted)):
20022002
ty_checker.raise_exc(fill_method, 'string', 'fill_method')
20032003

2004-
if not isinstance(limit, (types.Omitted, types.NoneType)):
2004+
if not isinstance(limit, (types.Omitted, types.NoneType)) and limit is not None:
20052005
ty_checker.raise_exc(limit, 'None', 'limit')
20062006

2007-
if not isinstance(freq, (types.Omitted, types.NoneType)):
2007+
if not isinstance(freq, (types.Omitted, types.NoneType)) and freq is not None:
20082008
ty_checker.raise_exc(freq, 'None', 'freq')
20092009

20102010
params = {'periods': 1, 'fill_method': '"pad"', 'limit': None, 'freq': None}

sdc/tests/test_dataframe.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2037,6 +2037,18 @@ def test_impl(df):
20372037
"D": [14, None, 6, 2, 6, 4]})
20382038
pd.testing.assert_frame_equal(hpat_func(df), test_impl(df))
20392039

2040+
@skip_sdc_jit
2041+
def test_pct_change_with_parameters_limit_and_freq(self):
2042+
def test_impl(df, limit, freq):
2043+
return df.pct_change(limit=limit, freq=freq)
2044+
2045+
hpat_func = sdc.jit(test_impl)
2046+
df = pd.DataFrame({"A": [14, 4, 5, 4, 1, 55],
2047+
"B": [5, 2, None, 3, 2, 32],
2048+
"C": [20, 20, 7, 21, 8, None],
2049+
"D": [14, None, 6, 2, 6, 4]})
2050+
pd.testing.assert_frame_equal(hpat_func(df, None, None), test_impl(df, None, None))
2051+
20402052
@skip_sdc_jit
20412053
def test_pct_change_with_parametrs(self):
20422054
def test_impl(df, periods, method):

0 commit comments

Comments
 (0)