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

Commit 6029a64

Browse files
author
Ehsan Totoni
committed
hiframes df.col.values
1 parent dd5670b commit 6029a64

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

hpat/hiframes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,14 @@ def _run_assign(self, assign):
140140
assign.value = df_cols[rhs.attr]
141141
self.df_cols.add(lhs) # save lhs as column
142142

143+
# c = df.column.values
144+
if (rhs.op=='getattr' and rhs.value.name in self.df_cols and
145+
rhs.attr == 'values'):
146+
# simply return the column
147+
# output is array so it's not added to df_cols
148+
assign.value = rhs.value
149+
return [assign]
150+
143151
# c = df.column.shift
144152
if (rhs.op=='getattr' and rhs.value.name in self.df_cols and
145153
rhs.attr in df_col_funcs):

hpat/tests/test_hiframes.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,19 @@
66
count_parfor_OneDs, count_array_OneDs, dist_IR_contains)
77

88
class TestHiFrames(unittest.TestCase):
9+
def test_basics(self):
10+
def test_impl(n):
11+
df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)})
12+
Ac = df['A'].values
13+
return Ac.sum()
14+
15+
hpat_func = hpat.jit(test_impl)
16+
n = 11
17+
self.assertEqual(hpat_func(n), test_impl(n))
18+
self.assertEqual(count_array_REPs(), 0)
19+
self.assertEqual(count_parfor_REPs(), 0)
20+
self.assertEqual(count_parfor_OneDs(), 1)
21+
922
def test_cumsum(self):
1023
def test_impl(n):
1124
df = pd.DataFrame({'A': np.ones(n), 'B': np.random.ranf(n)})

0 commit comments

Comments
 (0)