Skip to content

Commit ab8ff89

Browse files
committed
fixing output formating for orientational entropy
1 parent 46f650e commit ab8ff89

4 files changed

Lines changed: 18 additions & 7 deletions

File tree

CodeEntropy/entropy/nodes/orientational.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,16 @@ def run(self, shared_data: MutableMapping[str, Any], **_: Any) -> Dict[str, Any]
6464
symmetry = symmetry_number[group_id]
6565
line = linear[group_id]
6666

67-
results[group_id] = oe.calculate_orientational(
67+
result_value = oe.calculate_orientational(
6868
neighbor,
6969
symmetry,
7070
line,
7171
)
72+
results[group_id] = result_value
7273

7374
if reporter is not None:
7475
reporter.add_results_data(
75-
group_id, highest_level, "Orientational", results
76+
group_id, highest_level, "Orientational", result_value
7677
)
7778

7879
shared_data["orientational_entropy"] = results

CodeEntropy/entropy/orientational.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def calculate_orientational(
8989
total = self._gas_constant * math.log(omega)
9090
logger.debug("Orientational entropy total: %s", total)
9191

92-
return OrientationalEntropyResult(total=float(total))
92+
return total
9393

9494
@staticmethod
9595
def _omega(neighbour_count: int, symmetry: int, linear: bool) -> float:

tests/unit/CodeEntropy/entropy/test_graph.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ def test_build_creates_expected_nodes_and_edges():
1111
assert set(g._nodes.keys()) == {
1212
"vibrational_entropy",
1313
"configurational_entropy",
14+
"orientational_entropy",
1415
"aggregate_entropy",
1516
}
1617

1718
assert g._graph.has_edge("vibrational_entropy", "aggregate_entropy")
1819
assert g._graph.has_edge("configurational_entropy", "aggregate_entropy")
20+
assert g._graph.has_edge("orientational_entropy", "aggregate_entropy")
1921

2022

2123
def test_execute_runs_nodes_in_topological_order_and_merges_dict_outputs(shared_data):

tests/unit/CodeEntropy/entropy/test_orientational_entropy.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,33 @@
22

33
from CodeEntropy.entropy.orientational import OrientationalEntropy
44

5+
_GAS_CONST: float = 8.3144598484848
6+
57

68
def test_orientational_negative_count_raises():
7-
oe = OrientationalEntropy(None, None, None, None, None)
9+
oe = OrientationalEntropy(_GAS_CONST)
810
with pytest.raises(ValueError):
911
oe.calculate_orientational(-1, 1, False)
1012

1113

1214
def test_orientational_zero_count_contributes_zero():
13-
oe = OrientationalEntropy(None, None, None, None, None)
15+
oe = OrientationalEntropy(_GAS_CONST)
1416
assert oe.calculate_orientational(0, 1, False) == 0.0
1517

1618

1719
def test_omega_linear():
18-
oe = OrientationalEntropy(None, None, None, None, None)
20+
oe = OrientationalEntropy(_GAS_CONST)
1921
omega = oe._omega(6, 2, True)
2022
assert omega == 3.0
2123

2224

25+
def test_omega_nonlinear():
26+
oe = OrientationalEntropy(_GAS_CONST)
27+
omega = oe._omega(6, 2, False)
28+
assert omega == pytest.approx(13.02482)
29+
30+
2331
def test_omega_no_symmetry():
24-
oe = OrientationalEntropy(None, None, None, None, None)
32+
oe = OrientationalEntropy(_GAS_CONST)
2533
omega = oe._omega(6, 0, False)
2634
assert omega == 1.0

0 commit comments

Comments
 (0)