-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test-spatial.R
errors if sf adds attributes to sf objects
#210
Comments
Another approach would be to set expect_equal(duke_df$stops[colnames(gtfs_duke$stops)], gtfs_duke$stops, tolerance = 0.0001, check.attributes = FALSE)
expect_equal(x1[,c("n_stop_ids", "dist_mean", "dist_median", "dist_max")],
x2[,c("n_stop_ids", "dist_mean", "dist_median", "dist_max")],
check.attributes = FALSE) |
Thanks for the heads up and the code to fix the issue. I used |
Closed
Thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi there!
As currently written,
test-spatial.R
is partially testing that the underlying sf object never changes. Specifically, these two tests (the last line of the code blocks) will throw errors if sf ever changes the attributes attached to sf objects:tidytransit/tests/testthat/test-spatial.R
Lines 94 to 99 in 878e64a
tidytransit/tests/testthat/test-spatial.R
Lines 147 to 158 in 878e64a
The issue is that by using
expect_equal()
, testthat is partially testing if your objects contain exactly the same attributes. That means you're partially testing internal implementation details of the sf object that aren't guaranteed to remain the same over time. There's a bit more about how testing the attributes of objects created by other packages can be a problem on the Tidyverse blog.At the moment, we're trying to add a new attribute to sf objects, which causes these tests to error. I'm writing to ask if you'd consider changing these tests to allow sf to improve the internal structure of sf objects.
Specifically, if I understand these tests correctly, I think you're testing to make sure that column values are equivalent after data transformations. Would you consider looping through to compare each of the columns, rather than comparing the data structure as a whole? The first test could be:
And the second test:
If you're open to it, I'd be happy to send you a PR to make these changes!
The text was updated successfully, but these errors were encountered: