tests: add edge-case tests for fill() and drop_na() with Date, POSIXct, factor, and empty data frames#1642
Closed
LeonidasZhak wants to merge 2 commits into
Closed
Conversation
…empty data Add 7 new test blocks covering: - Factor columns and vectors preserving levels after NA replacement - Empty data frame returns unchanged - All-NA data frame fully replaced - Date column NA replacement - POSIXct column NA replacement
…t, factor, and empty data frames fill(): - Date columns (down and up) - POSIXct columns - Factor level preservation (not just attributes) - .by group boundaries on Date columns - 0-row data frames drop_na(): - Factor columns (levels preserved) - Date columns - POSIXct columns - 0-row data frames (grouped and ungrouped) - All-NA data frames
| df <- tibble(x = as.Date(c("2020-01-01", NA, "2020-01-03", NA))) | ||
|
|
||
| out <- fill(df, x) | ||
| expect_equal(out$x, as.Date(c("2020-01-01", "2020-01-01", "2020-01-03", "2020-01-03"))) |
Contributor
There was a problem hiding this comment.
[air] reported by reviewdog 🐶
Suggested change
| expect_equal(out$x, as.Date(c("2020-01-01", "2020-01-01", "2020-01-03", "2020-01-03"))) | |
| expect_equal( | |
| out$x, | |
| as.Date(c("2020-01-01", "2020-01-01", "2020-01-03", "2020-01-03")) | |
| ) |
| out <- fill(df, x) | ||
| expect_equal( | ||
| out$x, | ||
| as.POSIXct(c("2020-01-01 10:00", "2020-01-01 10:00", "2020-01-03 12:00", "2020-01-03 12:00")) |
Contributor
There was a problem hiding this comment.
[air] reported by reviewdog 🐶
Suggested change
| as.POSIXct(c("2020-01-01 10:00", "2020-01-01 10:00", "2020-01-03 12:00", "2020-01-03 12:00")) | |
| as.POSIXct(c( | |
| "2020-01-01 10:00", | |
| "2020-01-01 10:00", | |
| "2020-01-03 12:00", | |
| "2020-01-03 12:00" | |
| )) |
Author
|
Withdrawing this small automated PR while I consolidate an oversized batch of contributions and reduce maintainer review burden. Sorry for the noise, and thank you for maintaining the project. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds edge-case tests for two core data-cleaning functions:
fill()anddrop_na(). These cover common data types (Date, POSIXct, factor) and boundary conditions (0-row, all-NA) that had no test coverage.fill() tests added (6 blocks)
can fill Date columnscan fill POSIXct columnsfill preserves factor levelsfill with .by respects group boundaries on Date columnsworks with 0-row data framedrop_na() tests added (6 blocks)
can drop NAs in factor columnscan drop NAs in Date columnscan drop NAs in POSIXct columnsworks with 0-row data frameworks with 0-row grouped data frameall-NA data frame returns 0 rowsValidation
Diff: 100 lines added across 2 files.