-
Notifications
You must be signed in to change notification settings - Fork 280
Common physical props #1591
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
base: main
Are you sure you want to change the base?
Common physical props #1591
Conversation
Better represent that the object passes is a class (and not an instance of it).
Allows to be more descriptive and catch better errors on the simulations that need specific mesh types.
Better represent that the object passes is a class (and not an instance of it).
| self, | ||
| mesh, | ||
| survey=None, | ||
| *, |
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've done this to several classes to make it more clear in the source code which parameters should only be set as keywords.
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.
could we add comments throughout where we use * in the code to help developers understand why this is here and what keywords it is meant to catch? That would be helpful for contributors who are learning the codebase by reading it
|
@santisoler I think this is about ready now, I'd appreciate some feedback. I'll add documentation for the classes soon. One of the things I'm still unsure about is what to do with the one off physical properties that are in unique classes (that are not necessarily physical properties, but more like parameterizations of physical properties,) |
|
I decided to move the parameters I was suspicious of to the common physical properties, as more than one simulation used them. |
4627190 to
56361c3
Compare
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.
Looks good! I think we should include the physical properties as arguments for the constructor of simulations as well if we are still going to require them for the simulation to run, but I guess you are planning to tackle that in #1593, right?
The other thing that looks a little bit weird is having the simulation classes as childs of physical property classes. I understand the technicality of it (so they inherit the properties), but from an abstraction point of view it kind of looks weird. I'm nit picking, and I wouldn't block this PR because of that, but I wanted to mention it.
|
|
||
| class BaseEM1DSimulation(BaseSimulation): | ||
| class BaseEM1DSimulation( | ||
| BaseSimulation, ElectricalConductivity, MagneticPermeability, LayerThickness |
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 am raising this as a point of conversation... inheriting 4 classes introduces a fair bit of complexity for someone to understand when learning the codebase. I appreciate that the physical property classes are lightweight, but none-the-less, it does create a fair bit to navigate through to understand that we are going through 4 classes to instantiate this. Is there any way we could simplify this?
Having physical properties be properties of the class makes conceptual sense. Having a simulation inherit a physical property is a bit odd. I realize that it brings with it the benefits of not having to duplicate documentation.
If you really don't see an alternative, then I understand. But I wanted to raise it as something to discuss, as part of the goal of SimPEG is as a learning tool, and this introduces a new layer of complexity.
One of my overall goals is to "cleanup" the simulations. Some DiscussionThere's a few points to I think this highlights for discussion, First on the level of complexity of the codebase. I feel it's worth discussing where we should aim for, and there are a few different levels of people who interact with the code. I see at least three:
I feel like the internals of One of the biggest issues I currently see with our simulations is not that they have complicated inheritance, it's that they simply inherit too many properties from those parents that most people would never need to interact with. ( Another issue is that the "base" items live all over the place. There are fundamental bits of Simulations, Physical Properties, Models, Sources, Receivers, Surveys, etc.) based items in multiple of the first level subpackages of This PRNow moving onto this PR and my overall goals for unifying them here.
Then this last bit is more of a suspicion of mine, but I hope it also makes sense. I would trust someone who wants to make their own simulation to inherit a class rather than to make sure they use the correct combination of Some other alternatives:
So basically I believe moving them to common classes will reduce the overhead in the future. |
lheagy
left a comment
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 for pushing this forwards @jcapriot and apologies for taking soooo long to get back to you on this! I like the idea and I can see how this will simplify name changes in the future. My main comment is that if we could add a few comments for where the * is in the init to just explain what is happening, that would be helpful. A lot of folks learn SimPEG by reading the code, and it might not be obvious to all what is happening, so if we could help provide some guidance through comments, I think that would be helpful
| self, | ||
| mesh, | ||
| survey=None, | ||
| *, |
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.
could we add comments throughout where we use * in the code to help developers understand why this is here and what keywords it is meant to catch? That would be helpful for contributors who are learning the codebase by reading it
| def __init__( | ||
| self, | ||
| mesh, | ||
| *args, |
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.
similarly here, could we add a comment to help developers who are learning by reading the code?
|
Summary
Move physical properties to base classes meant for inheritance.
PR Checklist
expect style.
to a Pull Request
@simpeg/simpeg-developerswhen ready for review.Reference issue
Working towards #1429, and #1227
What does this implement/fix?
Moving the physical properties to base classes to reduce duplication, and planning ahead for their future rename.
The goal for doing this here is to have a single location to place deprecations on the rename.
Additional information