Skip to content

Commit

Permalink
Merge pull request #24 from bc118/add_Rsq_tol_params
Browse files Browse the repository at this point in the history
changed fit_validation_r_squared_rtol range to 0 < fit_min_validated_r_squared < 1
  • Loading branch information
bc118 authored Sep 24, 2023
2 parents 649053e + 4382da3 commit 7a9b036
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
10 changes: 5 additions & 5 deletions mosdef_dihedral_fit/dihedral_fit/fit_dihedral_with_gomc.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def fit_dihedral_with_gomc(
NOTE: This value may need adjusted to get the dihedral fit to solve correctly.
fit_validation_r_squared_rtol: float>0, default=2.5e-02
fit_validation_r_squared_rtol: float (0 < fit_min_validated_r_squared < 1), default=2.5e-02
Where the QM data is defined as the actual data; this is the difference
of the dihedral's calculated R-squared values between:
* The QM-MM fitting process, where the fit MM dihedral k-values are zero (0).
Expand Down Expand Up @@ -622,20 +622,20 @@ def fit_dihedral_with_gomc(
else:
raise TypeError(
f"ERROR: The 'fit_min_validated_r_squared' is a {type(fit_min_validated_r_squared)}, "
f"but it must be a float."
f"but it must be a 0<float<1."
)

# test the 'fit_validation_r_squared_rtol' input
if isinstance(fit_validation_r_squared_rtol, float):
if not fit_validation_r_squared_rtol > 0 :
if not (fit_validation_r_squared_rtol>0 and fit_validation_r_squared_rtol<1):
raise ValueError(
f"ERROR: The 'fit_validation_r_squared_rtol' = {fit_validation_r_squared_rtol}, "
f"but it must be a float>0.")
f"but it must be a 0<float<1.")

else:
raise TypeError(
f"ERROR: The 'fit_validation_r_squared_rtol' is a {type( fit_validation_r_squared_rtol)}, "
f"but it must be a float."
f"but it must be a 0<float<1."
)

# test the 'gomc_cpu_cores' input
Expand Down
12 changes: 6 additions & 6 deletions mosdef_dihedral_fit/tests/test_fit_dihedral_with_gomc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3927,7 +3927,7 @@ def test_fit_min_validated_r_squared_not_a_float(self):
with pytest.raises(
TypeError,
match=f"ERROR: The 'fit_min_validated_r_squared' is a {type(2)}, "
f"but it must be a float."
f"but it must be a 0<float<1."
):
fit_dihedral_with_gomc(
['CT', 'CT', 'C', 'OH'],
Expand All @@ -3954,7 +3954,7 @@ def test_fit_validation_r_squared_rtol_not_correct_value_is_0(self):
with pytest.raises(
ValueError,
match=f"ERROR: The 'fit_validation_r_squared_rtol' = {0.00}, "
f"but it must be a float>0"
f"but it must be a 0<float<1."
):
fit_dihedral_with_gomc(
['CT', 'CT', 'C', 'OH'],
Expand All @@ -3980,8 +3980,8 @@ def test_fit_validation_r_squared_rtol_not_correct_value_is_0(self):
def test_fit_validation_r_squared_rtol_not_correct_value_is_1(self):
with pytest.raises(
ValueError,
match=f"ERROR: The 'fit_validation_r_squared_rtol' = {-1.00}, "
f"but it must be a float>0."
match=f"ERROR: The 'fit_validation_r_squared_rtol' = {1.00}, "
f"but it must be a 0<float<1."
):
fit_dihedral_with_gomc(
['CT', 'CT', 'C', 'OH'],
Expand All @@ -4001,14 +4001,14 @@ def test_fit_validation_r_squared_rtol_not_correct_value_is_1(self):
atom_type_naming_style='general',
gomc_cpu_cores=1,
fit_min_validated_r_squared=0.99,
fit_validation_r_squared_rtol=-1.00
fit_validation_r_squared_rtol=1.00
)

def test_fit_validation_r_squared_rtol_not_a_float(self):
with pytest.raises(
TypeError,
match=f"ERROR: The 'fit_validation_r_squared_rtol' is a {type(2)}, "
f"but it must be a float."
f"but it must be a 0<float<1."
):
fit_dihedral_with_gomc(
['CT', 'CT', 'C', 'OH'],
Expand Down

0 comments on commit 7a9b036

Please sign in to comment.