Skip to content

Model.add_number and add_variable now allow unit objects as well as strings#172

Merged
MichaelClerx merged 4 commits intodevelopfrom
132-unit-arguments
Dec 6, 2019
Merged

Model.add_number and add_variable now allow unit objects as well as strings#172
MichaelClerx merged 4 commits intodevelopfrom
132-unit-arguments

Conversation

@MichaelClerx
Copy link
Copy Markdown
Contributor

See #132

Leaving in the option to use strings for now, as it's used in lots of tests etc. Might be nice for users too

@MichaelClerx MichaelClerx requested review from jonc125 and skeating and removed request for skeating December 2, 2019 20:03
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 2, 2019

Codecov Report

Merging #172 into develop will increase coverage by 0.25%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #172      +/-   ##
===========================================
+ Coverage    95.89%   96.14%   +0.25%     
===========================================
  Files            6        6              
  Lines          876      882       +6     
  Branches       182      184       +2     
===========================================
+ Hits           840      848       +8     
+ Misses          19       17       -2     
  Partials        17       17
Impacted Files Coverage Δ
cellmlmanip/units.py 96.37% <ø> (+0.72%) ⬆️
cellmlmanip/model.py 99.62% <100%> (ø) ⬆️
cellmlmanip/parser.py 95.05% <100%> (+0.02%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 575cb90...2f08502. Read the comment docs.

Copy link
Copy Markdown
Contributor

@jonc125 jonc125 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. Couple of minor suggestions; see what you think.

Comment thread cellmlmanip/model.py

:param number: A number (anything convertible to float).
:param units: A string unit representation.
:param units: A `pint` units representation
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As this also accepts strings, should we keep that option in the docs too? Or hide it just for use by our tests?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, and should it be double backticks? My reST is rusty!

Comment thread cellmlmanip/model.py
ontology_terms.append(uri_parts[-1])
return ontology_terms

def get_units(self, name):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Should we use this method above?

Comment thread cellmlmanip/units.py
:return: pint.Unit
throws pint.UndefinedUnitError if te unit is not present in registry
:return: `Unit`
throws pint.UndefinedUnitError if the unit is not present in registry
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could use the Sphinx :raises pint.UndefinedUnitError: if... syntax here, actually?

Copy link
Copy Markdown
Contributor

@skeating skeating left a comment

Choose a reason for hiding this comment

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

Looks cool to me

@skeating skeating mentioned this pull request Dec 5, 2019
27 tasks
@MichaelClerx MichaelClerx merged commit df5becb into develop Dec 6, 2019
@MichaelClerx MichaelClerx deleted the 132-unit-arguments branch December 6, 2019 16:08
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