Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] Refactor of BaseDistribution and descendants - generalised distribution param broadcasting in base class #5176

Merged
merged 8 commits into from Sep 9, 2023

Conversation

Alex-JG3
Copy link
Contributor

@Alex-JG3 Alex-JG3 commented Aug 28, 2023

Reference Issues/PRs

Related issue sktime/skpro#21

What does this implement/fix? Explain your changes.

Moves the _get_bc_params method from child distributions to the parent distribtion class, BaseDistribution.

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

No

What should a reviewer concentrate their feedback on?

This implementation is quite simple and doesn't use _tags and still means the child distributions have to call the _get_bc_params method.

Would you prefer the child distributions to not have to call the _get_bc_params method. This will mean putting the parameter names that need to broadcasted in _tags dictionary then writing the broadcasted parameters from BaseDistribution. Personally I think this is slightly over complicated although this approach follows the DRY principles more closely. I am open to intput here and happy to implement whatever is preferred.

Did you add any tests for the change?

Altered the _DistrDefaultMethodTester class to use the parent _get_bc_params method.

Any other comments?

PR checklist

For all contributions
  • I've added myself to the list of contributors with any new badges I've earned :-)
    How to: add yourself to the all-contributors file in the sktime root directory (not the CONTRIBUTORS.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 plus code if you also fixed the bug in the PR).maintenance - CI, test framework, release.
    See here for full badge reference
  • Optionally, I've added myself and possibly others to the CODEOWNERS file - do this if you want to become the owner or maintainer of an estimator you added.
    See here for further details on the algorithm maintainer role.
  • The PR title starts with either [ENH], [MNT], [DOC], or [BUG]. [BUG] - bugfix, [MNT] - CI, test framework, [ENH] - adding or improving code, [DOC] - writing or improving documentation or docstrings.
For new estimators
  • I've added the estimator to the API reference - in docs/source/api_reference/taskname.rst, follow the pattern.
  • I've added one or more illustrative usage examples to the docstring, in a pydocstyle compliant Examples section.
  • If the estimator relies on a soft dependency, I've set the python_dependencies tag and ensured
    dependency isolation, see the estimator dependencies guide.

@Alex-JG3 Alex-JG3 changed the title Generalise broadcasting [ENH]Generalise distribution param broadcasting Aug 28, 2023
sktime/proba/base.py Outdated Show resolved Hide resolved
sktime/proba/base.py Outdated Show resolved Hide resolved
fkiraly
fkiraly previously approved these changes Aug 28, 2023
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Hm, looks like an impovement!

Left some non-blocking suggestions.

Also, we should see if the tests run - as said, the skpro tests are more extensive, so let's open a copy there if this runs through.

@fkiraly fkiraly changed the title [ENH]Generalise distribution param broadcasting [ENH] Refactor of BaseDistribution and descendants - generalised distribution param broadcasting in base class Aug 29, 2023
Update distributions to pass tuples to _get_bc_params
Passing a 1D numpy array into the tuple constructor unpacks the elements
of the array, we want the whole array to be an item in the tuple.
sktime/proba/normal.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@fkiraly fkiraly left a comment

Choose a reason for hiding this comment

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

Excellent, thanks! This will help greatly with the base class refactor.

fkiraly pushed a commit to sktime/skpro that referenced this pull request Aug 31, 2023
…stribution param broadcasting in base class (#54)

Mirror of sktime sktime/sktime#5176

Refactors the `_get_bc_params` function in the `BaseDistribution` class.
Moves the `_get_bc_params` method from child distributions to the parent distribtion class, `BaseDistribution`.


This implementation is quite simple and doesn't use `_tags` and still means the child distributions have to call the `_get_bc_params` method.
@fkiraly fkiraly merged commit 7affb72 into sktime:main Sep 9, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Adding new functionality module:probability&simulation probability distributions and simulators
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants