-
Notifications
You must be signed in to change notification settings - Fork 70
fix(FXC-4341): Fix scene::plot_structures_porperty for doping #3115
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
fix(FXC-4341): Fix scene::plot_structures_porperty for doping #3115
Conversation
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.
Pull request overview
This PR fixes a bug in scene::plot_structures_property when plotting doping properties where doping is defined with SpatialDataArrays that have non-overlapping coordinates. The fix adds a fill_value=0 parameter to the interpolation call to handle coordinates outside the data range.
Key Changes
- Added
kwargs={"fill_value": 0}to theinterp()method call for SpatialDataArray doping data interpolation
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
1 file reviewed, 1 comment
|
@greptile update summary |
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". |
19c3acc to
e1327f6
Compare
e1327f6 to
40509e5
Compare
Diff CoverageDiff: origin/develop...HEAD, staged and unstaged changes
Summary
tidy3d/components/scene.pyLines 2157-2165 2157 data_is_2d = any(dim_size <= 1 for _, dim_size in doping.sizes.items())
2158 if not data_is_2d:
2159 selector = {"xyz"[normal_axis_ind]: normal_position}
2160 data_2D = doping.sel(**selector)
! 2161 contrib = data_2D.interp(
2162 **struct_coords,
2163 method="nearest",
2164 kwargs={"bounds_error": False, "fill_value": 0},
2165 ) |
40509e5 to
bc6648e
Compare
f527fef to
1e664e0
Compare
- Fixes scene::plot_structures_porperty with property=doping when the doping is defined with SpatialDataArrays that don't have overlapping coordinates
1e664e0 to
6e07d79
Compare
Fix scene::plot_structures_porperty with property=doping when the doping is defined with SpatialDataArrays that don't have overlapping coordinates
Greptile Summary
This PR fixes a bug in the
plot_structures_propertymethod where plotting doping with SpatialDataArrays that have non-overlapping coordinates would fail. The fix addsbounds_error=Falseandfill_value=0to the interpolation kwargs, allowing out-of-bounds points to be handled gracefully by setting them to 0 instead of raising an error. This change follows the existing interpolation pattern used elsewhere in the codebase (monitor_data.py).Confidence Score: 5/5
bounds_error=Falseandfill_value=0to interpolation kwargs. This directly addresses the issue where scipy's RegularGridInterpolator would fail on out-of-bounds points. The implementation matches established patterns elsewhere in the codebase (monitor_data.py). The change is well-tested by existing test cases (test_plot_property) which specifically test plotting with SpatialDataArray doping. No new logic branches or complex code paths are introduced.Important Files Changed
plot_structures_propertyby addingbounds_error=Falseandfill_value=0to kwargs when interpolating doping data with non-overlapping coordinates. This prevents scipy's RegularGridInterpolator from raising errors for out-of-bounds points.Sequence Diagram
sequenceDiagram participant User participant plot_structures_property participant interp_method participant RegularGridInterpolator User->>plot_structures_property: Call with SpatialDataArray doping plot_structures_property->>plot_structures_property: Create 100x100 grid for plotting plot_structures_property->>interp_method: interp(**struct_coords, method="nearest", kwargs={...}) Note over interp_method: Before fix: bounds_error=True (default)<br/>Grid points may fall outside data bounds interp_method->>RegularGridInterpolator: Create interpolator (bounds_error=True) RegularGridInterpolator-->>interp_method: ValueError if out-of-bounds! Note over plot_structures_property: After fix: bounds_error=False interp_method->>RegularGridInterpolator: Create interpolator (bounds_error=False, fill_value=0) RegularGridInterpolator->>RegularGridInterpolator: Out-of-bounds points → fill_value=0 RegularGridInterpolator-->>interp_method: Interpolated data with zeros for out-of-bounds interp_method-->>plot_structures_property: Successfully interpolated data plot_structures_property-->>User: Plot rendered successfullyNote
Prevents interpolation errors when plotting
dopingfromSpatialDataArraywith non-overlapping coordinates by tolerating out-of-bounds samples and filling them with zeros.scene.py(_pcolormesh_shape_doping_box), updatesdata_2D.interp(..., method="nearest", kwargs={"bounds_error": False, "fill_value": 0})to avoid failures and render out-of-bounds regions as 0Written by Cursor Bugbot for commit 6e07d79. This will update automatically on new commits. Configure here.