Skip to content

Changes to food scaling function#98

Merged
jucordero merged 7 commits intoFixOurFood:ffc_modelfrom
jucordero:ffc_scale_items
May 5, 2026
Merged

Changes to food scaling function#98
jucordero merged 7 commits intoFixOurFood:ffc_modelfrom
jucordero:ffc_scale_items

Conversation

@jucordero
Copy link
Copy Markdown
Collaborator

@jucordero jucordero commented Apr 21, 2026

Description

This pull requests partially addresses #93 by extending the functionality of balanced_scaling.

To-do list

  • Add a threshold value or cap scaling to implement the food_waste functionality
  • Allow scaling based on converted values of the input food balance sheet array
  • Allow multiple items lists and item/item group dependent scaling
  • Automatically create non-existing padding items

Checklist

@jucordero jucordero marked this pull request as draft April 22, 2026 16:52
@jucordero jucordero requested a review from Copilot April 22, 2026 16:53
Copy link
Copy Markdown
Contributor

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 extends balanced_scaling to support (a) keeping totals constant with optional “padding” items and (b) scaling based on pre-converted quantities via a conversion_arr. It also introduces a new pipeline-compatible helper (scale_above_threshold) intended to support “food_waste”-style threshold scaling.

Changes:

  • Add conversion_arr support to balanced_scaling (convert → scale → convert back).
  • Add padding_items / non-finite handling to balanced_scaling constant-balancing logic.
  • Add scale_above_threshold pipeline node and expand tests for a no-Year case.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
agrifoodpy/food/model.py Extends balanced_scaling (conversion + constant balancing changes) and adds new scale_above_threshold pipeline node.
agrifoodpy/food/tests/test_model.py Adds a balanced_scaling test case for datasets without a Year dimension and adjusts expected outputs.

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

Comment thread agrifoodpy/food/model.py
Comment thread agrifoodpy/food/model.py
Comment thread agrifoodpy/food/model.py
Comment thread agrifoodpy/food/model.py
Comment thread agrifoodpy/food/model.py Outdated
Comment thread agrifoodpy/food/model.py
Comment thread agrifoodpy/food/model.py Outdated
Comment thread agrifoodpy/food/model.py Outdated
Comment on lines +387 to +388
@pipeline_node(["fbs", "scale", "element", "threshold", "conversion_arr"])
def scale_above_threshold(
Comment thread agrifoodpy/food/model.py
Comment thread agrifoodpy/food/model.py
@jucordero jucordero changed the base branch from main to ffc_model April 29, 2026 12:59
@jucordero jucordero marked this pull request as ready for review May 5, 2026 15:04
@jucordero jucordero merged commit 516818f into FixOurFood:ffc_model May 5, 2026
4 checks passed
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