Skip to content
Merged
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
17 changes: 13 additions & 4 deletions src/muse/readers/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,11 +569,20 @@ def process_io_technodata(data: pd.DataFrame) -> xr.Dataset:
# Create xarray dataset
result = create_xarray_dataset(data)

# Fill in flexible data
if "flexible" in result.data_vars:
result["flexible"] = result.flexible.fillna(0)
else:
# Ensure both `fixed` and `flexible` inputs/outputs are defined. If only one is
# defined in the input data, create the other as a zeros array with the same shape.
has_fixed = "fixed" in result.data_vars
has_flexible = "flexible" in result.data_vars
if has_fixed and not has_flexible:
result["flexible"] = xr.zeros_like(result.fixed).rename("flexible")
elif has_flexible and not has_fixed:
result["fixed"] = xr.zeros_like(result.flexible).rename("fixed")
elif not has_fixed and not has_flexible:
raise ValueError("Neither 'fixed' nor 'flexible' levels were found.")
Comment on lines +572 to +581
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The new behavior for handling models with only flexible inputs (lines 578-579) lacks test coverage. While the existing test test_read_io_technodata verifies the standard case with both fixed and flexible inputs, there should be a test case that verifies the scenario where only flexible inputs are defined, ensuring that fixed inputs are correctly created as zeros.

Copilot uses AI. Check for mistakes.

# Fill any NaNs with zero
result["fixed"] = result.fixed.fillna(0)
result["flexible"] = result.flexible.fillna(0)

# Check commodities
result = check_commodities(result, fill_missing=True, fill_value=0)
Expand Down
Loading