Skip to content

Commit ab32e19

Browse files
authored
BugFix: NUMBER_BY_SYMBOL is a dict (#798)
use `dict[key]`, not `dict(key)` in plotter
2 parents 1039e88 + ecca8c5 commit ab32e19

3 files changed

Lines changed: 21 additions & 9 deletions

File tree

arc/plotter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ def save_irc_traj_animation(irc_f_path, irc_r_path, out_path):
751751
f.write(' Number Number Type X Y Z\n')
752752
f.write(' ---------------------------------------------------------------------\n')
753753
for i, symbol in enumerate(xyz['symbols']):
754-
el_num, x, y, z = NUMBER_BY_SYMBOL(symbol), xs[i], ys[i], zs[i]
754+
el_num, x, y, z = NUMBER_BY_SYMBOL[symbol], xs[i], ys[i], zs[i]
755755
f.write(f' {i + 1:>5} {el_num} 0 {x} {y} {z}\n')
756756
f.write(' ---------------------------------------------------------------------\n')
757757
f.write(' GradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGradGrad\n')

arc/plotter_test.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,16 @@ def test_delete_multi_species_output_file(self):
209209
self.assertFalse(os.path.isfile(os.path.join(ARC_PATH, 'arc', 'testing', 'acetylene.log')))
210210
self.assertFalse(os.path.isfile(os.path.join(ARC_PATH, 'arc', 'testing', 'N-Valeric_Acid.log')))
211211

212+
def test_save_irc_traj_animation(self):
213+
"""Test the save_irc_traj_animation function"""
214+
irc_f_path = os.path.join(ARC_PATH, 'arc', 'testing', 'irc', 'rxn_1_irc_1.out')
215+
irc_r_path = os.path.join(ARC_PATH, 'arc', 'testing', 'irc', 'rxn_1_irc_2.out')
216+
out_path = os.path.join(ARC_PATH, 'arc', 'testing', 'irc', 'rxn_1_irc_animation.out')
217+
self.assertFalse(os.path.isfile(out_path))
218+
plotter.save_irc_traj_animation(irc_f_path, irc_r_path, out_path)
219+
self.assertTrue(os.path.isfile(out_path))
220+
221+
212222
@classmethod
213223
def tearDownClass(cls):
214224
"""A function that is run ONCE after all unit tests in this class."""
@@ -218,7 +228,9 @@ def tearDownClass(cls):
218228
files_to_remove = [os.path.join(ARC_PATH, 'arc', 'testing', 'bde_report_test.txt'),
219229
os.path.join(ARC_PATH, 'arc', 'testing', 'water.log'),
220230
os.path.join(ARC_PATH, 'arc', 'testing', 'acetylene.log'),
221-
os.path.join(ARC_PATH, 'arc', 'testing', 'N-Valeric_Acid.log'),]
231+
os.path.join(ARC_PATH, 'arc', 'testing', 'N-Valeric_Acid.log'),
232+
os.path.join(ARC_PATH, 'arc', 'testing', 'irc', 'rxn_1_irc_animation.out'),
233+
]
222234
for file_path in files_to_remove:
223235
if os.path.isfile(file_path):
224236
os.remove(file_path)

arc/species/converter_test.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4003,7 +4003,7 @@ def test_modify_coords(self):
40034003
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
40044004
modification_type=modification_type, mol=mol1)
40054005
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4006-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 5)
4006+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
40074007

40084008
indices, new_val = [1, 0], -1.5
40094009
expected_xyz = {'symbols': ('O', 'C', 'C', 'O', 'H', 'H', 'H', 'H'), 'isotopes': (16, 12, 12, 16, 1, 1, 1, 1),
@@ -4034,7 +4034,7 @@ def test_modify_coords(self):
40344034
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
40354035
modification_type=modification_type, mol=mol1)
40364036
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4037-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 5)
4037+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
40384038

40394039
# test changing an angle to 180 degrees
40404040
indices, new_val = [0, 1, 2], 180
@@ -4080,7 +4080,7 @@ def test_modify_coords(self):
40804080
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
40814081
modification_type=modification_type, mol=mol1)
40824082
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4083-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 5)
4083+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
40844084

40854085
indices, new_val = [3, 2, 1, 0], -30
40864086
expected_xyz = {'symbols': ('O', 'C', 'C', 'O', 'H', 'H', 'H', 'H'), 'isotopes': (16, 12, 12, 16, 1, 1, 1, 1),
@@ -4131,7 +4131,7 @@ def test_modify_coords(self):
41314131
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
41324132
modification_type=modification_type, mol=mol1)
41334133
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4134-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 5)
4134+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
41354135

41364136
# test A_group modification
41374137
indices, new_val = [0, 1, 2], 160
@@ -4147,7 +4147,7 @@ def test_modify_coords(self):
41474147
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
41484148
modification_type=modification_type, mol=mol1)
41494149
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4150-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 5)
4150+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
41514151

41524152
indices, new_val = [1, 2, 5], 160
41534153
expected_xyz = {'symbols': ('O', 'C', 'C', 'S', 'O', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'),
@@ -4211,7 +4211,7 @@ def test_modify_coords(self):
42114211
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
42124212
modification_type=modification_type, mol=mol1)
42134213
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4214-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 5)
4214+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
42154215

42164216
indices, new_val = [5, 2, 1, 0], 180
42174217
expected_xyz = {'symbols': ('O', 'C', 'C', 'S', 'O', 'C', 'C', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H', 'H'),
@@ -4278,7 +4278,7 @@ def test_modify_coords(self):
42784278
new_xyz = converter.modify_coords(coords=xyz1, indices=indices, new_value=new_val,
42794279
modification_type=modification_type, mol=mol1)
42804280
self.assertTrue(almost_equal_coords_lists(new_xyz, expected_xyz))
4281-
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 4)
4281+
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=indices, mol=mol1), new_val, 3)
42824282
self.assertAlmostEqual(converter.get_zmat_param_value(coords=xyz1, indices=[4, 1, 2, 3], mol=mol1),
42834283
176.7937925, 4)
42844284
self.assertAlmostEqual(converter.get_zmat_param_value(coords=new_xyz, indices=[4, 1, 2, 3], mol=mol1),

0 commit comments

Comments
 (0)