Skip to content

Conversation

j-bowhay
Copy link
Member

@j-bowhay j-bowhay commented Jun 4, 2024

towards #20544

ttest_rel can be rewritten by calling ttest_1samp. In doing so we get array API support for free.

@github-actions github-actions bot added scipy.stats enhancement A new feature or improvement labels Jun 4, 2024
Co-authored-by: Matt Haberland <mhaberla@calpoly.edu>
@mdhaber
Copy link
Contributor

mdhaber commented Jun 4, 2024

@tupui @steppi Anything we're missing here? ISTM that if a) the function passes the original NumPy tests like this and b) ttest_1samp passes array API tests, we're covered.

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.

Go for it 👍

(Seems like we could deprecate it too no? But a follow up if we do I guess.)

@lucascolley lucascolley changed the title ENH: stats: rewrite ttest_rel in terms of ttest_ind ENH: stats: rewrite ttest_rel in terms of ttest_ind Jun 4, 2024
@mdhaber
Copy link
Contributor

mdhaber commented Jun 4, 2024

Seems like we could deprecate...

Haha yeah but I'll let you handle that one : ) (I assume that all the t-test functions are heavily used.)

[skip ci]

Co-authored-by: Lucas Colley <lucas.colley8@gmail.com>
@lucascolley
Copy link
Member

ttest_rel can be rewritten by calling ttest_ind

sanity check - why is this ttest_ind when the function actually calls ttest_1samp?

@mdhaber
Copy link
Contributor

mdhaber commented Jun 4, 2024

Just a typo. Original comment (#20762 (comment)) was to implement ttest_rel with ttest_1samp, as this does.

@mdhaber mdhaber changed the title ENH: stats: rewrite ttest_rel in terms of ttest_ind ENH: stats: rewrite ttest_rel in terms of ttest_1samp Jun 4, 2024
Copy link
Member

@lucascolley lucascolley left a comment

Choose a reason for hiding this comment

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

thanks all!

@lucascolley lucascolley merged commit 0690159 into scipy:main Jun 4, 2024
@lucascolley lucascolley added this to the 1.15.0 milestone Jun 4, 2024
@lucascolley lucascolley added the array types Items related to array API support and input array validation (see gh-18286) label Jun 4, 2024
@rgommers
Copy link
Member

rgommers commented Jun 5, 2024

This seems to cause failures when SCIPY_ARRAY_API is set:

FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_rel::test_vs_nonmasked - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_rel::test_fully_masked - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_rel::test_result_attributes - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_rel::test_zero_division - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_rel::test_alternative[less] - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_rel::test_alternative[greater] - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_ind::test_vs_nonmasked - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_ind::test_fully_masked - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_ind::test_result_attributes - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_ind::test_zero_division - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_ind::test_alternative[less] - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_ind::test_alternative[greater] - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_1samp::test_vs_nonmasked - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_1samp::test_fully_masked - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_1samp::test_result_attributes - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_1samp::test_zero_division - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_1samp::test_alternative[less] - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
FAILED scipy/stats/tests/test_mstats_basic.py::TestTtest_1samp::test_alternative[greater] - TypeError: Inputs of type `numpy.ma.MaskedArray` are not supported.
= 18 failed, 51686 passed, 4547 skipped, 11736 deselected, 218 xfailed, 13 xpassed in 473.45s (0:07:53) =

Could you perhaps address that in a follow-up PR @j-bowhay?

@lucascolley
Copy link
Member

should we just test -s stats in the Array API CI job rather than all of the separate test files?

@rgommers
Copy link
Member

rgommers commented Jun 5, 2024

That seems reasonable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
array types Items related to array API support and input array validation (see gh-18286) enhancement A new feature or improvement scipy.stats
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants