tests/testthat/test-stream-field-undefined-seed.R

test_that("an undefined seed does not blank the stream layer", {
  # with n = 5 on [-2, 2]^2, two of the 25 seeds sit on the charges at
  # (-1, -1) and (1, 1), where the field is undefined
  for (normalize in c(TRUE, FALSE)) {
    p <- ggplot() +
      geom_stream_field(
        fun = efield_maker(), xlim = c(-2, 2), ylim = c(-2, 2), n = 5,
        normalize = normalize
      )

    expect_no_warning(d <- layer_data(p))
    expect_equal(length(unique(d$group)), 23)
  }
})

Try the ggvfields package in your browser

Any scripts or data that you put into this service are public.

ggvfields documentation built on Nov. 16, 2026, 1:06 a.m.