Skip to content

feat: finalize_integers()#18

Merged
jonthegeek merged 8 commits into
mainfrom
copilot/feat-finalize-doubles-function
Mar 10, 2026
Merged

feat: finalize_integers()#18
jonthegeek merged 8 commits into
mainfrom
copilot/feat-finalize-doubles-function

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 10, 2026

  • Explore repo structure and verify existing tests pass
  • Add stbl to Imports in DESCRIPTION
  • Add Remotes: stbl=wranglezone/stbl to DESCRIPTION
  • Create tests/testthat/test-finalize_integers.R with tests
  • Create R/finalize_integers.R with implementation
  • Run roxygen2::roxygenise() to update NAMESPACE
  • Run air format .
  • Add NEWS.md entry
  • Use purrr::map() instead of lapply() in implementation
  • Add stbl::pkg_abort() input validation for non-data.frame input
  • Delete redundant "does not convert already-integer columns" test
  • Replace "returns a data frame" test with class-preservation test (tibble in → tibble out)
  • Add test for stbl::pkg_abort() error using stbl::expect_pkg_error_classes()
  • All 49 tests pass

Note: After development, the function was changed from finalize_doubles() to finalize_integers(), so some of the notes seem incorrect now.

Original prompt

This section details on the original issue you should resolve

<issue_title>feat: finalize_doubles()</issue_title>
<issue_description>## Summary

As a data wrangler, in order to store my dataset as efficiently as possible, I would like to automatically downcast double columns to integer when they contain only integer-valued data.

Proposed signature

finalize_doubles(dataset)

Arguments

  • dataset (data.frame) — The dataset to process.

Returns the dataset with all safely-downcasted double columns converted to integer.

Behavior

  • Iterates over all columns where stbl::is_int_ish(col) is TRUE (every value can be represented as an integer without loss of information).
  • Casts such columns using stbl::to_int(col).
  • Columns where is_int_ish() returns FALSE are left unchanged.

It's ok to add dplyr to Imports in DESCRIPTION if it makes the code cleaner to use dplyr::mutate() and dplyr::across().

References

Comments on the Issue (you are @copilot in this section)


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
Copilot AI changed the title [WIP] Add finalize_doubles() function to downcast double columns feat: finalize_doubles() Mar 10, 2026
Copy link
Copy Markdown
Contributor

@jonthegeek jonthegeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot Fix these issues.

Comment thread R/finalize_doubles.R Outdated
Comment thread tests/testthat/test-finalize_doubles.R Outdated
Comment thread tests/testthat/test-finalize_doubles.R Outdated
Comment thread R/finalize_doubles.R Outdated
Co-authored-by: jonthegeek <33983824+jonthegeek@users.noreply.github.com>
@jonthegeek jonthegeek changed the title feat: finalize_doubles() feat: finalize_integers() Mar 10, 2026
@jonthegeek jonthegeek marked this pull request as ready for review March 10, 2026 14:38
Copilot AI review requested due to automatic review settings March 10, 2026 14:38
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new exported helper finalize_integers() to downcast integerish columns/elements to integer for storage efficiency, wiring it into the package with docs, tests, and metadata updates.

Changes:

  • Implement finalize_integers() using stbl::is_int_ish() + stbl::to_int() with input validation via stbl::pkg_abort().
  • Add a dedicated testthat file covering conversion behavior, class preservation, and error classes.
  • Update package metadata/docs: DESCRIPTION (version/R dependency/stbl import + remote), NAMESPACE, NEWS.md, and generated Rd files.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
R/finalize_integers.R New exported function implementation + roxygen docs.
tests/testthat/test-finalize_integers.R New test coverage for conversion, lists, NA handling, class preservation, and errors.
man/finalize_integers.Rd Generated documentation for the new function.
DESCRIPTION Version bump; adds R (>= 4.1), stbl import, and remote.
NAMESPACE Exports finalize_integers().
NEWS.md Adds a user-facing entry for the new feature.
man/datawrap-package.Rd Minor generated reordering in useful links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread R/finalize_integers.R Outdated
Comment thread R/finalize_integers.R Outdated
Comment thread tests/testthat/test-finalize_integers.R Outdated
Comment thread NEWS.md Outdated
Comment thread NEWS.md Outdated
Comment thread R/finalize_integers.R Outdated
@jonthegeek jonthegeek enabled auto-merge (squash) March 10, 2026 14:53
Copy link
Copy Markdown
Contributor

@jonthegeek jonthegeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good as long as checks pass!

@jonthegeek jonthegeek merged commit eaa9669 into main Mar 10, 2026
8 checks passed
@jonthegeek jonthegeek deleted the copilot/feat-finalize-doubles-function branch March 10, 2026 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: finalize_integers()

3 participants