Skip to content

Conversation

@marcorudolphflex
Copy link
Contributor

@marcorudolphflex marcorudolphflex commented Dec 4, 2025

Greptile Overview

Greptile Summary

This PR adds cell-level tracking to KLayout DRC violation markers, enabling users to identify which design cells contain DRC violations.

Key changes:

  • Introduced DRCMarker base class with cell field that all marker types (EdgeMarker, EdgePairMarker, MultiPolygonMarker) now inherit from
  • Added violated_cells and violations_by_cell properties to both DRCViolation and DRCResults for cell-based analysis
  • Updated XML parsing in violations_from_file to extract cell information from the <cell> element
  • Added comprehensive tests for the new cell-aware helpers

The implementation maintains backward compatibility since DRCMarker was previously only a type alias (not exported) and is now a base class. All existing marker type functionality is preserved.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it adds new functionality without breaking existing APIs.
  • The changes are well-structured with a clear inheritance hierarchy, comprehensive test coverage for all new functionality, and proper backward compatibility. The DRCMarker base class pattern is clean and the cell extraction from XML is properly validated with error handling.
  • No files require special attention.

Important Files Changed

File Analysis

Filename Score Overview
tidy3d/plugins/klayout/drc/results.py 5/5 Added DRCMarker base class with cell field, helper properties for cell-based grouping (violated_cells, violations_by_cell) on both DRCViolation and DRCResults, and cell extraction from XML parsing.
tests/test_plugins/klayout/drc/test_drc.py 5/5 Added tests for new cell-related features, updated all parse_violation_value calls to include cell parameter, and enhanced test helpers to support cell names.
CHANGELOG.md 4/5 Added changelog entry for new cell-related features in DRCResults and DRCViolation.

Sequence Diagram

sequenceDiagram
    participant User
    participant DRCResults
    participant DRCViolation
    participant DRCMarker
    participant XMLParser as violations_from_file

    User->>DRCResults: load(resultsfile)
    DRCResults->>XMLParser: violations_from_file(resultsfile)
    XMLParser->>XMLParser: Parse XML categories
    loop For each item
        XMLParser->>XMLParser: Extract category, cell, value
        XMLParser->>DRCMarker: parse_violation_value(value, cell)
        DRCMarker-->>XMLParser: EdgeMarker/EdgePairMarker/MultiPolygonMarker
    end
    XMLParser-->>DRCResults: dict[str, DRCViolation]
    DRCResults-->>User: DRCResults instance
    
    User->>DRCResults: violations_by_cell
    DRCResults->>DRCViolation: violations_by_cell (for each category)
    DRCViolation->>DRCMarker: marker.cell (for each marker)
    DRCViolation-->>DRCResults: dict[str, DRCViolation]
    DRCResults-->>User: dict[str, list[DRCViolation]]
Loading

@marcorudolphflex
Copy link
Contributor Author

@greptile

@marcorudolphflex marcorudolphflex force-pushed the FXC-4413-get-cell-name-from-violation-marker-in-klayout-plugin branch from e70ce55 to c24ee38 Compare December 4, 2025 09:26
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@marcorudolphflex marcorudolphflex marked this pull request as ready for review December 4, 2025 09:29
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Diff Coverage

Diff: origin/develop...HEAD, staged and unstaged changes

  • tidy3d/plugins/klayout/drc/results.py (97.7%): Missing lines 454

Summary

  • Total: 43 lines
  • Missing: 1 line
  • Coverage: 97%

tidy3d/plugins/klayout/drc/results.py

  450             raise FileError("Encountered DRC item without a category in results file.")
  451         category = category_el.text.strip().strip("'\"")
  452         cell_el = item.find("cell")
  453         if cell_el is None or cell_el.text is None:
! 454             raise FileError("Encountered DRC item without a cell in results file.")
  455         cell = cell_el.text.strip().strip("'\"")
  456         value = item.find("values/value").text
  457         marker = parse_violation_value(value, cell=cell)
  458         markers = violations.setdefault(category, [])

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.

2 participants