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

Commit

Permalink
Merge pull request #890 from kozlov-alexey/feature/merge_from_release…
Browse files Browse the repository at this point in the history
…_0.33

Merge from integration/release_0.33 branch
  • Loading branch information
AlexanderKalistratov authored Jul 3, 2020
2 parents df4d8d3 + ef15baa commit 30e5395
Show file tree
Hide file tree
Showing 7 changed files with 294 additions and 301 deletions.
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
trigger:
- master
- '*'

pr:
- master
- '*'

jobs:
- template: buildscripts/azure/template-windows.yml
Expand Down
75 changes: 46 additions & 29 deletions sdc/functions/numpy_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,26 +534,61 @@ def sdc_fillna_overload(self, inplace=False, value=None):

dtype = self.dtype
isnan = get_isnan(dtype)

if (
(isinstance(inplace, types.Literal) and inplace.literal_value == True) or # noqa
(isinstance(inplace, bool) and inplace == True) # noqa
):

def sdc_fillna_inplace_noop(self, inplace=False, value=None):
return None

if isinstance(value, (types.NoneType, types.Omitted)) or value is None:
return sdc_fillna_inplace_noop

if isinstance(dtype, (types.Integer, types.Boolean)):
def sdc_fillna_inplace_int_impl(self, inplace=False, value=None):
return sdc_fillna_inplace_noop

if isinstance(dtype, types.Float):
def sdc_fillna_inplace_float_impl(self, inplace=False, value=None):
_value = np.nan if value is None else value
length = len(self)
for i in prange(length):
if isnan(self[i]):
self[i] = _value
return None

return sdc_fillna_inplace_int_impl
return sdc_fillna_inplace_float_impl

def sdc_fillna_inplace_float_impl(self, inplace=False, value=None):
length = len(self)
for i in prange(length):
if isnan(self[i]):
self[i] = value
if isinstance(dtype, types.UnicodeType):
# TO-DO: not supported, since no generic setitem for StringArray
return None

return sdc_fillna_inplace_float_impl

else:

def sdc_fillna_noop(self, inplace=False, value=None):
return copy(self)

if isinstance(value, (types.NoneType, types.Omitted)) or value is None:
return sdc_fillna_noop

if isinstance(dtype, (types.Integer, types.Boolean)):
return sdc_fillna_noop

if isinstance(dtype, types.Float):
def sdc_fillna_impl(self, inplace=False, value=None):
_value = np.nan if value is None else value
length = len(self)
filled_data = numpy.empty(length, dtype=dtype)
for i in prange(length):
if isnan(self[i]):
filled_data[i] = _value
else:
filled_data[i] = self[i]
return filled_data

return sdc_fillna_impl

if isinstance(self.dtype, types.UnicodeType):
def sdc_fillna_str_impl(self, inplace=False, value=None):
n = len(self)
Expand All @@ -562,9 +597,9 @@ def sdc_fillna_str_impl(self, inplace=False, value=None):
for i in prange(n):
s = self[i]
if sdc.hiframes.api.isna(self, i):
num_chars += len(value)
num_chars += get_utf8_size(value)
else:
num_chars += len(s)
num_chars += get_utf8_size(s)

filled_data = pre_alloc_string_array(n, num_chars)
for i in prange(n):
Expand All @@ -576,24 +611,6 @@ def sdc_fillna_str_impl(self, inplace=False, value=None):

return sdc_fillna_str_impl

if isinstance(dtype, (types.Integer, types.Boolean)):
def sdc_fillna_int_impl(self, inplace=False, value=None):
return copy(self)

return sdc_fillna_int_impl

def sdc_fillna_impl(self, inplace=False, value=None):
length = len(self)
filled_data = numpy.empty(length, dtype=dtype)
for i in prange(length):
if isnan(self[i]):
filled_data[i] = value
else:
filled_data[i] = self[i]
return filled_data

return sdc_fillna_impl


def nanmin(a):
pass
Expand Down
Loading

0 comments on commit 30e5395

Please sign in to comment.