Skip to content

additional scalings and new parser constructor#105

Merged
jucordero merged 2 commits into
FixOurFood:ffc_modelfrom
jucordero:ffc_yaml_scale
Jun 30, 2026
Merged

additional scalings and new parser constructor#105
jucordero merged 2 commits into
FixOurFood:ffc_modelfrom
jucordero:ffc_yaml_scale

Conversation

@jucordero

@jucordero jucordero commented Jun 11, 2026

Copy link
Copy Markdown
Collaborator

Description

This pull request introduces new functions which can be used as temporal profiles for the different scaling models in agrifoodpy

It also registers these scaling functions with the custom !scale tag to be used in yaml configuration files.
e.g.

nodes:
  - function: agrifoodpy.utils.nodes.write_to_datablock
    name: Write a linear profile to the datablock
    params:
      key: linear_scale
      value: !scale.linear_scale [2025, 2030, 2040, 2050, 1, 1.5]

Checklist

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 expands agrifoodpy’s temporal scaling utilities and integrates them into YAML pipeline configuration parsing via a custom !scale.* tag, enabling users to construct scaling xarray.DataArray profiles directly from config files.

Changes:

  • Added new scaling profile functions (piecewise linear/constant/smoothstep, step, pulse, smoothstep) and refactored linear_scale to use the new piecewise implementation.
  • Registered !scale.* YAML constructors in Pipeline.read() alongside existing !numpy.* / !xarray.* constructors.
  • Added/expanded unit tests and YAML fixtures validating both scaling behavior and YAML parsing.

Reviewed changes

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

Show a summary per file
File Description
docs/config_file.rst Documents YAML constructors, including the new !scale.* tags and examples.
agrifoodpy/utils/scaling.py Implements additional scaling functions and shared year-order validation.
agrifoodpy/utils/tests/test_scaling.py Adds broader unit test coverage across the scaling utilities.
agrifoodpy/pipeline/pipeline.py Adds !scale.* YAML multi-constructor support and scale tag resolution.
agrifoodpy/pipeline/tests/test_pipeline.py Adds YAML parsing tests for !scale.linear / !scale.logistic (positional + kwargs) and unsupported scale tags.
agrifoodpy/pipeline/tests/data/test_config_scale_unsupported_function.yaml YAML fixture validating unsupported !scale.* tag handling.
agrifoodpy/pipeline/tests/data/test_config_scale_logistic.yaml YAML fixture for positional !scale.logistic.
agrifoodpy/pipeline/tests/data/test_config_scale_logistic_kwargs.yaml YAML fixture for kwargs-based !scale.logistic.
agrifoodpy/pipeline/tests/data/test_config_scale_linear.yaml YAML fixture for positional !scale.linear.
agrifoodpy/pipeline/tests/data/test_config_scale_linear_kwargs.yaml YAML fixture for kwargs-based !scale.linear.

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

Comment thread docs/config_file.rst
Comment thread agrifoodpy/pipeline/pipeline.py
Comment on lines 81 to 82
c_end : (float)

Comment thread agrifoodpy/utils/scaling.py
Comment thread agrifoodpy/pipeline/pipeline.py
@jucordero jucordero merged commit 1327efd into FixOurFood:ffc_model Jun 30, 2026
2 of 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