Skip to content
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

Refactor interfaces and internal state of adjoint module objective quantities #1592

Merged
merged 2 commits into from
Jun 9, 2021

Conversation

ianwilliamson
Copy link
Contributor

@ianwilliamson ianwilliamson commented Jun 4, 2021

This PR picks up where #1588 left off with some refactoring of the mpa.ObjectiveQuantity child classes:

  • Many attributes of the mpa.ObjectiveQuantity child classes are not correctly indicated as being private
  • Some attributes of the mpa.ObjectiveQuantity child classes (e.g. source in EigenmodeCoefficient) should apparently not even be part of the internal state (since they're unused) and are initialized in an adhoc manner throughout different methods of the classes
  • Functions such as adj_src_scale() and create_time_profile() should actually be methods of mpa.ObjectiveQuantity

In an effort to streamline the process of debugging tricky issues such as #1585, the interfaces, attributes, and data marshaling in the adjoint module should be standardized in the mpa.ObjectiveQuantity.

@ianwilliamson ianwilliamson force-pushed the adjoint-refactor branch 2 times, most recently from 69fa732 to dcdeeee Compare June 4, 2021 19:46
@ianwilliamson ianwilliamson changed the title WIP: Refactor interfaces and internal state of adjoint module objective quantities Refactor interfaces and internal state of adjoint module objective quantities Jun 5, 2021
@ianwilliamson
Copy link
Contributor Author

ianwilliamson commented Jun 5, 2021

Okay, I think this should be good to go on my end.

@ianwilliamson ianwilliamson requested a review from smartalecH June 5, 2021 02:13
@smartalecH
Copy link
Collaborator

Many attributes of the mpa.ObjectiveQuantity child classes are not correctly indicated as being private

Many of these quantities don't need to be private, do they? From a flexibility perspective, this seems restricting.

@ianwilliamson
Copy link
Contributor Author

Many of these quantities don't need to be private, do they?

These objects use a lot of internal state to pass information between various steps (registering monitors, performing fwd and adjoint sims, etc) and if that state isn't supposed to be accessed/modified by external code then, yes, they need to be marked as private.

Part of the goal here is to indicate to tools, such as pylint, what the intended data access patterns and APIs are. Pylint can then help us to identify bugs through static analysis.

From a flexibility perspective, this seems restricting.

There is nothing preventing you from querying these variables in environments such as colab. If there's something missing from the public API that's needed by some other piece of unchecked in code, we can incorporate that. Let me know if there's something specific.

…methods, mark private attributes as private
@stevengj stevengj merged commit 9a62965 into NanoComp:master Jun 9, 2021
@ianwilliamson ianwilliamson deleted the adjoint-refactor branch June 10, 2021 16:44
bencbartlett pushed a commit to bencbartlett/meep that referenced this pull request Sep 9, 2021
…antities (NanoComp#1592)

* Eliminate unneeded state from `ObjectiveQuantity`, consolidate their methods, mark private attributes as private

* Update to use _infer_dims
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.

3 participants