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

DEP: stats: remove deprecated binom_test #18610

Merged
merged 3 commits into from Jun 1, 2023
Merged

Conversation

mdhaber
Copy link
Contributor

@mdhaber mdhaber commented Jun 1, 2023

Reference issue

Closes gh-18581

What does this implement/fix?

This removes the deprecated function stats.binom_test.

Additional information

See comments about removal of old tests inline.

@mdhaber mdhaber added scipy.stats deprecated Items related to behavior that has been deprecated labels Jun 1, 2023
result = stats.binomtest(x, n, p=p, alternative=alternative)
return result.pvalue

def test_data(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Source of reference values unknown. Already well-tested, so remove.

pval = self.binom_test_func([682, 243], p=3/4)
assert_almost_equal(pval, 0.38249155957481695, 11)

def test_bad_len_x(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See new test_invalid_k_wrong_type.

def test_bad_n(self):
# len(x) is 1, but n is invalid.
# Missing n
assert_raises(ValueError, self.binom_test_func, [100])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Python raises an error when there are too few arguments. No need to test.

# Missing n
assert_raises(ValueError, self.binom_test_func, [100])
# n less than x[0]
assert_raises(ValueError, self.binom_test_func, [100], n=50)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See existing test_invalid_k_too_big.

# n less than x[0]
assert_raises(ValueError, self.binom_test_func, [100], n=50)

def test_bad_p(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See new test_invalid_p_range.

assert_raises(ValueError,
self.binom_test_func, [50, 50], p=2.0)

def test_alternatives(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Source of reference values unknown. Already well-tested, so remove.

assert_almost_equal(res, 0.0437479701823997)

@pytest.mark.skipif(sys.maxsize <= 2**32, reason="32-bit does not overflow")
def test_boost_overflow_raises(self):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

See new test_boost_overflow_raises.

@j-bowhay j-bowhay added this to the 1.12.0 milestone Jun 1, 2023
Copy link
Member

@j-bowhay j-bowhay left a comment

Choose a reason for hiding this comment

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

Apart from the lint failure which looks related, LGTM

@mdhaber
Copy link
Contributor Author

mdhaber commented Jun 1, 2023

Thanks. I fixed that in the second commit.

@j-bowhay
Copy link
Member

j-bowhay commented Jun 1, 2023

Sorry missed this first time around, there is also a reference to it here

__all__ = [ # noqa: F822
'mvsdist',
'bayes_mvs', 'kstat', 'kstatvar', 'probplot', 'ppcc_max', 'ppcc_plot',
'boxcox_llf', 'boxcox', 'boxcox_normmax', 'boxcox_normplot',
'shapiro', 'anderson', 'ansari', 'bartlett', 'levene', 'binom_test',
'fligner', 'mood', 'wilcoxon', 'median_test',
'circmean', 'circvar', 'circstd', 'anderson_ksamp',
'yeojohnson_llf', 'yeojohnson', 'yeojohnson_normmax',
'yeojohnson_normplot', 'annotations', 'namedtuple', 'isscalar', 'log',
'around', 'unique', 'arange', 'sort', 'amin', 'amax', 'atleast_1d',
'array', 'compress', 'exp', 'ravel', 'count_nonzero', 'arctan2',
'hypot', 'optimize', 'find_repeats',
'chi2_contingency', 'distributions', 'rv_generic', 'Mean',
'Variance', 'Std_dev', 'ShapiroResult', 'AndersonResult',
'Anderson_ksampResult', 'AnsariResult', 'BartlettResult',
'LeveneResult', 'FlignerResult', 'WilcoxonResult'
]

@mdhaber
Copy link
Contributor Author

mdhaber commented Jun 1, 2023

Thanks. Thant should be the last of them. The rest are in the release notes.

image

@j-bowhay j-bowhay merged commit 62e2879 into scipy:main Jun 1, 2023
1 check passed
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 scipy.stats
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEP: removal of stats.binom_test
2 participants