Skip to content

Conversation

@damiano-flex
Copy link
Contributor

@damiano-flex damiano-flex commented Jan 14, 2026

Note

Strengthens GaussianDoping input validation and aligns schemas/tests accordingly.

  • Enforces ref_con < concentration; raises validation error to prevent invalid sigma calculation
  • Constrains source to [xmin,xmax,ymin,ymax,zmin,zmax] via type (Literal[...]) and JSON schema enums across simulation schemas
  • Warns when any finite box dimension is < 2*width to flag potentially insufficient transition region
  • Updates tests to cover new validators (error on invalid ref_con, source validation, width-size warnings) and documents changes in CHANGELOG.md

Written by Cursor Bugbot for commit c3b3ec4. This will update automatically on new commits. Configure here.

Greptile Summary

This PR strengthens input validation for GaussianDoping by adding three frontend validators. The changes enforce that ref_con < concentration (preventing mathematical errors in sigma calculation), restrict source to valid face identifiers via Literal type, and warn users when any finite box dimension is smaller than 2*width (indicating potential issues in the transition region). The implementation follows established patterns using pydantic validators and the logging system. Test coverage is comprehensive, validating all three scenarios including edge cases like np.inf dimensions and all coordinate directions.

Confidence Score: 4/5

  • This PR is safe to merge with minor style improvements needed
  • The validators implement correct mathematical constraints and the test coverage is comprehensive. Previous review comments have identified style guide violations (single quotes in messages, changelog categorization) that should be addressed but don't affect functionality
  • Pay attention to tidy3d/components/tcad/doping.py for style guide compliance with single quotes in error/warning messages

Important Files Changed

Filename Overview
tidy3d/components/tcad/doping.py Added validators for ref_con < concentration check, source face validation via Literal type, and width-vs-size warnings; addresses reported issues with single quotes, np.inf handling
tests/test_components/test_heat_charge.py Added comprehensive tests for ref_con validation, source validator, and width-vs-size warnings; includes all three dimensions (x, y, z) and np.inf handling

Sequence Diagram

sequenceDiagram
    participant User
    participant GaussianDoping
    participant Validator
    participant Logger

    User->>GaussianDoping: Create with params (ref_con, concentration, width, size, source)
    
    GaussianDoping->>Validator: Validate source field
    Note over Validator: Type checking via Literal["xmin", "xmax", "ymin", "ymax", "zmin", "zmax"]
    Validator-->>GaussianDoping: Valid source or ValidationError
    
    GaussianDoping->>Validator: _validate_ref_con_less_than_concentration(concentration)
    Validator->>Validator: Check ref_con < concentration
    alt ref_con >= concentration
        Validator-->>GaussianDoping: Raise ValueError
    else ref_con < concentration
        Validator-->>GaussianDoping: Return valid concentration
    end
    
    GaussianDoping->>Validator: _validate_width_vs_size(width)
    Validator->>Validator: Loop over size dimensions (x, y, z)
    loop For each dimension
        alt not np.isinf(size[i]) and size[i] < 2*width
            Validator->>Logger: log.warning about insufficient size
        end
    end
    Validator-->>GaussianDoping: Return valid width
    
    GaussianDoping-->>User: Instance created or ValidationError raised
Loading

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.

2 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@github-actions
Copy link
Contributor

github-actions bot commented Jan 14, 2026

Diff Coverage

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

  • tidy3d/components/tcad/doping.py (100%)

Summary

  • Total: 18 lines
  • Missing: 0 lines
  • Coverage: 100%

@damiano-flex damiano-flex force-pushed the chore/damiano/validate_gaussian_doping branch from 98ba3bf to 65f324e Compare January 15, 2026 10:07
@damiano-flex
Copy link
Contributor Author

@greptileai Check the updated PR and provide a new confidence score.

greptile-apps[bot]

This comment was marked as off-topic.

@damiano-flex damiano-flex force-pushed the chore/damiano/validate_gaussian_doping branch from 261e108 to 1bdec8f Compare January 15, 2026 10:18
@damiano-flex
Copy link
Contributor Author

@greptileai Check the updated PR and provide a new confidence score. Be careful, I didn't remove any tests!

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

Copy link
Contributor

@marc-flex marc-flex left a comment

Choose a reason for hiding this comment

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

Thanks Damiano!
Just a couple of comments below

@damiano-flex damiano-flex force-pushed the chore/damiano/validate_gaussian_doping branch 2 times, most recently from ca63742 to d733d4a Compare January 15, 2026 12:45
@damiano-flex
Copy link
Contributor Author

@greptileai make the final check and ensure all the issues have been solved. All the tests passed.

@damiano-flex damiano-flex force-pushed the chore/damiano/validate_gaussian_doping branch from d733d4a to c3b3ec4 Compare January 15, 2026 12:48
@greptile-apps
Copy link

greptile-apps bot commented Jan 15, 2026

Greptile's behavior is changing!

From now on, if a review finishes with no comments, we will not post an additional "statistics" comment to confirm that our review found nothing to comment on. However, you can confirm that we reviewed your changes in the status check section.

This feature can be toggled off in your Code Review Settings by deselecting "Create a status check for each PR".

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.

3 participants