• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

CCPBioSim / CodeEntropy / 14059657073

25 Mar 2025 12:31PM UTC coverage: 38.633% (+8.9%) from 29.725%
14059657073

push

github

web-flow
Merge pull request #73 from CCPBioSim/34-implement-python-logging

Implement Python Logging

137 of 211 new or added lines in 9 files covered. (64.93%)

5 existing lines in 1 file now uncovered.

243 of 629 relevant lines covered (38.63%)

1.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

56.0
/CodeEntropy/config/data_logger.py
1
import json
3✔
2
import logging
3✔
3

4
from tabulate import tabulate
3✔
5

6
# Set up logger
7
logger = logging.getLogger(__name__)
3✔
8

9

10
class DataLogger:
3✔
11
    def __init__(self):
3✔
12
        self.molecule_data = []
3✔
13
        self.residue_data = []
3✔
14

15
    def save_dataframes_as_json(self, molecule_df, residue_df, outfile):
3✔
16
        """Save multiple DataFrames into a single JSON file with separate keys"""
NEW
17
        data = {
×
18
            "molecule_data": molecule_df.to_dict(orient="records"),
19
            "residue_data": residue_df.to_dict(orient="records"),
20
        }
21

22
        # Write JSON data to file
NEW
23
        with open(outfile, "w") as out:
×
NEW
24
            json.dump(data, out, indent=4)
×
25

26
    def add_results_data(self, molecule, level, type, S_molecule):
3✔
27
        """Add data for molecule-level entries"""
NEW
28
        self.molecule_data.append([molecule, level, type, f"{S_molecule}"])
×
29

30
    def add_residue_data(self, molecule, residue, type, S_trans_residue):
3✔
31
        """Add data for residue-level entries"""
NEW
32
        self.residue_data.append([molecule, residue, type, f"{S_trans_residue}"])
×
33

34
    def log_tables(self):
3✔
35
        """Log both tables at once"""
36
        # Log molecule data
37
        if self.molecule_data:
3✔
NEW
38
            logger.info("Molecule Data Table:")
×
NEW
39
            table_str = tabulate(
×
40
                self.molecule_data,
41
                headers=["Molecule ID", "Level", "Type", "Result (J/mol/K)"],
42
                tablefmt="grid",
43
            )
NEW
44
            logger.info(f"\n{table_str}")
×
45

46
        # Log residue data
47
        if self.residue_data:
3✔
NEW
48
            logger.info("Residue Data Table:")
×
NEW
49
            table_str = tabulate(
×
50
                self.residue_data,
51
                headers=["Molecule ID", "Residue", "Type", "Result (J/mol/K)"],
52
                tablefmt="grid",
53
            )
NEW
54
            logger.info(f"\n{table_str}")
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc