vdiffr
vdiffr copied to clipboard
arm64 rounding problem
linked to https://github.com/tidyverse/ggplot2/issues/5110
I found out in the ggplot2 test a problem with rounding for the arm64 machine for the vdiffr
test (vdiffr::expect_doppelganger
).
One of the coordinates is not properly rounded x="0.000000000000064"
instead of x='0.00'
.
As the function vdiffr:::write_svg
is based on the C code, it is not surprising to me.
Minimal example the ggplot2 test.
library(ggplot2)
df <- data.frame(x = 1:3, y = 1:3, z = c("a", "b", "a"), a = 1)
plot <- ggplot(df, aes(x, y, colour = z)) +
geom_point() +
facet_wrap(~ a) +
theme_bw(base_size = 33)
High level:
capt <- capture.output(
vdiffr::expect_doppelganger("theme_bw_large", plot),
type = "message"
)
readLines(trimws(capt[4]))[21]
# <rect x='0.000000000000064' y='0.00' width='720.00' height='576.00' style='stroke-width: 3.20; stroke: #FFFFFF; fill: #FFFFFF;' />
Low level.
temp_svg <- tempfile(fileext = ".svg")
# use vdiffr:::svglite_ which use the C _vdiffr_svglite_
vdiffr:::write_svg(plot, temp_svg)
readLines(temp_svg)[21]
# <rect x='0.000000000000064' y='0.00' width='720.00' height='576.00' style='stroke-width: 3.20; stroke: #FFFFFF; fill: #FFFFFF;' />
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#> setting value
#> version R version 4.2.2 (2022-10-31)
#> os macOS Ventura 13.0
#> system aarch64, darwin20
#> ui X11
#> language (EN)
#> collate en_US.UTF-8
#> ctype en_US.UTF-8
#> tz Europe/Warsaw
#> date 2022-12-18
#> pandoc 2.18 @ /Applications/RStudio.app/Contents/MacOS/quarto/bin/tools/ (via rmarkdown)
#>
#> ─ Packages ───────────────────────────────────────────────────────────────────
#> package * version date (UTC) lib source
#> cli 3.4.1 2022-09-23 [1] CRAN (R 4.2.0)
#> digest 0.6.30 2022-10-18 [1] CRAN (R 4.2.0)
#> evaluate 0.18 2022-11-07 [1] CRAN (R 4.2.2)
#> fastmap 1.1.0 2021-01-25 [1] CRAN (R 4.2.0)
#> fs 1.5.2 2021-12-08 [1] CRAN (R 4.2.0)
#> glue 1.6.2 2022-02-24 [1] CRAN (R 4.2.0)
#> highr 0.9 2021-04-16 [1] CRAN (R 4.2.0)
#> htmltools 0.5.3.9002 2022-11-23 [1] Github (rstudio/htmltools@39b3f1f)
#> knitr 1.40 2022-08-24 [1] CRAN (R 4.2.0)
#> lifecycle 1.0.3 2022-10-07 [1] CRAN (R 4.2.0)
#> magrittr 2.0.3 2022-03-30 [1] CRAN (R 4.2.0)
#> purrr 0.3.5 2022-10-06 [1] CRAN (R 4.2.0)
#> R.cache 0.16.0 2022-07-21 [1] CRAN (R 4.2.0)
#> R.methodsS3 1.8.2 2022-06-13 [1] CRAN (R 4.2.0)
#> R.oo 1.25.0 2022-06-12 [1] CRAN (R 4.2.0)
#> R.utils 2.12.1 2022-10-30 [1] CRAN (R 4.2.0)
#> reprex 2.0.2 2022-08-17 [1] CRAN (R 4.2.0)
#> rlang 1.0.6 2022-09-24 [1] CRAN (R 4.2.0)
#> rmarkdown 2.17 2022-10-07 [1] CRAN (R 4.2.0)
#> rstudioapi 0.14 2022-08-22 [1] CRAN (R 4.2.0)
#> sessioninfo 1.2.2 2021-12-06 [1] CRAN (R 4.2.0)
#> stringi 1.7.8 2022-07-11 [1] CRAN (R 4.2.0)
#> stringr 1.4.1 2022-08-20 [1] CRAN (R 4.2.0)
#> styler 1.8.1 2022-11-07 [1] CRAN (R 4.2.2)
#> withr 2.5.0 2022-03-03 [1] CRAN (R 4.2.0)
#> xfun 0.34 2022-10-18 [1] CRAN (R 4.2.0)
#> yaml 2.3.6 2022-10-18 [1] CRAN (R 4.2.0)
#>
#> [1] /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/library
#>
#> ──────────────────────────────────────────────────────────────────────────────
Created on 2022-12-18 with reprex v2.0.2