Describe the bug
When a unit group metric is associated with a mix of negative and positive values (depending on the unit group), executing 'bst.UnitGroup.df_from_groups(, fraction=True)' yields fractions that scale to the sum of positive values of the metric rather than the sum of all values. This means they do not add to 100%, as many users may desire. An argument needs to be added to scale these to the sum of all values (so they add to 100%).
To Reproduce
import biosteam as bst
from biorefineries import sugarcane as sc
sc.load()
unit_groups = bst.UnitGroup.group_by_area(sc.sys.units)
for i in unit_groups:
i.metric(i.get_net_electricity_production,
'Net electricity production',
'kW')
df_TEA_breakdown = bst.UnitGroup.df_from_groups(
unit_groups, fraction=True,
)
print(df_TEA_breakdown)
Expected behavior
Output:
Net electricity production
0 108
100 -3.14
200 -3.83
300 -0.872
Actual behavior
Output:
Net electricity production
0 100
100 -2.92
200 -3.55
300 -0.808
Describe the bug When a unit group metric is associated with a mix of negative and positive values (depending on the unit group), executing 'bst.UnitGroup.df_from_groups(
, fraction=True)' yields fractions that scale to the sum of positive values of the metric rather than the sum of all values. This means they do not add to 100%, as many users may desire. An argument needs to be added to scale these to the sum of all values (so they add to 100%).
To Reproduce
Expected behavior Output: Net electricity production 0 108 100 -3.14 200 -3.83 300 -0.872
Actual behavior Output: Net electricity production 0 100 100 -2.92 200 -3.55 300 -0.808
Version