Skip to content

fix: preserve explicitly provided zero carbon intensity - #1441

Open
nawaaaaaAaar wants to merge 2 commits into
mlco2:masterfrom
nawaaaaaAaar:fix/zero-carbon-intensity
Open

nawaaaaaAaar wants to merge 2 commits into
mlco2:masterfrom
nawaaaaaAaar:fix/zero-carbon-intensity

Conversation

@nawaaaaaAaar

@nawaaaaaAaar nawaaaaaAaar commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1440.

Treat a numeric zero carbon-intensity value as a provided factor, not as missing data. This applies both to direct country intensity and to zero-valued source factors when accounting for covered generation.

No shipped factor values, accounting definitions, or fallback behavior for genuinely missing source factors are changed.

Verification on Python 3.12.13:

  • Six new cases: four regressions fail before the fix, two positive-factor controls pass.
  • Package test command: 686 passed, two skipped, three integration cases deselected, ten subtests passed.
  • All applicable autoflake/isort/Black/flake8 hooks passed.

Zero-valued source factors are tested with a controlled factor-table fixture. The package test scope excludes visualization and API/dashboard integration; it is not a scientific validation of alternative factor tables.

AI disclosure: autonomously implemented and tested using Perplexity Computer (GPT-6.1). No human review is claimed.

Combined with #1439 and #1443: 695 passed, two skipped, three integration cases deselected and twelve subtests passed. PR is open and ready for review; hosted verification workflows require maintainer approval. A successful PR-size labeler is not a hosted test pass.

@nawaaaaaAaar
nawaaaaaAaar requested a review from a team as a code owner October 5, 2026 16:13
Copilot AI balanced review requested due to automatic review settings October 5, 2026 16:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@davidberenstein1957 davidberenstein1957 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Correct fix: a zero source factor is a value, not a missing one, so is not None is the right test in both places in core/emissions.py. total_TWh still resolves to None and is skipped, so nothing else changes. Tests included. Fixes #1440.

@codecov

codecov Bot commented Oct 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.30%. Comparing base (7929a4f) to head (57ee053).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1441      +/-   ##
==========================================
+ Coverage   92.07%   92.30%   +0.23%     
==========================================
  Files          49       49              
  Lines        5199     5199              
==========================================
+ Hits         4787     4799      +12     
+ Misses        412      400      -12     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicit zero carbon intensity is discarded as a missing factor

3 participants