JuliaData / CategoricalArrays.jl

Arrays for working with categorical data (both nominal and ordinal)
Other
125 stars 33 forks source link

similar should not pirate Array Types in methods? #402

Open vtjnash opened 1 year ago

vtjnash commented 1 year ago

It seems like the only reason similar would be called on Array{<:CategoricalValue} with a new eltype of CategoricalValue means the user apparently explicitly wanted an Array (otherwise, it would have been called with an AbstractRange typeof(1:1) for instance). It seems like this package might be not following user expectations here, which is also appearing to cause many invalidations during loading, leading to worse precompile results across the Julia ecosystem. I think we should delete these extra similar methods, so that requests for a similar object to a Base Vector does indeed return some similar Vector to the original. But keep the methods for typeof(1:1), so that collect with a CategoricalValue does still get the CategoricalArray as intended, when the user has not otherwise tried to explicitly ask for it to return a Base.Vector type as the argument to collect_to?