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
DOC: Return type for quantiles seems to depend on quantile method. #22323
Comments
Thanks for the note @aschaffer, that is indeed incorrect. We fixed things up in gh-19857 (and followups). IIRC there was a tiny bit of back and forth here also over the time (at least for boolean inputs). In any case, the comment is correct for all interpolating/continuous methods, I believe (should double check the code maybe). What is important is that all methods that give a "discontiguous" results have no interpolation and we (now?) retain the input |
OK, double checking the rule for interpolated values: the actual "rule" is more complicated and drops implicitly out of the interpolation calculation. However, unless you care about |
It's probably worth noting that for discontinuous methods who return one or the other end of the interval within which the quantile input falls, it might make sense to return results of same type as source array. But for continuous methods; or, discontinuous methods that could return mid-intervals (e.g., averaged-inverted-cdf) some conversion to floating point is necessary, if the source array is integer(-like). |
For the discontinuous methods we "always" return the same dtype as the input. But, at least For the interpolated ones, we take into account the dtype of Luckily, numerical types it mainly leads to that upcast to float64 with the only odd case being |
Describe the issue:
Per quantile dox:
"If the input contains integers or floats smaller than float64, the output data-type is float64. Otherwise, the output data-type is the same as that of the input."
For example, for an integer source array, the result should be converted to float64. Regardless of the selected method.
However,
There's no mention in the dox that the output type depends on the selected method.
Reproduce the code example:
Error message:
r1.dtype != r2.dtype True
NumPy/Python version information:
1.23.0 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:04:10)
[GCC 10.3.0]
Context for the issue:
No response
The text was updated successfully, but these errors were encountered: