-
Notifications
You must be signed in to change notification settings - Fork 12
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
set-like operations #14
Comments
We could also use < for subset. |
You'd have to treat them as bags (aka multisets). Which could definitely be useful in some contexts, but is probably not intuitive for anyone to justify the syntactic sugar. For example, I could not tell off the top of my head how On the other hand, I think it would make a great deal of sense to include these set (and/or bag) ops as methods for the index types, with the same names as the methods of the Maybe down the road, once EditAfter 5 minutes of reading https://en.wikipedia.org/wiki/Multiset, I know understand how the set-like ops work for bags. It's not super complicated, but I think my point about it being unintuitive for most users still stands |
It would also be useful to have various set-like operations, treating the elements indexed by an index as a set
in
meaning subset+
and&
meaning union|
meaning intersection-
meaning subtraction (idx1 - idx2
are the elements indexed byidx1
but notidx2
)For example,
idx1 in idx2
would return True if all the elements indexed byidx1
are also indexed byidx2
.idx1 + idx2
would give an index representing the elements indexed by eitheridx1
oridx2
.There will be lots of cases where they have to raise exceptions obviously because it can't be computed. I don't know if the canonical form after
reduce(shape)
will always avoid that, or if we would also need method variants that can include a shape. There will also be cases where the index can't be represented except by an array index.Another issue is that for integer array indices, the same element can be indexed multiple times, so it doesn't completely make sense to treat it as a set.
The text was updated successfully, but these errors were encountered: