Skip to content

chore: Improve local subpixel warnings and docstrings#3252

Open
caseyflex wants to merge 1 commit intodevelopfrom
chore/casey/modewarning
Open

chore: Improve local subpixel warnings and docstrings#3252
caseyflex wants to merge 1 commit intodevelopfrom
chore/casey/modewarning

Conversation

@caseyflex
Copy link
Contributor

@caseyflex caseyflex commented Feb 6, 2026

Fixes unclear warnings / docstrings reported by Tyler.
Related FAQ PR: flexcompute/tidy3d-faq#60


Note

Low Risk
Primarily documentation/logging changes with a small conditional change to when a warning is emitted; no solver algorithms or numerical outputs are modified.

Overview
Updates local-mode-solver behavior so ModeSolver.solve() only emits its “use remote mode solver for better accuracy” warning when tidy3d-extras local subpixel averaging is not active, and adds/expands docstrings to consistently describe the config.simulation.use_local_subpixel toggle across ModeSolver.solve(), ModeSimulation.run_local(), Simulation.epsilon(), and Simulation.epsilon_on_grid().

Improves user-facing documentation (docs/configuration/reference.rst, docs/extras/index.rst) to spell out the tri-state semantics (True=require extras, False=staircasing, None=use when available), and adds tests ensuring the warning is suppressed/enabled appropriately.

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

@caseyflex caseyflex force-pushed the chore/casey/modewarning branch from 96ace94 to 932579b Compare February 6, 2026 22:58
@caseyflex caseyflex requested a review from tylerflex February 6, 2026 23:00
@caseyflex caseyflex force-pushed the chore/casey/modewarning branch from 932579b to e86822e Compare February 6, 2026 23:12
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

@caseyflex caseyflex force-pushed the chore/casey/modewarning branch from e86822e to f37b815 Compare February 6, 2026 23:50
@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2026

Diff Coverage

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

  • tidy3d/components/mode/mode_solver.py (100%)

Summary

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

Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

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

a couple comments, also same thing about the use of quotes in the pip install extras, I'm not sure if it's just a Mac thing. It trips me up from time to time, but now that I know about it, I know how to fix it. just worried some users might get no matches found: tidy3d[extras] which is what I see on Mac if I copy that syntax.

log_once=True,
)
# only warn if tidy3d-extras local subpixel is not enabled
if not tidy3d_extras["use_local_subpixel"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

won't this also warn If this is left to default of None? should it be if ... is False?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I actually think I want this to warn if left at the default of None, if tidy3d-extras isn’t installed (because then subpixel won’t work out the box, and the warning then is the current desired behavior). The warning is updated to recommend extras as well though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that this value im checking is whether extras package loaded, not the config flag

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Although if the config flag is false, this decorator will explicitly unload extras

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically this value tells you exactly whether subpixel is actually being used in the current function

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok I see. yea I thought this was the config flag.

From my perspective as a user, it should just be a warning if for whatever reason I'm not using subpixel. If I am, it should be quiet? is that consistent with your thinking too and the logic here?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess another question is whether the current logic now prints 2 warnings (one if tidy3d extras not installed and one if subpixel is not used?) that would be less ideal

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it should only warn here if subpixel isn’t being used.

There usually should not be two warnings. Only this one if subpixel is not being used. There will be another warning if tidy3d-extras is installed but failed to load for another reason like user permissions, but I think that’s good

- Changed the interpretation of `waist_distance` and `waist_distances` for backward-propagating Gaussian beams (`GaussianBeam`, `AstigmaticGaussianBeam`, `GaussianBeamProfile`, `AstigmaticGaussianBeamProfile`). Previously, the waist position was interpreted relative to the directed propagation axis, meaning switching `direction` from `+` to `-` would also flip the waist position in the global reference frame. Now, the waist position is defined consistently for both directions: a positive `waist_distance` always places the beam waist behind the source/monitor plane (toward the negative normal axis), regardless of propagation direction. This ensures reciprocity between Gaussian sources and overlap monitors used in port-based S-matrix calculations. Users with existing simulations using backward-propagating Gaussian beams with non-zero waist distances may need to adjust their values.

### Changed
- Improved `ModeSolver.solve()` to suppress the accuracy warning when local subpixel averaging is enabled via `tidy3d-extras`, and expanded docstrings for `ModeSolver.solve()`, `ModeSimulation.run_local()`, `Simulation.epsilon()`, and `Simulation.epsilon_on_grid()` to document the `config.simulation.use_local_subpixel` option.
Copy link
Collaborator

Choose a reason for hiding this comment

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

might be better under "fixed"

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