-
Notifications
You must be signed in to change notification settings - Fork 50
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[frontend]: implementation and testing for VisualizationSpec #2147
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.
Nice thanks @groberts-flex, this is already looking really good. Most of the comments are pretty minor, so this should be good to go after a little bit of iteration!
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.
Thanks @groberts-flex , this is high quality work and I think the feature will be very useful and timely for us. I had a couple high level comments but will leave the rest to yannick and dario.
- could you add a short changelog item to describe the feature?
- this PR introduces some more coupling between
tidy3d/components
andtidy3d/viz.py
. Namely the VizSpec is defined in viz.py rather than incomponents
. We are working towards makingmatplotlib
an optional dependency of tidy3d to make it a more lightweight package. In this PR for example we are doing some changes to how viz are done for this goal. I think in the long run we want to also consider plotting as a "wrapper" around the core pydantic model definition. I think this PR accomplishes that more or less because of thePlotParams.override_with_viz_spec
method. My question (largely for @yaugenst-flex too perhaps) is whether any of this architecture conflicts with our long term plan to decouple plotting from the data structure definition? and if so, do we want to for example move VizSpec intocomponents
?
Thanks @tylerflex for the comments! There is some explicit coupling to matplotlib in the |
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.
Ok nice this is looking good! One last thing I just noticed.. this should be merged into pre/2.8
and not into develop
. The plotting import in viz.py
will need to be lazy then (you'll see). So I think maybe address those two minor comments I left and then apply the changes from your commits to the pre/2.8
branch instead.
@tylerflex @groberts-flex regarding where In terms of long-term restructuring of visualization / repo I think this change is net neutral because this all needs to be revisited anyways (also e.g. for #2141). Maybe @daquinteroflex has additional thoughts? |
eb1e9ed
to
ba3ccf4
Compare
Regarding this point, yeah this might be a bit of a problem. The idea behind the minimal install is to be able to validate simulations in a very constrained environment, ideally without matplotlib as a dependency.
Option 1 is probably not great because it can lead to GUI bugs. I would be ok with both 2 or 3 for now, not sure how involved option 2 is. |
Nice work Greg, look forward to more of your contributions! So yeah, the goal is to restructure the way we do plotting in the future so it is more "easier to extend", completely on-the-fly, clear on what's actually happening to the figure (easier to debug), and have it self contained/decoupled from the internal class parameters themselves as possible. In this sense, some of these methods may need to be restructured in the future. (Your help would be most welcome if you're interested eventually!) So now that we can merge #2087, this PR rebase onto that might identify some changes on the imports as Yannick and Tyler suggest. Re the validator, option 3 looks good if it can be tested too (we would really benefit from testing it eventually in this #2073 but that'd be down the line. |
ba3ccf4
to
aaae37a
Compare
Thanks Dario, that all sounds reasonable to me, thanks for the details on where viz stuff is headed! I rebased the changes and settled the merge conflicts in viz.py |
@groberts-flex Thanks for implementing this feature so quickly. The way it is implemented at the medium level works great for implementation in PhotonForge. We don't have to change much! Thanks again. |
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.
I'll approve this now, as far as I can see it's ready to go. We might want to add some additional plotting parameters to VisualizationSpec
down the line though.
Only one tiny thing: Could you change the commit message @groberts-flex to explicitly mention the addition of VisualizationSpec
?
aaae37a
to
90fd369
Compare
Thanks @groberts-flex! It is a very nice new feature! From the GUI side, it seems nice. I have no additional comments. In GUI, users pick up colors from this interface. So, it should work very well. |
Adding ability to have a visualization specification for a medium that overrides the plotting parameters in the structure plotting code so that structures in the gui can be specified to have fixed colors and not change when new structures are added. For task "VisualizationSpec for Structure / Medium".
Attached below are screenshots from local testing to show the ability to set different face color, edge color, and alpha as well as usage of default plotting parameters when no visualization specification is included in the medium
Magenta, Cyan, 0.1



Red, Blue, 0.5
No visualization spec included in medium