plotly failures with dev rlang
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 55/100
- Issue-Typ
- Bug
- Klarheit
- Größtenteils klar
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- r
- Bereich
- data-visualization, testing
Rechercherichtung
Der Fehler wird durch tests/testthat/test-ggplot-legend.R abgedeckt, und Guide-Titel werden in ggplotly.R ungefähr in den Zeilen 1071-1072 zusammengesetzt. Führe zunächst den fehlschlagenden Test mit der dev-Version von rlang aus und untersuche, wie die Reihenfolge der Guides bestimmt wird. Erledigt ist die Aufgabe, wenn der Test für den Legend titel unter der aktualisierten rlang-Version mit deterministischer Reihenfolge erfolgreich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
I'm seeing failures for plotly with dev rlang:
Running ‘testthat.R’
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
> library("testthat")
> library("plotly")
Loading required package: ggplot2
Attaching package: 'plotly'
The following object is masked from 'package:ggplot2':
...
Expected `legend_title` to match regexp "factor\\(cyl\\)$".
Actual text:
✖ │ factor(cyl)<br />factor(vs)
[ FAIL 2 | WARN 23 | SKIP 63 | PASS 1449 ]
Deleting unused snapshots: 'ggplot-contour/contour.svg' and
'ggplot-heatmap/heatmap.svg'
Error:
! Test failures.
Execution halted
Claude traced this to rlang::hash() producing different hashes in the new version (which was deliberate to fix other stability issues see https://github.com/r-lib/rlang/issues/1681#issuecomment-4267291605):
The chain is:
1. rlang dev changed hash() values (commit 229db8154 — "Stable hash()"). The NEWS says: "with this version all hash values will now be different". This is intentional for cross-R-version
stability.
2. ggplot2's Guides$merge sorts by hash. In Guides$merge(), each guide gets a key {order}_{hash} and then split(pairs, hashes) is called. R's split() returns groups in alphabetical order
of factor levels. So the final guide order depends on the alphabetical sort of the hash strings.
3. plotly concatenates guide titles in order. At ggplotly.R:1071-1072:
legendTitles <- compact(lapply(gdefs, function(g) if (inherits(g, "legend")) g$title else NULL))
legendTitle <- paste(legendTitles, collapse = br())
4. The plotly test asserts a specific order (test-ggplot-legend.R:32-33):
expect_match(legend_title, "^factor\\(vs\\)") # vs first
expect_match(legend_title, "factor\\(cyl\\)$") # cyl last
With CRAN rlang, the hashes sort as 99_124c... (vs) < 99_4d3... (cyl) → title = factor(vs)<br />factor(cyl).
With dev rlang, the hashes sort as 99_aefe... (cyl) < 99_ebf7... (vs) → title = factor(cyl)<br />factor(vs).
I've talked to the ggplot2 maintainers and they recommend using the order argument to make guide placement deterministic. Claude also suggests this fix (unverified):
diff --git a/tests/testthat/test-ggplot-legend.R b/tests/testthat/test-ggplot-legend.R
index 9dd92ea..d1d97e5 100644
--- a/tests/testthat/test-ggplot-legend.R
+++ b/tests/testthat/test-ggplot-legend.R
@@ -29,8 +29,8 @@ test_that("Discrete colour and shape get merged into one legend", {
nms, paste0("(", d$vs, ",", d$cyl, ")")
)
legend_title <- info$layout$legend$title$text
- expect_match(legend_title, "^factor\\(vs\\)")
- expect_match(legend_title, "factor\\(cyl\\)$")
+ expect_match(legend_title, "factor\\(vs\\)")
+ expect_match(legend_title, "factor\\(cyl\\)")
})
As a heads up, I'm planning to release this rlang update within the next two weeks.
- Vorherrschende Sprache
- R
- Sterne
- 2.7k
- Forks
- 641
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus plotly/plotly.R
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 35/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 72/100
-
save_image Error Offen
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 52/100
Alle Issues in plotly/plotly.R
Ähnliche Issues
-
documentation pkg infrastructure
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
epiverse-trace/epiparameter#511 ·
-
function:write_dwc
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
-
Urgent request: Due to vulnerabilities move to API version 12.6.1 (12.6.2 eventually) or 13.1.1 Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
jbkunst/highcharter#849 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
r-lib/pkgdepends#485 · 3 Kommentare ·
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 92/100