Skip to content

Commit

Permalink
Merge pull request #41 from barche/missing
Browse files Browse the repository at this point in the history
Support missing values
  • Loading branch information
jw3126 authored Feb 16, 2021
2 parents 6d94473 + b066a28 commit 4154d53
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "UnitfulRecipes"
uuid = "42071c24-d89e-48dd-8a24-8a12d9b8861f"
authors = ["Benoit Pasquier", "Jan Weidner"]
version = "1.0.1"
version = "1.0.2"

[deps]
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Expand Down
14 changes: 7 additions & 7 deletions src/UnitfulRecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export @P_str
Main recipe
==========#

@recipe function f(::Type{T}, x::T) where T <: AbstractArray{<:Quantity}
@recipe function f(::Type{T}, x::T) where T <: AbstractArray{<:Union{Missing,<:Quantity}}
axisletter = plotattributes[:letter] # x, y, or z
fixaxis!(plotattributes, x, axisletter)
end
Expand Down Expand Up @@ -50,25 +50,25 @@ const AMat{T} = AbstractArray{T,2} where T
end

# Recipe for vectors of vectors
@recipe function f(::Type{T}, x::T) where T <: AbstractVector{<:AbstractVector{<:Quantity}}
@recipe function f(::Type{T}, x::T) where T <: AbstractVector{<:AbstractVector{<:Union{Missing,<:Quantity}}}
axisletter = plotattributes[:letter] # x, y, or z
[fixaxis!(plotattributes, x, axisletter) for x in x]
end

# Recipes for functions
@recipe function f(f::Function, x::T) where T <: AVec{<:Quantity}
@recipe function f(f::Function, x::T) where T <: AVec{<:Union{Missing,<:Quantity}}
x, f.(x)
end
@recipe function f(x::T, f::Function) where T <: AVec{<:Quantity}
@recipe function f(x::T, f::Function) where T <: AVec{<:Union{Missing,<:Quantity}}
x, f.(x)
end
@recipe function f(x::T, y::AVec, f::Function) where T <: AVec{<:Quantity}
@recipe function f(x::T, y::AVec, f::Function) where T <: AVec{<:Union{Missing,<:Quantity}}
x, y, f.(x',y)
end
@recipe function f(x::AVec, y::T, f::Function) where T <: AVec{<:Quantity}
@recipe function f(x::AVec, y::T, f::Function) where T <: AVec{<:Union{Missing,<:Quantity}}
x, y, f.(x',y)
end
@recipe function f(x::T1, y::T2, f::Function) where {T1<:AVec{<:Quantity}, T2<:AVec{<:Quantity}}
@recipe function f(x::T1, y::T2, f::Function) where {T1<:AVec{<:Union{Missing,<:Quantity}}, T2<:AVec{<:Union{Missing,<:Quantity}}}
x, y, f.(x',y)
end

Expand Down
8 changes: 8 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,11 @@ end
@test yguide(plt,1) == "m"
@test yguide(plt,2) == "s"
end

@testset "Missing values" begin
x = 1:5
y = [1.0*u"s", 2.0*u"s", missing, missing, missing]
@show typeof(y)
plt = plot(x,y)
@test yguide(plt,1) == "s"
end

2 comments on commit 4154d53

@jw3126
Copy link
Owner Author

@jw3126 jw3126 commented on 4154d53 Feb 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/30139

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v1.0.2 -m "<description of version>" 4154d53eaa212d0775eba8ae0add94d71963eab9
git push origin v1.0.2

Please sign in to comment.