Skip to content
This repository has been archived by the owner on Oct 21, 2022. It is now read-only.

Support segments #120

Closed
wants to merge 2 commits into from
Closed

Conversation

AlexRobson
Copy link

@AlexRobson AlexRobson commented Sep 3, 2022

In Plots at some point there was a switch in how representing how segments were handled going from:

[1.0, 1.0, NaN, 1.0, 1.0, NaN, 1.0, 1.0, NaN]

To:

[[1.0, 1.0], [1.0, 1.0], [1.0, 1.0]]

In Intervals, recipes are used to plot the segments for each Interval. So these segments look like:

[[DateTime("2017-01-01T00:00:00"), DateTime("2017-01-01T01:00:00")], [DateTime("2017-01-01T01:00:00"), DateTime("2017-01-01T02:00:00")]

I have an MR that updated that, however I've found that it was not working when using such DateTime types. I believe the issue is here. I'm not too sure on the internals of the package, but I believe that we need to add these methods, and top of these original recipes:

@recipe f(::Type{DateTime}, dt::DateTime) = # Existing 
    (dt -> Dates.value(dt), datetimeformatter)
@recipe f(::Type{Vector{T}}, dt::Vector{T}) where {T<:DateTime} = 
    (dt -> Dates.value.(dt), datetimeformatter) # New method

This MR simply adds these. Testing with my branch in Intervals, this does create the correct plots. It is unclear whether additional tests are needed, as it looks like this uses a test suite from Plots.

Related:
invenia/Intervals.jl#159


EDIT: Closing this. I've misunderstood the workings of the package here.

@AlexRobson AlexRobson changed the title Support segments Draft: Support segments Sep 3, 2022
@AlexRobson AlexRobson changed the title Draft: Support segments Support segments Sep 3, 2022
@AlexRobson AlexRobson closed this Sep 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant