Skip to content

Commit

Permalink
Fix String -> AbstractString (#35)
Browse files Browse the repository at this point in the history
* Fix String -> AbstractString

* Fix docs
  • Loading branch information
briochemc authored Jan 6, 2021
1 parent 386112f commit b32dabd
Show file tree
Hide file tree
Showing 3 changed files with 8 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.0"
version = "1.0.1"

[deps]
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Expand Down
2 changes: 1 addition & 1 deletion docs/lit/examples/2_Plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ y = rand(20, 3)*u"W"
x = (1:size(y,1))*u"Hz"
plot(x, y, xlabel="XLABEL", xlims=(-5, 30), xflip=true, xticks=0:2:20, background_color=RGB(0.2, 0.2, 0.2), leg=false)
hline!(mean(y, dims=1) + rand(1, 3)*u"W", line=(4, :dash, 0.6, [:lightgreen :green :darkgreen]))
vline!([5, 10]*u"W") # this is a current Plots v1.0.3 bug. Should be Hz
vline!([5, 10]*u"Hz")
title!("TITLE")
yaxis!("YLABEL", :log10)

Expand Down
12 changes: 6 additions & 6 deletions src/UnitfulRecipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,11 @@ Label string containing unit information
=======================================#

abstract type AbstractProtectedString <: AbstractString end
struct ProtectedString <: AbstractProtectedString
content::String
struct ProtectedString{S} <: AbstractProtectedString
content::S
end
struct UnitfulString{U} <: AbstractProtectedString
content::String
struct UnitfulString{S,U} <: AbstractProtectedString
content::S
unit::U
end
# Minimum required AbstractString interface to work with Plots
Expand Down Expand Up @@ -161,9 +161,9 @@ append_unit_if_needed!(attr, key, label::UnitfulString, u) = nothing
function append_unit_if_needed!(attr, key, label::Nothing, u)
attr[key] = UnitfulString(string(u), u)
end
function append_unit_if_needed!(attr, key, label::String, u)
function append_unit_if_needed!(attr, key, label::S, u) where {S <: AbstractString}
if label ""
attr[key] = UnitfulString(string(label, " (", u, ")"), u)
attr[key] = UnitfulString(S(string(label, " (", u, ")")), u)
end
end

Expand Down

2 comments on commit b32dabd

@briochemc
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@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/27542

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.1 -m "<description of version>" b32dabd823f777b737c09f9acffa1cc112c4d2b8
git push origin v1.0.1

Please sign in to comment.