Skip to content

75 notebooks#84

Open
dalonsoa wants to merge 2 commits into
mainfrom
75_notebooks
Open

75 notebooks#84
dalonsoa wants to merge 2 commits into
mainfrom
75_notebooks

Conversation

@dalonsoa

@dalonsoa dalonsoa commented Jul 16, 2026

Copy link
Copy Markdown

Description

Update the capacity notebook to account for the new output file structure - which is far from ideal from the processing perspective. Performance-wise, there are vectorised options that are faster than apply, but this one was more readable.

The output plot is:

Screenshot from 2026-07-16 08-50-09

Close #75

Type of change

  • Documentation (non-breaking change that adds or improves the documentation)
  • New feature (non-breaking change which adds functionality)
  • Optimization (non-breaking, back-end change that speeds up the code)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (whatever its nature)

Key checklist

  • All tests pass (eg. python -m pytest)
  • Pre-commit hooks run successfully (eg. pre-commit run --all-files)

Further checks

  • Code is commented, particularly in hard-to-understand areas
  • Tests added or an issue has been opened to tackle that in the future.
    (Indicate issue here: # (issue))

Copilot AI review requested due to automatic review settings July 16, 2026 06:48
@dalonsoa dalonsoa requested review from AdrianDAlessandro, dc2917 and tsmbland and removed request for Copilot July 16, 2026 06:50
@dalonsoa

Copy link
Copy Markdown
Author

The latest MUSE2 release uses the old file structure, so those tests are failing - but it is for a known reason.

@dc2917 dc2917 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Seems reasonable to me!

is far from ideal from the processing perspective. Performance-wise, there are vectorised options that are faster than apply, but this one was more readable.

I think for a notebook this sounds like a good approach.

@dalonsoa

Copy link
Copy Markdown
Author

This is the vectorised version, by the way:

# Try merging on asset_id first, then fall back to group_id for unmatched rows
merged = asset_capacities.merge(
    assets[["asset_id", "agent_id", "process_id", "commission_year"]],
    on="asset_id",
    how="left"
)

# Fill in rows where asset_id was None using group_id
mask = merged["agent_id"].isna()
fallback = asset_capacities[mask].merge(
    assets[["group_id", "agent_id", "process_id", "commission_year"]],
    on="group_id",
    how="left"
)

merged.loc[mask, ["agent_id", "process_id", "commission_year"]] = fallback[["agent_id", "process_id", "commission_year"]].values
asset_capacities = merged

@dc2917

dc2917 commented Jul 16, 2026

Copy link
Copy Markdown

This is the vectorised version, by the way:

Yeah, it's not that it's unclear, but it does make the process look more cumbersome, even if it's less work for the computer to do. I guess it depends on the purpose of the notebook?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Notebooks failing due to changes in the output format

2 participants