Skip to content

[BUG] reject non-positive sigma/scale in Normal and Laplace #959#1065

Open
shubhumre777 wants to merge 1 commit into
sktime:mainfrom
shubhumre777:shubh/first-patch
Open

[BUG] reject non-positive sigma/scale in Normal and Laplace #959#1065
shubhumre777 wants to merge 1 commit into
sktime:mainfrom
shubhumre777:shubh/first-patch

Conversation

@shubhumre777

Copy link
Copy Markdown

Reference Issues/PRs

Fixes #959

What does this implement/fix? Explain your changes.

This PR adds input parameter validation to the constructors (__init__) of both the Normal and Laplace distributions to enforce strictly positive scale parameters (sigma for Normal and scale for Laplace).

Previously, passing non-positive values allowed mathematically invalid negative values to propagate to the _pdf calculation. The input validation uses a robust vectorized numpy check np.any(np.asarray(...) <= 0) to seamlessly handle both scalar values and multi-dimensional array structures without crashing.

Does your contribution introduce a new dependency? If yes, which one?

No.

What should a reviewer concentrate their feedback on?

The vector/array validation logic implementation using np.any(np.asarray(...) <= 0) inside the constructors.

Did you add any tests for the change?

Yes, added a new automated unit test file:
skpro/distributions/tests/test_parameter_validation.py which verifies that both distributions throw a descriptive ValueError on negative and zero boundary values.

Any other comments?

This is my first contribution to skpro , Excited to hear feedback.

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG].

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]Normal and Laplace accept non-positive sigma/scale and return invalid pdf values

1 participant