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

Dataset: don't scale non-default units #470

Merged
merged 2 commits into from Nov 8, 2019

Conversation

mattwelborn
Copy link
Contributor

@mattwelborn mattwelborn commented Nov 7, 2019

Description

This PR fixes a bug in Dataset which caused data columns whose units do not match those of the dataframe to be incorrectly scaled. For example, in a dataset whose default_driver is energy but which contains a contributed values column of dipole moments, setting self.units = "hartree" (from self.units="kcal/mol"`) would cause the dipole moments to be scaled by 1/627.

Status

  • Changelog updated
  • Ready to go

for column in self.df.columns:
try:
self.df[column] *= constants.conversion_factor(self._column_metadata[column]["units"], value)
if self._column_metadata[column]["units"] != self._units:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

there might be a better way to check this to not trigger on "kcal/mol" != "kcal / mol"

Copy link
Contributor

@dgasmith dgasmith Nov 7, 2019

Choose a reason for hiding this comment

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

>>> qcel.constants.Quantity('kcal/mol') == qcel.constants.Quantity('kcal / mol')
True
>>> qcel.constants.Quantity('kcal/mol') != qcel.constants.Quantity('kJ / mol')
True

Copy link
Contributor

@dgasmith dgasmith Nov 7, 2019

Choose a reason for hiding this comment

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

Or more concrete:

>>> q1 = qcel.constants.Quantity('kcal/mol')
>>> q2 = qcel.constants.Quantity('kilocalorie / mole')
>>> q1 == q2
True

@codecov
Copy link

codecov bot commented Nov 8, 2019

Codecov Report

Merging #470 into master will decrease coverage by 0.05%.
The diff coverage is 87.5%.

@dgasmith dgasmith merged commit 91b554e into MolSSI:master Nov 8, 2019
@mattwelborn mattwelborn deleted the dataset_units branch November 30, 2019 18:42
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.

None yet

2 participants