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

A generic units class for pyiron #397

Merged
merged 30 commits into from Aug 13, 2021
Merged

A generic units class for pyiron #397

merged 30 commits into from Aug 13, 2021

Conversation

sudarsan-surendralal
Copy link
Member

Leveraging the capabilities of pint to handle units for different simulation codes as well as modelling length and timescales.

@sudarsan-surendralal sudarsan-surendralal added the enhancement New feature or request label Aug 9, 2021
@sudarsan-surendralal sudarsan-surendralal marked this pull request as ready for review August 10, 2021 13:27
Copy link
Contributor

@pmrv pmrv left a comment

Choose a reason for hiding this comment

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

I left a few small remarks, but generally looks really nice!

I especially liked the detailed usage examples, do they pass under doctest? No problem if they don't, tough, but it's easy to check and a nice bonus.

pyiron_base/generic/units.py Show resolved Hide resolved
pyiron_base/generic/units.py Outdated Show resolved Hide resolved
pyiron_base/generic/units.py Show resolved Hide resolved
pyiron_base/generic/units.py Outdated Show resolved Hide resolved
pyiron_base/generic/units.py Outdated Show resolved Hide resolved
pyiron_base/generic/units.py Outdated Show resolved Hide resolved
pyiron_base/generic/units.py Show resolved Hide resolved
code_units.add_quantity(quantity="energy",
unit=pint_registry.kilocal / (pint_registry.mol * pint_registry.N_A))
code_units.add_labels(labels=["energy_tot", "energy_pot"], quantity="energy")
# Raise Error for undefined quantity
Copy link
Contributor

@pmrv pmrv Aug 12, 2021

Choose a reason for hiding this comment

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

Comments like this could live inside self.assertRaises(..., msg='Raise Error for undefined quantity') to make the test output a little bit more readable.

tests/generic/test_units.py Outdated Show resolved Hide resolved
pyiron_base/generic/units.py Outdated Show resolved Hide resolved
sudarsan-surendralal and others added 11 commits August 12, 2021 12:28
Co-authored-by: Marvin Poul <poul@mpie.de>
Co-authored-by: Marvin Poul <poul@mpie.de>
Co-authored-by: Marvin Poul <poul@mpie.de>
Co-authored-by: Marvin Poul <poul@mpie.de>
Co-authored-by: Marvin Poul <poul@mpie.de>
� Conflicts:
�	pyiron_base/generic/units.py
@sudarsan-surendralal sudarsan-surendralal linked an issue Aug 12, 2021 that may be closed by this pull request
@sudarsan-surendralal
Copy link
Member Author

I've found a way to test the Docstrings properly as well. If this is also okay, I can merge this!

@pmrv
Copy link
Contributor

pmrv commented Aug 13, 2021

I've found a way to test the Docstrings properly as well. If this is also okay, I can merge this!

Cool! I had meant to just check it once, but this will make keeping the docstring up to date much easier, thanks!

@pmrv pmrv self-requested a review August 13, 2021 13:03
@sudarsan-surendralal sudarsan-surendralal merged commit de24445 into master Aug 13, 2021
@delete-merged-branch delete-merged-branch bot deleted the units branch August 13, 2021 13:08
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.

Ontology for units
3 participants