Skip to content
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

Add findall_window #225

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Add findall_window #225

wants to merge 1 commit into from

Conversation

timholy
Copy link
Member

@timholy timholy commented Sep 3, 2021

Continued from #223

Closes #224

@timholy timholy marked this pull request as draft September 3, 2021 09:34
@codecov
Copy link

codecov bot commented Sep 3, 2021

Codecov Report

Attention: Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.

Project coverage is 90.29%. Comparing base (02407fa) to head (7179644).
Report is 23 commits behind head on master.

Files with missing lines Patch % Lines
src/findall_window.jl 0.00% 22 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #225      +/-   ##
==========================================
- Coverage   91.60%   90.29%   -1.32%     
==========================================
  Files          11       12       +1     
  Lines        1513     1535      +22     
==========================================
  Hits         1386     1386              
- Misses        127      149      +22     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@timholy timholy mentioned this pull request Sep 4, 2021
@johnnychen94
Copy link
Member

I haven't checked it very carefully, but maybe this is related to the performance gap to findlocalmaxima

function sum_window_mean_ver1(X)
    out = zero(float(eltype(X)))
    R = CartesianIndices(X)
    Δ = oneunit(eltype(R))
    @inbounds @simd for p in R
        window = max(p-Δ, first(R)):min(p+Δ, last(R))
        out += mean(view(X, window))
    end
    return out
end

function sum_window_mean_ver2(X)
    out = zero(float(eltype(X)))
    R = CartesianIndices(X)
    Δ = oneunit(eltype(R))
    @inbounds @simd for p in R
        window = max(p-Δ, first(R)):min(p+Δ, last(R))
        mean_val = zero(eltype(out))
        for q in window
            mean_val += X[q]
        end
        out += mean_val/length(window)
    end
    return out
end
julia> @btime sum_window_mean_ver1($X);
  164.748 μs (0 allocations: 0 bytes)
julia> @btime sum_window_mean_ver2($X)
  64.137 μs (0 allocations: 0 bytes)

@timholy
Copy link
Member Author

timholy commented Sep 13, 2021

Did you try creating your own mean function in case it's something about the one in Statistics?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

introduce a findall version of mapwindow
2 participants