FWIW, I came up with the following snippet to get the behavior that I want:
const nchans = size(userData.samples, 2)
const samples = sub(userData.samples, tuple(rng, ntuple(nchans - 1, _
->:)...))
It appears to work.
On Sunday, February 1, 2015 at 8:38:09 PM UTC-5, Tim Holy wrote:
>
> SubArrays have been entirely rewritten in 0.4, and can do quite a few
> tricks
> that the old ones can't. Changing the dimensionality of the view compared
> to
> the parent, as in your example, is one of them. Here's another example of
> something you simply can't do on 0.3:
>
> julia> A = reshape(1:15, 3, 5)
> 3x5 Array{Int64,2}:
> 1 4 7 10 13
> 2 5 8 11 14
> 3 6 9 12 15
>
> julia> b = sub(A, [2, 7, 8])
> 3-element SubArray{Int64,1,Array{Int64,2},(Array{Int64,1},),0}:
> 2
> 7
> 8
>
> julia> b[2] = -1
> -1
>
> julia> A
> 3x5 Array{Int64,2}:
> 1 4 -1 10 13
> 2 5 8 11 14
> 3 6 9 12 15
>
> If anything, the divergence between the two will grow further once
> https://github.com/JuliaLang/julia/issues/9874 is addressed.
>
> Best,
> --Tim
>
> On Sunday, February 01, 2015 12:02:56 PM Daniel Casimiro wrote:
> > Hi,
> >
> > I noticed that the "sub" function behaves differently in master and
> version
> > 0.3.5, when handling data of type Array{Float64, 1}. I am not sure if
> the
> > change is intentional.
> >
> > The following works as expected on Julia master:
> >
> > *julia>* *sub([1.0; 2; 3; 4], 1:3, :)*
> >
> > but, fails in version 0.3.5 with the following error:
> > > *ERROR: `sub` has no method matching sub(::Array{Float64,1},
> > >
> > > ::(UnitRange{Int64},UnitRange{Int64}))*
> > >
> > > * in sub at subarray.jl:80** in sub at subarray.jl:132*
> >
> > Is this a bug in Julia 0.3.5 or master?
> >
> > This came up in this pull request:
> > https://github.com/dancasimiro/WAV.jl/pull/20. I just figured out that
> my
> > "fix" is broken too.
> >
> > Thanks.
>
>