H transport initialisation refactoring#661
Merged
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## fenicsx #661 +/- ##
========================================
Coverage 98.87% 98.87%
========================================
Files 23 23
Lines 974 974
========================================
Hits 963 963
Misses 11 11 ☔ View full report in Codecov by Sentry. |
Collaborator
RemDelaporteMathurin
left a comment
There was a problem hiding this comment.
This looks great to me, thanks for fixing this. It is a common pitfall in python!
Just have a few comments for future proofing 🚀
Comment on lines
+103
to
+110
| self.subdomains = subdomains or [] | ||
| self.species = species or [] | ||
| self.reactions = reactions or [] | ||
| self.temperature = temperature | ||
| self.sources = sources | ||
| self.boundary_conditions = boundary_conditions | ||
| self.sources = sources or [] | ||
| self.boundary_conditions = boundary_conditions or [] | ||
| self.settings = settings | ||
| self.exports = exports | ||
| self.exports = exports or [] |
Collaborator
There was a problem hiding this comment.
Nice hack, I didn't know of this way of doing things.
Does it work for all python versions?
Also, we may want to add a comment to say what this does for people like me who don't know this
Merged
10 tasks
Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com>
RemDelaporteMathurin
approved these changes
Dec 5, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Proposed changes
We habe a minor python bug when multiple instances of the same class are within the same script, and with attributes that default to empty lists, if a value is appended to this list, it becomes the default for subsequent instances like so:
gives:
The changes presented fixes this by altering the attribute defaults in
HydrogenTransportProblemfromto:
and this seems to fix it. Found this in a handy pitfall guide: https://docs.python-guide.org/writing/gotchas/
Types of changes
What types of changes does your code introduce to FESTIM?
Checklist
Further comments
If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...