FeatureTransforms.jl
FeatureTransforms.jl copied to clipboard
Cannot mutate rows / columns in isolation
MWE
julia> M = reshape(1:9, 3, 3);
julia> p = Power(3);
julia> FeatureTransforms.apply(M, p; dims=1, inds=1)
3-element Vector{Int64}:
1
64
343
julia> FeatureTransforms.apply!(M, p; dims=1, inds=1)
ERROR: indexed assignment fails for a reshaped range; consider calling collect
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:33
[2] _rs_setindex!_err()
@ Base ./reshapedarray.jl:279
[3] setindex!(A::Base.ReshapedArray{Int64, 2, UnitRange{Int64}, Tuple{}}, val::Int64, index::Int64)
@ Base ./reshapedarray.jl:275
[4] setindex!
@ ./subarray.jl:335 [inlined]
[5] macro expansion
@ ./multidimensional.jl:903 [inlined]
[6] macro expansion
@ ./cartesian.jl:64 [inlined]
[7] _unsafe_setindex!
@ ./multidimensional.jl:898 [inlined]
[8] _setindex!
@ ./multidimensional.jl:887 [inlined]
[9] setindex!(A::SubArray{Int64, 1, Base.ReshapedArray{Int64, 2, UnitRange{Int64}, Tuple{}}, Tuple{Int64, Base.Slice{Base.OneTo{Int64}}}, true}, v::Vector{Int64}, I::Function)
@ Base ./abstractarray.jl:1267
[10] apply!(A::Base.ReshapedArray{Int64, 2, UnitRange{Int64}, Tuple{}}, t::Power; dims::Int64, inds::Int64, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
@ FeatureTransforms ~/.julia/dev/FeatureTransforms/src/apply.jl:60
[11] top-level scope
@ REPL[23]:1
I wonder should FeatureTransforms.apply(M, p; dims=1, inds=1) return the full array in the first place? I think that would solve it.