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

Some methods from the standard library don't fulfil their contract #92

@tomasaschan

Description

@tomasaschan

unique(A::DataArray) reorders items

According to the spec, unique(A) should not re-order elements. However, it does for DataArrays:

julia> A = sort(rand(100)); # Get some data, sorted for simplicity
julia> DA = DataArray(A);
julia> all(diff(unique(A)) .>= 0) # Test that this works for regular arrays
true
julia> all(diff(unique(DA)) .>= 0) # It doesn't work for DataArrays!
false
julia> all(diff(unique(DA.data)) .>= 0) # It DOES work for the underlying data
true

Note that this is a problem even without any 'NA` values.

For sorted data this isn't really a big problem, as I can just re-sort it again, but for data that is not sorted but where ordering is important (such as experimental observations) that's not an option either.

sort(A::DataArray) throws error when missing values

Using A and DA as above, I get

julia> sort(DA)
100-element DataArray{Float64,1}:
 0.000314079
 0.00973866 
 # etc...

i.e. it Just Works(TM). However, if there are missing values:

julia> DA[35] = NA;
julia> sort(DA)
ERROR: no method isnan(ForwardOrdering, NAtype)
 in nans2right! at sort.jl:409
 in fpsort! at sort.jl:428
 in sort! at sort.jl:441
 in sort at sort.jl:334

I'd prefer if it "just worked" and placed all NA values last...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions