DataArrays.jl
DataArrays.jl copied to clipboard
max of integer DataArrays results in Array{Any}. Breaks max of several DataArrays
The max
function changes the type when applied to instances of DataArrays
. As a side effect, taking the maximum of 3 or more instances ofDataArrays
result in an error:
julia> u = DataArray([1,2,3]); v = DataArray([0,4,0]); w =[4,0,0];
julia> u = DataArray([1,2,3]); v = DataArray([0,4,0]); w = DataArray([4,0,0]);
julia> typeof(max(u,v))
Array{Any,1}
julia> max(u,v,w)
ERROR: no method isless(DataArray{Int64,1}, Array{Any,1})
in max at operators.jl:71
I have this issue with Julia 0.3.0 preview (mac binary package). In Julia 0.2.0 max
returns and Array{Int64, 1}
While perhaps not ideal, at least this allowed to execute max(u,v,w)
.
Not totally sure, but I think you probably want maximum, not max.
maximum
seems to give a 1-element Array{Int64,1}
, but I am interested in a 3-element Array{Int64,1}
, such that each component contains the maximum of the corresponding components of the original data arrays. The function max
used to give me that and it continues to do so for ordinary arrays.
We don't currently implement max
in operators.jl
, so we are falling back on the implementation in Base, which evidently changed between 0.2 and 0.3. We should implement max
in operators.jl
.
Agreed, that's the easiest solution.
max(::Array, ::Array)
and maximum(::Array)
do different things, and DataArrays matches the Base definitions. Looks like the original issue here is unresolved.
Apologies for deleting the post. I realized the difference as soon as i read the documentation after I posted. So ended up deleting the post. Didnt realize you had answered it already! That was fast. For reference : (original post) Why does DataArrays not have 'max' compared to max(::Arrays) and have a maximum instead?