[ENH] Remove redundant method overrides in Skellam and FDist#963
Open
ANANYA542 wants to merge 1 commit intosktime:mainfrom
Open
[ENH] Remove redundant method overrides in Skellam and FDist#963ANANYA542 wants to merge 1 commit intosktime:mainfrom
ANANYA542 wants to merge 1 commit intosktime:mainfrom
Conversation
Both Skellam and FDist extend _ScipyAdapter and implement _get_scipy_param() correctly. However, they both manually overrode _pmf/_pdf, _cdf, _ppf, _mean, and _var with logic that is identical to what the adapter already provides natively. This commit removes those redundant methods, letting the base class handle them as designed, reducing code duplication. Fixes sktime#944
Author
|
@fkiraly -if you could review this pr and let me know if some changes or explanation under the same are required |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Both
Skellamand FDist distributions extend _ScipyAdapter and implement _get_scipy_param() correctly. However, they both manually overrode _pmf / _pdf, _cdf, _ppf, _mean, and _var with logic that is completely identical to what the adapter already provides natively.For example,
Skellam._pmfmanually does:For example,
Skellam._pmfmanually does:def _pmf(self, x):
mu1 = self._bc_params["mu1"]
mu2 = self._bc_params["mu2"]
return skellam.pmf(x, mu1, mu2)
But _ScipyAdapter._pmf already does exactly this via _get_scipy_param() . Since Skellam._get_scipy_param() returns [mu1, mu2], {}, both paths are mathematically identical. These overrides add roughly 25 redundant lines per file with no functional difference whatsoever. This commit removes those redundant methods, letting the _ScipyAdapter
base class handle them as designed, which significantly reduces code duplication. I validated this locally by removing the overrides and confirming identical outputs before and after.
Reference Issues/PRs
Fixes #944
What does this implement/fix? Explain your changes.
This PR deletes redundant core distribution method overrides from skellam.py and f.py (or f_dist.py), allowing them to cleanly inherit the exact same behavior from _ScipyAdapter.
Does your contribution introduce a new dependency? If yes, which one?
no
What should a reviewer concentrate their feedback on?
Did you add any tests for the change?
No new tests are required because the existing distribution tests in the CI pipeline automatically verify that mean, var,pdf/
pmf, cdf and ppf work correctly, ensuring no functionality is broken by relying on the base class.
Any other comments?
The screenshot for the fix has been attatched

PR checklist
For all contributions
How to: add yourself to the all-contributors file in the
skproroot directory (not theCONTRIBUTORS.md). Common badges:code- fixing a bug, or adding code logic.doc- writing or improving documentation or docstrings.bug- reporting or diagnosing a bug (get this pluscodeif you also fixed the bug in the PR).maintenance- CI, test framework, release.See here for full badge reference
For new estimators
docs/source/api_reference/taskname.rst, follow the pattern.Examplessection.python_dependenciestag and ensureddependency isolation, see the estimator dependencies guide.