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

Implement Series.std() in new style #222

Merged
merged 5 commits into from
Oct 26, 2019

Conversation

densmirn
Copy link
Contributor

No description provided.

raise TypingError('{} Unsupported parameters. Given {}: {}'.format(_func_name, name, arg))

def hpat_pandas_series_std_impl(self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
return math.sqrt(self.var(axis=axis, skipna=skipna, level=level, ddof=ddof, numeric_only=numeric_only))
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because numpy implementation has ddof=0 by default, but ddof=1 is by default for pandas. Implementation of series.var takes into account the fact.

msg = 'Method std(). The object must be a number. Given self.dtype: {}'
self.assertIn(msg.format(types.unicode_type), str(raises.exception))

def test_series_std_unsupported_axis(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Appreciate this, thank you.
Maybe it is better to combine all tests (for this method) for parameters check into one test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me make such change.

def hapt_pandas_series_std(self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
"""
Pandas Series method :meth:`pandas.Series.std` implementation.
.. only:: developer
Copy link
Contributor

Choose a reason for hiding this comment

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

please insert blank line. Otherwise it will be treated as the same line with above in documentation generator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Test: python -m hpat.runtests hpat.tests.test_series.TestSeries.test_series_std_unsupported_axis
Test: python -m hpat.runtests hpat.tests.test_series.TestSeries.test_series_std_unsupported_level
Test: python -m hpat.runtests hpat.tests.test_series.TestSeries.test_series_std_unsupported_numeric_only
Parameters
Copy link
Contributor

Choose a reason for hiding this comment

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

please insert blank line. Otherwise it will be treated as the same line with above in documentation generator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

If None, will attempt to use everything, then use only numeric data.
Not implemented for Series.
*unsupported*
Returns
Copy link
Contributor

Choose a reason for hiding this comment

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

please insert blank line. Otherwise it will be treated as the same line with above in documentation generator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

:obj:`scalar`
returns :obj:`scalar`
"""
_func_name = 'Method std().'
Copy link
Contributor

Choose a reason for hiding this comment

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

please insert blank line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@@ -173,6 +173,74 @@ def hpat_pandas_series_shape_impl(self):
return hpat_pandas_series_shape_impl


@overload_method(SeriesType, 'std')
def hpat_pandas_series_std(self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
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
def hpat_pandas_series_std(self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
def hpat_pandas_series_std(self, axis=None, skipna=True, level=None, ddof=1, numeric_only=None):

skipna : bool, default True

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

@densmirn densmirn Oct 24, 2019

Choose a reason for hiding this comment

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

According to the Pandas documentation skipna=None by default for series.std. I was guided by that.

0/None/'index' - row-wise operation
1/'columns' - column-wise operation
*unsupported*
skipna: :obj:`bool`
Copy link
Contributor

Choose a reason for hiding this comment

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

skipna : bool, default True

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But default value is None according to Pandas documentation on this method.

if not isinstance(arg, (types.Omitted, types.NoneType)) and arg is not None:
raise TypingError('{} Unsupported parameters. Given {}: {}'.format(_func_name, name, arg))

def hpat_pandas_series_std_impl(self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
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
def hpat_pandas_series_std_impl(self, axis=None, skipna=None, level=None, ddof=1, numeric_only=None):
def hpat_pandas_series_std_impl(self, axis=None, skipna=True, level=None, ddof=1, numeric_only=None):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Pandas documentation says otherwise.

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

Successfully merging this pull request may close these issues.

None yet

4 participants