diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a50adba..7da3c1d6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,4 +48,6 @@ jobs: coverage report coverage xml - name: Upload coverage to Codecov - uses: codecov/codecov-action@v2 + uses: codecov/codecov-action@v3 + with: + token: ${{ secrets.CODECOV_TOKEN }} diff --git a/docs/docs_requirements.txt b/docs/docs_requirements.txt index 483053fc..9785db46 100644 --- a/docs/docs_requirements.txt +++ b/docs/docs_requirements.txt @@ -6,3 +6,4 @@ sphinxcontrib.bibtex matplotlib numpy numpydoc +jinja2<3.1 diff --git a/hymd/configure_runtime.py b/hymd/configure_runtime.py index d71bc909..d0852d61 100644 --- a/hymd/configure_runtime.py +++ b/hymd/configure_runtime.py @@ -8,6 +8,7 @@ import cProfile import logging import pstats +import tomli from .logger import Logger, print_header from .input_parser import read_config_toml, parse_config_toml @@ -188,14 +189,14 @@ def profile_atexit(): ) if args.topol is not None: - topol = read_config_toml(args.topol) + topol = tomli.loads(read_config_toml(args.topol)) # Check if we have single "itp" files and add their keys to topol if os.path.dirname(args.topol) == "": args.topol = "./" + args.topol if "include" in topol["system"]: for file in topol["system"]["include"]: path = f"{os.path.dirname(args.topol)}/{file}" - itps = read_config_toml(path) + itps = tomli.loads(read_config_toml(path)) for mol, itp in itps.items(): topol[mol] = itp else: diff --git a/hymd/input_parser.py b/hymd/input_parser.py index 64150a23..cd78af76 100644 --- a/hymd/input_parser.py +++ b/hymd/input_parser.py @@ -313,10 +313,9 @@ def __str__(self): def read_config_toml(file_path): - with open(file_path, "rb") as in_file: - toml_content = tomli.load(in_file) - return toml_content - + with open(file_path, "r") as in_file: + file_content = in_file.read() + return file_content def propensity_potential_coeffs(x: float, comm): alpha_coeffs = np.array( @@ -369,6 +368,9 @@ def propensity_potential_coeffs(x: float, comm): def parse_config_toml(toml_content, file_path=None, comm=MPI.COMM_WORLD): config_dict = {} + # read toml to a dictionary + toml_content = tomli.loads(toml_content) + # Defaults = None for n in ( "box_size", diff --git a/pyproject.toml b/pyproject.toml index be1c00c8..2b419ccb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,4 +1,4 @@ [build-system] -requires = ["setuptools<60", "wheel", "numpy", "cython", "mpi4py"] +requires = ["setuptools<60", "wheel", "numpy<1.24", "cython", "mpi4py"] [tool.black] exclude = "\\(./)" diff --git a/requirements.txt b/requirements.txt index 26550d7a..d89ef680 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,7 @@ h5py mpi4py mpsort networkx -numpy +numpy<1.24 pfft-python pmesh sympy diff --git a/test/test_configure_runtime.py b/test/test_configure_runtime.py index 9ee3e77e..598f6225 100644 --- a/test/test_configure_runtime.py +++ b/test/test_configure_runtime.py @@ -15,54 +15,54 @@ def test_configure_runtime(h5py_molecules_file, config_toml, basearg = [config_toml_file, h5py_molecules_file] - parsed, config, prng = configure_runtime(basearg, comm) + parsed, config, prng, topol = configure_runtime(basearg, comm) assert isinstance(parsed, Namespace) assert isinstance(config, Config) assert isinstance(prng, np.random.Generator) assert parsed.destdir == "." assert parsed.logfile == "sim.log" - parsed, _, _ = configure_runtime(["-v", "2"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["-v", "2"]+basearg, comm) assert parsed.verbose == 2 - parsed, _, _ = configure_runtime(["--disable-field"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--disable-field"]+basearg, comm) assert parsed.disable_field - parsed, _, _ = configure_runtime(["--disable-bonds"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--disable-bonds"]+basearg, comm) assert parsed.disable_bonds - parsed, _, _ = configure_runtime(["--disable-angle-bonds"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--disable-angle-bonds"]+basearg, comm) assert parsed.disable_angle_bonds - parsed, _, _ = configure_runtime(["--disable-dihedrals"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--disable-dihedrals"]+basearg, comm) assert parsed.disable_dihedrals - parsed, _, _ = configure_runtime(["--disable-dipole"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--disable-dipole"]+basearg, comm) assert parsed.disable_dipole - parsed, _, _ = configure_runtime(["--double-precision"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--double-precision"]+basearg, comm) assert parsed.double_precision - parsed, _, _ = configure_runtime(["--double-output"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--double-output"]+basearg, comm) assert parsed.double_output - parsed, _, _ = configure_runtime(["--dump-per-particle"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--dump-per-particle"]+basearg, comm) assert parsed.dump_per_particle - parsed, _, _ = configure_runtime(["--force-output"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--force-output"]+basearg, comm) assert parsed.force_output - parsed, _, _ = configure_runtime(["--velocity-output"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--velocity-output"]+basearg, comm) assert parsed.velocity_output - parsed, _, _ = configure_runtime(["--disable-mpio"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--disable-mpio"]+basearg, comm) assert parsed.disable_mpio - parsed, _, _ = configure_runtime(["--destdir", "testdir"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--destdir", "testdir"]+basearg, comm) assert parsed.destdir == "testdir" - parsed, _, _ = configure_runtime(["--seed", "54321"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--seed", "54321"]+basearg, comm) assert parsed.seed == 54321 - parsed, _, _ = configure_runtime(["--logfile", "test.log"]+basearg, comm) + parsed, _, _, _ = configure_runtime(["--logfile", "test.log"]+basearg, comm) assert parsed.logfile == "test.log" diff --git a/test/test_file_io.py b/test/test_file_io.py index 86eff807..5f16a185 100644 --- a/test/test_file_io.py +++ b/test/test_file_io.py @@ -62,11 +62,12 @@ def test_setup_time_dependent_element(config_toml, tmp_path): assert isinstance(group, h5py.Group) assert group.name == "/test/position" - assert group.attrs["units"] == "nm" assert isinstance(step, h5py.Dataset) assert isinstance(time, h5py.Dataset) + assert time.attrs["unit"] == "ps" assert isinstance(value, h5py.Dataset) + assert value.attrs["unit"] == "nm" out.close_file()