Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .helm/values.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ juliaMemoryRequest: "8000Mi"
juliaMemoryLimit: "8000Mi"
juliaDeploymentStrategy:
rollingUpdate:
maxSurge: 0%
maxSurge: "0%"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Classify the change according to the following categories:
##### Removed
### Patches

## v3.12.2
### Patches
- Enable the downloadable results spreadsheet (`job/generate_results_table` endpoint) to work with previous runs by avoiding errors when trying to do math with values of type None - handle None as zero/0

## v3.12.1
### Minor Updates
### Added
Expand Down
8 changes: 4 additions & 4 deletions reoptjl/custom_table_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,14 @@
{
"label" : "Purchased Electricity Cost ($/yr)",
"key" : "purchased_electricity_cost",
"bau_value" : lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_before_tax_bau") + safe_get(df, "outputs.CHP.year_one_standby_cost_before_tax_bau") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_before_tax_bau"),
"scenario_value": lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_before_tax") + safe_get(df, "outputs.CHP.year_one_standby_cost_before_tax") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_before_tax")
"bau_value" : lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_before_tax_bau") + safe_get(df, "outputs.Financial.year_one_chp_standby_cost_before_tax_bau") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_before_tax_bau"),
"scenario_value": lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_before_tax") + safe_get(df, "outputs.Financial.year_one_chp_standby_cost_before_tax") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_before_tax")
},
{
"label" : "Purchased Electricity Cost, After Tax ($/yr)",
"key" : "purchased_electricity_cost",
"bau_value" : lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_after_tax_bau") + safe_get(df, "outputs.CHP.year_one_standby_cost_after_tax_bau") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_after_tax_bau"),
"scenario_value": lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_after_tax") + safe_get(df, "outputs.CHP.year_one_standby_cost_after_tax") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_after_tax")
"bau_value" : lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_after_tax_bau") + safe_get(df, "outputs.Financial.year_one_chp_standby_cost_after_tax_bau") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_after_tax_bau"),
"scenario_value": lambda df: safe_get(df, "outputs.ElectricTariff.year_one_bill_after_tax") + safe_get(df, "outputs.Financial.year_one_chp_standby_cost_after_tax") - safe_get(df, "outputs.ElectricTariff.year_one_export_benefit_after_tax")
},
{
"label" : "Electricity Cost Savings ($/yr)",
Expand Down
4 changes: 3 additions & 1 deletion reoptjl/custom_table_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ def colnum_string(n: int) -> str:
return string

def safe_get(df: Dict[str, Any], key: str, default: Any = 0) -> Any:
return df.get(key, default)
"""Safely get a value from a dictionary with a default fallback."""
Copy link

Copilot AI Apr 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated safe_get function now forces a return value of 0 when a key exists with a None value or when default is None. It would be helpful to update the docstring to clearly explain that None is automatically converted to 0 to avoid unintended behavior.

Suggested change
"""Safely get a value from a dictionary with a default fallback."""
"""
Safely get a value from a dictionary with a default fallback.
If the key exists in the dictionary with a value of None, or if the default
value is explicitly set to None, the function will return 0. This ensures
that None values are always converted to 0.
Args:
df (Dict[str, Any]): The dictionary to retrieve the value from.
key (str): The key to look up in the dictionary.
default (Any, optional): The default value to return if the key is not found.
Defaults to 0. If set to None, it will be treated as 0.
Returns:
Any: The value associated with the key, or the default value (converted to 0 if None).
"""

Copilot uses AI. Check for mistakes.
value = df.get(key, default if default is not None else 0)
return value if value is not None else 0