Skip to content

Commit 68bc865

Browse files
committed
got rid of some warning
1 parent 8c464e0 commit 68bc865

4 files changed

Lines changed: 16 additions & 4 deletions

File tree

integration_tests/test_monte_carlo_move.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import sys
22
import os
3+
import time
34
import unittest
45
import numpy as np
56
from pint import UnitRegistry
@@ -41,16 +42,19 @@ def setUp(self):
4142
cut_off = rc,
4243
thermo_outputs = "Epot-press",
4344
desired_temperature = T,
44-
neighbor = 20,
45+
neighbor = 50,
4546
displace_mc = displace_mc,
4647
)
4748

4849
def test_monte_carlo_run(self):
4950
"""Test if the Monte Carlo simulation runs without errors."""
5051
try:
5152
# Run the Monte Carlo simulation (this should not raise an exception)
53+
ti = time.time()
5254
self.mc.run()
5355
# If it runs successfully, assert True
56+
tf = time.time()
57+
print("Duration:", np.round(tf-ti, 2), "s")
5458
self.assertTrue(True)
5559
except Exception as e:
5660
# If any exception occurs, fail the test and print the error

molecular_simulation_code/measurements_utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from numba import njit
22
import numpy as np
3-
from typing import List
3+
from numba.typed import List
44

55
from distances_utilities import compute_vector_matrix
66
from forces_utilities import compute_force_matrix

molecular_simulation_code/simulation_handler.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import numpy as np
2+
from numba.typed import List
23

34
from contacts_utilities import contact_matrix, compute_neighbor_lists
45

@@ -18,7 +19,12 @@ def update_neighbor_lists(self, force_update=False):
1819
box=self.box_mda)
1920

2021
# Compute the neighbor lists from the contact matrix
21-
self.neighbor_lists = compute_neighbor_lists(matrix)
22+
python_neighbor_lists = compute_neighbor_lists(matrix)
23+
24+
# Convert Python list to numba.typed.List
25+
self.neighbor_lists = List()
26+
for neighbors in python_neighbor_lists:
27+
self.neighbor_lists.append(neighbors)
2228

2329
def update_cross_coefficients(self, force_update=False):
2430
"""Update the Lennard-Jones cross-coefficients for all atom pairs."""

molecular_simulation_code/simulation_logger.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@ def setup_logger(folder_name, overwrite=False):
99
logger.setLevel(logging.INFO)
1010
logger.propagate = False # Disable propagation to prevent double logging
1111

12-
# Clear any existing handlers if this function is called again
12+
# Close and clear existing handlers, if any
1313
if logger.hasHandlers():
14+
for handler in logger.handlers:
15+
handler.close() # Ensure handlers are properly closed
1416
logger.handlers.clear()
1517

1618
# Create handlers for console and file

0 commit comments

Comments
 (0)