Skip to content

Conversation

@SebastianGoldmann
Copy link

@SebastianGoldmann SebastianGoldmann marked this pull request as ready for review November 2, 2025 14:12
@SebastianGoldmann SebastianGoldmann changed the title Aligned skew and kurt results with scipy.stats BUG: Aligned skew and kurt results with scipy.stats Nov 2, 2025
result = s.sem(ddof=1)
assert pd.isna(result)

def test_skew(self):
Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing this test?

Copy link
Author

Choose a reason for hiding this comment

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

HI Alvaro,

Thank you for the review.

In my previous commit I thought these were duplicated tests, but looking at it again these should not be removed. I will revert and update the tests.

alt = lambda x: sp_stats.kurtosis(x, bias=False)
self._check_stat_op("kurt", alt, string_series)

def test_kurt_corner(self):
Copy link
Member

Choose a reason for hiding this comment

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

Why are you removing this test?

Comment on lines 560 to +565
# fix for handling cases where all elements in an axis are the same
if isinstance(result, np.ndarray):
result[np.max(values, axis=axis) == np.min(values, axis=axis)] = 0
result[np.max(values, axis=axis) == np.min(values, axis=axis)] = np.nan
return result
elif np.max(values) == np.min(values):
return 0.0
return np.nan
Copy link
Member

Choose a reason for hiding this comment

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

I think these branches can be removed, since SciPy already assigns NaN.

Suggested change
# fix for handling cases where all elements in an axis are the same
if isinstance(result, np.ndarray):
result[np.max(values, axis=axis) == np.min(values, axis=axis)] = 0
result[np.max(values, axis=axis) == np.min(values, axis=axis)] = np.nan
return result
elif np.max(values) == np.min(values):
return 0.0
return np.nan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Wrong skewness and kurtosis in Rolling.{skew,kurt} for degenerate distributions

2 participants