Skip to content

Conversation

@henrikjacobsenfys
Copy link
Member

Added desired units for the dependent parameter constructors, and a method to change it later: set_desired_unit

@codecov
Copy link

codecov bot commented Jan 9, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.16%. Comparing base (bd10653) to head (585305e).

Files with missing lines Patch % Lines
src/easyscience/variable/parameter.py 86.66% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop     #188   +/-   ##
========================================
  Coverage    81.15%   81.16%           
========================================
  Files           52       52           
  Lines         4267     4279   +12     
  Branches       740      742    +2     
========================================
+ Hits          3463     3473   +10     
- Misses         624      625    +1     
- Partials       180      181    +1     
Flag Coverage Δ
unittests 81.16% <86.66%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/easyscience/variable/parameter.py 90.35% <86.66%> (-0.14%) ⬇️

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

This pull request does not contain a valid label. Please add one of the following labels: ['[scope] bug', '[scope] enhancement', '[scope] documentation', '[scope] significant', '[scope] maintenance']

try:
self._convert_unit(self._desired_unit)
except Exception as e:
raise UnitError(f'Failed to convert unit from {temporary_parameter.unit} to {self._desired_unit}: {e}')
Copy link
Member

Choose a reason for hiding this comment

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

Should we completely bail out on bad unit conversion? Maybe return the original value with the original unit and warn users of the failure of the unit conversion.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, good question. I tend to think yes, since something must have gone wrong if the user expects a unit that is incompatible with the calculated unit.

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.

3 participants