Skip to content

Using withr::with_seed does not propagate to ggrepel::geom_label_repel seed by default #161

@radlinsky

Description

@radlinsky

This is more of an FYI and question than an issue because I solved it.. it confused me for a solid few hours.. similarly to #97 when I snapshot_review, my plots looked identical by eye, but the log showed very subtle differences. Spot the difference?

< before                                                                       
> after                                                                        
@@ 40,5 / 40,5 @@                                                              
  <circle cx='261.35' cy='114.31' r='8.71' style='stroke-width: 0.35;' />      
  <line x1='261.35' y1='93.46' x2='261.35' y2='113.23' style='stroke-width: 1.07
  ; stroke: #868686; stroke-opacity: 0.70; stroke-dasharray: 1.42,4.27;' />    
< <polygon points='246.86,93.46 275.84,93.46 275.76,93.46 276.10,93.45 276.44,93
: .38 276.77,93.25 277.07,93.08 277.34,92.86 277.57,92.60 277.75,92.31 277.89,91
: .99 277.97,91.65 278.00,91.30 278.00,91.30 278.00,82.55 278.00,82.55 277.97,82
: .20 277.89,81.86 277.75,81.55 277.57,81.25 277.34,80.99 277.07,80.77 276.77,80
: .60 276.44,80.47 276.10,80.40 275.84,80.39 246.86,80.39 247.12,80.40 246.77,80
: .39 246.43,80.43 246.09,80.53 245.78,80.68 245.49,80.88 245.24,81.12 245.03,81
: .39 244.87,81.70 244.76,82.03 244.71,82.38 244.70,82.55 244.70,91.30 244.71,91
: .13 244.71,91.48 244.76,91.82 244.87,92.15 245.03,92.46 245.24,92.74 245.49,92
: .98 245.78,93.17 246.09,93.32 246.43,93.42 246.77,93.46 ' style='stroke-width:
:  0.53; stroke: #000000; stroke-opacity: 0.70; fill: #FF8000; fill-opacity: 0.7
: 0;' />                                                                       
> <polygon points='246.86,93.46 275.84,93.46 275.75,93.46 276.10,93.45 276.44,93
: .38 276.77,93.25 277.07,93.08 277.34,92.86 277.57,92.60 277.75,92.31 277.89,91
: .99 277.97,91.65 278.00,91.30 278.00,91.30 278.00,82.55 278.00,82.55 277.97,82
: .20 277.89,81.86 277.75,81.55 277.57,81.25 277.34,80.99 277.07,80.77 276.77,80
: .60 276.44,80.47 276.10,80.40 275.84,80.39 246.86,80.39 247.12,80.40 246.77,80
: .39 246.42,80.43 246.09,80.53 245.78,80.68 245.49,80.88 245.24,81.12 245.03,81
: .39 244.87,81.70 244.76,82.03 244.70,82.38 244.70,82.55 244.70,91.30 244.70,91
: .13 244.70,91.48 244.76,91.82 244.87,92.15 245.03,92.46 245.24,92.74 245.49,92
: .98 245.78,93.17 246.09,93.32 246.42,93.42 246.77,93.46 ' style='stroke-width:
:  0.53; stroke: #000000; stroke-opacity: 0.70; fill: #FF8000; fill-opacity: 0.7
: 0;' />                                                                       
  <text x='261.35' y='89.86' text-anchor='middle' style='font-size: 8.54px; fill
  : #000000; fill-opacity: 0.70; font-family: sans;' textLength='26.10px' length
  Adjust='spacingAndGlyphs'>chr1#4</text>                                      
  </g>                                                                         

Third set of points 275.76,93.46 vs 275.75,93.46

In my unit test, I was wrapping plot generation with withr::with_seed so I expected identical plots. However, the plot generation included ggrepel::geom_label_repel which ignores seeds by default. After I set geom_text_repel seed manually, then the plots do generate identically, and vdiffr passes.

@lionel- what about adding an option to do some kind of rounding to allow for very slight differences like this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions