FFC project future#106
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds forward-projection capabilities for Food Balance Sheet (FBS) datasets, introducing new intervention models for projecting domestic use via population changes and increasing production via yield scaling, while also extending the Year-coordinate utilities (including an optional pivot year) and strengthening test coverage for add_years.
Changes:
- Added
project_by_populationandincrease_production_yieldpipeline nodes toagrifoodpy.food.model. - Extended
add_yearsto supportpivot_year, handle duplicate year inputs, and add a Year dimension when missing. - Updated/expanded tests around
add_years, and cleaned minor docs/formatting.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
agrifoodpy/utils/tests/test_add_years.py |
Renames the test function to correctly reflect add_years coverage. |
agrifoodpy/utils/nodes.py |
Extends the add_years node API to pass through pivot_year. |
agrifoodpy/tests/test_base_class.py |
Expands unit tests for XarrayAccessorBase.add_years across multiple scenarios. |
agrifoodpy/food/tests/test_model.py |
Minor whitespace cleanup. |
agrifoodpy/food/model.py |
Introduces new FBS projection models driven by population and yield scaling. |
agrifoodpy/food/food.py |
Updates scale_element docstring parameter naming. |
agrifoodpy/array_accessor.py |
Extends add_years accessor with pivot_year and additional year-handling logic. |
agrifoodpy/__init__.py |
Exposes key public classes (FoodBalanceSheet, LandDataArray, XarrayAccessorBase) at the package root. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Description
This PR introduces a model to project the food balance sheet according to population and yield changes.
The
project_by_populationfunction scales domestic use elements proportional to population changes.It scales imports and production according to an elasticity parameter to keep the food balance sheet balanced.
Depending on the selected items and given instructions, it also scales seed, feed, and processing quantities.
The
increase_production_yieldfunction scales production of certain items according to a scaling function.It also adjusts trade elements to keep the food balance sheet balanced.
Checklist