Skip to content

Conversation

@estanton22
Copy link

@estanton22 estanton22 commented May 28, 2025

I added a very basic EMode plugin and some documentation.

Summary by Sourcery

Integrate the EMode Photonix solver as a new plugin in GDSFactory, including documentation updates, example notebook, project dependency, and a basic integration test

New Features:

  • Introduce gplugins.emode package wrapping the EMode Python API for mode solving and Eigenmode Expansion propagation
  • Provide a new Jupyter notebook demonstrating EMode plugin usage

Enhancements:

  • Update mode solver documentation and table of contents to list the proprietary EMode plugin

Build:

  • Add 'emodeconnection' dependency to pyproject.toml

Documentation:

  • Expand docs/plugins_mode_solver.md with EMode installation and usage details

Tests:

  • Add a basic integration test script for the EMode plugin in gplugins/emode/tests

@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented May 28, 2025

Reviewer's Guide

Introduces a new EMode plugin by updating documentation, configuration, project metadata, and adding both example notebook and plugin code with tests for seamless integration of the EMode mode solver and EME propagation into GDSFactory.

Sequence Diagram: EMode Plugin Call Forwarding

sequenceDiagram
    actor UserCode
    participant gplugins_emode as "gplugins.emode"
    participant emc_lib as "emodeconnection"

    UserCode->>gplugins_emode: call function (e.g., EMode(), open_file())
    activate gplugins_emode
    gplugins_emode->>emc_lib: call corresponding function (e.g., EMode(), open_file())
    activate emc_lib
    emc_lib-->>gplugins_emode: return result
    deactivate emc_lib
    gplugins_emode-->>UserCode: return result
    deactivate gplugins_emode
Loading

Class Diagram: gplugins.emode Module Structure and Dependencies

classDiagram
  class GPluginsEMode {
    <<Python Module>>
    name: "gplugins.emode"
    +EMode
    +open_file()
    +get()
    +inspect()
  }
  class EmodeconnectionLib {
    <<Python Library>>
    name: "emodeconnection"
    +EMode
    +open_file()
    +get()
    +inspect()
  }
  GPluginsEMode ..> EmodeconnectionLib : imports and re-exports symbols
Loading

File-Level Changes

Change Details Files
Revamped documentation to include the EMode plugin
  • Converted mode solver list to categorized open-source and proprietary sections
  • Added mention of MEOW and new EMode solver in mode solver guide
  • Updated table of contents and Sphinx config to include emode notebook
docs/plugins_mode_solver.md
docs/_toc.yml
docs/_config.yml
Augmented project metadata to register EMode as a dependency
  • Added 'emode' entry to pyproject.toml dependencies array
pyproject.toml
Added a demonstration notebook for the EMode plugin
  • Created notebooks/emode.ipynb with markdown and code examples for setup and usage
notebooks/emode.ipynb
Implemented the EMode plugin package with initialization and tests
  • Introduced gplugins/emode/init.py exposing EMode API
  • Added a sample SOI test script under gplugins/emode/tests demonstrating solver workflow
gplugins/emode/__init__.py
gplugins/emode/tests/SOI.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @estanton22 - I've reviewed your changes - here's some feedback:

  • Rename the test file to start with test_ (e.g., test_SOI.py) and add assertions so pytest will discover and validate the plugin functionality automatically.
  • Add a runtime check or clear error message when the external EMode software isn't installed or accessible, to guide users through missing dependencies.
  • Expand the new notebook with end-to-end example cells that execute a mode solve and visualize results, so users see the plugin in action.
Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

- ``tidy3d``: Finite difference Frequency Domain (FDFD).
- ``MPB``: FDFD with periodic boundary conditions.
- ``Femwell``: Finite Element (FEM).
- ``meow``: The tidy3d mode solver is also used by the MEOW plugin to get the Sparameters of components via Eigenmode Expansion.
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (typo): Typo: "Sparameters" should likely be "S-parameters".

"S-parameters" is the correct term for scattering parameters in this context.

Suggested change
- ``meow``: The tidy3d mode solver is also used by the MEOW plugin to get the Sparameters of components via Eigenmode Expansion.
- ``meow``: The tidy3d mode solver is also used by the MEOW plugin to get the S-parameters of components via Eigenmode Expansion.

@joamatab joamatab self-requested a review May 28, 2025 18:11
Copy link
Contributor

@joamatab joamatab left a comment

Choose a reason for hiding this comment

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

Looks good, i would improve the tests if possible

em.plot()

## Close EMode
em.close() No newline at end of file
Copy link
Contributor

Choose a reason for hiding this comment

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

it would be great to have some actual tests

for example:

def test_neff():
    assert np.isclose(neff, 2.4)

Copy link
Author

Choose a reason for hiding this comment

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

Thanks Joaquin. I just removed this test because it was actually more of an example. Once I build some real integrations with GDSFactory, I will add some real tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

sounds good, I'll keep the PR open then

once you can directly make mode simulations from GDSFactory layerstack we can merge this

Copy link
Author

Choose a reason for hiding this comment

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

Hi Joaquin, I added some functionality for EMode to use the LayerStack from GDSFactory.

The test (gplugins/emode/tests/SOI.py) works, but I'd like some feedback on how I implemented the CrossSection specifications.

If it looks good to you, I think it's ready to merge.

Copy link
Author

@estanton22 estanton22 left a comment

Choose a reason for hiding this comment

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

This is an initial implementation of the EMode plugin with one test case showcasing integration with the gdsfactory LayerStack.

@joamatab joamatab requested a review from MatthewMckee4 as a code owner June 18, 2025 13:24
@joamatab
Copy link
Contributor

joamatab commented Aug 8, 2025

sorry for the late reply, the notebook added in this PR seem to fail

@estanton22
Copy link
Author

I fixed the issue with compiling the emode notebook. I also tested the build docs run commands and they completed without errors on my machine.

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