8000 Series.add / Series.lt with fill_value by 1e-to · Pull Request #655 · IntelPython/sdc · GitHub
[go: up one dir, main page]

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

Series.add / Series.lt with fill_value #655

Merged
merged 22 commits into from
Apr 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix algo for scalars
  • Loading branch information
elena.totmenina committed Mar 21, 2020
commit c48f2e36a14caed8244762da82d38dccf7608c21
92 changes: 56 additions & 36 deletions sdc/sdc_autogenerated.py
< 10000 td id="diff-e5a30b63234c4c98253cb380afedafc7ab94e37f52312788c5ecd647b56cf89fL467" data-line-number="467" class="blob-num blob-num-context js-linkable-line-number">
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,15 @@ def sdc_pandas_series_add(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_add_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data + numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) + other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -293,14 +294,15 @@ def sdc_pandas_series_div(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_div_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data / numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) / other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -460,14 +462,15 @@ def sdc_pandas_series_sub(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_sub_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data - numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) - other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -627,14 +630,15 @@ def sdc_pandas_series_mul(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_mul_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data * numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) * other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -794,14 +798,15 @@ def sdc_pandas_series_truediv(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_truediv_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data / numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) / other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -961,14 +966,15 @@ def sdc_pandas_series_floordiv(self, other, level=None, fill_value=None, axis=0)
# specializations for numeric series only
if not operands_are_series:
def _series_floordiv_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data // numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) // other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -1124,14 +1130,15 @@ def sdc_pandas_series_mod(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_mod_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data % numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) % other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -1291,14 +1298,15 @@ def sdc_pandas_series_pow(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_pow_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data ** numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) ** other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -1452,11 +1460,13 @@ def sdc_pandas_series_lt(self, other, level=None, fill_value=None, axis=0):
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_lt_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data < other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self < other._data, index=other._index, name=other._name)

return _series_lt_scalar_impl
Expand Down Expand Up @@ -1577,11 +1587,13 @@ def sdc_pandas_series_gt(self, other, level=None, fill_value=None, axis=0):
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_gt_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data > other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self > other._data, index=other._index, name=other._name)

return _series_gt_scalar_impl
Expand Down Expand Up @@ -1702,11 +1714,13 @@ def sdc_pandas_series_le(self, other, level=None, fill_value=None, axis=0):
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_le_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data <= other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self <= other._data, index=other._index, name=other._name)

return _series_le_scalar_impl
Expand Down Expand Up @@ -1827,11 +1841,13 @@ def sdc_pandas_series_ge(self, other, level=None, fill_value=None, axis=0):
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_ge_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data >= other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self >= other._data, index=other._index, name=other._name)

return _series_ge_scalar_impl
Expand Down Expand Up @@ -1952,11 +1968,13 @@ def sdc_pandas_series_ne(self, other, level=None, fill_value=None, axis=0):
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_ne_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data != other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self != other._data, index=other._index, name=other._name)

return _series_ne_scalar_impl
Expand Down Expand Up @@ -2077,11 +2095,13 @@ def sdc_pandas_series_eq(self, other, level=None, fill_value=None, axis=0):
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_eq_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data == other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self == other._data, index=other._index, name=other._name)

return _series_eq_scalar_impl
Expand Down
13 changes: 8 additions & 5 deletions sdc/sdc_methods_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,15 @@ def sdc_pandas_series_binop(self, other, level=None, fill_value=None, axis=0):
# specializations for numeric series only
if not operands_are_series:
def _series_binop_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)

if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(self._data), dtype=numpy.float64)
result_data[:] = self._data + numpy.float64(other)
return pandas.Series(result_data, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
result_data = numpy.empty(len(other._data), dtype=numpy.float64)
result_data[:] = numpy.float64(self) + other._data
return pandas.Series(result_data, index=other._index, name=other._name)
Expand Down Expand Up @@ -278,11 +279,13 @@ def sdc_pandas_series_comp_binop(self, other, level=None, fill_value=None, axis=
fill_value_is_none = isinstance(fill_value, (types.NoneType, types.Omitted)) or fill_value is None
if not operands_are_series:
def _series_comp_binop_scalar_impl(self, other, level=None, fill_value=None, axis=0):
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
if self_is_series == True: # noqa
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(self._data, inplace=True, value=fill_value)
return pandas.Series(self._data < other, index=self._index, name=self._name)
else:
if not (fill_value is None or numpy.isnan(fill_value)):
numpy_like.fillna(other._data, inplace=True, value=fill_value)
return pandas.Series(self < other._data, index=other._index, name=other._name)

return _series_comp_binop_scalar_impl
Expand Down
0