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

New default value for DerivedQuantities.show_units #892

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

RemDelaporteMathurin
Copy link
Collaborator

Fixes #860 but instead of deprecating the show_units argument, I just have it default to True.

What do you think @jhdark @KulaginVladimir? I thought it'd be nice to keep the functionality in case someone doesn't want the units in (eg. they are working in moles)...

@RemDelaporteMathurin RemDelaporteMathurin changed the title Housekeeping New default value for DerivedQuantities.show_units Oct 8, 2024
Copy link

codecov bot commented Oct 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.24%. Comparing base (abe3942) to head (fb46ab6).
Report is 24 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #892      +/-   ##
==========================================
- Coverage   99.56%   99.24%   -0.32%     
==========================================
  Files          61       61              
  Lines        2750     2796      +46     
==========================================
+ Hits         2738     2775      +37     
- Misses         12       21       +9     

☔ 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 great, just a few minor comments from me. The largest change I think would be just to add this new export_unit property in each of the doc strings for the exports.

Comment on lines +35 to +41
@property
def export_unit(self):
if self.field == "T":
return "K"
else:
return "H m-3"

Copy link
Collaborator

Choose a reason for hiding this comment

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

If you're going to add this new property everywhere, it should also go in the doc strings

@@ -39,7 +39,7 @@ def __init__(self, field) -> None:
self.T = None
self.data = []
self.t = []
self.show_units = False
self.show_units = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could maybe add this new default to the doc string

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well if it's not an argument then it's not really a default value. Like we don't document the fact that data has a "default" value of [] in the docstrings

Comment on lines +50 to +51
mesh = f.UnitIntervalMesh(10)
V = f.FunctionSpace(mesh, "P", 1)
Copy link
Collaborator

Choose a reason for hiding this comment

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

could import the mesh and function space from .tools.py? not necessary though

if self.field == "T":
quantity_title = f"Heat flux surface {self.surface}"
else:
quantity_title = f"{self.field} flux surface {self.surface}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Actually, seen as only the mobile solute can used in the flux calculation, is it worth hard coding this?

Suggested change
quantity_title = f"{self.field} flux surface {self.surface}"
quantity_title = f"solute flux surface {self.surface}"

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well I wouldn't cause we may move away from "solute" at some point

if field == "T":
expected_title = f"Heat flux surface {surface} ({my_h_flux.export_unit})"
else:
expected_title = f"{field} flux surface {surface} ({my_h_flux.export_unit})"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Again see previous comment on surface flux. Might be mistaken though

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

see previous comment

@jhdark
Copy link
Collaborator

jhdark commented Oct 25, 2024

Also might be worth adding another test for all the derived quantities without units, as many aren't being test at the moment (avg_surf, avg_vol, max_surf, max_vol, min_surf, min_vol, point_value, tot_surf, tot_vol). Just to get the full coverage

Co-authored-by: James Dark <65899899+jhdark@users.noreply.github.com>
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.

Deprecate DerivedQuantities.show_units
2 participants