Skip to content

Commit

Permalink
applied black
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiCheng45 committed Mar 11, 2024
1 parent 14d3ab7 commit e586775
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 24 deletions.
20 changes: 16 additions & 4 deletions MDANSE/Tests/UnitTests/AtomMapping/test_atom_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,20 @@ def test_get_element_from_mapping_with_no_entry_raises_error_with_bad_label():


def test_fill_remaining_labels_fill_mapping_correctly_already_filled_1():
labels = [AtomLabel("label1", molecule="mol1"), AtomLabel("label2", molecule="mol1")]
labels = [
AtomLabel("label1", molecule="mol1"),
AtomLabel("label2", molecule="mol1"),
]
mapping = {"molecule=mol1": {"label1": "C", "label2": "C"}}
fill_remaining_labels(mapping, labels)
assert mapping == {"molecule=mol1": {"label1": "C", "label2": "C"}}


def test_fill_remaining_labels_fill_mapping_correctly_already_filled_2():
labels = [AtomLabel("label1", molecule="mol1"), AtomLabel("label1", molecule="mol1")]
labels = [
AtomLabel("label1", molecule="mol1"),
AtomLabel("label1", molecule="mol1"),
]
mapping = {"molecule=mol1": {"label1": "C"}}
fill_remaining_labels(mapping, labels)
assert mapping == {"molecule=mol1": {"label1": "C"}}
Expand All @@ -108,12 +114,18 @@ def test_check_mapping_valid_as_elements_are_correct():


def test_check_mapping_not_valid_as_elements_not_correct():
labels = [AtomLabel("label1", molecule="mol1"), AtomLabel("label2", molecule="mol1")]
labels = [
AtomLabel("label1", molecule="mol1"),
AtomLabel("label2", molecule="mol1"),
]
mapping = {"molecule=mol1": {"label1": "C", "label2": "aaa"}}
assert not check_mapping_valid(mapping, labels)


def test_check_mapping_not_valid_due_to_missing_mappings():
labels = [AtomLabel("label1", molecule="mol1"), AtomLabel("label2", molecule="mol1")]
labels = [
AtomLabel("label1", molecule="mol1"),
AtomLabel("label2", molecule="mol1"),
]
mapping = {"molecule=mol1": {"label1": "C"}}
assert not check_mapping_valid(mapping, labels)
3 changes: 2 additions & 1 deletion MDANSE/Tests/UnitTests/test_configurator.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def test_integer_configurator(self):
self.assertEqual(configurator["value"], 10)
configurator.configure(10.1)
self.assertEqual(configurator["value"], 10)
configurator.configure('xxxx')
configurator.configure("xxxx")
self.assertFalse(configurator.valid)

def test_float_configurator(self):
Expand Down Expand Up @@ -137,6 +137,7 @@ def test_projection_planar(self):

def test_XYZFileConfigurator_with_cp2k_pos():
from MDANSE.Framework.Configurators.XYZFileConfigurator import XYZFileConfigurator

xyz_file = XYZFileConfigurator("test")
xyz_file["filename"] = cp2k_pos
xyz_file.parse()
Expand Down
44 changes: 25 additions & 19 deletions MDANSE/Tests/UnitTests/test_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,15 +248,17 @@ def test_xyz_mdt_conversion_file_exists_and_loads_up_successfully(compression):


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_dlp_mdt_conversion_file_exists_and_loads_up_successfully_with_dlp_version_2(compression):
def test_dlp_mdt_conversion_file_exists_and_loads_up_successfully_with_dlp_version_2(
compression,
):
temp_name = tempfile.mktemp()

parameters = {
'atom_aliases': '{}',
'field_file': dlp_field_v2,
'fold': False,
'history_file': dlp_history_v2,
'output_file': (temp_name, 64, compression),
"atom_aliases": "{}",
"field_file": dlp_field_v2,
"fold": False,
"history_file": dlp_history_v2,
"output_file": (temp_name, 64, compression),
}
dl_poly = Converter.create("DL_POLY")
dl_poly.run(parameters, status=True)
Expand All @@ -269,15 +271,17 @@ def test_dlp_mdt_conversion_file_exists_and_loads_up_successfully_with_dlp_versi


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_dlp_mdt_conversion_file_exists_and_loads_up_successfully_with_dlp_version_4(compression):
def test_dlp_mdt_conversion_file_exists_and_loads_up_successfully_with_dlp_version_4(
compression,
):
temp_name = tempfile.mktemp()

parameters = {
'atom_aliases': '{}',
'field_file': dlp_field_v4,
'fold': False,
'history_file': dlp_history_v4,
'output_file': (temp_name, 64, compression),
"atom_aliases": "{}",
"field_file": dlp_field_v4,
"fold": False,
"history_file": dlp_history_v4,
"output_file": (temp_name, 64, compression),
}
dl_poly = Converter.create("DL_POLY")
dl_poly.run(parameters, status=True)
Expand All @@ -290,15 +294,17 @@ def test_dlp_mdt_conversion_file_exists_and_loads_up_successfully_with_dlp_versi


@pytest.mark.parametrize("compression", ["none", "gzip", "lzf"])
def test_namd_mdt_conversion_file_exists_and_loads_up_successfully_and_chemical_system_has_correct_number_of_atoms(compression):
def test_namd_mdt_conversion_file_exists_and_loads_up_successfully_and_chemical_system_has_correct_number_of_atoms(
compression,
):
temp_name = tempfile.mktemp()

parameters = {
'dcd_file': apoferritin_dcd,
'fold': False,
'output_file': (temp_name, 64, compression),
'pdb_file': apoferritin_pdb,
'time_step': '1.0',
"dcd_file": apoferritin_dcd,
"fold": False,
"output_file": (temp_name, 64, compression),
"pdb_file": apoferritin_pdb,
"time_step": "1.0",
}
namd = Converter.create("NAMD")
namd.run(parameters, status=True)
Expand All @@ -310,4 +316,4 @@ def test_namd_mdt_conversion_file_exists_and_loads_up_successfully_and_chemical_
assert hdftradj["instance"].chemical_system.number_of_atoms == 12397

hdftradj["instance"].close()
os.remove(temp_name + ".mdt")
os.remove(temp_name + ".mdt")
1 change: 1 addition & 0 deletions MDANSE/Tests/UnitTests/test_text_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def trajectory():
trajectory = HDFTrajectoryInputData(short_traj)
yield trajectory


def test_temperature(trajectory):
temp_name = tempfile.mktemp()
parameters = {}
Expand Down

0 comments on commit e586775

Please sign in to comment.