Skip to content

Conversation

mdhaber
Copy link
Contributor

@mdhaber mdhaber commented Apr 1, 2022

Reference issue

Closes gh-15747
gh-11394

What does this implement/fix?

gh-11394 deprecated the ability to implement _rvs without a size parameter. _rvs is a private method, but it's in a public class, so immediate removal of support for _rvs without a size parameter had backward-compatibility concerns. The authors added special treatment for _rvs methods without a size parameter, but this can be removed now that a deprecation warning has been raised for years. This PR now always passes size when rvs calls _rvs, and it tests that there is an error (rather than deprecation warning) when an _rvs method that does not accept size gets passed size.

Additional information

gh-11394 suggested that it was supposed to do something similar w.r.t. random_state: remove reliance of _rvs methods on a _random_state attribute and instead require that they accept a random_state parameter. However, it did not raise a deprecation warning for _rvs methods that don't accept random_state, and _random_state is still used throughout the distribution infrastructure, so I didn't touch that.

@mdhaber mdhaber added scipy.stats maintenance Items related to regular maintenance tasks deprecated Items related to behavior that has been deprecated labels Apr 1, 2022
@mdhaber mdhaber requested a review from h-vetinari April 1, 2022 23:14
Copy link
Member

@h-vetinari h-vetinari left a comment

Choose a reason for hiding this comment

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

Aside from making the linter happy, this LGTM! :)

Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

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

Thanks Matt! Just one nit for me.

Copy link
Member

@tupui tupui left a comment

Choose a reason for hiding this comment

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

Thanks Matt! Just one nit for me. (Sorry for the double comment, GH mobile is buggy)

@tupui tupui merged commit 2abf930 into scipy:main Apr 2, 2022
@tupui tupui added this to the 1.9.0 milestone Apr 2, 2022
patnr added a commit to patnr/scipy that referenced this pull request Apr 5, 2022
* master: (632 commits)
  Update _dual_annealing.py (scipy#15939)
  TST: stats: make `check_sample_var` two-sided (scipy#15723)
  DOC: sparse.linalg: add citations for COLAMD
  DOC: fix missing comma in conf
  ENH/MAINT: Version switcher from the sphinx theme (scipy#15380)
  MAINT: stats: remove support for `_rvs` without `size` parameter (scipy#15917)
  BUG: Handle base case for scipy.integrate.simpson when span along the axis is 0  (scipy#15824)
  MAINT: stats: adjust tolerance for failing test only
  MAINT: stats: adjust tolerance of failing TestTruncnorm
  MAINT: special: Clean up C style in ndtr.c
  CI: remove pin on Jinja2 (scipy#15895)
  STY: Remove white spaces
  MAINT: stats: exempt gilbrat from refguide_check
  MAINT: stats: rename continuous_gilbrat->continuous_gibrat
  MAINT: stats: correct name Gilbrat -> Gibrat
  [ENH] circvar calculated simply as 1-R (scipy#5747)
  DEP: deal with deprecation of ndim >1 in bspline
  MAINT: stats: more specific error type from `rv_continuous.fit` (scipy#15778)
  DOC: fix import in example in _morestats (scipy#15900)
  [BUG] make p-values consistent with the literature (scipy#15894)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecated Items related to behavior that has been deprecated maintenance Items related to regular maintenance tasks scipy.stats
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEP: stats: remove support for _rvs without size parameter
3 participants