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

Conversation

densmirn
Copy link
Contributor

@densmirn densmirn commented Oct 3, 2019

No description provided.

install_array_method(fname, generic_expand_cumulative_series)

# TODO: add itemsize, strides, etc. when removed from Pandas
_not_series_array_attrs = ['flat', 'ctypes', 'itemset', 'reshape', 'sort', 'flatten']

# Array attributes which overlap Series attributes
_excluded_array_attrs = ['cumsum']
Copy link
Contributor

@shssf shssf Oct 3, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you try just add cumsum into _not_series_array_attrs array?

Copy link
Contributor Author

@densmirn densmirn Oct 4, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I did. In this case the method isn't skipped because condition attr not in _not_series_array_attrs is True due to attr = 'resolve_cumsum' but not just 'cumsum'. It looks like an issue, because now this condition is always True. Perhaps attr.replace('resolve_', '') might be useful in this case.

# use ArrayAttribute for attributes not defined in SeriesAttribute
for attr, func in numba.typing.arraydecl.ArrayAttribute.__dict__.items():
if (attr.startswith('resolve_')
and attr not in SeriesAttribute.__dict__
and attr not in _not_series_array_attrs):
and attr not in _not_series_array_attrs
and attr.replace('resolve_', '') not in _excluded_array_attrs):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you show all function names registered by setattr(SeriesAttribute, attr, func)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

print(attr.replace('resolve_', '')) printed
dtype, itemsize, shape, strides, ndim, size, flat, ctypes, flags, T, real, imag, transpose, item, itemset, nonzero, reshape, sort, view, ravel, flatten, prod, sum, mean, var, std, argmin, argmax

@densmirn densmirn force-pushed the feature/series_cumsum branch 5 times, most recently from 9d73d3d to c3baf97 Compare October 7, 2019 07:06
@densmirn densmirn requested a review from shssf October 7, 2019 07:09
@shssf
Copy link
Contributor

shssf commented Oct 10, 2019

Please resolve conflicts

@densmirn densmirn force-pushed the feature/series_cumsum branch 4 times, most recently from 4e8e09a to 6b74735 Compare October 15, 2019 07:15
axis: :obj:`int`, :obj:`str`
Axis along which the operation acts
0/None - row-wise operation
1 - column-wise operation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it looks like description is not quite accurate. this parameter can be integer or string (as described in line 1507).
Please add string variant. I mean something like 0 or ‘index’, 1 or ‘columns’

Returns
-------
:obj:`pandas.Series`
returns :obj:`pandas.Series` object
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might return scalar but I don't know cases for this

_func_name = 'Method cumsum().'

if not isinstance(self, SeriesType):
raise TypingError('{} The object must be a pandas.series. Given self: {}'.format(_func_name, self))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given self -> Given

raise TypingError('{} The object must be a pandas.series. Given self: {}'.format(_func_name, self))

if not isinstance(self.dtype, types.Number):
raise TypingError('{} The object must be a number. Given self.dtype: {}'.format(_func_name, self.dtype))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #216 (comment)
also, message Given self.dtype means nothing for user. Please keep messages understandable as much as possible

def hpat_pandas_series_cumsum_impl(self, axis=None, skipna=True):
if skipna:
# nampy.nancumsum replaces NANs with 0, series.cumsum does not, so replace back 0 with NANs
data = numpy.nancumsum(self._data)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use something like local_data instead data to avoid intersection with class variables and types

pyfunc = test_impl
cfunc = hpat.jit(pyfunc)

series = pd.Series([1.0, np.nan, 9.0, -1.0, 7.0])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see #217 (comment)

@densmirn densmirn force-pushed the feature/series_cumsum branch 5 times, most recently from d0b90c9 to 49be153 Compare October 16, 2019 12:27
Copy link
Contributor

@shssf shssf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of input data, it might be too early to implement this.
I would be better to implement it for all tests (at least in Series) at one time.
Anyway, please follow data type hierarchy if you would like to start this in this PR

[1.0, np.nan, -1.0, 0.0, 5e-324],
[np.nan, np.inf, np.NINF, np.NZERO]
]
FLOAT_EXAMPLE, *_ = FLOAT_EXAMPLES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on need this variable. FLOAT_EXAMPLES[0] instead

@@ -34,6 +37,28 @@
),
]]

FLOAT_EXAMPLES = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
FLOAT_EXAMPLES = [
test_global_input_data_float64 = [

]
FLOAT_EXAMPLE, *_ = FLOAT_EXAMPLES
INT_EXAMPLE = [1, -1, 0, 18446744073709551615]
NUM_EXAMPLES = [INT_EXAMPLE] + FLOAT_EXAMPLES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
NUM_EXAMPLES = [INT_EXAMPLE] + FLOAT_EXAMPLES
test_global_input_data_numeric = [INT_EXAMPLE] + FLOAT_EXAMPLES

[np.nan, np.inf, np.NINF, np.NZERO]
]
FLOAT_EXAMPLE, *_ = FLOAT_EXAMPLES
INT_EXAMPLE = [1, -1, 0, 18446744073709551615]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
INT_EXAMPLE = [1, -1, 0, 18446744073709551615]
test_global_input_data_integer64 = [1, -1, 0, 18446744073709551615]


STR_EXAMPLES = [
['', 'a' 'aa', 'aaa', 'b', 'aab', 'ab', 'abababab'],
UNICODE_EXAMPLES
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't include it here

INT_EXAMPLE = [1, -1, 0, 18446744073709551615]
NUM_EXAMPLES = [INT_EXAMPLE] + FLOAT_EXAMPLES

UNICODE_EXAMPLES = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
UNICODE_EXAMPLES = [
test_global_input_data_unicode_kind4 = [

]

min_int64 = -9223372036854775808
max_int64 = 9223372036854775807
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sys.intmax

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@densmirn Use numba.targets.builtins.get_type_max_value for this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added.

@densmirn densmirn force-pushed the feature/series_cumsum branch from 8dfe505 to c7e9319 Compare October 23, 2019 15:54
@densmirn densmirn requested a review from shssf October 23, 2019 15:55
@densmirn densmirn requested a review from Hardcode84 October 25, 2019 07:00
@densmirn
Copy link
Contributor Author

@shssf, @kozlov-alexey could you take the next round to review the PR?

@shssf shssf merged commit 7722b6e into IntelPython:master Oct 25, 2019
@densmirn densmirn deleted the feature/series_cumsum branch June 9, 2020 12:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants