running does not work for Matrix
Opened this issue · 2 comments
jerlich commented
MWE:
using RollingFunctions
f(x,y) = sum((x.-y).^2)
running(f, rand(1000), rand(1000), 10) # works!
running(f, rand(2,1000), 10) # error
ERROR: UndefVarError: `data` not defined
Stacktrace:
[1] basic_running(window_fn::typeof(f), data1::Matrix{Float64}, window_span::Int64)
@ RollingFunctions ~/.julia/dev/RollingFunctions/src/run/runmatrix.jl:17
[2] #running#72
@ ~/.julia/dev/RollingFunctions/src/run/run.jl:41 [inlined]
[3] running(window_fn::typeof(f), data1::Matrix{Float64}, window_span::Int64)
@ RollingFunctions ~/.julia/dev/RollingFunctions/src/run/run.jl:38
[4] top-level scope
@ REPL[10]:1
I checked the code to see if it was a quick fix, but when i change data
to data1
it sometimes worked and sometimes sig faulted.
That was on a Mac M1. Checking on linux intel.
jerlich commented
On linux i get the same.
❯ git diff (base)
diff --git a/src/run/runmatrix.jl b/src/run/runmatrix.jl
index b13fd660..3aaeb0f2 100644
--- a/src/run/runmatrix.jl
+++ b/src/run/runmatrix.jl
@@ -14,7 +14,7 @@ function basic_running(window_fn::Function, data1::AbstractMatrix{T}, window_spa
ntapers = n - nvalues
rettype = rts(window_fn, (Vector{T},))
- results = Matrix{rettype}(undef, size(data))
+ results = Matrix{rettype}(undef, size(data1))
@inbounds for idx in 1:ntapers
@views results[idx] = window_fn(ᵛʷdata1[1:idx])
@@ -22,7 +22,7 @@ function basic_running(window_fn::Function, data1::AbstractMatrix{T}, window_spa
ilow, ihigh = 1, window_span
@inbounds for idx in ntapers+1:n
- @views results[idx, :] .= map(window_fn, eachcol(ᵛʷdata[ilow:ihigh, :]))
+ @views results[idx, :] .= map(window_fn, eachcol(ᵛʷdata1[ilow:ihigh, :]))
ilow = ilow + 1
ihigh = ihigh + 1
end
This results in
julia> running(f, rand(2,1000),10)
free(): invalid size
[168045] signal (6.-6): Aborted
in expression starting at none:0
pthread_kill at /lib/x86_64-linux-gnu/libc.so.6 (unknown line) raise at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
abort at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
unknown function (ip: 0x71abb2289675)
unknown function (ip: 0x71abb22a0cfb)
unknown function (ip: 0x71abb22a2a53)
free at /lib/x86_64-linux-gnu/libc.so.6 (unknown line)
_ZN4llvm13LazyValueInfo13releaseMemoryEv.part.348 at /home/jerlich/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu/bi
n/../lib/julia/libLLVM-15jl.so (unknown line)
_ZN4llvm6detail19AnalysisResultModelINS_8FunctionENS_17LazyValueAnalysisENS_13LazyValueInfoENS_17PreservedAnalyse
sENS_15AnalysisManagerIS2_JEE11InvalidatorELb1EED0Ev at /home/jerlich/.julia/juliaup/julia-1.10.4+0.x64.linux.gnu
/bin/../lib/julia/libLLVM-15jl.so (unknown line)
_ZN4llvm15AnalysisManagerINS_8FunctionEJEE10invalidateERS1_RKNS_17PreservedAnalysesE at /home/jerlich/.julia/juli
aup/julia-1.10.4+0.x64.linux.gnu/bin/../lib/julia/libLLVM-15jl.so (unknown line)
_ZN4llvm11PassManagerINS_8FunctionENS_15AnalysisManagerIS1_JEEEJEE3runERS1_RS3_ at /home/jerlich/.julia/juliaup/j
ulia-1.10.4+0.x64.linux.gnu/bin/../lib/julia/libLLVM-15jl.so (unknown line)
malloc(): unaligned tcache chunk detected
fish: Job 1, 'julia --project=.' terminated by signal SIGABRT (Abort)
JeffreySarnoff commented
Thank you for the information. I have no immediate recollection of that code, but will take a look.