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

Commit 47064c9

Browse files
authored
Series copy numpy-like call (#588)
* numpy-like copy * Fix dtype initial * fix impl bool+number * small fix * fix tests * Replace copy call * pep fix
1 parent e7b75ff commit 47064c9

3 files changed

Lines changed: 7 additions & 6 deletions

File tree

sdc/datatypes/hpat_pandas_series_functions.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2129,17 +2129,18 @@ def hpat_pandas_series_copy(self, deep=True):
21292129
if isinstance(self.index, types.NoneType):
21302130
def hpat_pandas_series_copy_impl(self, deep=True):
21312131
if deep:
2132-
return pandas.Series(data=self._data.copy(), name=self._name)
2132+
return pandas.Series(data=numpy_like.copy(self._data), name=self._name)
21332133
else:
21342134
return pandas.Series(data=self._data, name=self._name)
21352135
return hpat_pandas_series_copy_impl
21362136
else:
21372137
def hpat_pandas_series_copy_impl(self, deep=True):
21382138
if deep:
2139-
return pandas.Series(data=self._data.copy(), index=self._index.copy(), name=self._name)
2139+
return pandas.Series(data=numpy_like.copy(self._data), index=numpy_like.copy(self._index),
2140+
name=self._name)
21402141
else:
21412142
# Shallow copy of index is not supported yet
2142-
return pandas.Series(data=self._data, index=self._index.copy(), name=self._name)
2143+
return pandas.Series(data=self._data, index=numpy_like.copy(self._index), name=self._name)
21432144
return hpat_pandas_series_copy_impl
21442145

21452146

sdc/functions/numpy_like.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def sdc_copy_overload(self):
140140
Test: python -m sdc.runtests sdc.tests.test_sdc_numpy -k copy
141141
"""
142142

143-
if not isinstance(self, types.Array):
143+
if not isinstance(self, (types.Array, StringArrayType)):
144144
return None
145145

146146
dtype = self.dtype
@@ -155,7 +155,7 @@ def sdc_copy_number_impl(self):
155155

156156
return sdc_copy_number_impl
157157

158-
if isinstance(dtype, types.npytypes.UnicodeCharSeq):
158+
if isinstance(dtype, (types.npytypes.UnicodeCharSeq, types.UnicodeType, types.StringLiteral)):
159159
def sdc_copy_string_impl(self):
160160
return self.copy()
161161

sdc/tests/tests_perf/test_perf_series.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def _test_case(self, pyfunc, name, total_data_length, data_num=1, input_data=tes
7373
TC(name='at', size=[10 ** 7], call_expr='data.at[3]', usecase_params='data'),
7474
TC(name='chain_add_and_sum', size=[20 * 10 ** 6, 25 * 10 ** 6, 30 * 10 ** 6], call_expr='(A + B).sum()',
7575
usecase_params='A, B', data_num=2),
76-
TC(name='copy', size=[10 ** 8]),
76+
TC(name='copy', size=[10 ** 7]),
7777
TC(name='corr', size=[10 ** 7],params='other', data_num=2),
7878
TC(name='count', size=[10 ** 8]),
7979
TC(name='cov', size=[10 ** 8], params='other', data_num=2),

0 commit comments

Comments
 (0)