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

Simplify unit handling in some setters #1570

Closed
wants to merge 3 commits into from
Closed

Conversation

mattwthompson
Copy link
Member

At various points in time we've needed to bake in logic to gracefully handle similar but heterogenous inputs. Each implementation has diverged over time; this change consolidates them and funnels most of the logic to a single choke point.

@codecov
Copy link

codecov bot commented Apr 3, 2023

Codecov Report

Merging #1570 (b5e86a8) into main (a498ae0) will increase coverage by 0.01%.
The diff coverage is 71.42%.

Additional details and impacted files

@mattwthompson mattwthompson marked this pull request as ready for review April 5, 2023 22:24
Comment on lines 411 to 420
def test_set_partial_charges_openmm_quantity(self, water):
import openmm.unit

with pytest.raises(ValueError, match="Cannot set.*openmm.unit"):
water.atoms[2].partial_charge = 0.0 * openmm.unit.elementary_charge

Copy link
Member Author

Choose a reason for hiding this comment

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

This could be added back (I forget why I removed it) but the error message will probably be difference since this is no longer being handled internally.

@mattwthompson mattwthompson added this to the 0.13.0 milestone Apr 21, 2023
@mattwthompson mattwthompson force-pushed the simpler-units branch 2 times, most recently from 6566b08 to 4e58a81 Compare June 28, 2023 21:21
@mattwthompson mattwthompson marked this pull request as draft June 29, 2023 13:55
@mattwthompson mattwthompson marked this pull request as ready for review July 3, 2023 14:19
Comment on lines -165 to -166
return str(input_quantity)

Copy link
Member

Choose a reason for hiding this comment

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

😱 How... long has this been around...?

Comment on lines -414 to -420
@requires_pkg("openmm")
def test_set_partial_charges_openmm_quantity(self, water):
import openmm.unit

with pytest.raises(ValueError, match="Cannot set.*openmm.unit"):
water.atoms[2].partial_charge = 0.0 * openmm.unit.elementary_charge

Copy link
Member

Choose a reason for hiding this comment

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

IIUC, this is no longer an error because the openmm Quantities are now valid inputs.

@mattwthompson
Copy link
Member Author

Thanks for the review - I'll have to look back and see why I wanted these changes in the first place and if they're still needed.

@mattwthompson mattwthompson marked this pull request as draft October 24, 2023 03:40
@mattwthompson mattwthompson deleted the simpler-units branch May 13, 2024 16:38
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.

2 participants