|
4 | 4 | import tempfile |
5 | 5 | import unittest |
6 | 6 |
|
| 7 | +import numpy as np |
7 | 8 | import pandas as pd |
8 | 9 |
|
9 | 10 | from CodeEntropy.config.data_logger import DataLogger |
@@ -57,19 +58,32 @@ def test_add_results_data(self): |
57 | 58 | ) |
58 | 59 | self.assertEqual( |
59 | 60 | self.logger.molecule_data, |
60 | | - [("0", "united_atom", "Transvibrational", 653.4041220313459)], |
| 61 | + [(0, "united_atom", "Transvibrational", 653.4041220313459)], |
61 | 62 | ) |
62 | 63 |
|
63 | 64 | def test_add_residue_data(self): |
64 | 65 | """ |
65 | 66 | Test that add_residue_data correctly appends a residue-level entry. |
66 | 67 | """ |
67 | 68 | self.logger.add_residue_data( |
68 | | - 0, "DA", "united_atom", "Transvibrational", 122.61216935211893 |
| 69 | + 0, "DA", "united_atom", "Transvibrational", 10, 122.61216935211893 |
69 | 70 | ) |
70 | 71 | self.assertEqual( |
71 | 72 | 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]], |
73 | 87 | ) |
74 | 88 |
|
75 | 89 | def test_save_dataframes_as_json(self): |
@@ -128,14 +142,16 @@ def test_log_tables_rich_output(self): |
128 | 142 | 0, "united_atom", "Transvibrational", 653.4041220313459 |
129 | 143 | ) |
130 | 144 | self.logger.add_residue_data( |
131 | | - 0, "DA", "united_atom", "Transvibrational", 122.61216935211893 |
| 145 | + 0, "DA", "united_atom", "Transvibrational", 10, 122.61216935211893 |
132 | 146 | ) |
| 147 | + self.logger.add_group_label(0, "DA", 10, 100) |
133 | 148 |
|
134 | 149 | self.logger.log_tables() |
135 | 150 |
|
136 | 151 | output = console.export_text() |
137 | 152 | assert "Molecule Entropy Results" in output |
138 | 153 | assert "Residue Entropy Results" in output |
| 154 | + assert "Group ID to Residue Label Mapping" in output |
139 | 155 |
|
140 | 156 |
|
141 | 157 | if __name__ == "__main__": |
|
0 commit comments