-
-
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
Dimspec should include Range #1829
Comments
+1 for this. I would love to see this be added. I believe that |
Outside of indexing, : by itself is a singleton of type |
If we are going to include |
Why not just support anything that has The only thing that is missing right now, surprisingly, is scalars. |
I still rather object to making scalars iterable. This is a bad idea, imo, especially because it means something very different to iterate certain scalars, such as strings. |
It seems to me that your interface for strings already treats them as containers of characters, not as scalars. Making scalars iterable (with length
|
I have to say that I'm on board with the idea of a no-op |
It's true unfortunately; if scalars weren't iterable it would create nasty special cases in array indexing. In fact we would almost need to add an interface |
Ok, maybe this is fine. Let's give it a try. I guess it does jive with the idea of scalers as zero-dimensional tensors. |
Yes, having scalars iterable makes it a lot easier for indexing, which was also the context of earlier discussions. |
So, the proposal at this point is to add a Or is there some more general way to declare an arbitrary iterable container of |
|
Julia uses a type
Dimspec
to define sets of dimensions for things likesum(A, dims)
, currently defined astypealias Dimspec Union(Int,Dims)
whereDims
istypealias Dims (Int...)
.I have been playing with this (for #1805), and it seems like it would be very convenient to have
Dimspec
includeRange{Int}
as well.For example, this would allow you to do things like
sum(x, 1:ndims(x)-1)
to sum over all but the last dimension ofx
. Currently, in order to do this you need something likesum(x, ntuple(ndims(x)-1, i -> i))
, which is rather ugly. I keep running into cases like this.It would also be nice for
sum(x, :)
to be equivalent tosum(x)
(and similarly for other functions acceptingDimspec
types). I don't really grok how:
by itself works in Julia right now, though.The text was updated successfully, but these errors were encountered: