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

Lookup conversion helper functions #807

Closed
alex-s-gardner opened this issue Sep 20, 2024 · 3 comments
Closed

Lookup conversion helper functions #807

alex-s-gardner opened this issue Sep 20, 2024 · 3 comments
Labels
enhancement New feature or request

Comments

@alex-s-gardner
Copy link
Contributor

I find myself needing the utility of these three lookup helper functions contained in GeoMakie and I'm wondering if it would make sense to bring these over to DD:

function _lookup_to_vector(l)
if isintervals(l)
bs = intervalbounds(l)
x = first.(bs)
push!(x, last(last(bs)))
else # ispoints(l)
collect(parent(l))
end
end
function _lookup_to_vertex_vector(l)
if isintervals(l)
return parent(DD.shiftlocus(DD.Center(), l))
else # ispoints(l)
return collect(parent(l))
end
end
function _lookup_to_interval(l)
# TODO: warn or error if not regular sampling.
# Maybe use Preferences.jl to determine if we should error or warn.
l1 = if isnolookup(l)
Sampled(parent(l); order=ForwardOrdered(), sampling=Intervals(Center()), span=Regular(1))
elseif ispoints(l)
set(l, Intervals()) # this sets the intervals to be `Intervals(Center())` by default. Same as heatmap behaviour.
else # isintervals(l)
l
end
return IntervalSets.Interval(bounds(l1)...)
end

@rafaqz rafaqz added the enhancement New feature or request label Nov 2, 2024
@rafaqz
Copy link
Owner

rafaqz commented Nov 5, 2024

These are very Makie specific things, the vector length is length(lookup) + 1 because Makie wants that. And the vertex is because Makie specifically wants center points.

I don't think we can export these as general use functions.

@rafaqz rafaqz closed this as completed Nov 5, 2024
@asinghvi17
Copy link
Collaborator

I would say that edgevector on at least Regular and Irregular lookups would be valuable for histograms etc?

@rafaqz
Copy link
Owner

rafaqz commented Nov 5, 2024

Maybe, I'm not sure it's worth the extra function when we have intervalbounds already

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

No branches or pull requests

3 participants