-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complement type, possible approach to #1032. #4892
Conversation
Paired on this with @punkrockpolly, see: https://github.com/punkrockpolly/Playing-with-Julia/blob/master/negatedindex.jl The premise of the Complement type is that it abstracts the complement of a collection – primarily that `x in c` <=> `!(x in c.collection)` This commit punts on indexing for more than two dimensions because that turns out to be an incredibly invasive change to huge amounts the multidimensional array indexing code.
I think the only reasonable way to do this is as I described in #1032. Currently all the indexing code simply iterates over index objects ( Other than that, the idea of a collection that contains every possible value except certain ones scares me a little. |
It's not really a collection – it's not iterable. The only thing you can really do with it is check for containment. The only reason I stuck it in collections is because it wraps collection objects. |
Well, that's fair, I can get over my fear :) I love the idea of using |
bump. I'd like to merge this and see how it pans out. |
For me it's a big +1. For NamedArrays, we would also add |
Agreed. I originally had that in there and took it out to keep the PR minimal. Easy to add back. |
We could ditch |
This pull request lacks support for indexing general indices(v::AbstractArray, dim::Integer, I::Union(Real, AbstractVector)) = I
indices(v::AbstractArray, dim::Integer, I::Complement) = getindex(v, filter(i -> in(i, I), 1:size(v, dim)))
getindex(v::AbstractArray, I::Union(Real, AbstractVector, Complement)...) = getindex(v, [indices(v, dim, I[dim]) for dim in 1:length(I)]...) But:
|
Yes, indexing code needs a lot of work to make this work more generically. @punkrockpolly and I started down that path but it didn't look like there was any end in sight, so we just kind of gave up. At least by having the [pao: fix typo in @punkrockpolly's username] |
OK, I see. High-performance functions can probably wait for even longer then. |
any interest in making this work for a limited number of dimensions? (pending a rewrite of general array indexing off in the distant future) |
6c7c7e3
to
1a4c02f
Compare
Paired on this with @punkrockpolly, see:
https://github.com/punkrockpolly/Playing-with-Julia/blob/master/negatedindex.jl
The premise of the Complement type is that it abstracts the complement of a collection – primarily that
This commit punts on indexing for more than two dimensions because that turns out to be an incredibly invasive change to huge amounts the multidimensional array indexing code.