Skip to content

Commit

Permalink
Add test to check platform precision using a string + fix error (#551)
Browse files Browse the repository at this point in the history
* add test to check platform precision using a string

* Remove import in function that was causing an unbound local var
  • Loading branch information
mikemhenry authored Feb 22, 2022
1 parent 7e6926f commit 4fab09b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 5 additions & 0 deletions openmmtools/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ def test_platform_supports_precision():
if supported_precisions != set(['mixed']):
raise Exception(f"'CPU' platform should support 'mixed' precision, but platform_supports_precision reports {supported_precisions}")


def test_string_platform_supports_precision():
"""Test that if we use a string for the platform name, it works"""
assert platform_supports_precision("CPU", "mixed")

# =============================================================================
# TEST STRING MATHEMATICAL EXPRESSION PARSING UTILITIES
# =============================================================================
Expand Down
4 changes: 0 additions & 4 deletions openmmtools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,6 @@ def platform_supports_precision(platform, precision):
return precision in ['mixed']

if platform.getName() in ['CUDA', 'OpenCL']:
try:
import openmm
except ImportError: # OpenMM < 7.6
from simtk import openmm
properties = { 'Precision' : precision }
system = openmm.System()
system.addParticle(1.0) # Cannot create Context on a system with no particles
Expand Down

0 comments on commit 4fab09b

Please sign in to comment.