Skip to content

Commit a0f476e

Browse files
committed
fix and update unit tests to reflect changes made within this refactor
1 parent b63156a commit a0f476e

3 files changed

Lines changed: 291 additions & 197 deletions

File tree

tests/test_CodeEntropy/test_data_logger.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import tempfile
55
import unittest
66

7+
import numpy as np
78
import pandas as pd
89

910
from CodeEntropy.config.data_logger import DataLogger
@@ -57,19 +58,32 @@ def test_add_results_data(self):
5758
)
5859
self.assertEqual(
5960
self.logger.molecule_data,
60-
[("0", "united_atom", "Transvibrational", 653.4041220313459)],
61+
[(0, "united_atom", "Transvibrational", 653.4041220313459)],
6162
)
6263

6364
def test_add_residue_data(self):
6465
"""
6566
Test that add_residue_data correctly appends a residue-level entry.
6667
"""
6768
self.logger.add_residue_data(
68-
0, "DA", "united_atom", "Transvibrational", 122.61216935211893
69+
0, "DA", "united_atom", "Transvibrational", 10, 122.61216935211893
6970
)
7071
self.assertEqual(
7172
self.logger.residue_data,
72-
[[0, "DA", "united_atom", "Transvibrational", 122.61216935211893]],
73+
[[0, "DA", "united_atom", "Transvibrational", 10, 122.61216935211893]],
74+
)
75+
76+
def test_add_residue_data_with_numpy_array(self):
77+
"""
78+
Test that add_residue_data correctly converts a NumPy array to a list.
79+
"""
80+
frame_array = np.array([10])
81+
self.logger.add_residue_data(
82+
1, "DT", "united_atom", "Transvibrational", frame_array, 98.123456789
83+
)
84+
self.assertEqual(
85+
self.logger.residue_data,
86+
[[1, "DT", "united_atom", "Transvibrational", [10], 98.123456789]],
7387
)
7488

7589
def test_save_dataframes_as_json(self):
@@ -128,14 +142,16 @@ def test_log_tables_rich_output(self):
128142
0, "united_atom", "Transvibrational", 653.4041220313459
129143
)
130144
self.logger.add_residue_data(
131-
0, "DA", "united_atom", "Transvibrational", 122.61216935211893
145+
0, "DA", "united_atom", "Transvibrational", 10, 122.61216935211893
132146
)
147+
self.logger.add_group_label(0, "DA", 10, 100)
133148

134149
self.logger.log_tables()
135150

136151
output = console.export_text()
137152
assert "Molecule Entropy Results" in output
138153
assert "Residue Entropy Results" in output
154+
assert "Group ID to Residue Label Mapping" in output
139155

140156

141157
if __name__ == "__main__":

0 commit comments

Comments
 (0)