Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 23, 2023
1 parent 797b2e9 commit ec39a40
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 40 deletions.
29 changes: 14 additions & 15 deletions mosdef_gomc/formats/gmso_gomc_conf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1446,13 +1446,12 @@ def _get_possible_ensemble_input_variables(ensemble_type):
]

elif ensemble_type in ["GEMC_NPT", "GEMC_NVT"]:
extra_sim_info_variables_list = \
[
"RcutCoulomb_box_1",
"FixVolBox0",
"MultiParticleLiquid",
"MultiParticleGas"
]
extra_sim_info_variables_list = [
"RcutCoulomb_box_1",
"FixVolBox0",
"MultiParticleLiquid",
"MultiParticleGas",
]

free_energy_variables_list = [] # always empty for GEMC

Expand Down Expand Up @@ -3146,9 +3145,7 @@ def __init__(
self.MultiParticleLiquid = default_input_variables_dict[
"MultiParticleLiquid"
]
self.MultiParticleGas = default_input_variables_dict[
"MultiParticleGas"
]
self.MultiParticleGas = default_input_variables_dict["MultiParticleGas"]

# MEMC data input
self.ExchangeVolumeDim = default_input_variables_dict[
Expand Down Expand Up @@ -3499,8 +3496,8 @@ def __init__(
)

if (
input_var_keys_list[var_iter] == key
and key in possible_ensemble_variables_list
input_var_keys_list[var_iter] == key
and key in possible_ensemble_variables_list
):
self.MultiParticleLiquid = self.input_variables_dict[key]

Expand All @@ -3513,8 +3510,8 @@ def __init__(
)

if (
input_var_keys_list[var_iter] == key
and key in possible_ensemble_variables_list
input_var_keys_list[var_iter] == key
and key in possible_ensemble_variables_list
):
self.MultiParticleGas = self.input_variables_dict[key]

Expand Down Expand Up @@ -6682,7 +6679,9 @@ def write_conf_file(self, conf_filename):
"GEMC_NVT",
]:
data_control_file.write(
"{:25s} {}\n".format("MultiParticleLiquid", self.MultiParticleLiquid)
"{:25s} {}\n".format(
"MultiParticleLiquid", self.MultiParticleLiquid
)
)
data_control_file.write(
"{:25s} {}\n".format("MultiParticleGas", self.MultiParticleGas)
Expand Down
74 changes: 49 additions & 25 deletions mosdef_gomc/tests/test_gmso_gomc_conf_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1728,7 +1728,9 @@ def test_save_basic_GEMC_NPT(self, ethane_gomc):
"RcutCoulomb_box_1": True,
}

def test_save_change_most_variable_NVT_mulitparticle(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_NVT_mulitparticle(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand Down Expand Up @@ -1810,7 +1812,9 @@ def test_save_change_most_variable_NVT_mulitparticle(self, ethane_gomc, ethanol_
},
)

with open("test_save_change_most_variable_NVT_mulitparticle.conf", "r") as fp:
with open(
"test_save_change_most_variable_NVT_mulitparticle.conf", "r"
) as fp:
variables_read_dict = {
"Restart": False,
"ExpertMode": False,
Expand Down Expand Up @@ -2350,7 +2354,9 @@ def test_save_change_most_variable_NVT_mulitparticle(self, ethane_gomc, ethanol_
"OutSurfaceTension": True,
}

def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_default(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_default(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand Down Expand Up @@ -2384,7 +2390,10 @@ def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_default(self,
},
)

with open("test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_default.conf", "r") as fp:
with open(
"test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_default.conf",
"r",
) as fp:
variables_read_dict = {
"MultiParticleLiquid": False,
"MultiParticleGas": False,
Expand All @@ -2409,8 +2418,9 @@ def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_default(self,
"MultiParticleGas": True,
}


def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_both_false(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_both_false(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand Down Expand Up @@ -2446,7 +2456,10 @@ def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_both_false(se
},
)

with open("test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_both_false.conf", "r") as fp:
with open(
"test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_both_false.conf",
"r",
) as fp:
variables_read_dict = {
"MultiParticleLiquid": False,
"MultiParticleGas": False,
Expand All @@ -2471,7 +2484,9 @@ def test_save_change_most_variable_GEMC_NVT_mulitparticle_settings_both_false(se
"MultiParticleGas": True,
}

def test_save_change_most_variable_GEMC_NPT_mulitparticle_settings_both_true(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_GEMC_NPT_mulitparticle_settings_both_true(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand Down Expand Up @@ -2507,7 +2522,10 @@ def test_save_change_most_variable_GEMC_NPT_mulitparticle_settings_both_true(sel
},
)

with open("test_save_change_most_variable_GEMC_NPT_mulitparticle_settings_both_true.conf", "r") as fp:
with open(
"test_save_change_most_variable_GEMC_NPT_mulitparticle_settings_both_true.conf",
"r",
) as fp:
variables_read_dict = {
"MultiParticleLiquid": False,
"MultiParticleGas": False,
Expand All @@ -2532,7 +2550,9 @@ def test_save_change_most_variable_GEMC_NPT_mulitparticle_settings_both_true(sel
"MultiParticleGas": True,
}

def test_save_change_most_variable_GEMC_NPT_mulitparticle_not_printed_for_NVT(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_GEMC_NPT_mulitparticle_not_printed_for_NVT(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand All @@ -2546,13 +2566,13 @@ def test_save_change_most_variable_GEMC_NPT_mulitparticle_not_printed_for_NVT(se
forcefield_selection="oplsaa",
)
with pytest.raises(
ValueError,
match=r"ERROR: All the correct input variables where not provided for "
r"the NVT ensemble. Please be sure to check that the keys in the "
r"input variables dictionary \(input_variables_dict\) is correct, and "
r"be aware that added spaces before or after the variable in any keys "
r"will also give this warning. The bad variable inputs ensemble "
r"inputs = \['MultiParticleLiquid', 'MultiParticleGas'\]",
ValueError,
match=r"ERROR: All the correct input variables where not provided for "
r"the NVT ensemble. Please be sure to check that the keys in the "
r"input variables dictionary \(input_variables_dict\) is correct, and "
r"be aware that added spaces before or after the variable in any keys "
r"will also give this warning. The bad variable inputs ensemble "
r"inputs = \['MultiParticleLiquid', 'MultiParticleGas'\]",
):
gomc_control.write_gomc_control_file(
charmm,
Expand All @@ -2574,7 +2594,9 @@ def test_save_change_most_variable_GEMC_NPT_mulitparticle_not_printed_for_NVT(se
},
)

def test_save_change_most_variable_GEMC_NPT_bad_mulitparticle_liquid_setting(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_GEMC_NPT_bad_mulitparticle_liquid_setting(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand All @@ -2591,11 +2613,11 @@ def test_save_change_most_variable_GEMC_NPT_bad_mulitparticle_liquid_setting(sel
)

with pytest.raises(
ValueError,
match=r"ERROR: The following input variables have "
r"bad values \(check spelling and for empty spaces in the keys or that "
r"the values are in the correct form with the acceptable values\)"
r": \['MultiParticleLiquid'\]",
ValueError,
match=r"ERROR: The following input variables have "
r"bad values \(check spelling and for empty spaces in the keys or that "
r"the values are in the correct form with the acceptable values\)"
r": \['MultiParticleLiquid'\]",
):
gomc_control.write_gomc_control_file(
charmm,
Expand All @@ -2617,7 +2639,9 @@ def test_save_change_most_variable_GEMC_NPT_bad_mulitparticle_liquid_setting(sel
},
)

def test_save_change_most_variable_GEMC_NPT_bad_mulitparticle_gas_setting(self, ethane_gomc, ethanol_gomc):
def test_save_change_most_variable_GEMC_NPT_bad_mulitparticle_gas_setting(
self, ethane_gomc, ethanol_gomc
):
test_box_ethane_ethanol = mb.fill_box(
compound=[ethane_gomc, ethanol_gomc],
n_compounds=[1, 1],
Expand Down Expand Up @@ -16205,4 +16229,4 @@ def test_exp6_with_exp6_conf_config(self, hexane_ua):
"Coordinates_box_0": True,
"Structure_box_0": True,
"Potential": True,
}
}

0 comments on commit ec39a40

Please sign in to comment.