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

Error message when temperature is not defined #768

Merged
merged 1 commit into from
May 30, 2024

Conversation

RemDelaporteMathurin
Copy link
Collaborator

Proposed changes

I've noticed that it's easy to miss the temperature field when setting up a model. And the error message that's produced isn't straightforward:

Traceback (most recent call last):
  File "/home/remidm/FESTIM/mwe_2.py", line 19, in <module>
    my_model.initialise()
  File "/home/remidm/FESTIM/festim/generic_simulation.py", line 264, in initialise
    self.attribute_source_terms()
  File "/home/remidm/FESTIM/festim/generic_simulation.py", line 173, in attribute_source_terms
    self.T.sources = []
    ^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'sources'

Instead, this PR adds a clearer error message upon calling initialise()

Traceback (most recent call last):
  File "/home/remidm/FESTIM/mwe_2.py", line 18, in <module>
    my_model.initialise()
  File "/home/remidm/FESTIM/festim/generic_simulation.py", line 257, in initialise
    raise AttributeError("Temperature is not defined")
AttributeError: Temperature is not defined

Types of changes

What types of changes does your code introduce to FESTIM?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

Checklist

  • Black formatted
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@RemDelaporteMathurin RemDelaporteMathurin added this to the v1.3 milestone May 30, 2024
@RemDelaporteMathurin RemDelaporteMathurin added the enhancement New feature or request label May 30, 2024
Copy link

codecov bot commented May 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.52%. Comparing base (24420e6) to head (d4a8d6e).
Report is 233 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #768      +/-   ##
==========================================
+ Coverage   99.51%   99.52%   +0.01%     
==========================================
  Files          58       58              
  Lines        2468     2523      +55     
==========================================
+ Hits         2456     2511      +55     
  Misses         12       12              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@jhdark jhdark 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 to me, we could make a list of other common warnings that could be added as a good first issue too.

@RemDelaporteMathurin RemDelaporteMathurin merged commit 315aebd into main May 30, 2024
6 checks passed
@RemDelaporteMathurin RemDelaporteMathurin deleted the error-message-when-no-temp branch June 4, 2024 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants