-
Notifications
You must be signed in to change notification settings - Fork 9
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
RecommendedCutoffMixin
: store the unit of cutoffs in extras
#57
Conversation
@mbercx I served you a cold one! 🍺 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deze PR is bijna even lekker als een Tripel Karmeliet! 🍺
Still left a few comments. Main issue is the fact that the units are set to None
in the extras when no unit is specified in the set_cutoffs
method.
@@ -107,16 +128,19 @@ def set_cutoffs(self, cutoffs: dict, default_stringency: str = None) -> None: | |||
:param default_stringency: the default stringency to be used when ``get_recommended_cutoffs`` is called. If is | |||
possible to not specify this if and only if the cutoffs only contain a single stringency set. That one will | |||
then automatically be set as default. | |||
:param unit: TODO |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By storing the unit of the cutoffs values explicitly in the extras, it not only will give more certainty to the user of what the cutoffs mean because they can inspect the unit, but the `get_recommended_cutoffs` method can also provide the `unit` argument to automatically convert it to another unit of energy if so desired. The conversion between units is provided by the `pint` library, which is added as a dependency. Users can specify units in the API through strings using the names that are recognized by `pint`. Both the shorthand, e.g. `eV`, as well as the long version `electron_volt` can be used. Other common energy units are `Ry` and `Eh`, for Rydberg and Hartree atomic units respectively. The default unit that is set when defining recommended cutoffs is still set to be electron volt, which was the implicitly assumed unit uptil now. Families that have been created with versions preceding this commit, will not actually have the unit defined in the unit, but `get_cutoffs_unit` will return the default electron volt if it is missing. This does mean that the `RecommendedCutoffMixin`DEFAULT_UNIT` cannot be changed or this would lead to old families to be interpreted to have the incorrect unit.
3686caa
to
24eb652
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another round, bartender!
@@ -143,13 +169,17 @@ def get_recommended_cutoffs(self, *, elements=None, structure=None, stringency=N | |||
:param stringency: optional stringency if different from the default. | |||
:return: tuple of recommended wavefunction and density cutoff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where is the unit
parameter? 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⭐ ⭐ ⭐ ⭐ ⭐ Would review again.
Fixes #47
By storing the unit of the cutoffs values explicitly in the extras, it
not only will give more certainty to the user of what the cutoffs mean
because they can inspect the unit, but the
get_recommended_cutoffs
method can also provide the
unit
argument to automatically convert itto another unit of energy if so desired.
The conversion between units is provided by the
pint
library, which isadded as a dependency. Users can specify units in the API through
strings using the names that are recognized by
pint
. Both theshorthand, e.g.
eV
, as well as the long versionelectron_volt
can beused. Other common energy units are
Ry
andEh
, for Rydberg andHartree atomic units respectively.
The default unit that is set when defining recommended cutoffs is still
set to be electron volt, which was the implicitly assumed unit uptil now.
Families that have been created with versions preceding this commit,
will not actually have the unit defined in the unit, but
get_cutoffs_unit
will return the default electron volt if it ismissing. This does mean that the
RecommendedCutoffMixin.DEFAULT_UNIT
cannot be changed or this would lead to old families to be interpreted
to have the incorrect unit.