-
Notifications
You must be signed in to change notification settings - Fork 37
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
what should assignment with colons do? #23
Comments
Did you want to set (1,1) and (2,2) to 1 in this case? I feel like it should have a different index type, but then things become a bit too verbose. |
I'm not sure what I wanted :) But it's clear that implicitly taking the product space of the indices is designed for dense arrays. To assign sparse arrays, you want a sparse index space. So one API that makes sense is
We already have the |
Of course that still leaves the question of what to do with colons. If we keep the usual product space interpretation of plain indices, I'm inclined not to allow them. |
Noticed this from AxisArrays. I'm not sure I follow, but I think you are wishing it would just assign to the already-stored values? Over at https://github.com/timholy/ArrayIteration.jl, that would be called something like |
Yes, that's probably what I want. I'm beginning to think the key abstraction is IndexSpace, subsuming
Then I could get the "write only to existing locations" behavior using
|
Very similar thinking to my own. I'm not sure which formulation I like better---yours is certainly attractive. Just to explain my own reasoning, the motivation behind the design in ArrayIteration was to support not just
I think of indices and values similar to the keys/values of an associative array. |
Surprising nobody, I added something very similar to NDSparse; there is a function This is quite exciting; it seems all we need to do is pick a few common names. There are a few other fairly trivial API issues, e.g.
|
👍 Love it. I'm happy to change the names/strategy I've started with, as common ground is precious and multiple heads hammering out design even moreso.
I always worry about what happens if someone does |
As it happens, For things like |
This is where the word Data in NDSparseData may help signal that it does not follow array rules. |
just worth saying that the original implementation of sparse |
That's fine for matrices but doesn't make sense when your domain is "strings" or "version numbers" or "dollar values". |
Yes, that's why I say a SparseMatrixCSC is not really sparse --- it's a dense matrix with clever storage. |
or that there is a linear algebra point of view and a container point of view |
I'm simply claiming that some objects have a cartesian product of indices, and some don't. I'm fine with considering that interface totally separate from linear algebra --- for example you might have a linear operator that does't support indexing, and that's fine. We just want a common interface for things that do have these properties. |
The famous sparse paper was about sparse matrices. We are talking about sparse storage here - so yes containers vs. matrices. |
I don't really see what that concretely implies for what we're discussing here. I maintain that sparse matrices can be discussed in this framework. The fact is they implement the same interface as dense matrices: they have a number of rows and columns, and they have a value for each of MxN index positions. The same idea applies to containers. However, sparse matrices also contain an object |
Ok - I do agree with dense and sparse index spaces, and that is an idea that we can bring back into matrices as well. |
There are richer sets of sparse storage than |
I have nothing to add here apart from irrepressible enthusiasm. |
I'm fine with the idea of this not acting like a regular array, but of course if the goal is to design an API that is reasonably generic then that API needs to be designed with arrays also in mind. In other words, let's try to make things work for everyone. As soon as you think about arrays, many computations end up involving more than one array, and that makes life more interesting. For example, |
Would it make sense to think of |
I wrote up some thoughts on what it means to be an array: https://gist.github.com/JeffBezanson/24b9e2820262cdeb74f96b81534a4d1f The goal is to get the basics exactly right. It's mostly unsurprising, but there are a couple interesting implications. I think what's there would be enough to get AxisArrays, NDSparse, SparseMatrixCSC, and OffsetArrays on the same page. also cc @mbauman |
This is awesome. I posted some comments in the gist. |
Thanks. Reply posted --- I'm not sure if gist comments generate notifications. |
They don't seem to, so thanks for the ping. |
This is not really intuitive to me:
What we're doing now is converting
:
to a vector of all the unique indices in its dimension. This is trying to be consistent with dense arrays, where assignment operates on the product of the given indices. For example:This doesn't seem like the right thing for sparse arrays, but it's understandable. The colon behavior is much more surprising.
The text was updated successfully, but these errors were encountered: