Skip to content

Conversation

@dramanica
Copy link
Member

@dramanica dramanica commented Jan 7, 2026

Summary by CodeRabbit

  • New Features

    • Added support for Common Era (time_ce) time specification in location_series function.
    • Improved error messages when variables are not yet downloaded, providing specific function calls with exact parameters.
  • Tests

    • Enhanced test coverage for time_ce handling and updated error message assertions.
  • Documentation

    • Updated README with refreshed content and modernized badge references.
    • Minor editorial improvements to contributor guidelines.
  • Chores

    • Updated GitHub Actions workflows to use 'main' branch instead of 'master'.
    • Development version initiated (2.2.0.9000).
    • Updated codecov configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 7, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

This PR modernizes the codebase with a branch migration from master to main, refactors climate data extraction functions to consolidate region-based workflows, updates CI/CD pipelines, and adds error message improvements. Documentation and version metadata are also updated to reflect development progress.

Changes

Cohort / File(s) Summary
GitHub Actions Workflows
.github/workflows/R-CMD-check.yaml, .github/workflows/pkgdown.yaml, .github/workflows/lint.yaml, .github/workflows/test-coverage.yaml
Branch references updated from master to main; pkgdown.yaml enables PR triggers for main/dev; test-coverage.yaml enhanced with dev branch support, checkout v4 upgrade, xml2 dependency, Cobertura format conversion, Codecov v4 action, and artifact uploads on failure.
GitHub Actions Deprecated Workflows
.github/old/R-CMD-check.yaml, .github/old/pkgdown_temp.yaml
Removed archived workflow configurations from old directory.
Core Region/Location Data Extraction
R/location_series.R, R/location_slice_from_region_series_fast.R, R/region_series.R
Consolidated region-based workflow: replaced multiple per-dataset handling with region_series() call; refactored time retrieval to use time_bp(climate_brick); introduced buffer/nearest-neighbor interpolation paths with terra::adjacent for missing data; added time_ce conversion logic; improved time alignment flow across locations.
Climate Data Download Functions
R/download_worldclim_future.R
Added resolution-based branching: uses parallel multi_download for resolution > 5, per-URL curl_download iteration for smaller resolutions; tracks per-URL success and prints failure diagnostics before error.
Minor Function Documentation
R/bathy_to_spatraster.R, R/download_etopo_subset.R, R/check_var_downloaded.R
Roxygen doc updates: marmap type references changed to direct code formatting; error message expanded to indicate multiple variables and provide concrete download_dataset call signature with dataset and variable names.
Data-Raw Scripts
data-raw/location_slice_from_region_series_fast.R, data-raw/notes_on_ecoregions.R
New function location_slice_from_region_series() added with time/coordinate handling, buffer/interpolation modes, and biome factor support; conditional file download logic introduced for ecoregion data.
Generated Documentation
man/bathy_to_spatraster.Rd, man/download_etopo_subset.Rd, man/location_slice_from_region_series.Rd, man/mode.Rd, man/pastclim-package.Rd
Documentation source references updated; parameter descriptions reformatted; maintainer metadata appended with copyright holder note.
Version & Metadata
DESCRIPTION, NEWS.md, codecov.yml
Version bumped to 2.2.0.9000; RoxygenNote updated to 7.3.3; development version header added to NEWS; codecov config now excludes three R scripts from coverage reports.
Testing
tests/testthat/test_location_series.R, tests/testthat/test_location_slice.R, tests/testthat/test_region_series.R, tests/testthat/test_distance_from_sea.R
Error message expectations updated to use regex patterns reflecting new pluralized variable message format; new time_ce test coverage added; minor spacing cleanup.
Project Documentation
README.md, .github/CONTRIBUTING.md
README badges and content rewritten with main branch links; description condensed; contributor guidance updated with editorial refinements.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 Huzzah! The branch now points to main,
Climate data flows through a simpler vein,
Workflows tested with coverage so fine,
Time slices aligned in perfect design,
A hop forward—dev version takes flight!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title "Faster extract" is vague and generic, using non-descriptive terms that don't clearly convey the specific technical changes made in the changeset. Consider a more descriptive title that indicates the main change, such as "Refactor location_series and related functions to improve performance" or "Optimize data extraction with region_series consolidation".
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@dramanica dramanica changed the base branch from main to dev January 7, 2026 10:59
@dramanica dramanica requested a review from Copilot January 7, 2026 12:32
Copy link

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

This PR introduces performance optimizations to the extract functionality by implementing a faster version of location_slice_from_region_series. The changes focus on improving efficiency when extracting climate data for multiple locations and time slices.

Key changes:

  • Added support for Common Era (time_ce) time specification in location_series function
  • Refactored location_slice_from_region_series to extract values more efficiently using vectorized operations
  • Updated internal functions to use region_series directly for better performance

Reviewed changes

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

Show a summary per file
File Description
tests/testthat/test_location_series.R Added test coverage for time_ce parameter handling
R/location_slice_from_region_series_fast.R Refactored to use vectorized terra::extract operations and improved neighbor interpolation logic
R/location_series.R Modified to call location_slice_from_region_series internally and handle time_ce conversion
R/region_series.R Reorganized code to retrieve time axis earlier in the process
data-raw/location_slice_from_region_series_fast.R Development version with debugging code and incomplete implementations
man/*.Rd Updated roxygen documentation references and maintainer information
R/download_etopo_subset.R, R/bathy_to_spatraster.R Changed marmap function references from bracketed links to backtick format
DESCRIPTION Updated RoxygenNote version to 7.3.3
Comments suppressed due to low confidence (3)

R/location_slice_from_region_series_fast.R:192

  • Typo in comment: "vales" should be "values".
    R/location_slice_from_region_series_fast.R:214
  • Trailing whitespace on an otherwise empty line. This should be removed for consistency with coding style.
    R/location_slice_from_region_series_fast.R:164
  • Unused variable n_neighbours. The variable is assigned the value ncol(neighbours_list) but is never used afterwards in the function.

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

# if we are not using a buffer, we try to get all the values from
# specific locations directly
if (!buffer) {
browser()
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Debug statement browser() should be removed before merging to production. This will cause execution to halt during normal operation.

Suggested change
browser()

Copilot uses AI. Check for mistakes.
Comment on lines 67 to 68


Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Excess trailing whitespace on blank lines. These empty lines contain only whitespace which should be removed for consistency with coding style.

Copilot uses AI. Check for mistakes.
Comment on lines 133 to 134


Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Trailing whitespace on empty lines. These should be removed for consistency with coding style.

Copilot uses AI. Check for mistakes.
# do the same for time-ce
locations_ts_ce <- location_series(
x = locations[, c("longitude", "latitude")],
time_ce = c(-20000, -10000, -5000)+1950,
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Missing space around + operator. The expression should be c(-20000, -10000, -5000) + 1950 with spaces around the plus sign for better readability and consistency with R style guidelines.

Suggested change
time_ce = c(-20000, -10000, -5000)+1950,
time_ce = c(-20000, -10000, -5000) + 1950,

Copilot uses AI. Check for mistakes.
y = neighbours_coords,
layer = neighbours_list$layer
)
browser()
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Debug statement browser() should be removed before merging to production. This will cause execution to halt during normal operation.

Suggested change
browser()

Copilot uses AI. Check for mistakes.
Comment on lines 125 to 127



Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Excessive trailing whitespace on empty lines. These should be removed for consistency with coding style.

Copilot uses AI. Check for mistakes.
)
# convert from matrix (one row per location) to data.frame where first
# column is focal location, second column is id of each neighbour
n_neighbours <- ncol(neighbours_list)
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

Unused variable n_neighbours. The variable is assigned the value ncol(neighbours_list) but is never used afterwards in the function.

Suggested change
n_neighbours <- ncol(neighbours_list)

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Jan 7, 2026

Codecov Report

❌ Patch coverage is 98.87640% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 87.45%. Comparing base (cfb4e51) to head (6945960).
⚠️ Report is 4 commits behind head on dev.

Files with missing lines Patch % Lines
R/get_biome_classes.R 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##              dev      #80      +/-   ##
==========================================
+ Coverage   87.33%   87.45%   +0.11%     
==========================================
  Files          61       61              
  Lines        1856     1873      +17     
==========================================
+ Hits         1621     1638      +17     
  Misses        235      235              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link

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

Copilot reviewed 25 out of 25 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

R/location_slice_from_region_series_fast.R:191

  • Typo in comment: "vales" should be "values".
    R/location_slice_from_region_series_fast.R:134
  • Extra space in comment: "value column" should be "value column" (double space should be single space).

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

directions = directions
)

# TODO if we had time_ce, we should convert back from time_bp
Copy link

Copilot AI Jan 7, 2026

Choose a reason for hiding this comment

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

This TODO comment is obsolete. The code immediately following (lines 128-132) already implements the conversion from time_bp back to time_ce when time_ce is not null. The TODO should be removed.

Suggested change
# TODO if we had time_ce, we should convert back from time_bp

Copilot uses AI. Check for mistakes.
Copy link

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

Copilot reviewed 26 out of 26 changed files in this pull request and generated no new comments.

Comments suppressed due to low confidence (5)

R/location_slice_from_region_series_fast.R:216

  • Typo in comment: "has no method" is correct English (the change from "has not" to "has no" is appropriate).
    R/location_slice_from_region_series_fast.R:177
  • The comment mentions a "BUG" in terra. While this may be accurate, the comment should clarify whether this is a known workaround or if there's a tracking issue. Consider adding a link to the terra issue tracker if available, or remove the "BUG" label if this is simply documenting the required approach.
    R/location_slice_from_region_series_fast.R:131
  • The refactored code at line 131 introduces a bug when x is a numeric vector (cell numbers). However, there is no test coverage for the numeric input path in location_slice_from_region_series. Consider adding a test case that passes cell numbers instead of a data.frame to ensure this code path works correctly.
    R/location_slice_from_region_series_fast.R:131
  • The variable coords is undefined when x is numeric (not a data.frame). This line should use coords_df instead of locations_data[coords] to correctly extract coordinates for both data.frame and numeric inputs. The coords_df variable is properly set at lines 114-118 to handle both cases.
    R/location_slice_from_region_series_fast.R:58
  • The word "readd" is not a standard word. It should be "re-add" or better yet, "return" since the code is determining whether to return time_ce format instead of time_bp format in the output.

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

@dramanica dramanica merged commit a1b5cbe into dev Jan 8, 2026
16 of 17 checks passed
dramanica added a commit that referenced this pull request Jan 8, 2026
@dramanica dramanica mentioned this pull request Jan 8, 2026
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.

2 participants