-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
BUG: scipy.stats.ttest_1samp
raises an error when using keepdims=True
#20725
Comments
I think I managed to find what the problem is, I'll try a PR if it's alright! |
sure, go for it! |
LMK if you're still working on this, otherwise I'll likely fix it tonight. There are some features that have been added since |
Indeed, I thought about adding such a heuristic, e.g., expanding dims only from arrays and not from any other types. However I was unsure of the impact of such a change and was trying to understand the implications, since |
No, go ahead and try that approach when you can, and I can review. I don't think you can only expand dims from arrays because you will want to expand NumPy scalar types, too. But see what happens if you just look out for Python return ([(np.expand_dims(output, reduced_axes) if not isinstance(output, int) else output) for output in res]
if keepdims else res) And add all the other functions in
That should smoke out any other cases I'm not thinking of. But IIRC there should not be too many cases - it really might be just the few functions that return a result with this |
gh-20734 fixes the bug for |
Describe your issue.
Setting
keepdims=True
when usingscipy.stats.ttest_1samp
leads to an error.Reproducing Code Example
Error message
SciPy/NumPy/Python version and system information
The text was updated successfully, but these errors were encountered: