Skip to content

Improvements to scale_add #65

@jucordero

Description

@jucordero

Currently, the scale_add function transfers quantities between elements in a FoodBalanceSheet dataset, but doesn't pay much attention to element_out after the delta has been added or subtracted.
Something I've found myself doing very often is to check whether any quantity in element_out falls below zero. This is useful if, for instance, negative quantities do not make sense and / or the excess must be transferred to another element

ds_out = ds.fbs.scale_add(element_in="food", element_out="production", scale=scale, items=items)
excess = ds_out["production"].where(ds_out["production"] < 0, other=0)
ds_out["production"] -= excess
ds_out["imports"] += excess

An "excess" or "fallback" parameter could be used to transfer these quantities to an alternative element, in a similar way to the balanced_scaling model we already have.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions