Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Unhelpful error with quantile!(x, q) #174

Open
JockLawrie opened this issue Nov 2, 2015 · 2 comments
Open

Unhelpful error with quantile!(x, q) #174

JockLawrie opened this issue Nov 2, 2015 · 2 comments

Comments

@JockLawrie
Copy link

Hi there,
When computing quantiles on DataArrays, if the DataArray contains an NA I get an error that could be more helpful. See example below.

using DataArrays

x = DataArray(Int64, 3)
x[1] = 1
x[2] = 2
x[3] = 3
quantile!(x, [0.5])    # OK, no problem

x[3] = NA
quantile!(x, [0.5])    # Unhelpful error

The error is:
ERROR: MethodError: isnan has no method matching isnan(::DataArrays.NAtype) in quantile! at statistics.jl:528

The source code of statistics.jl has the message "quantiles are undefined in presence of NaNs", which is more helpful. How can this message be shown rather than the one currently shown?

@nalimilan
Copy link
Member

This is because the generic implementation for AbstractArray is used, instead of a specific method for DataArray. You could easily fix this by copying the general method, restricting its signature to DataArrays, and adding a check for isna before that for isnan.

(But these days, the development focus has moved towards NullableArrays.jl, which offers a much better performance and will eventually replace DataArrays.jl.)

@JockLawrie
Copy link
Author

OK thanks. Given the current direction towards NullableArrays.jl I'm inclined to not put any effort into this issue. Feel free to close.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants