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

Commit 0a1b051

Browse files
authored
Unskip 9 tests on df.getitem (#607)
* Unskip 9 tests on df.getitem * Minor change in tests on dataframe
1 parent f23c3bf commit 0a1b051

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

sdc/rewrites/dataframe_getitem_attribute.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,19 @@ def apply(self):
7272

7373
return new_block
7474

75+
def _mk_unique_var(self, prefix):
76+
"""Make unique var name checking self.func_ir._definitions"""
77+
name = mk_unique_var(prefix)
78+
while name in self.func_ir._definitions:
79+
name = mk_unique_var(prefix)
80+
81+
return name
82+
7583
def _assign_const(self, inst, prefix='$const0'):
7684
"""Create constant from attribute of the instruction."""
7785
const_node = Const(inst.value.attr, inst.loc)
78-
const_var = Var(inst.target.scope, mk_unique_var(prefix), inst.loc)
86+
unique_var_name = self._mk_unique_var(prefix)
87+
const_var = Var(inst.target.scope, unique_var_name, inst.loc)
7988

8089
self.func_ir._definitions[const_var.name] = [const_node]
8190
self.typemap[const_var.name] = StringLiteral(inst.value.attr)

sdc/tests/test_dataframe.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ def test_impl(n, A, B):
7373
B = np.random.ranf(n)
7474
pd.testing.assert_frame_equal(hpat_func(n, A, B), test_impl(n, A, B))
7575

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

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

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

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

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

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

173-
@skip_numba_jit("Accessing series with df.A syntax is not implemented yet")
174168
def test_pass_df_str(self):
175169
def test_impl(df):
176170
return (df.A == 'a').sum()
@@ -230,7 +224,7 @@ def test_impl():
230224
hpat_func = self.jit(test_impl)
231225
pd.testing.assert_frame_equal(hpat_func(), test_impl())
232226

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

322-
@skip_numba_jit
323316
def test_filter1(self):
324317
def test_impl(n):
325318
df = pd.DataFrame({'A': np.arange(n) + n, 'B': np.arange(n)**2})
@@ -332,7 +325,7 @@ def test_impl(n):
332325
self.assertEqual(count_array_REPs(), 0)
333326
self.assertEqual(count_parfor_REPs(), 0)
334327

335-
@skip_numba_jit
328+
@skip_numba_jit('np.sum of Series unsupported')
336329
def test_filter2(self):
337330
def test_impl(n):
338331
df = pd.DataFrame({'A': np.arange(n) + n, 'B': np.arange(n)**2})
@@ -345,7 +338,7 @@ def test_impl(n):
345338
self.assertEqual(count_array_REPs(), 0)
346339
self.assertEqual(count_parfor_REPs(), 0)
347340

348-
@skip_numba_jit
341+
@skip_numba_jit('np.sum of Series unsupported')
349342
def test_filter3(self):
350343
def test_impl(n):
351344
df = pd.DataFrame({'A': np.arange(n) + n, 'B': np.arange(n)**2})
@@ -1720,7 +1713,6 @@ def test_impl(df, periods, method):
17201713
result = hpat_func(df, periods, method)
17211714
pd.testing.assert_frame_equal(result, result_ref)
17221715

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

0 commit comments

Comments
 (0)