diff --git a/CI/functional_tests/test_molten_salts.py b/CI/functional_tests/test_molten_salts.py index 6d30a73c..1276ddf4 100644 --- a/CI/functional_tests/test_molten_salts.py +++ b/CI/functional_tests/test_molten_salts.py @@ -25,6 +25,7 @@ ------- Perform a functional test on two molten salts. """ + from typing import Tuple import pytest diff --git a/CI/functional_tests/test_water_study.py b/CI/functional_tests/test_water_study.py index f289581f..4399bf57 100644 --- a/CI/functional_tests/test_water_study.py +++ b/CI/functional_tests/test_water_study.py @@ -25,6 +25,7 @@ ------- Functional test for the analysis of a GROMACS water simulation. """ + from typing import List import pytest diff --git a/CI/integration_tests/calculators/__test_structure_factor.py b/CI/integration_tests/calculators/__test_structure_factor.py index 80edfbf3..e705bc91 100644 --- a/CI/integration_tests/calculators/__test_structure_factor.py +++ b/CI/integration_tests/calculators/__test_structure_factor.py @@ -24,6 +24,7 @@ Summary ------- """ + import json import os from pathlib import Path diff --git a/CI/integration_tests/calculators/_test_green_kubo_thermal_conductivity.py b/CI/integration_tests/calculators/_test_green_kubo_thermal_conductivity.py index 75cc696e..792ca3c0 100644 --- a/CI/integration_tests/calculators/_test_green_kubo_thermal_conductivity.py +++ b/CI/integration_tests/calculators/_test_green_kubo_thermal_conductivity.py @@ -24,6 +24,7 @@ Summary ------- """ + import json import os from pathlib import Path diff --git a/CI/integration_tests/calculators/_test_green_kubo_viscosity.py b/CI/integration_tests/calculators/_test_green_kubo_viscosity.py index 058dcfb8..2bc74440 100644 --- a/CI/integration_tests/calculators/_test_green_kubo_viscosity.py +++ b/CI/integration_tests/calculators/_test_green_kubo_viscosity.py @@ -24,6 +24,7 @@ Summary ------- """ + import json import os from pathlib import Path diff --git a/CI/integration_tests/calculators/_test_nernst_einstein_ionic_conductivity.py b/CI/integration_tests/calculators/_test_nernst_einstein_ionic_conductivity.py index 4dca532f..36877c73 100644 --- a/CI/integration_tests/calculators/_test_nernst_einstein_ionic_conductivity.py +++ b/CI/integration_tests/calculators/_test_nernst_einstein_ionic_conductivity.py @@ -24,6 +24,7 @@ Summary ------- """ + import json import os from pathlib import Path diff --git a/CI/integration_tests/calculators/test_angular_distribution_function.py b/CI/integration_tests/calculators/test_angular_distribution_function.py index 85903312..47f48551 100644 --- a/CI/integration_tests/calculators/test_angular_distribution_function.py +++ b/CI/integration_tests/calculators/test_angular_distribution_function.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_coordination_numbers.py b/CI/integration_tests/calculators/test_coordination_numbers.py index 231cb4c7..d904a9a3 100644 --- a/CI/integration_tests/calculators/test_coordination_numbers.py +++ b/CI/integration_tests/calculators/test_coordination_numbers.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_einstein_diffusion_coefficients.py b/CI/integration_tests/calculators/test_einstein_diffusion_coefficients.py index 24d67c08..f40d82b1 100644 --- a/CI/integration_tests/calculators/test_einstein_diffusion_coefficients.py +++ b/CI/integration_tests/calculators/test_einstein_diffusion_coefficients.py @@ -24,6 +24,7 @@ Summary ------- """ + import dataclasses import os diff --git a/CI/integration_tests/calculators/test_einstein_distinct_diffusion_coefficients.py b/CI/integration_tests/calculators/test_einstein_distinct_diffusion_coefficients.py index ac2c80f2..e8c24397 100644 --- a/CI/integration_tests/calculators/test_einstein_distinct_diffusion_coefficients.py +++ b/CI/integration_tests/calculators/test_einstein_distinct_diffusion_coefficients.py @@ -31,6 +31,7 @@ values. """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_einstein_helfand_ionic_conductivity.py b/CI/integration_tests/calculators/test_einstein_helfand_ionic_conductivity.py index 29b6689b..282db8d7 100644 --- a/CI/integration_tests/calculators/test_einstein_helfand_ionic_conductivity.py +++ b/CI/integration_tests/calculators/test_einstein_helfand_ionic_conductivity.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_green_kubo_distinct_diffusion_coefficients.py b/CI/integration_tests/calculators/test_green_kubo_distinct_diffusion_coefficients.py index 6bff4151..5a2aae30 100644 --- a/CI/integration_tests/calculators/test_green_kubo_distinct_diffusion_coefficients.py +++ b/CI/integration_tests/calculators/test_green_kubo_distinct_diffusion_coefficients.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_green_kubo_ionic_conductivity.py b/CI/integration_tests/calculators/test_green_kubo_ionic_conductivity.py index e7b86513..4bb4ca29 100644 --- a/CI/integration_tests/calculators/test_green_kubo_ionic_conductivity.py +++ b/CI/integration_tests/calculators/test_green_kubo_ionic_conductivity.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import numpy as np diff --git a/CI/integration_tests/calculators/test_green_kubo_self_diffusion_coefficients.py b/CI/integration_tests/calculators/test_green_kubo_self_diffusion_coefficients.py index c9b6c1a2..25b857d4 100644 --- a/CI/integration_tests/calculators/test_green_kubo_self_diffusion_coefficients.py +++ b/CI/integration_tests/calculators/test_green_kubo_self_diffusion_coefficients.py @@ -24,6 +24,7 @@ Summary ------- """ + import dataclasses import os @@ -103,9 +104,7 @@ def test_calculator(tmp_path, desired_memory): time_should_be = time_step * np.arange(0, vacf_range) * units.time thermal_vel_SI = np.sqrt(3 * kT / mass) * units.length / units.time relaxation_time_SI = relaxation_time * units.time - vacf_should_be = thermal_vel_SI**2 * np.exp( - -time_should_be / relaxation_time_SI - ) + vacf_should_be = thermal_vel_SI**2 * np.exp(-time_should_be / relaxation_time_SI) diff_coeff_should_be = diff_coeff * units.length**2 / units.time np.testing.assert_allclose(res["time"], time_should_be, atol=1e-6) diff --git a/CI/integration_tests/calculators/test_kirkwood_buff_integrals.py b/CI/integration_tests/calculators/test_kirkwood_buff_integrals.py index 6aa275e3..7225b7ca 100644 --- a/CI/integration_tests/calculators/test_kirkwood_buff_integrals.py +++ b/CI/integration_tests/calculators/test_kirkwood_buff_integrals.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_potential_of_mean_force.py b/CI/integration_tests/calculators/test_potential_of_mean_force.py index f1799656..014e0d00 100644 --- a/CI/integration_tests/calculators/test_potential_of_mean_force.py +++ b/CI/integration_tests/calculators/test_potential_of_mean_force.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/calculators/test_radial_distribution_function.py b/CI/integration_tests/calculators/test_radial_distribution_function.py index 787c3c3a..db1e8c23 100644 --- a/CI/integration_tests/calculators/test_radial_distribution_function.py +++ b/CI/integration_tests/calculators/test_radial_distribution_function.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pytest diff --git a/CI/integration_tests/transformations/test_molecular_mapping_results.py b/CI/integration_tests/transformations/test_molecular_mapping_results.py index 8e76ee68..f171ccb5 100644 --- a/CI/integration_tests/transformations/test_molecular_mapping_results.py +++ b/CI/integration_tests/transformations/test_molecular_mapping_results.py @@ -25,6 +25,7 @@ ------- Test the outcome of molecular mapping. """ + from typing import List, Tuple import pytest diff --git a/CI/integration_tests/visualizer/znvis_visualizer.py b/CI/integration_tests/visualizer/znvis_visualizer.py index 16c1f808..795b4879 100644 --- a/CI/integration_tests/visualizer/znvis_visualizer.py +++ b/CI/integration_tests/visualizer/znvis_visualizer.py @@ -25,6 +25,7 @@ ------- Test that the visualizer runs. """ + import os import tempfile import time diff --git a/CI/unit_tests/database/test_experiment_database.py b/CI/unit_tests/database/test_experiment_database.py index a830ce62..f6f8516e 100644 --- a/CI/unit_tests/database/test_experiment_database.py +++ b/CI/unit_tests/database/test_experiment_database.py @@ -24,6 +24,7 @@ Summary ------- """ + import dataclasses import os diff --git a/CI/unit_tests/database/test_file_read.py b/CI/unit_tests/database/test_file_read.py index 53afd57d..eeba9173 100644 --- a/CI/unit_tests/database/test_file_read.py +++ b/CI/unit_tests/database/test_file_read.py @@ -1,4 +1,5 @@ """Test MDSuite file reading.""" + import numpy as np import mdsuite diff --git a/CI/unit_tests/database/test_simulation_database.py b/CI/unit_tests/database/test_simulation_database.py index 8c0d7043..bac0a160 100644 --- a/CI/unit_tests/database/test_simulation_database.py +++ b/CI/unit_tests/database/test_simulation_database.py @@ -23,6 +23,7 @@ ------- Test for module for the simulation database. """ + import os import tempfile import unittest @@ -52,13 +53,11 @@ def test_build_path_input(self): "Pressure": (5000, 6), "Temperature": (5000, 1), } - architecture = database._build_path_input( - { - "Na": {"Forces": (200, 5000, 3)}, - "Pressure": (5000, 6), - "Temperature": (5000, 1), - } - ) + architecture = database._build_path_input({ + "Na": {"Forces": (200, 5000, 3)}, + "Pressure": (5000, 6), + "Temperature": (5000, 1), + }) self.assertDictEqual(assertion, architecture) os.chdir("..") temp_dir.cleanup() diff --git a/CI/unit_tests/experiment/test_Experiment.py b/CI/unit_tests/experiment/test_Experiment.py index 991247b1..e484ddfb 100644 --- a/CI/unit_tests/experiment/test_Experiment.py +++ b/CI/unit_tests/experiment/test_Experiment.py @@ -1,4 +1,5 @@ """Test MDSuite Experiment class.""" + import pytest from mdsuite.experiment.experiment import Experiment diff --git a/CI/unit_tests/experiment/test_run_computation.py b/CI/unit_tests/experiment/test_run_computation.py index 7d648498..d68c8124 100644 --- a/CI/unit_tests/experiment/test_run_computation.py +++ b/CI/unit_tests/experiment/test_run_computation.py @@ -9,6 +9,7 @@ Description: """ + from unittest.mock import Mock from mdsuite.experiment.run import RunComputation diff --git a/CI/unit_tests/graph_modules/test_molecular_graph.py b/CI/unit_tests/graph_modules/test_molecular_graph.py index 2c4fefa6..d86a7ee5 100644 --- a/CI/unit_tests/graph_modules/test_molecular_graph.py +++ b/CI/unit_tests/graph_modules/test_molecular_graph.py @@ -25,6 +25,7 @@ ------- Module to test the molecular graph module. """ + from dataclasses import dataclass from pathlib import Path @@ -90,15 +91,13 @@ def test_apply_system_cutoff(self): cutoff_tensor = tf.constant(cutoff_data, dtype=tf.float32) # Middle range cutoff - target = tf.constant( - [ - [0, 0, 0, 0, 1], - [0, 0, 1, 1, 1], - [0, 0, 0, 1, 1], - [0, 0, 0, 0, 0], - [1, 0, 1, 1, 0], - ] - ) + target = tf.constant([ + [0, 0, 0, 0, 1], + [0, 0, 1, 1, 1], + [0, 0, 0, 1, 1], + [0, 0, 0, 0, 0], + [1, 0, 1, 1, 0], + ]) mask = _apply_system_cutoff(cutoff_tensor, cutoff=5) np.testing.assert_array_equal(np.diagonal(mask), zeros) np.testing.assert_array_equal(mask, target) diff --git a/CI/unit_tests/memory_manager/test_memory_manager.py b/CI/unit_tests/memory_manager/test_memory_manager.py index b89ad00a..1ae4d332 100644 --- a/CI/unit_tests/memory_manager/test_memory_manager.py +++ b/CI/unit_tests/memory_manager/test_memory_manager.py @@ -19,6 +19,7 @@ ------- Test for the memory manager module. """ + import unittest import numpy as np diff --git a/CI/unit_tests/project/test_project_add_experiment.py b/CI/unit_tests/project/test_project_add_experiment.py index 795a1d1d..e9d5b67b 100644 --- a/CI/unit_tests/project/test_project_add_experiment.py +++ b/CI/unit_tests/project/test_project_add_experiment.py @@ -24,6 +24,7 @@ Summary ------- """ + import os import pathlib diff --git a/CI/unit_tests/project/test_project_database.py b/CI/unit_tests/project/test_project_database.py index 950a1a12..ff2870c9 100644 --- a/CI/unit_tests/project/test_project_database.py +++ b/CI/unit_tests/project/test_project_database.py @@ -24,6 +24,7 @@ Summary ------- """ + import os from pathlib import Path from tempfile import TemporaryDirectory diff --git a/CI/unit_tests/project/test_project_instantiation.py b/CI/unit_tests/project/test_project_instantiation.py index cb3c8462..dfc9af82 100644 --- a/CI/unit_tests/project/test_project_instantiation.py +++ b/CI/unit_tests/project/test_project_instantiation.py @@ -9,6 +9,7 @@ Description: """ + import pathlib import mdsuite diff --git a/CI/unit_tests/project/test_project_load_experiments.py b/CI/unit_tests/project/test_project_load_experiments.py index 7b857645..c90f113c 100644 --- a/CI/unit_tests/project/test_project_load_experiments.py +++ b/CI/unit_tests/project/test_project_load_experiments.py @@ -24,6 +24,7 @@ Summary ------- """ + import os from tempfile import TemporaryDirectory diff --git a/CI/unit_tests/transformations/test_transformations.py b/CI/unit_tests/transformations/test_transformations.py index 1da77c28..a5e54c2a 100644 --- a/CI/unit_tests/transformations/test_transformations.py +++ b/CI/unit_tests/transformations/test_transformations.py @@ -153,9 +153,9 @@ def test_unwrap_coordinates(): # x stays in box 0 # y jumps 0 -> -1 -> -1 -> 0 # z jumps 0 -> 1 -> 1 -> 2 - pos = np.array( - [[[0.5, 0.1, 3.2]], [[0.6, 2.1, 0.9]], [[0.6, 2.1, 2.1]], [[0.6, 0.1, 0.1]]] - ) + pos = np.array([ + [[0.5, 0.1, 3.2]], [[0.6, 2.1, 0.9]], [[0.6, 2.1, 2.1]], [[0.6, 0.1, 0.1]] + ]) pos = np.swapaxes(pos, 0, 1) print(np.shape(pos)) @@ -172,14 +172,12 @@ def test_unwrap_coordinates(): output, carryover = trafo.transform_batch(input, carryover=last_carryover) - output_should_be = np.array( - [ - [[4 * 1.1 + 0.5, 0.1, 3.2]], - [[4 * 1.1 + 0.6, -0.1, 4.2]], - [[4 * 1.1 + 0.6, -0.1, 5.4]], - [[4 * 1.1 + 0.6, 0.1, 6.7]], - ] - ) + output_should_be = np.array([ + [[4 * 1.1 + 0.5, 0.1, 3.2]], + [[4 * 1.1 + 0.6, -0.1, 4.2]], + [[4 * 1.1 + 0.6, -0.1, 5.4]], + [[4 * 1.1 + 0.6, 0.1, 6.7]], + ]) output_should_be = np.swapaxes(output_should_be, 0, 1) carryover_should_be = {"last_pos": [[0.6, 0.1, 0.1]], "last_image_box": [[4, 0, 2]]} assertDeepAlmostEqual(output.numpy(), output_should_be) diff --git a/CI/unit_tests/transformations/test_transformator_parent.py b/CI/unit_tests/transformations/test_transformator_parent.py index 4c901eda..bbd59cbf 100644 --- a/CI/unit_tests/transformations/test_transformator_parent.py +++ b/CI/unit_tests/transformations/test_transformator_parent.py @@ -21,6 +21,7 @@ -------- If you use this module please cite us with: """ + import os import numpy as np diff --git a/CI/unit_tests/utils/test_calculator_helper_methods.py b/CI/unit_tests/utils/test_calculator_helper_methods.py index 07cb6f44..e08f729c 100644 --- a/CI/unit_tests/utils/test_calculator_helper_methods.py +++ b/CI/unit_tests/utils/test_calculator_helper_methods.py @@ -25,6 +25,7 @@ ------- Module for testing the calculator helper methods. """ + import numpy as np import pytest from numpy.testing import assert_array_equal, assert_raises diff --git a/CI/unit_tests/utils/test_constants.py b/CI/unit_tests/utils/test_constants.py index e74bcbb7..b6a18fd1 100644 --- a/CI/unit_tests/utils/test_constants.py +++ b/CI/unit_tests/utils/test_constants.py @@ -1,4 +1,5 @@ """Test for MDSuite utils.constants.""" + import dataclasses import pytest diff --git a/CI/unit_tests/utils/test_meta_functions.py b/CI/unit_tests/utils/test_meta_functions.py index 226d3bbe..56c7e196 100644 --- a/CI/unit_tests/utils/test_meta_functions.py +++ b/CI/unit_tests/utils/test_meta_functions.py @@ -25,6 +25,7 @@ ------- Test the meta functions module. """ + import os import numpy as np diff --git a/CI/unit_tests/utils/test_molecule_class.py b/CI/unit_tests/utils/test_molecule_class.py index 79430ce3..88f0a2ad 100644 --- a/CI/unit_tests/utils/test_molecule_class.py +++ b/CI/unit_tests/utils/test_molecule_class.py @@ -25,6 +25,7 @@ ------- Unit tests for the molecule data class. """ + import pytest import mdsuite diff --git a/CI/unit_tests/utils/test_scaling_functions.py b/CI/unit_tests/utils/test_scaling_functions.py index 6d00fb03..b22ca2b8 100644 --- a/CI/unit_tests/utils/test_scaling_functions.py +++ b/CI/unit_tests/utils/test_scaling_functions.py @@ -20,6 +20,7 @@ ------- Unit tests for the scaling functions module. """ + import unittest import numpy as np diff --git a/CI/unit_tests/utils/test_testing.py b/CI/unit_tests/utils/test_testing.py index b96b3e75..2c95850a 100644 --- a/CI/unit_tests/utils/test_testing.py +++ b/CI/unit_tests/utils/test_testing.py @@ -25,6 +25,7 @@ ------- Test the mdsuite testing modules. """ + import time import unittest diff --git a/CI/unit_tests/utils/test_units.py b/CI/unit_tests/utils/test_units.py index 688131a5..d02f7192 100644 --- a/CI/unit_tests/utils/test_units.py +++ b/CI/unit_tests/utils/test_units.py @@ -1,4 +1,5 @@ """Test MDSuite units.""" + import mdsuite as mds diff --git a/docs/source/conf.py b/docs/source/conf.py index 26714572..a25843b7 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,6 +24,7 @@ Summary ------- """ + import sys import sphinx_rtd_theme diff --git a/mdsuite/__init__.py b/mdsuite/__init__.py index 54b42ce0..60089182 100644 --- a/mdsuite/__init__.py +++ b/mdsuite/__init__.py @@ -24,6 +24,7 @@ Summary ------- """ + try: from importlib import metadata except ImportError: # for Python<3.8 diff --git a/mdsuite/calculators/__init__.py b/mdsuite/calculators/__init__.py index f9987948..09c3cc4d 100644 --- a/mdsuite/calculators/__init__.py +++ b/mdsuite/calculators/__init__.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations from mdsuite.calculators.angular_distribution_function import ( diff --git a/mdsuite/calculators/angular_distribution_function.py b/mdsuite/calculators/angular_distribution_function.py index 4b6c91a3..3dfe8bfd 100644 --- a/mdsuite/calculators/angular_distribution_function.py +++ b/mdsuite/calculators/angular_distribution_function.py @@ -27,6 +27,7 @@ describes the average distribution of angles between three particles of species a, b, and c. Note that a, b, and c may all be the same species, e.g. Na-Na-Na. """ + import itertools import logging from abc import ABC diff --git a/mdsuite/calculators/calculator.py b/mdsuite/calculators/calculator.py index 77aba53a..b158e6e5 100644 --- a/mdsuite/calculators/calculator.py +++ b/mdsuite/calculators/calculator.py @@ -25,6 +25,7 @@ ------- Parent class for the calculators. """ + from __future__ import annotations import functools diff --git a/mdsuite/calculators/coordination_number_calculation.py b/mdsuite/calculators/coordination_number_calculation.py index 07c84125..8cd11599 100644 --- a/mdsuite/calculators/coordination_number_calculation.py +++ b/mdsuite/calculators/coordination_number_calculation.py @@ -25,6 +25,7 @@ ------- Module to compute coodination numbers. """ + import logging from dataclasses import dataclass @@ -320,12 +321,12 @@ def _get_coordination_numbers( lower_bound = integral_data[val[0]] upper_bound = integral_data[val[1]] - coordination_numbers[f"CN_{int(key) + 1}"] = np.mean( - [lower_bound, upper_bound] - ) - coordination_numbers[f"CN_{int(key) + 1}_error"] = np.std( - [lower_bound, upper_bound] - ) / np.sqrt(2) + coordination_numbers[f"CN_{int(key) + 1}"] = np.mean([ + lower_bound, upper_bound + ]) + coordination_numbers[f"CN_{int(key) + 1}_error"] = np.std([ + lower_bound, upper_bound + ]) / np.sqrt(2) return coordination_numbers diff --git a/mdsuite/calculators/einstein_diffusion_coefficients.py b/mdsuite/calculators/einstein_diffusion_coefficients.py index c51efae7..fa21a773 100644 --- a/mdsuite/calculators/einstein_diffusion_coefficients.py +++ b/mdsuite/calculators/einstein_diffusion_coefficients.py @@ -25,6 +25,7 @@ ------- Module for the computation of self-diffusion coefficients using the Einstein method. """ + from __future__ import annotations import logging diff --git a/mdsuite/calculators/einstein_distinct_diffusion_coefficients.py b/mdsuite/calculators/einstein_distinct_diffusion_coefficients.py index bbb8bdb9..db1f8a02 100644 --- a/mdsuite/calculators/einstein_distinct_diffusion_coefficients.py +++ b/mdsuite/calculators/einstein_distinct_diffusion_coefficients.py @@ -25,6 +25,7 @@ ------- Module for computing distinct diffusion coefficients using the Einstein method. """ + import itertools import warnings from dataclasses import dataclass diff --git a/mdsuite/calculators/einstein_helfand_ionic_conductivity.py b/mdsuite/calculators/einstein_helfand_ionic_conductivity.py index 0d303f9c..86829bc7 100644 --- a/mdsuite/calculators/einstein_helfand_ionic_conductivity.py +++ b/mdsuite/calculators/einstein_helfand_ionic_conductivity.py @@ -25,6 +25,7 @@ ------- MDSuite module for the computation of ionic conductivity using the Einstein method. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/einstein_helfand_thermal_conductivity.py b/mdsuite/calculators/einstein_helfand_thermal_conductivity.py index ba24b9cd..78ccd7ab 100644 --- a/mdsuite/calculators/einstein_helfand_thermal_conductivity.py +++ b/mdsuite/calculators/einstein_helfand_thermal_conductivity.py @@ -25,6 +25,7 @@ ------- MDSuite module for the computation of thermal conductivity using the Einstein method. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/einstein_helfand_thermal_kinaci.py b/mdsuite/calculators/einstein_helfand_thermal_kinaci.py index e63e0ebd..0652ab4b 100644 --- a/mdsuite/calculators/einstein_helfand_thermal_kinaci.py +++ b/mdsuite/calculators/einstein_helfand_thermal_kinaci.py @@ -26,6 +26,7 @@ MDSuite module for the computation of the thermal conductivity in solids using the Einstein method as applied to the Kinaci integrated thermal flux. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/green_kubo_distinct_diffusion_coefficients.py b/mdsuite/calculators/green_kubo_distinct_diffusion_coefficients.py index 31f56d22..1e36ad2a 100644 --- a/mdsuite/calculators/green_kubo_distinct_diffusion_coefficients.py +++ b/mdsuite/calculators/green_kubo_distinct_diffusion_coefficients.py @@ -25,6 +25,7 @@ ------- Module for computing distinct diffusion coefficients using the Green-Kubo method. """ + import itertools from abc import ABC from dataclasses import dataclass @@ -58,6 +59,7 @@ class Args: class GreenKuboDistinctDiffusionCoefficients(TrajectoryCalculator, ABC): """ Class for the Green-Kubo diffusion coefficient implementation + Attributes ---------- experiment : object @@ -212,6 +214,7 @@ def _map_over_particles(self, ds_a: np.ndarray, ds_b: np.ndarray) -> np.ndarray: def ref_conf_map(ref_dataset, full_ds): """ Maps over the atoms axis in dataset + Parameters ---------- dataset diff --git a/mdsuite/calculators/green_kubo_ionic_conductivity.py b/mdsuite/calculators/green_kubo_ionic_conductivity.py index 7447971e..23f4e55c 100644 --- a/mdsuite/calculators/green_kubo_ionic_conductivity.py +++ b/mdsuite/calculators/green_kubo_ionic_conductivity.py @@ -28,6 +28,7 @@ electrical charge due to the mobility of the ions contained within it. This differs from electronic conductivity which is transferred by electrons. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/green_kubo_self_diffusion_coefficients.py b/mdsuite/calculators/green_kubo_self_diffusion_coefficients.py index 6e72a629..70db653f 100644 --- a/mdsuite/calculators/green_kubo_self_diffusion_coefficients.py +++ b/mdsuite/calculators/green_kubo_self_diffusion_coefficients.py @@ -25,6 +25,7 @@ ------- Module for the computation of diffusion coefficients using the Green-Kubo approach. """ + from abc import ABC from dataclasses import dataclass from typing import Any, List, Union @@ -60,6 +61,7 @@ class Args: class GreenKuboDiffusionCoefficients(TrajectoryCalculator, ABC): """ Class for the Green-Kubo diffusion coefficient implementation + Attributes ---------- experiment : object diff --git a/mdsuite/calculators/green_kubo_thermal_conductivity.py b/mdsuite/calculators/green_kubo_thermal_conductivity.py index 0c7f0f60..bc5c87f7 100644 --- a/mdsuite/calculators/green_kubo_thermal_conductivity.py +++ b/mdsuite/calculators/green_kubo_thermal_conductivity.py @@ -26,6 +26,7 @@ MDSuite module for the computation of the thermal conductivity using the Green-Kubo relation. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/green_kubo_viscosity.py b/mdsuite/calculators/green_kubo_viscosity.py index 20aa38d8..8b02b5ac 100644 --- a/mdsuite/calculators/green_kubo_viscosity.py +++ b/mdsuite/calculators/green_kubo_viscosity.py @@ -26,6 +26,7 @@ MDSuite module for the computation of the viscosity in a system using the Green-Kubo relation as applied to the momentum flux measured during a simulation. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/green_kubo_viscosity_flux.py b/mdsuite/calculators/green_kubo_viscosity_flux.py index 0966b21e..855978f4 100644 --- a/mdsuite/calculators/green_kubo_viscosity_flux.py +++ b/mdsuite/calculators/green_kubo_viscosity_flux.py @@ -26,6 +26,7 @@ MDSuite module for the computation of viscosity using the Green-Kubo relation as applied to the stress on a system. """ + from abc import ABC from dataclasses import dataclass diff --git a/mdsuite/calculators/kirkwood_buff_integrals.py b/mdsuite/calculators/kirkwood_buff_integrals.py index e11bbb74..96168aab 100644 --- a/mdsuite/calculators/kirkwood_buff_integrals.py +++ b/mdsuite/calculators/kirkwood_buff_integrals.py @@ -25,6 +25,7 @@ ------- Module for the computation of kirkwood buff integrals. """ + import logging from dataclasses import dataclass diff --git a/mdsuite/calculators/nernst_einstein_ionic_conductivity.py b/mdsuite/calculators/nernst_einstein_ionic_conductivity.py index 26a41804..a712e4bf 100644 --- a/mdsuite/calculators/nernst_einstein_ionic_conductivity.py +++ b/mdsuite/calculators/nernst_einstein_ionic_conductivity.py @@ -24,6 +24,7 @@ Summary ------- """ + import logging import operator @@ -112,9 +113,9 @@ def _load_data(self): tensor_values: dict A dictionary of tensor_values stored in the yaml file """ - test = self.experiment.export_property_data( - {"property": "Diffusion_Coefficients"} - ) + test = self.experiment.export_property_data({ + "property": "Diffusion_Coefficients" + }) return test @property @@ -134,30 +135,22 @@ def truth_table(self): "No support for different data ranges! This method always picks the" " first entry in the database!" ) - case_1 = self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Green_Kubo_Self_Diffusion_Coefficients", - } - ) - case_2 = self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Green_Kubo_Distinct_Diffusion_Coefficients", - } - ) - case_3 = self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Einstein_Self_Diffusion_Coefficients", - } - ) - case_4 = self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Einstein_Distinct_Diffusion_Coefficients", - } - ) + case_1 = self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Green_Kubo_Self_Diffusion_Coefficients", + }) + case_2 = self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Green_Kubo_Distinct_Diffusion_Coefficients", + }) + case_3 = self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Einstein_Self_Diffusion_Coefficients", + }) + case_4 = self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Einstein_Distinct_Diffusion_Coefficients", + }) truth_table = [ list(map(operator.not_, [not case_1, not case_2])), list(map(operator.not_, [not case_3, not case_4])), @@ -276,13 +269,11 @@ def _run_nernst_einstein(self): ne_table = [self.truth_table[0][0], self.truth_table[1][0]] if ne_table[0]: input_data = [ - self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Green_Kubo_Self_Diffusion_Coefficients", - "subjects": [species[0] for species in self.species], - } - ) + self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Green_Kubo_Self_Diffusion_Coefficients", + "subjects": [species[0] for species in self.species], + }) ] data = self._nernst_einstein(input_data) properties = { @@ -296,13 +287,11 @@ def _run_nernst_einstein(self): if ne_table[1]: input_data = [ - self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Einstein_Self_Diffusion_Coefficients", - "subjects": [species[0] for species in self.species], - } - ) + self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Einstein_Self_Diffusion_Coefficients", + "subjects": [species[0] for species in self.species], + }) ] data = self._nernst_einstein(input_data) @@ -333,23 +322,19 @@ def _run_corrected_nernst_einstein(self): if cne_table[0]: input_self = [ - self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Green_Kubo_Self_Diffusion_Coefficients", - "subjects": [species], - } - )[0] + self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Green_Kubo_Self_Diffusion_Coefficients", + "subjects": [species], + })[0] for species in self.species ] input_distinct = [ - self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Green_Kubo_Distinct_Diffusion_Coefficients", - "subjects": [species], - } - )[0] + self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Green_Kubo_Distinct_Diffusion_Coefficients", + "subjects": [species], + })[0] for species in self.species ] data = self._corrected_nernst_einstein(input_self, input_distinct) @@ -365,23 +350,19 @@ def _run_corrected_nernst_einstein(self): if cne_table[1]: input_self = [ - self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Einstein_Self_Diffusion_Coefficients", - "subjects": [species], - } - )[0] + self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Einstein_Self_Diffusion_Coefficients", + "subjects": [species], + })[0] for species in self.species ] input_distinct = [ - self.experiment.export_property_data( - { - "property": "Diffusion_Coefficients", - "analysis": "Einstein_Distinct_Diffusion_Coefficients", - "subjects": [species], - } - )[0] + self.experiment.export_property_data({ + "property": "Diffusion_Coefficients", + "analysis": "Einstein_Distinct_Diffusion_Coefficients", + "subjects": [species], + })[0] for species in self.species ] data = self._corrected_nernst_einstein(input_self, input_distinct) diff --git a/mdsuite/calculators/potential_of_mean_force.py b/mdsuite/calculators/potential_of_mean_force.py index c51ed4b5..27d32e9a 100644 --- a/mdsuite/calculators/potential_of_mean_force.py +++ b/mdsuite/calculators/potential_of_mean_force.py @@ -26,6 +26,7 @@ Module for the computation of the potential of mean force (PMF). The PMF can be used to better understand effective bond strength between species of a system. """ + import logging from dataclasses import dataclass @@ -319,9 +320,9 @@ def _get_pomf_values(self, pomf: np.ndarray, radii: np.ndarray) -> dict: lower_bound = pomf[val[0]] upper_bound = pomf[val[1]] pomf_data[f"POMF_{int(key) + 1}"] = np.mean([lower_bound, upper_bound]) - pomf_data[f"POMF_{int(key) + 1}_error"] = np.std( - [lower_bound, upper_bound] - ) / np.sqrt(2) + pomf_data[f"POMF_{int(key) + 1}_error"] = np.std([ + lower_bound, upper_bound + ]) / np.sqrt(2) return pomf_data diff --git a/mdsuite/calculators/radial_distribution_function.py b/mdsuite/calculators/radial_distribution_function.py index 5b576bf1..b954296a 100644 --- a/mdsuite/calculators/radial_distribution_function.py +++ b/mdsuite/calculators/radial_distribution_function.py @@ -27,6 +27,7 @@ describes the probability of finding a particle of species b at a distance r of species a. """ + from __future__ import annotations import itertools @@ -354,18 +355,18 @@ def _calculate_radial_distribution_functions(self): Updates the class state with the full RDF for each desired species pair. """ # Compute the true RDF for each species combination. - self.rdf.update( - {key: np.array(val.numpy(), dtype=float) for key, val in self.rdf.items()} - ) + self.rdf.update({ + key: np.array(val.numpy(), dtype=float) for key, val in self.rdf.items() + }) for names in self.key_list: self.selected_species = names.split("_") # TODO use selected_species instead of names, it is more clear prefactor = self._calculate_prefactor(names) # calculate the prefactor - self.rdf.update( - {names: self.rdf.get(names) * prefactor} - ) # Apply the prefactor + self.rdf.update({ + names: self.rdf.get(names) * prefactor + }) # Apply the prefactor log.debug("Writing RDF to database!") x_data = self._ang_to_nm( @@ -508,9 +509,9 @@ def compute_species_values( ], axis=0, ) - stop_ = start_ + tf.constant( - [particles_list[tuples[0]], particles_list[tuples[1]]] - ) + stop_ = start_ + tf.constant([ + particles_list[tuples[0]], particles_list[tuples[1]] + ]) rdf[names] = self.bin_minibatch( start_, @@ -738,6 +739,7 @@ def _spherical_symmetry(data: np.array) -> np.array: # TODO make it a property ---------- data : np.array tensor_values on which to operate + Returns ------- function_values : np.array @@ -751,6 +753,7 @@ def _correction_1(data: np.array) -> np.array: tensor_values : np.array tensor_values on which to operate + Returns ------- function_values : np.array @@ -765,6 +768,7 @@ def _correction_2(data: np.array) -> np.array: tensor_values : np.array tensor_values on which to operate + Returns ------- function_values : np.array @@ -786,6 +790,7 @@ def _correction_2(data: np.array) -> np.array: def _piecewise(data: np.array) -> np.array: """ Return a piecewise operation on a set of tensor_values + Parameters ---------- data : np.array diff --git a/mdsuite/calculators/spatial_distribution_function.py b/mdsuite/calculators/spatial_distribution_function.py index 521537b0..76e7d803 100644 --- a/mdsuite/calculators/spatial_distribution_function.py +++ b/mdsuite/calculators/spatial_distribution_function.py @@ -25,6 +25,7 @@ ------- Module for the spatial distribution function calculator. """ + from __future__ import annotations import logging @@ -168,6 +169,7 @@ def _load_positions(self, indices: list, species: str) -> tf.Tensor: List of indices to take from the database_path species: str The species to load the positions from + Returns ------- loaded_data : tf.Tensor diff --git a/mdsuite/calculators/structure_factor.py b/mdsuite/calculators/structure_factor.py index fc97ee58..f4cb9c10 100644 --- a/mdsuite/calculators/structure_factor.py +++ b/mdsuite/calculators/structure_factor.py @@ -23,6 +23,7 @@ ------- Code for the computation of the structure factor. """ + import logging from dataclasses import dataclass @@ -175,9 +176,9 @@ def __call__( self.q_values = np.linspace(0.5, 12, resolution) self._compute_angstsrom_volume() # correct the volume of the system. - self.number_of_atoms = sum( - [species.n_particles for species in self.experiment.species.values()] - ) + self.number_of_atoms = sum([ + species.n_particles for species in self.experiment.species.values() + ]) self.total_density = self.number_of_atoms / self.volume # Construct the species dictionary and fill all species information. @@ -279,9 +280,9 @@ def _compute_weight_factors(self) -> dict: species_names = pair.split("_") form_factors = [self.species_dict[item].form_factor for item in species_names] mean_square_form_factor = np.mean(form_factors) ** 2 - molar_fraction = np.prod( - [self.species_dict[item].molar_fraction for item in species_names] - ) + molar_fraction = np.prod([ + self.species_dict[item].molar_fraction for item in species_names + ]) weight_factors[pair] = ( molar_fraction * np.prod(form_factors) / mean_square_form_factor ) diff --git a/mdsuite/calculators/trajectory_calculator.py b/mdsuite/calculators/trajectory_calculator.py index 49311da3..5d2dd0ac 100644 --- a/mdsuite/calculators/trajectory_calculator.py +++ b/mdsuite/calculators/trajectory_calculator.py @@ -25,6 +25,7 @@ ------- A parent class for calculators that operate on the trajectory. """ + from __future__ import annotations from abc import ABC diff --git a/mdsuite/calculators/transformations_reference.py b/mdsuite/calculators/transformations_reference.py index 880ce715..ccaadc3a 100644 --- a/mdsuite/calculators/transformations_reference.py +++ b/mdsuite/calculators/transformations_reference.py @@ -24,6 +24,7 @@ Summary ------- """ + switcher_transformations = { "Translational_Dipole_Moment": "TranslationalDipoleMoment", "Ionic_Current": "IonicCurrent", diff --git a/mdsuite/database/calculator_database.py b/mdsuite/database/calculator_database.py index f6a98701..30ae8465 100644 --- a/mdsuite/database/calculator_database.py +++ b/mdsuite/database/calculator_database.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations import logging diff --git a/mdsuite/database/data_manager.py b/mdsuite/database/data_manager.py index 8b514fd2..4968b0d7 100644 --- a/mdsuite/database/data_manager.py +++ b/mdsuite/database/data_manager.py @@ -27,6 +27,7 @@ generators. These generators allow for the full use of the TF data pipelines but can required special formatting rules. """ + import logging import numpy as np @@ -175,6 +176,7 @@ def generator( Path to the tensor_values in the database_path dictionary : bool If true, tensor_values is returned in a dictionary + Returns ------- """ @@ -242,6 +244,7 @@ def atom_generator( Path to the tensor_values in the database_path dictionary : bool If true, tensor_values is returned in a dictionary + Returns ------- """ @@ -309,6 +312,7 @@ def ensemble_generator(self, system: bool = False, glob_data: dict = None) -> tu def dictionary_generator(ensemble_loop, correlation_time, data_range): """ Generator for the ensemble loop + Parameters ---------- ensemble_loop : int @@ -317,6 +321,7 @@ def dictionary_generator(ensemble_loop, correlation_time, data_range): Distance between ensembles data_range : int Size of each ensemble + Returns ------- None. diff --git a/mdsuite/database/database_base.py b/mdsuite/database/database_base.py index 4c34b97f..c88bae6f 100644 --- a/mdsuite/database/database_base.py +++ b/mdsuite/database/database_base.py @@ -24,6 +24,7 @@ Summary ------- """ + import logging from pathlib import Path diff --git a/mdsuite/database/experiment_database.py b/mdsuite/database/experiment_database.py index 0cbe7045..8b574053 100644 --- a/mdsuite/database/experiment_database.py +++ b/mdsuite/database/experiment_database.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations import dataclasses diff --git a/mdsuite/database/mdsuite_properties.py b/mdsuite/database/mdsuite_properties.py index bc012bbe..c9fb35b4 100644 --- a/mdsuite/database/mdsuite_properties.py +++ b/mdsuite/database/mdsuite_properties.py @@ -24,6 +24,7 @@ Summary ------- """ + from dataclasses import dataclass from mdsuite.database.simulation_database import PropertyInfo diff --git a/mdsuite/database/project_database.py b/mdsuite/database/project_database.py index d8097971..c1c40c13 100644 --- a/mdsuite/database/project_database.py +++ b/mdsuite/database/project_database.py @@ -24,6 +24,7 @@ Summary ------- """ + import logging from pathlib import Path diff --git a/mdsuite/database/scheme.py b/mdsuite/database/scheme.py index ee91f256..1972fbb2 100644 --- a/mdsuite/database/scheme.py +++ b/mdsuite/database/scheme.py @@ -24,6 +24,7 @@ Summary ------- """ + import logging from sqlalchemy import Boolean, Column, ForeignKey, Integer, String diff --git a/mdsuite/database/simulation_database.py b/mdsuite/database/simulation_database.py index 60668fdb..6d36e2cb 100644 --- a/mdsuite/database/simulation_database.py +++ b/mdsuite/database/simulation_database.py @@ -24,6 +24,7 @@ Summary ------- """ + import dataclasses import logging import pathlib @@ -197,6 +198,7 @@ def __init__(self, species_list: List[SpeciesInfo], chunk_size: int): def add_data(self, data: np.ndarray, config_idx, species_name, property_name): """ Add configuration data to the chunk + Parameters ---------- data: diff --git a/mdsuite/experiment/experiment.py b/mdsuite/experiment/experiment.py index 57167776..21361a71 100644 --- a/mdsuite/experiment/experiment.py +++ b/mdsuite/experiment/experiment.py @@ -24,6 +24,7 @@ Summary ------- """ + import copy import importlib.resources import json @@ -471,6 +472,7 @@ def add_data( format with its own reader or want to use non-default arguments for your reader, instantiate the reader and pass it to this method. TODO reference online documentation of data loading in the error messages + Parameters ---------- simulation_data : str or pathlib.Path or mdsuite.file_io.file_read.FileProcessor @@ -689,6 +691,7 @@ def _species_list_to_architecture_dict(species_list, n_configurations): # TODO let the database handler use the species list directly instead of the dict """ converter from species list to legacy architecture dict + Parameters ---------- species_list diff --git a/mdsuite/experiment/run.py b/mdsuite/experiment/run.py index 3cd0a00d..c4aa952a 100644 --- a/mdsuite/experiment/run.py +++ b/mdsuite/experiment/run.py @@ -9,6 +9,7 @@ Description: Collection of calculators / transformations for exp.run """ + from __future__ import annotations import functools diff --git a/mdsuite/experiment/run_module.py b/mdsuite/experiment/run_module.py index 9aea3351..15924799 100644 --- a/mdsuite/experiment/run_module.py +++ b/mdsuite/experiment/run_module.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations from typing import TYPE_CHECKING @@ -44,6 +45,7 @@ class RunModule: def __init__(self, parent, module_dict, **kwargs): """Initialize the attributes + Parameters ---------- parent: Experiment diff --git a/mdsuite/file_io/chemfiles_read.py b/mdsuite/file_io/chemfiles_read.py index b71b097f..716639db 100644 --- a/mdsuite/file_io/chemfiles_read.py +++ b/mdsuite/file_io/chemfiles_read.py @@ -1,4 +1,5 @@ """Test MDSuites chemfiles read module.""" + import pathlib import typing diff --git a/mdsuite/file_io/extxyz_files.py b/mdsuite/file_io/extxyz_files.py index 4e255863..9e0cb7a8 100644 --- a/mdsuite/file_io/extxyz_files.py +++ b/mdsuite/file_io/extxyz_files.py @@ -24,6 +24,7 @@ Summary ------- """ + import copy import logging import pathlib @@ -257,6 +258,7 @@ def _get_property_to_column_idx_dict( header to analyse var_names: dict of translations from MDsuite property names to extxyz property names + Returns ------- species_index: int diff --git a/mdsuite/file_io/file_read.py b/mdsuite/file_io/file_read.py index ed25ed27..e63ce2ff 100644 --- a/mdsuite/file_io/file_read.py +++ b/mdsuite/file_io/file_read.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations import abc diff --git a/mdsuite/file_io/lammps_flux_files.py b/mdsuite/file_io/lammps_flux_files.py index 79fd45bd..bf325894 100644 --- a/mdsuite/file_io/lammps_flux_files.py +++ b/mdsuite/file_io/lammps_flux_files.py @@ -24,6 +24,7 @@ Summary ------- """ + import pathlib import typing @@ -65,6 +66,7 @@ def __init__( Initialize the lammps flux reader. Since the flux file does not have a fixed expected content, you need to provide the necessary metadata (sample_rate, box_l) here manually + Parameters ---------- file_path diff --git a/mdsuite/file_io/lammps_trajectory_files.py b/mdsuite/file_io/lammps_trajectory_files.py index 939ae0ac..cfce5892 100644 --- a/mdsuite/file_io/lammps_trajectory_files.py +++ b/mdsuite/file_io/lammps_trajectory_files.py @@ -209,9 +209,9 @@ def _get_species_information( # skip the header mdsuite.file_io.tabular_text_files.skip_n_lines(file, self.n_header_lines) # read one configuration - traj_data = np.stack( - [np.array(list(file.readline().split())) for _ in range(n_particles)] - ) + traj_data = np.stack([ + np.array(list(file.readline().split())) for _ in range(n_particles) + ]) # sort by particle id if not self.trajectory_is_sorted_by_ids: traj_data = sort_array_by_column(traj_data, header_id_index) diff --git a/mdsuite/file_io/script_input.py b/mdsuite/file_io/script_input.py index 31fd5eca..91b4babb 100644 --- a/mdsuite/file_io/script_input.py +++ b/mdsuite/file_io/script_input.py @@ -1,4 +1,5 @@ """MDSuite script input module.""" + import typing import mdsuite.file_io.file_read @@ -16,6 +17,7 @@ def __init__( ): """ Provide all the data needed for this class to act as a FileProcessor + Parameters ---------- data diff --git a/mdsuite/file_io/tabular_text_files.py b/mdsuite/file_io/tabular_text_files.py index 704d5ee5..e0d104bc 100644 --- a/mdsuite/file_io/tabular_text_files.py +++ b/mdsuite/file_io/tabular_text_files.py @@ -1,4 +1,5 @@ """MDSuite Tabular Text file reader module.""" + import abc import copy import dataclasses @@ -72,6 +73,7 @@ def __init__( custom_column_names. The result, self._column_name_dict is supposed to be used by child functions to create their TabularTextFileReaderData + Parameters ---------- file_path: @@ -165,6 +167,7 @@ def _read_process_n_configurations( ) -> mdsuite.database.simulation_database.TrajectoryChunkData: """ Read n configurations and package them into a trajectory chunk of the right format + Parameters ---------- file: @@ -185,14 +188,12 @@ def _read_process_n_configurations( # skip the header mdsuite.file_io.tabular_text_files.skip_n_lines(file, n_header_lines) # read one config - traj_data = np.stack( - [ - (list(file.readline().split())) - for _ in range( - self.tabular_text_reader_data.n_particles, - ) - ] - ) + traj_data = np.stack([ + (list(file.readline().split())) + for _ in range( + self.tabular_text_reader_data.n_particles, + ) + ]) # sort by id if self.tabular_text_reader_data.sort_by_column_idx is not None: traj_data = mdsuite.utils.meta_functions.sort_array_by_column( @@ -224,6 +225,7 @@ def read_n_lines(file, n_lines: int, start_at: int = None) -> list: """ Get n_lines lines, starting at line number start_at. If start_at is None, read from the current file state + Returns ------- A list of strings, one string for each line. @@ -237,6 +239,7 @@ def read_n_lines(file, n_lines: int, start_at: int = None) -> list: def skip_n_lines(file, n_lines: int) -> None: """ skip n_lines in file + Parameters ---------- file: the file where we skip lines diff --git a/mdsuite/graph_modules/molecular_graph.py b/mdsuite/graph_modules/molecular_graph.py index 2e9b1afc..417f9f20 100644 --- a/mdsuite/graph_modules/molecular_graph.py +++ b/mdsuite/graph_modules/molecular_graph.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations import logging diff --git a/mdsuite/memory_management/__init__.py b/mdsuite/memory_management/__init__.py index 4df5406b..5569909d 100644 --- a/mdsuite/memory_management/__init__.py +++ b/mdsuite/memory_management/__init__.py @@ -24,6 +24,7 @@ Summary ------- """ + from .memory_manager import MemoryManager __all__ = ["MemoryManager"] diff --git a/mdsuite/memory_management/memory_manager.py b/mdsuite/memory_management/memory_manager.py index f0ce2e07..06929e4e 100644 --- a/mdsuite/memory_management/memory_manager.py +++ b/mdsuite/memory_management/memory_manager.py @@ -24,6 +24,7 @@ Summary ------- """ + import logging from typing import Tuple @@ -355,6 +356,7 @@ def get_ensemble_loop( Data range to be used in the analysis. correlation_time : int Correlation time to be considered when looping over the tensor_values + Returns ------- data_range_partitions : int diff --git a/mdsuite/project/project.py b/mdsuite/project/project.py index f5a4666c..aa4e05a2 100644 --- a/mdsuite/project/project.py +++ b/mdsuite/project/project.py @@ -21,6 +21,7 @@ ------- Parent class for the project. """ + from __future__ import annotations import logging @@ -273,6 +274,7 @@ def disable_experiments(self, names: Union[str, list]): ---------- names: Name or list of names of experiments that should be instantiated and loaded into self.experiments + Returns ------- @@ -297,6 +299,7 @@ def add_data(self, data_sets: dict): values: str or mdsuite.file_io.file_read.FileProcessor refer to mdsuite.experiment.add_data() for an explanation of the file specification options + Returns ------- Updates the experiment classes. diff --git a/mdsuite/time_series/__init__.py b/mdsuite/time_series/__init__.py index 8a4b0600..4498dc49 100644 --- a/mdsuite/time_series/__init__.py +++ b/mdsuite/time_series/__init__.py @@ -24,6 +24,7 @@ Summary ------- """ + from .energies import Energies time_series_dict = {"Energies": Energies} diff --git a/mdsuite/time_series/base.py b/mdsuite/time_series/base.py index 89be20f6..93b8c7cd 100644 --- a/mdsuite/time_series/base.py +++ b/mdsuite/time_series/base.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/mdsuite/time_series/energies.py b/mdsuite/time_series/energies.py index a7e4da65..ca0b75b2 100644 --- a/mdsuite/time_series/energies.py +++ b/mdsuite/time_series/energies.py @@ -24,6 +24,7 @@ Summary ------- """ + from __future__ import annotations from typing import TYPE_CHECKING diff --git a/mdsuite/transformations/__init__.py b/mdsuite/transformations/__init__.py index effd50ac..7fb4808e 100644 --- a/mdsuite/transformations/__init__.py +++ b/mdsuite/transformations/__init__.py @@ -24,6 +24,7 @@ Summary ------- """ + from .integrated_heat_current import IntegratedHeatCurrent from .ionic_current import IonicCurrent from .kinaci_integrated_heat_current import KinaciIntegratedHeatCurrent diff --git a/mdsuite/transformations/integrated_heat_current.py b/mdsuite/transformations/integrated_heat_current.py index 56334f9b..9a1e9e99 100644 --- a/mdsuite/transformations/integrated_heat_current.py +++ b/mdsuite/transformations/integrated_heat_current.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/ionic_current.py b/mdsuite/transformations/ionic_current.py index f8261dd8..ddf15b64 100644 --- a/mdsuite/transformations/ionic_current.py +++ b/mdsuite/transformations/ionic_current.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/kinaci_integrated_heat_current.py b/mdsuite/transformations/kinaci_integrated_heat_current.py index 0fb01bd6..d52ee08d 100644 --- a/mdsuite/transformations/kinaci_integrated_heat_current.py +++ b/mdsuite/transformations/kinaci_integrated_heat_current.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import numpy as np diff --git a/mdsuite/transformations/map_molecules.py b/mdsuite/transformations/map_molecules.py index 697735f1..cb7a4d6b 100644 --- a/mdsuite/transformations/map_molecules.py +++ b/mdsuite/transformations/map_molecules.py @@ -24,6 +24,7 @@ Summary ------- """ + import logging from typing import List @@ -151,11 +152,9 @@ def _get_type_spec(self, path_list: list) -> dict: type_spec[str.encode(item)] = tf.TensorSpec( shape=(None, None, 3), dtype=self.dtype ) - type_spec.update( - { - str.encode("data_size"): tf.TensorSpec(shape=(), dtype=tf.int32), - } - ) + type_spec.update({ + str.encode("data_size"): tf.TensorSpec(shape=(), dtype=tf.int32), + }) return type_spec diff --git a/mdsuite/transformations/momentum_flux.py b/mdsuite/transformations/momentum_flux.py index df2d89d9..d10bae2b 100644 --- a/mdsuite/transformations/momentum_flux.py +++ b/mdsuite/transformations/momentum_flux.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/scale_coordinates.py b/mdsuite/transformations/scale_coordinates.py index 6275d6a8..80d0de73 100644 --- a/mdsuite/transformations/scale_coordinates.py +++ b/mdsuite/transformations/scale_coordinates.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/test_trafos.py b/mdsuite/transformations/test_trafos.py index c7a089b4..ff9b39d1 100644 --- a/mdsuite/transformations/test_trafos.py +++ b/mdsuite/transformations/test_trafos.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import numpy as np diff --git a/mdsuite/transformations/thermal_flux.py b/mdsuite/transformations/thermal_flux.py index 015c6f4c..5c7dd51f 100644 --- a/mdsuite/transformations/thermal_flux.py +++ b/mdsuite/transformations/thermal_flux.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import numpy as np diff --git a/mdsuite/transformations/transformation_dict.py b/mdsuite/transformations/transformation_dict.py index 43c51ed2..a2f4119f 100644 --- a/mdsuite/transformations/transformation_dict.py +++ b/mdsuite/transformations/transformation_dict.py @@ -24,6 +24,7 @@ Summary ------- """ + from mdsuite.database.mdsuite_properties import mdsuite_properties as mdp from mdsuite.transformations import ( CoordinateUnwrapper, diff --git a/mdsuite/transformations/transformations.py b/mdsuite/transformations/transformations.py index 58baf090..42e37c80 100644 --- a/mdsuite/transformations/transformations.py +++ b/mdsuite/transformations/transformations.py @@ -25,6 +25,7 @@ ------- Parent class for the transformations. """ + from __future__ import annotations import abc @@ -179,6 +180,7 @@ def _save_output( # todo for the future: this should not be part of the transformation. # the transformation should yield a batch and the experiment should take care of # storing it in the correct place, just as with file inputs + Returns ------- saves the tensor_values to the database_path. @@ -447,6 +449,7 @@ def run_transformation(self, species: typing.Iterable[str] = None): """ Perform the batching and data loading for the transformation, then calls transform_batch + Parameters ---------- species : Iterable[str] @@ -473,18 +476,16 @@ def run_transformation(self, species: typing.Iterable[str] = None): continue output_data_structure = self._prepare_database_entry(species_name) - type_spec, const_input_data = self.get_generator_type_spec_and_const_data( - [species_name] - ) + type_spec, const_input_data = self.get_generator_type_spec_and_const_data([ + species_name + ]) const_input_data = const_input_data[species_name] self._prepare_monitors(list(type_spec.keys())) batch_generator, batch_generator_args = self.data_manager.batch_generator() - type_spec.update( - { - str.encode("data_size"): tf.TensorSpec(shape=(), dtype=tf.int32), - } - ) + type_spec.update({ + str.encode("data_size"): tf.TensorSpec(shape=(), dtype=tf.int32), + }) data_set = tf.data.Dataset.from_generator( batch_generator, args=batch_generator_args, output_signature=type_spec ) @@ -554,6 +555,7 @@ def run_transformation(self, species: typing.Iterable[str] = None) -> None: """ Perform the batching and data loading for the transformation, then calls transform_batch + Parameters ---------- species : Iterable[str] @@ -584,11 +586,9 @@ def run_transformation(self, species: typing.Iterable[str] = None) -> None: type_spec, const_input_data = self.get_generator_type_spec_and_const_data(species) self._prepare_monitors(list(type_spec.keys())) batch_generator, batch_generator_args = self.data_manager.batch_generator() - type_spec.update( - { - str.encode("data_size"): tf.TensorSpec(shape=(), dtype=tf.int32), - } - ) + type_spec.update({ + str.encode("data_size"): tf.TensorSpec(shape=(), dtype=tf.int32), + }) data_set = tf.data.Dataset.from_generator( batch_generator, args=batch_generator_args, output_signature=type_spec ) diff --git a/mdsuite/transformations/translational_dipole_moment.py b/mdsuite/transformations/translational_dipole_moment.py index 496e2ded..b765008e 100644 --- a/mdsuite/transformations/translational_dipole_moment.py +++ b/mdsuite/transformations/translational_dipole_moment.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/unwrap_coordinates.py b/mdsuite/transformations/unwrap_coordinates.py index 4b177de1..ed66bba6 100644 --- a/mdsuite/transformations/unwrap_coordinates.py +++ b/mdsuite/transformations/unwrap_coordinates.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/unwrap_via_indices.py b/mdsuite/transformations/unwrap_via_indices.py index 53224e90..d94f12e5 100644 --- a/mdsuite/transformations/unwrap_via_indices.py +++ b/mdsuite/transformations/unwrap_via_indices.py @@ -24,6 +24,7 @@ Summary ------- """ + import typing import tensorflow as tf diff --git a/mdsuite/transformations/velocity_from_positions.py b/mdsuite/transformations/velocity_from_positions.py index 1f294d3b..924b921d 100644 --- a/mdsuite/transformations/velocity_from_positions.py +++ b/mdsuite/transformations/velocity_from_positions.py @@ -12,6 +12,7 @@ ------- Calculate the velocity of particles from their positions """ + import typing import tensorflow as tf diff --git a/mdsuite/utils/calculator_helper_methods.py b/mdsuite/utils/calculator_helper_methods.py index 7e8001e6..5adfa705 100644 --- a/mdsuite/utils/calculator_helper_methods.py +++ b/mdsuite/utils/calculator_helper_methods.py @@ -25,6 +25,7 @@ ------- Static methods used in calculators are kept here rather than polluting the parent class. """ + import logging from typing import Any, Iterable, Tuple, Union diff --git a/mdsuite/utils/colours.py b/mdsuite/utils/colours.py index 92f48a13..b6d00853 100644 --- a/mdsuite/utils/colours.py +++ b/mdsuite/utils/colours.py @@ -1,4 +1,5 @@ """MDSuite colours module.""" + import dataclasses diff --git a/mdsuite/utils/config.py b/mdsuite/utils/config.py index ed67728e..6242bfd4 100644 --- a/mdsuite/utils/config.py +++ b/mdsuite/utils/config.py @@ -24,6 +24,7 @@ Summary ------- """ + from dataclasses import dataclass diff --git a/mdsuite/utils/constants.py b/mdsuite/utils/constants.py index 79844774..c82a409e 100644 --- a/mdsuite/utils/constants.py +++ b/mdsuite/utils/constants.py @@ -24,6 +24,7 @@ Summary ------- """ + import dataclasses diff --git a/mdsuite/utils/helpers.py b/mdsuite/utils/helpers.py index 9a5d3495..1d298f26 100644 --- a/mdsuite/utils/helpers.py +++ b/mdsuite/utils/helpers.py @@ -9,6 +9,7 @@ Description: """ + import contextlib import numpy as np diff --git a/mdsuite/utils/meta_functions.py b/mdsuite/utils/meta_functions.py index 2b988fd7..17b36788 100644 --- a/mdsuite/utils/meta_functions.py +++ b/mdsuite/utils/meta_functions.py @@ -468,6 +468,7 @@ def get_nearest_divisor(a: int, b: int) -> int: def split_array(data: np.array, condition: np.array) -> list: """ split an array by a condition + Parameters ---------- data : np.array diff --git a/mdsuite/utils/molecule.py b/mdsuite/utils/molecule.py index f20c30cb..f0ca7d17 100644 --- a/mdsuite/utils/molecule.py +++ b/mdsuite/utils/molecule.py @@ -25,6 +25,7 @@ ------- Module for the MDSuite molecule dataclass """ + from dataclasses import dataclass diff --git a/mdsuite/utils/report_computer_characteristics.py b/mdsuite/utils/report_computer_characteristics.py index 64745427..47ed503c 100644 --- a/mdsuite/utils/report_computer_characteristics.py +++ b/mdsuite/utils/report_computer_characteristics.py @@ -24,6 +24,7 @@ Summary ------- """ + import re from os import path from pathlib import Path diff --git a/mdsuite/utils/scale_functions.py b/mdsuite/utils/scale_functions.py index a9ad0823..bce40f85 100644 --- a/mdsuite/utils/scale_functions.py +++ b/mdsuite/utils/scale_functions.py @@ -24,6 +24,7 @@ Summary ------- """ + import numpy as np @@ -81,6 +82,7 @@ def quadratic_scale_function( Scalar scaling factor for the inner multiplication outer_scale_factor : int Scalar scaling factor for the outer multiplication + Returns ------- scaled_memory : int diff --git a/mdsuite/utils/tensor_flow/layers.py b/mdsuite/utils/tensor_flow/layers.py index d6f00734..a9a8de1b 100644 --- a/mdsuite/utils/tensor_flow/layers.py +++ b/mdsuite/utils/tensor_flow/layers.py @@ -24,6 +24,7 @@ Summary ------- """ + import tensorflow as tf from .helpers import triu_indices as compute_triu diff --git a/mdsuite/utils/testing.py b/mdsuite/utils/testing.py index 81898832..3a83d261 100644 --- a/mdsuite/utils/testing.py +++ b/mdsuite/utils/testing.py @@ -24,6 +24,7 @@ Summary ------- """ + import multiprocessing import traceback diff --git a/mdsuite/utils/units.py b/mdsuite/utils/units.py index 6ff57aa1..dccb7c6f 100644 --- a/mdsuite/utils/units.py +++ b/mdsuite/utils/units.py @@ -24,6 +24,7 @@ Summary ------- """ + from dataclasses import dataclass standard_state_pressure = 100000 # Pa -- Standard state pressure diff --git a/mdsuite/visualizer/d2_data_visualization.py b/mdsuite/visualizer/d2_data_visualization.py index 0f463f6b..8d7607de 100644 --- a/mdsuite/visualizer/d2_data_visualization.py +++ b/mdsuite/visualizer/d2_data_visualization.py @@ -24,6 +24,7 @@ Summary ------- """ + import pathlib from typing import List, Union diff --git a/mdsuite/visualizer/d3_data_visualizer.py b/mdsuite/visualizer/d3_data_visualizer.py index 8dffcd21..7574ca96 100644 --- a/mdsuite/visualizer/d3_data_visualizer.py +++ b/mdsuite/visualizer/d3_data_visualizer.py @@ -25,6 +25,7 @@ ------- Module for the MDSuite 3d visualizer. """ + import importlib.resources import json from typing import Union diff --git a/mdsuite/visualizer/znvis_visualizer.py b/mdsuite/visualizer/znvis_visualizer.py index 5b9ab2d9..db830793 100644 --- a/mdsuite/visualizer/znvis_visualizer.py +++ b/mdsuite/visualizer/znvis_visualizer.py @@ -25,6 +25,7 @@ ------- Module implementing the ZnVis visualizer in MDSuite. """ + import importlib.resources import json diff --git a/setup.py b/setup.py index 999d6a63..e5c01325 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ Summary ------- """ + from pathlib import Path import setuptools