-
Notifications
You must be signed in to change notification settings - Fork 65
feat(medium): track parent medium from which the medium is derived #3001
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(medium): track parent medium from which the medium is derived #3001
Conversation
6d54aa0 to
65af874
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/simulation.pytidy3d/components/structure.py |
|
Adding the class itself as its field looks messy with pydantic. Probably an |
|
Would it help if we add the |
That's right. On the other hand, we'll also want to keep track when there is no perturbation, so that the two generated materials are still considered the same. Then with perturbation applied, the subpixel should be applied in the same way to avoid abrupt change. |
actually, if only |
That's a good idea! |
65af874 to
0c56c88
Compare
d86a445 to
1e9b1a3
Compare
54e3cd2 to
c6eba54
Compare
Not elegant, especially the quote in the type.
Greptile Overview
Greptile Summary
Added a
super_mediumfield toAbstractMediumthat tracks the parent medium from which a derived medium was created. This is set in theperturbed_copy()methods ofPerturbationMediumandPerturbationPoleResidue, allowing users to trace back to the original perturbation medium.Key Changes:
super_medium: Optional["MediumType"]field toAbstractMediumwith forward referenceAbstractMedium.update_forward_refs()call (though it currently resolves toAnyinstead of the fullMediumTypeunion)perturbed_copy()in bothPerturbationMediumandPerturbationPoleResidueto setsuper_medium = selfbefore returning derived mediumsIssues Found:
Anyinstead of the actualMediumType, which reduces type safetyConfidence Score: 4/5
super_mediumfield and sets it appropriately in all code paths. The test coverage is excellent and validates the expected behavior. However, the forward reference resolution at line 1166 usesAnyinstead of the fullMediumTypeunion, which undermines type safety for the new field. Additionally, a CHANGELOG entry is missing per project guidelines.tidy3d/components/medium.pyline 1166 for the forward reference resolution issueImportant Files Changed
File Analysis
super_mediumfield to track parent medium and updated forward reference resolution; needs CHANGELOG entrysuper_mediumfield on bothPerturbationMediumandPerturbationPoleResidueSequence Diagram
sequenceDiagram participant User participant PerturbationMedium participant Medium participant CustomMedium User->>PerturbationMedium: perturbed_copy() alt No perturbation data PerturbationMedium->>PerturbationMedium: Create new_dict excluding perturbation fields PerturbationMedium->>PerturbationMedium: Set super_medium = self PerturbationMedium->>Medium: parse_obj(new_dict) Medium-->>User: Return Medium with super_medium set else With perturbation data PerturbationMedium->>PerturbationMedium: Apply perturbations to fields PerturbationMedium->>PerturbationMedium: Set super_medium = self PerturbationMedium->>CustomMedium: parse_obj(new_dict) CustomMedium-->>User: Return CustomMedium with super_medium set endContext used:
dashboard- Require a changelog entry for any PR that is not purely an internal refactor. (source)