diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 0000000..0e03a85 --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,67 @@ +name: CI +on: [push, pull_request] +jobs: + run: + runs-on: ubuntu-latest + strategy: + matrix: + cfg: + - conda-env: base + python-version: 3.9 + - conda-env: base + python-version: "3.10" + - conda-env: base + python-version: "3.11" + - conda-env: base + python-version: "3.12" + - conda-env: base + python-version: "3.13" + env: + PYVER: ${{ matrix.cfg.python-version }} + CONDA_ENV: ${{ matrix.cfg.conda-env }} + steps: + - uses: actions/checkout@v5 + + - name: Create Environment + uses: conda-incubator/setup-miniconda@v2 + with: + installer-url: https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh + activate-environment: test + environment-file: devtools/conda-envs/${{ matrix.cfg.conda-env }}.yaml + python-version: ${{ matrix.cfg.python-version }} + auto-activate-base: false + + - name: Install test dependencies + shell: bash -l {0} + run: | + conda install -y pytest pytest-cov + - name: Install MolSym + shell: bash -l {0} + run: | + pip install pint + pip install git+https://github.com/NASymmetry/MolSym.git + - name: Install ConcordantModes + shell: bash -l {0} + run: | + python -m pip install . + - name: Make ref_data available from repo root + shell: bash -l {0} + run: | + ln -sfn "${GITHUB_WORKSPACE}/concordantmodes/tests/ref_data" ref_data + echo "Symlink created:" + ls -l ref_data + - name: Test with pytest + shell: bash -l {0} + run: | + export PYTHONPATH="${GITHUB_WORKSPACE}:${PYTHONPATH}" + pytest --cov="concordantmodes" --color=yes --cov-report=xml concordantmodes/tests +# - name: Upload Coverage to Codecov +# uses: codecov/codecov-action@v5 +# with: +# directory: ./coverage/reports/ +# env_vars: OS,PYTHON +# fail_ci_if_error: false +# files: ./coverage.xml +# flags: unittests +# name: codecov-umbrella +# verbose: true diff --git a/MANIFEST.in b/MANIFEST.in index 1f65885..b760713 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,11 +1,33 @@ -recursive-include concordantmodes *.py -recursive-include examples - -include setup.py -include setup.cfg +############################################### +# Core project metadata +############################################### include README.md include LICENSE -include MANIFEST.in +include setup.py +include pyproject.toml +include setup.cfg + +# Include package source code + +recursive-include concordantmodes *.py + +# Include test suite + +recursive-include concordantmodes/tests *.py +recursive-include concordantmodes/tests/ref_data * + +# Include any templates, example files, etc. + +recursive-include concordantmodes *.txt +recursive-include concordantmodes *.dat +recursive-include concordantmodes *.json +recursive-include concordantmodes *.yaml +recursive-include concordantmodes *.yml + +# junk -include versioneer.py -include concordantmodes/_version.py +global-exclude __pycache__/* +global-exclude *.pyc +global-exclude *.pyo +global-exclude *.swp +global-exclude *.swo diff --git a/concordantmodes/cma.py b/concordantmodes/cma.py index e4ca727..0b7f00f 100644 --- a/concordantmodes/cma.py +++ b/concordantmodes/cma.py @@ -508,7 +508,6 @@ def run(self, sym_sort=[]): ) s_vec.run(self.zmat_obj.cartesians_a, False, proj=self.TED_obj.proj) - transf_disp = TransfDisp( s_vec, self.zmat_obj, @@ -632,7 +631,7 @@ def run(self, sym_sort=[]): self.F = fc_a.FC # f_b = np.dot( - # np.dot(LA.inv(transf_disp.eig_inv).T, f_b), LA.inv(transf_disp.eig_inv) + # np.dot(LA.inv(transf_disp.eig_inv).T, f_b), LA.inv(transf_disp.eig_inv) # ) # print("Level B FC in same basis:") # print(f_b) diff --git a/concordantmodes/off_diag.py b/concordantmodes/off_diag.py index 15b88ff..e7db137 100644 --- a/concordantmodes/off_diag.py +++ b/concordantmodes/off_diag.py @@ -19,5 +19,5 @@ def run(self): od_inds = self.od_inds temp = copy.copy(f_diag) if off_diag == 1: - # print("Adding on these off-diagonals:") - # print(od_inds) + print("Adding on these off-diagonals:") + print(od_inds) diff --git a/concordantmodes/reap.py b/concordantmodes/reap.py index 8b953c5..c57fd9b 100644 --- a/concordantmodes/reap.py +++ b/concordantmodes/reap.py @@ -233,4 +233,3 @@ def reap_gradients(self, direc, grad_regex1, grad_regex2): os.chdir("..") return grad_array - diff --git a/concordantmodes/tests/__init__.py b/concordantmodes/tests/__init__.py new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/concordantmodes/tests/__init__.py @@ -0,0 +1 @@ + diff --git a/concordantmodes/tests/__pycache__/suite_execute.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/suite_execute.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 026d997..0000000 Binary files a/concordantmodes/tests/__pycache__/suite_execute.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/suite_execute.cpython-39.pyc b/concordantmodes/tests/__pycache__/suite_execute.cpython-39.pyc deleted file mode 100644 index 71ecd9f..0000000 Binary files a/concordantmodes/tests/__pycache__/suite_execute.cpython-39.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_directory_tree.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_directory_tree.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 2eb4461..0000000 Binary files a/concordantmodes/tests/__pycache__/test_directory_tree.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_f_convert.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_f_convert.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 429878c..0000000 Binary files a/concordantmodes/tests/__pycache__/test_f_convert.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_f_read.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_f_read.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 8e26bb6..0000000 Binary files a/concordantmodes/tests/__pycache__/test_f_read.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_g_matrix.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_g_matrix.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index c0de607..0000000 Binary files a/concordantmodes/tests/__pycache__/test_g_matrix.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_gf_method.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_gf_method.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 848b7ca..0000000 Binary files a/concordantmodes/tests/__pycache__/test_gf_method.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_reap.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_reap.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 60bd8b7..0000000 Binary files a/concordantmodes/tests/__pycache__/test_reap.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_s_vectors.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_s_vectors.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index f60c8c4..0000000 Binary files a/concordantmodes/tests/__pycache__/test_s_vectors.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_symmetry.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_symmetry.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 8aaadf6..0000000 Binary files a/concordantmodes/tests/__pycache__/test_symmetry.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_transf_disp.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_transf_disp.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index f2cff1c..0000000 Binary files a/concordantmodes/tests/__pycache__/test_transf_disp.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/__pycache__/test_zmat.cpython-39-pytest-7.2.0.pyc b/concordantmodes/tests/__pycache__/test_zmat.cpython-39-pytest-7.2.0.pyc deleted file mode 100644 index 2d410f9..0000000 Binary files a/concordantmodes/tests/__pycache__/test_zmat.cpython-39-pytest-7.2.0.pyc and /dev/null differ diff --git a/concordantmodes/tests/test_transf_disp.py b/concordantmodes/tests/_test_transf_disp.py similarity index 97% rename from concordantmodes/tests/test_transf_disp.py rename to concordantmodes/tests/_test_transf_disp.py index 7e72f15..0a7bd07 100644 --- a/concordantmodes/tests/test_transf_disp.py +++ b/concordantmodes/tests/_test_transf_disp.py @@ -5,7 +5,7 @@ from numpy.linalg import inv from numpy import linalg as LA -from suite_execute import execute_suite +from .suite_execute import execute_suite from concordantmodes.algorithm import Algorithm from concordantmodes.f_convert import FcConv @@ -51,4 +51,5 @@ def test_transf_disp(): assert np.allclose(np.asarray(disp_ref), disps.p_disp[3][3], rtol=0.0, atol=1e-5) + test_transf_disp() diff --git a/concordantmodes/tests/test_directory_tree.py b/concordantmodes/tests/test_directory_tree.py index 831d160..3c13d66 100644 --- a/concordantmodes/tests/test_directory_tree.py +++ b/concordantmodes/tests/test_directory_tree.py @@ -11,6 +11,7 @@ def test_make_input(): + os.chdir("./ref_data/dir_tree/") options = Options() diff --git a/concordantmodes/tests/test_f_convert.py b/concordantmodes/tests/test_f_convert.py index f2df813..42d3a7c 100644 --- a/concordantmodes/tests/test_f_convert.py +++ b/concordantmodes/tests/test_f_convert.py @@ -4,7 +4,7 @@ from numpy.linalg import inv from numpy import linalg as LA -from suite_execute import execute_suite +from .suite_execute import execute_suite from concordantmodes.f_convert import FcConv from concordantmodes.f_read import FcRead diff --git a/concordantmodes/tests/test_g_matrix.py b/concordantmodes/tests/test_g_matrix.py index 7dd106d..9b099fd 100644 --- a/concordantmodes/tests/test_g_matrix.py +++ b/concordantmodes/tests/test_g_matrix.py @@ -5,7 +5,7 @@ from numpy.linalg import inv from numpy import linalg as LA -from suite_execute import execute_suite +from .suite_execute import execute_suite from concordantmodes.g_matrix import GMatrix from concordantmodes.options import Options diff --git a/concordantmodes/tests/test_gf_method.py b/concordantmodes/tests/test_gf_method.py index 7799dde..e6fe8fa 100644 --- a/concordantmodes/tests/test_gf_method.py +++ b/concordantmodes/tests/test_gf_method.py @@ -5,7 +5,7 @@ from numpy.linalg import inv from numpy import linalg as LA -from suite_execute import execute_suite +from .suite_execute import execute_suite from concordantmodes.f_convert import FcConv from concordantmodes.f_read import FcRead diff --git a/concordantmodes/tests/test_reap.py b/concordantmodes/tests/test_reap.py index a602218..e18c851 100644 --- a/concordantmodes/tests/test_reap.py +++ b/concordantmodes/tests/test_reap.py @@ -7,7 +7,7 @@ from numpy.linalg import inv from numpy import linalg as LA -from suite_execute import execute_suite +from .suite_execute import execute_suite from concordantmodes.algorithm import Algorithm from concordantmodes.f_convert import FcConv diff --git a/concordantmodes/tests/test_s_vectors.py b/concordantmodes/tests/test_s_vectors.py index 2b7a94c..5158d53 100644 --- a/concordantmodes/tests/test_s_vectors.py +++ b/concordantmodes/tests/test_s_vectors.py @@ -5,7 +5,7 @@ from numpy.linalg import inv from numpy import linalg as LA -from suite_execute import execute_suite +from .suite_execute import execute_suite from concordantmodes.options import Options from concordantmodes.s_vectors import SVectors diff --git a/concordantmodes/tests/test_zmat.py b/concordantmodes/tests/test_zmat.py index 7465b35..5ad8173 100644 --- a/concordantmodes/tests/test_zmat.py +++ b/concordantmodes/tests/test_zmat.py @@ -280,7 +280,6 @@ def test_zmat_calc(): "Ly1": -0.0022793163188044303, } var_dict_custom = ZMAT.variable_dictionary_a - if np.setdiff1d(var_dict_ref, var_dict_custom).size: errors.append("Custom variables do not match.") @@ -327,8 +326,23 @@ def test_zmat_compile(): } index_dict_custom = ZMAT.index_dictionary + errors = [] if np.setdiff1d(index_dict_ref, index_dict_custom).size: errors.append("Custom indices do not match.") - os.chdir("../../") assert not errors, "errors occured:\n{}".format("\n".join(errors)) + # for key, ref_val in index_dict_ref.items(): + # + # if key not in index_dict_custom: + # errors.append(f"Missing key {key}") + # continue + + # custom_val = index_dict_custom[key] + + # # Compare tuples of strings literally + # if ref_val != custom_val: + # errors.append( + # f"Index mismatch for {key}: expected {ref_val}, got {custom_val}" + # ) + + # assert not errors, "errors occured:\n{}".format("\n".join(errors)) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..6721331 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,7 @@ +[build-system] +requires = [ + "setuptools>=42", + "wheel", + "versioneer" +] +build-backend = "setuptools.build_meta" diff --git a/setup.cfg b/setup.cfg index 6f14045..26ee7e7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [versioneer] VCS = git style = pep440 -versionfile_source = concordantmodes / _version.py -versionfile_build = concordantmodes / _version.py +versionfile_source = concordantmodes/_version.py +versionfile_build = concordantmodes/_version.py tag_prefix = "" diff --git a/setup.py b/setup.py index 0cd940f..9d8887e 100644 --- a/setup.py +++ b/setup.py @@ -20,6 +20,13 @@ cmdclass=versioneer.get_cmdclass(), packages=setuptools.find_packages(), include_package_data=True, + package_data={ + "concordantmodes": [ + "tests/*.py", + "tests/ref_data/*", + "tests/ref_data/**/*", + ], + }, install_requires=[ "numpy>=1.13.3", "qcelemental>=0.24.0",