Skip to content

Commit

Permalink
Fix potential bugs with format strings (#3633)
Browse files Browse the repository at this point in the history
Co-authored-by: Anshul Singhvi <[email protected]>
  • Loading branch information
ScottPJones and asinghvi17 committed Feb 17, 2024
1 parent 7d0d15c commit fe320c0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## [Unreleased]

- Fixed bugs with format strings and add new features by switching to Format.jl [#3633](https://github.com/MakieOrg/Makie.jl/pull/3633).
- Fixed an issue where CairoMakie would unnecessarily rasterize polygons [#3605](https://github.com/MakieOrg/Makie.jl/pull/3605).
- Added `PointBased` conversion trait to `scatterlines` recipe [#3603](https://github.com/MakieOrg/Makie.jl/pull/3603).

Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ FFMPEG_jll = "b22a6f82-2f65-5046-a5b2-351ab43fb4e5"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
FilePaths = "8fc22ac5-c921-52a6-82fd-178b2807b824"
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
Formatting = "59287772-0a20-5a39-b81b-1366585eb4c0"
Format = "1fa38f19-a742-5d3f-a2b9-30dd87b9d5f8"
FreeType = "b38be410-82b0-50bf-ab77-7b57e271db43"
FreeTypeAbstraction = "663a7486-cb36-511b-a19d-713bb74d65c9"
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
Expand Down Expand Up @@ -75,7 +75,7 @@ Downloads = "1, 1.6"
FileIO = "1.6"
FilePaths = "0.8"
FixedPointNumbers = "0.6, 0.7, 0.8"
Formatting = "0.4"
Format = "1.3"
FreeType = "3.0, 4.0"
FreeTypeAbstraction = "0.10"
GeometryBasics = "0.4.2"
Expand Down
2 changes: 1 addition & 1 deletion src/makielayout/MakieLayout.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Formatting
import Format
import Animations
using GridLayoutBase
using GridLayoutBase: GridSubposition
Expand Down
2 changes: 1 addition & 1 deletion src/makielayout/blocks/slidergrid.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function block_docs(::Type{SliderGrid})
and `label`, and optionally a `format` for the value label. Beyond that, you can set
any keyword that `Slider` takes, such as `startvalue`.
The `format` keyword can be a `String` with Formatting.jl style, such as "{:.2f}Hz", or
The `format` keyword can be a `String` with Format.jl style, such as "{:.2f}Hz", or
a function.
## Constructors
Expand Down
6 changes: 3 additions & 3 deletions src/makielayout/helpers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ Returns a `NamedTuple`:
`(slider = slider, label = label, valuelabel = valuelabel, layout = layout)`
Specify a format function for the value label with the `format` keyword or pass a format string used by `Formatting.format`.
Specify a format function for the value label with the `format` keyword or pass a format string used by `Format.format`.
The slider is forwarded the keywords from `sliderkw`.
The label is forwarded the keywords from `labelkw`.
The value label is forwarded the keywords from `valuekw`.
Expand Down Expand Up @@ -362,7 +362,7 @@ Returns a `NamedTuple`:
`(sliders = sliders, labels = labels, valuelabels = valuelabels, layout = layout)`
Specify format functions for the value labels with the `formats` keyword or pass format strings used by `Formatting.format`.
Specify format functions for the value labels with the `formats` keyword or pass format strings used by `Format.format`.
The sliders are forwarded the keywords from `sliderkw`.
The labels are forwarded the keywords from `labelkw`.
The value labels are forwarded the keywords from `valuekw`.
Expand Down Expand Up @@ -428,7 +428,7 @@ function apply_format(value, format)
end

function apply_format(value, formatstring::String)
Formatting.format(formatstring, value)
Format.format(formatstring, value)
end

Makie.get_scene(ax::Axis) = ax.scene
Expand Down
4 changes: 2 additions & 2 deletions src/makielayout/lineaxis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -662,9 +662,9 @@ get_ticklabels(formatfunction::Function, values) = formatfunction(values)
"""
get_ticklabels(formatstring::AbstractString, values)
Gets tick labels by formatting each value in `values` according to a `Formatting.format` format string.
Gets tick labels by formatting each value in `values` according to a `Format.format` format string.
"""
get_ticklabels(formatstring::AbstractString, values) = [Formatting.format(formatstring, v) for v in values]
get_ticklabels(formatstring::AbstractString, values) = [Format.format(formatstring, v) for v in values]

function get_ticks(m::MultiplesTicks, any_scale, ::Automatic, vmin, vmax)
dvmin = vmin / m.multiple
Expand Down
4 changes: 2 additions & 2 deletions src/makielayout/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ end
Common objects that can be used for tick formatting are:
- A `Function` that takes a vector of numbers and returns a vector of labels. A label can be anything
that can be plotted by the `text` primitive.
- A `String` which is used as a format specifier for `Formatting.jl`. For example, `"{:.2f}kg"`
- A `String` which is used as a format specifier for `Format.jl`. For example, `"{:.2f}kg"`
formats numbers rounded to 2 decimal digits and with the suffix `kg`.
"""
xtickformat = Makie.automatic
Expand Down Expand Up @@ -504,7 +504,7 @@ end
Common objects that can be used for tick formatting are:
- A `Function` that takes a vector of numbers and returns a vector of labels. A label can be anything
that can be plotted by the `text` primitive.
- A `String` which is used as a format specifier for `Formatting.jl`. For example, `"{:.2f}kg"`
- A `String` which is used as a format specifier for `Format.jl`. For example, `"{:.2f}kg"`
formats numbers rounded to 2 decimal digits and with the suffix `kg`.
"""
ytickformat = Makie.automatic
Expand Down

0 comments on commit fe320c0

Please sign in to comment.