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

Temperature can be given as float or sp.Expr #770

Conversation

RemDelaporteMathurin
Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin commented May 31, 2024

Proposed changes

This fixes #741 by adding a setter/getter to the T attribute of Simulation.

Now, users can simply give the temperature as a numerical value or sympy Expression without having to create a Temperature object.

Little QoL improvement!

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 the enhancement New feature or request label May 31, 2024
Copy link

codecov bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.52%. Comparing base (fb2c99f) to head (6cb7559).
Report is 196 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #770   +/-   ##
=======================================
  Coverage   99.51%   99.52%           
=======================================
  Files          58       58           
  Lines        2488     2501   +13     
=======================================
+ Hits         2476     2489   +13     
  Misses         12       12           

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

@RemDelaporteMathurin RemDelaporteMathurin changed the title Temperature can be given as float Temperature can be given as float or sp.Expr Jun 4, 2024
Comment on lines +172 to +179
@T.setter
def T(self, value):
if isinstance(value, festim.Temperature):
self._T = value
elif value is None:
self._T = value
elif isinstance(value, (int, float, sp.Expr)):
self._T = festim.Temperature(value)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possibly, an else case with an error can be included to add clarity? Similar to

else:
raise TypeError(
"Accepted types for traps are list, festim.Traps or festim.Trap"
)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added

@RemDelaporteMathurin RemDelaporteMathurin merged commit 4573636 into festim-dev:main Jun 5, 2024
5 checks passed
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.

Give temperature as float
2 participants