additional scalings and new parser constructor - #105
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_scaleto use the new piecewise implementation. - Registered
!scale.*YAML constructors inPipeline.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 on lines
81
to
82
| c_end : (float) | ||
|
|
jucordero
added a commit
that referenced
this pull request
Aug 5, 2026
* Changes to food scaling function (#98) * Changes to food scaling function * scale above threshold, deprecated drop in tests * Guard against fallback being defined but origin being not Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * accept scalar conv_arr, fixed conversion, input params in pipeline mode * unit tests, fixed behaviour of scale parameter --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * added land conversion methods (#100) * added land conversion methods * unit tests and docs * fixed mask and value_array validation in add_category * added food scaling from land function (#104) * added food scaling from land function * Update agrifoodpy/food/model.py multiple sum Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * Update agrifoodpy/food/model.py Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * Update agrifoodpy/food/model.py removed land_dimension option Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * Update agrifoodpy/food/model.py Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * added unittest and characters limit * Update agrifoodpy/food/model.py Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * Update agrifoodpy/food/model.py Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * Update agrifoodpy/food/model.py Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * removed datablock and out_key from food_scaling_from_land --------- Co-authored-by: Juan Pablo Cordero <34517350+jucordero@users.noreply.github.com> * FFC project future (#106) * projecting food balance sheet by population * Removed stale tests * fixed docs, guards for zero denoms, consistent docs * changed labelling for no show parameters in plot functions * unit tests * additional scalings and new parser constructor (#105) * additional scalings and new parser constructor * updated docs * multiple return keys for tuple returning functions (#107) * multiple return keys for tuple returning functions * return key validation and tuple keys * fixed docstrings * options for land plot (#109) * options for land plot * updated label values --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Co-authored-by: OttaviaTr <74863355+OttaviaTr@users.noreply.github.com>
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 pull request introduces new functions which can be used as temporal profiles for the different scaling models in
agrifoodpyIt also registers these scaling functions with the custom
!scaletag to be used in yaml configuration files.e.g.
Checklist