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

Could probably dispatch on method for get_start_stop_indices #6

Open
ali-ramadhan opened this issue Sep 1, 2019 · 1 comment
Open

Comments

@ali-ramadhan
Copy link

Could probably dispatch on method if it was a type or via the Val type although I think the latter is discouraged.

juxta.jl/src/juxta.jl

Lines 89 to 109 in 7162bef

function get_start_stop_indices(dim_vector::Vector,
physical_start::Real,
physical_stop::Real,
method::String)
if method == "subset"
dim_vector_temp = dim_vector .- physical_start
start = findfirst(x -> x>=0, dim_vector_temp)
dim_vector_temp = dim_vector .- physical_stop
stop = findlast(x -> x<=0, dim_vector_temp)
if physical_start == physical_stop
return (stop, start)
end
elseif method == "nearest"
dim_vector_temp = abs.(dim_vector .- physical_start)
start = findmin(dim_vector_temp)[2]
dim_vector_temp = abs.(dim_vector .- physical_stop)
stop = findmin(dim_vector_temp)[2]
end
return (start, stop)
end

@beta-effect
Copy link
Owner

Could probably dispatch on method if it was a type

I am not sure how to do this. Please help.

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

No branches or pull requests

2 participants