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

SubArrays and reduce/map #94

Open
tshort opened this issue Dec 13, 2015 · 1 comment
Open

SubArrays and reduce/map #94

tshort opened this issue Dec 13, 2015 · 1 comment

Comments

@tshort
Copy link

tshort commented Dec 13, 2015

I don't see a way to run reduce operations on SubArrays of NullableArrays.

julia> a = NullableArray([1:5;])

julia> nullify!(a,1)

julia> reduce(+, a, skipnull=true)
Nullable(14)

julia> reduce(+, sub(a, 1:4), skipnull=true)
ERROR: MethodError: `reduce` has no method matching reduce(::Function, ::SubArray{Nullable{Int64},1,NullableArrays.NullableArray{Int64,1},Tuple{UnitRange{Int64}},1})
Closest candidates are:
  reduce(::Any, ::Any)
  reduce(::Any, ::Any, ::Any)
  reduce(::Any, ::Number)
  ...

It would be nice to have a more generic way to indicate how to treat nulls during reduction, for example:

reduce(+, skipnulls(a))
reduce(+, skipnulls(sub(a, 1:4)))
sum(skipnulls(a))
sum(skipnulls(sub(a, 1:4)))

Here, skipnulls could return a simple iterator or a wrapper type.

Also, map with the lift= argument doesn't support SubArrays of NullableArrays.

@davidagold
Copy link
Contributor

That's a very interesting proposal (the skipnulls constructor).

I have exams for my first quarter of graduate school through this coming Tuesday. After that I'll have time at least to implement a reduce methods for SubArrays of NullableArrays, and hopefully also to experiment with the API you suggest.

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

No branches or pull requests

2 participants