Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion sdc/rewrites/dataframe_getitem_attribute.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,19 @@ def apply(self):

return new_block

def _mk_unique_var(self, prefix):
"""Make unique var name checking self.func_ir._definitions"""
name = mk_unique_var(prefix)
while name in self.func_ir._definitions:
name = mk_unique_var(prefix)

return name

def _assign_const(self, inst, prefix='$const0'):
"""Create constant from attribute of the instruction."""
const_node = Const(inst.value.attr, inst.loc)
const_var = Var(inst.target.scope, mk_unique_var(prefix), inst.loc)
unique_var_name = self._mk_unique_var(prefix)
const_var = Var(inst.target.scope, unique_var_name, inst.loc)

self.func_ir._definitions[const_var.name] = [const_node]
self.typemap[const_var.name] = StringLiteral(inst.value.attr)
Expand Down
14 changes: 3 additions & 11 deletions sdc/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def test_impl(n, A, B):
B = np.random.ranf(n)
pd.testing.assert_frame_equal(hpat_func(n, A, B), test_impl(n, A, B))

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_create2(self):
def test_impl():
df = pd.DataFrame({'A': [1, 2, 3]})
Expand All @@ -82,7 +81,6 @@ def test_impl():

self.assertEqual(hpat_func(), test_impl())

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_create3(self):
def test_impl(n):
df = pd.DataFrame({'A': np.arange(n)})
Expand All @@ -92,7 +90,6 @@ def test_impl(n):
n = 11
self.assertEqual(hpat_func(n), test_impl(n))

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_create_str(self):
def test_impl():
df = pd.DataFrame({'A': ['a', 'b', 'c']})
Expand All @@ -112,7 +109,6 @@ def test_impl(n):
n = 11
pd.testing.assert_frame_equal(hpat_func(n), test_impl(n))

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_create_with_series2(self):
# test creating dataframe from passed series
def test_impl(A):
Expand Down Expand Up @@ -160,7 +156,6 @@ def test_impl():
hpat_func = self.jit(test_impl)
pd.testing.assert_frame_equal(hpat_func(), test_impl())

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_pass_df1(self):
def test_impl(df):
return (df.A == 2).sum()
Expand All @@ -170,7 +165,6 @@ def test_impl(df):
df = pd.DataFrame({'A': np.arange(n)})
self.assertEqual(hpat_func(df), test_impl(df))

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_pass_df_str(self):
def test_impl(df):
return (df.A == 'a').sum()
Expand Down Expand Up @@ -230,7 +224,7 @@ def test_impl():
hpat_func = self.jit(test_impl)
pd.testing.assert_frame_equal(hpat_func(), test_impl())

@unittest.skip("pending df filter support")
@skip_sdc_jit("pending df filter support")
def test_box3(self):
def test_impl(df):
df = df[df.A != 'dd']
Expand Down Expand Up @@ -319,7 +313,6 @@ def test_impl(df):
{'A': np.arange(n), 'B': np.ones(n), 'C': np.random.ranf(n)})
pd.testing.assert_frame_equal(hpat_func(df), test_impl(df))

@skip_numba_jit
def test_filter1(self):
def test_impl(n):
df = pd.DataFrame({'A': np.arange(n) + n, 'B': np.arange(n)**2})
Expand All @@ -332,7 +325,7 @@ def test_impl(n):
self.assertEqual(count_array_REPs(), 0)
self.assertEqual(count_parfor_REPs(), 0)

@skip_numba_jit
@skip_numba_jit('np.sum of Series unsupported')
def test_filter2(self):
def test_impl(n):
df = pd.DataFrame({'A': np.arange(n) + n, 'B': np.arange(n)**2})
Expand All @@ -345,7 +338,7 @@ def test_impl(n):
self.assertEqual(count_array_REPs(), 0)
self.assertEqual(count_parfor_REPs(), 0)

@skip_numba_jit
@skip_numba_jit('np.sum of Series unsupported')
def test_filter3(self):
def test_impl(n):
df = pd.DataFrame({'A': np.arange(n) + n, 'B': np.arange(n)**2})
Expand Down Expand Up @@ -1720,7 +1713,6 @@ def test_impl(df, periods, method):
result = hpat_func(df, periods, method)
pd.testing.assert_frame_equal(result, result_ref)

@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
def test_list_convert(self):
def test_impl():
df = pd.DataFrame({'one': np.array([-1, np.nan, 2.5]),
Expand Down