Are you using 0.3 or 0.4? You could try making `SpatialData` a subtype of
`AbstractArray`. It's possible to do on either version, but it's
substantially easier to do on 0.4. Then you could use any of the methods
in base that are defined for `AbstractArray` (including `maximum`)
directly.
What I'm actually trying to do is create a type for spatial data:
typealias SpatialData Dict{Tuple{Integer,Integer,Integer},Real}
data = SpatialData([(i,j,k) = rand() for i=1:10, j=1:20, k=1:30])
However I need to do some checks on the size of the bounding box,
(10,20,30) in this case.
What
Hi Matt,
That is a very good suggestion! I'm using Julia 0.4, how would you retrieve
the locations from an AbstractArray?
immutable SpatialData : AbstractArray{Real,3} end
is all that is needed to define the type?
-Júlio
Are the 'unset' indices defined to have some value in your application? If
not, trying to shoehorn this into an `AbstractArray` probably won't work
very well. Also note that, while correct, using the methods in base will
be slow if you have very large and very sparse matrices.
In defining
Yes, unfortunately the unset values shouldn't be listed as 0 for instance.
I'll try move forward with my current implementation and see if the code is
ok.
Thanks,
-Júlio
This is reasonably clean:
[y[i] for y in x, i in 1:3]
If performance matters you are probably better off with the other
suggestions.
Den måndag 6 juli 2015 kl. 22:10:01 UTC+2 skrev Júlio Hoffimann:
Hi,
How to convert:
1000-element Array{Tuple{Integer,Integer,Integer},1}:
(10,2,1)
Hi Simon,
Thank you, will check it later.
-Júlio
You could do also try this, which does not introduce any overhead:
reinterpret(Int, tuple_array, (3, 1000))
But it only works with Julia 0.4 and I'm not sure if you would consider it
as clean.
Am Montag, 6. Juli 2015 16:10:01 UTC-4 schrieb Júlio Hoffimann:
Hi,
How to convert:
1000-element