Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package spglib for openSUSE:Factory checked in at 2022-12-04 14:59:01 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/spglib (Old) and /work/SRC/openSUSE:Factory/.spglib.new.1835 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "spglib" Sun Dec 4 14:59:01 2022 rev:7 rq:1039934 version:2.0.2 Changes: -------- --- /work/SRC/openSUSE:Factory/spglib/spglib.changes 2022-09-15 22:59:33.929278933 +0200 +++ /work/SRC/openSUSE:Factory/.spglib.new.1835/spglib.changes 2022-12-04 14:59:40.928729244 +0100 @@ -1,0 +2,7 @@ +Sat Dec 3 20:52:00 UTC 2022 - Dirk Müller <dmuel...@suse.com> + +- update to 2.0.2: + * Fix segmentation fault in spgms_get_symmetry_with_site_tensors with high symprec + * Fix possible segmentation fault in get_magnetic_dataset with high symprec + +------------------------------------------------------------------- Old: ---- spglib-2.0.1.tar.gz New: ---- spglib-2.0.2.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ spglib.spec ++++++ --- /var/tmp/diff_new_pack.Akt907/_old 2022-12-04 14:59:41.356731711 +0100 +++ /var/tmp/diff_new_pack.Akt907/_new 2022-12-04 14:59:41.364731756 +0100 @@ -18,7 +18,7 @@ %define shlib libsymspg1 Name: spglib -Version: 2.0.1 +Version: 2.0.2 Release: 0 Summary: Find and handle crystal symmetries License: BSD-3-Clause ++++++ spglib-2.0.1.tar.gz -> spglib-2.0.2.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/.github/ISSUE_TEMPLATE/bug_report.md new/spglib-2.0.2/.github/ISSUE_TEMPLATE/bug_report.md --- old/spglib-2.0.1/.github/ISSUE_TEMPLATE/bug_report.md 1970-01-01 01:00:00.000000000 +0100 +++ new/spglib-2.0.2/.github/ISSUE_TEMPLATE/bug_report.md 2022-11-06 06:44:10.000000000 +0100 @@ -0,0 +1,33 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +## Describe the bug + +<!-- A clear and concise description of what the bug is. --> + +## To Reproduce + +<!-- +If you use spglib's Python API, please do not use ASE or Pymatgen's wrapper to make it easier to identify your problem. +The format for crystal structures is shown here: https://spglib.github.io/spglib/python-spglib.html#variables +If spglib returns different results by changing `symprec`, `angle_tolerance`, or `mag_symprec`, please report it too. +--> + +## Expected behavior + +<!-- A clear and concise description of what you expected to happen. --> + +## Environment + +- Python version: +- Spglib's version: + +## Additional context + +<!-- Add any other context about the problem here. --> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/.github/ISSUE_TEMPLATE/feature_request.md new/spglib-2.0.2/.github/ISSUE_TEMPLATE/feature_request.md --- old/spglib-2.0.1/.github/ISSUE_TEMPLATE/feature_request.md 1970-01-01 01:00:00.000000000 +0100 +++ new/spglib-2.0.2/.github/ISSUE_TEMPLATE/feature_request.md 2022-11-06 06:44:10.000000000 +0100 @@ -0,0 +1,24 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +## Is your feature request related to a problem? Please describe. + +<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] --> + +## Describe the solution you'd like + +<!-- A clear and concise description of what you want to happen. --> + +## Describe alternatives you've considered + +<!-- A clear and concise description of any alternative solutions or features you've considered. --> + +## Additional context + +<!-- Add any other context or screenshots about the feature request here. --> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/.github/workflows/pypi-wheel-builds.yml new/spglib-2.0.2/.github/workflows/pypi-wheel-builds.yml --- old/spglib-2.0.1/.github/workflows/pypi-wheel-builds.yml 1970-01-01 01:00:00.000000000 +0100 +++ new/spglib-2.0.2/.github/workflows/pypi-wheel-builds.yml 2022-11-06 06:44:10.000000000 +0100 @@ -0,0 +1,78 @@ +name: Spglib PyPI Wheel builds for linux + +on: + push: + branches: + - rc + - master + +jobs: + build_wheels: + name: Build wheels on ${{ matrix.os }} + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-20.04, windows-2019, macOS-11] + + steps: + - uses: actions/checkout@v3 + + - name: Set up QEMU + if: runner.os == 'Linux' + uses: docker/setup-qemu-action@v2 + with: + platforms: all + + - name: Build wheels + uses: pypa/cibuildwheel@v2.9.0 + env: + CIBW_ARCHS_LINUX: auto aarch64 + CIBW_ARCHS_MACOS: x86_64 arm64 + with: + package-dir: python + output-dir: wheelhouse + config-file: "{package}/pyproject.toml" + + - uses: actions/upload-artifact@v3 + with: + path: ./wheelhouse/*.whl + + build_sdist: + name: Build source distribution + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build sdist + run: | + pip install numpy + cd python + sh pre-build-script.sh + python setup.py sdist + cd .. + - uses: actions/upload-artifact@v3 + with: + path: python/dist/*.tar.gz + + upload_pypi: + needs: [build_wheels, build_sdist] + runs-on: ubuntu-latest + steps: + - uses: actions/download-artifact@v3 + with: + name: artifact + path: dist + + - name: Publish package to TestPyPI + if: startsWith(github.ref, 'refs/heads/rc') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + - name: Publish package to PyPI + if: startsWith(github.ref, 'refs/heads/master') + uses: pypa/gh-action-pypi-publish@release/v1 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/.github/workflows/pypi-wheels-win-mac.yml new/spglib-2.0.2/.github/workflows/pypi-wheels-win-mac.yml --- old/spglib-2.0.1/.github/workflows/pypi-wheels-win-mac.yml 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/.github/workflows/pypi-wheels-win-mac.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,84 +0,0 @@ -name: Spglib PyPI Wheel builds for win and mac - -on: - push: - branches: - - rc - - master - -jobs: - build_wheels: - name: Build wheels on ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [windows-2019, macOS-11] - - steps: - - uses: actions/checkout@v3 - - # Used to host cibuildwheel - - uses: actions/setup-python@v3 - - - name: Install cibuildwheel - run: python -m pip install cibuildwheel==2.9.0 - # to supply options, put them in 'env', like: - # env: - # CIBW_SOME_OPTION: value - - - name: Build wheels for macOS - if: matrix.os == 'macOS-11' - env: - CIBW_ARCHS_MACOS: x86_64 arm64 - run: | - python -m cibuildwheel --output-dir wheelhouse python - - - name: Build wheels for win - if: matrix.os != 'macOS-11' - run: | - python -m cibuildwheel --output-dir wheelhouse python - - - uses: actions/upload-artifact@v3 - with: - path: ./wheelhouse/*.whl - - # build_sdist: - # name: Build source distribution - # runs-on: ubuntu-latest - # steps: - # - uses: actions/checkout@v3 - # - name: Build sdist - # run: | - # pip install numpy - # cd python - # sh pre-build-script.sh - # python setup.py sdist - # cd .. - # - uses: actions/upload-artifact@v3 - # with: - # path: python/dist/*.tar.gz - - upload_pypi: - # needs: [build_wheels, build_sdist] - needs: [build_wheels] - runs-on: ubuntu-latest - steps: - - uses: actions/download-artifact@v3 - with: - name: artifact - path: dist - - - name: Publish package to TestPyPI - if: startsWith(github.ref, 'refs/heads/rc') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - - - name: Publish package to PyPI - if: startsWith(github.ref, 'refs/heads/master') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/.github/workflows/pypi-wheels.yml new/spglib-2.0.2/.github/workflows/pypi-wheels.yml --- old/spglib-2.0.1/.github/workflows/pypi-wheels.yml 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/.github/workflows/pypi-wheels.yml 1970-01-01 01:00:00.000000000 +0100 @@ -1,83 +0,0 @@ -name: Spglib PyPI Wheel builds - -on: - push: - branches: - - rc - - master - -jobs: - build-wheel: - name: Build ${{ matrix.platform }} wheels - runs-on: ubuntu-latest - strategy: - matrix: - platform: - - manylinux2014_x86_64 - - manylinux2014_aarch64 - - manylinux2010_x86_64 - fail-fast: false - steps: - - uses: actions/checkout@v2 - - - name: Set up QEMU - if: matrix.platform == 'manylinux2014_aarch64' - uses: docker/setup-qemu-action@v1 - - name: Set up Python - uses: actions/setup-python@v2 - with: - python-version: '3.9' - - name: Build sdist - if: matrix.platform == 'manylinux2010_x86_64' - run: | - pip install numpy - cd python - sh pre-build-script.sh - python setup.py sdist - cd .. - - name: Build manylinux Python wheels manylinux2014_x86_64 - if: matrix.platform == 'manylinux2014_x86_64' - uses: RalfG/python-wheels-manylinux-build@v0.3.4-manylinux2014_x86_64 - with: - python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' - pre-build-command: 'sh pre-build-script.sh' - package-path: ./python - - name: Build manylinux Python wheels manylinux2014_aarch64 - if: matrix.platform == 'manylinux2014_aarch64' - uses: RalfG/python-wheels-manylinux-build@v0.3.4-manylinux2014_aarch64 - with: - python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' - pre-build-command: 'sh pre-build-script.sh' - package-path: ./python - - name: Build manylinux Python wheels manylinux2010_x86_64 - if: matrix.platform == 'manylinux2010_x86_64' - uses: RalfG/python-wheels-manylinux-build@v0.3.4-manylinux2010_x86_64 - with: - python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39 cp310-cp310' - pre-build-command: 'sh pre-build-script.sh' - package-path: ./python - - name: mkdir - run: | - mkdir dist - - name: copy source - if: matrix.platform == 'manylinux2010_x86_64' - run: | - cp ./python/dist/*.tar.gz dist - - name: copy manylinux wheels - run: | - cp ./python/dist/*manylinux*whl dist - - - name: Publish package to TestPyPI - if: startsWith(github.ref, 'refs/heads/rc') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.TEST_PYPI_API_TOKEN }} - repository_url: https://test.pypi.org/legacy/ - - - name: Publish package to PyPI - if: startsWith(github.ref, 'refs/heads/master') - uses: pypa/gh-action-pypi-publish@release/v1 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/CMakeLists.txt new/spglib-2.0.2/CMakeLists.txt --- old/spglib-2.0.1/CMakeLists.txt 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/CMakeLists.txt 2022-11-06 06:44:10.000000000 +0100 @@ -80,6 +80,17 @@ ${PROJECT_SOURCE_DIR}/src/spin.c ${PROJECT_SOURCE_DIR}/src/symmetry.c) +# avoid One Definition Rule problems +# only available since 3.16.0 +# VERSION_GREATER_EQUAL only available since 3.7.0, so let's do it manually +if (NOT CMAKE_MAJOR_VERSION LESS "3") + if (CMAKE_MAJOR_VERSION GREATER "3" OR NOT CMAKE_MINOR_VERSION LESS "16") + set_source_files_properties( + ${SOURCES} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON + ) + endif() +endif() + # Shared library add_library(symspg SHARED ${SOURCES}) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/admin.md new/spglib-2.0.2/admin.md --- old/spglib-2.0.1/admin.md 1970-01-01 01:00:00.000000000 +0100 +++ new/spglib-2.0.2/admin.md 2022-11-06 06:44:10.000000000 +0100 @@ -0,0 +1,6 @@ +# Releasing a new Spglib version + +1. Update <doc/releases.md> +2. Increment version at <src/version.h> +3. Push the commit to `rc` branch (Github actions publishes the package to TestPyPI automatically) +4. Push the commit to `master` branch (Github actions publishes the package to PyPI automatically) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/doc/magnetic_symmetry_flags.md new/spglib-2.0.2/doc/magnetic_symmetry_flags.md --- old/spglib-2.0.1/doc/magnetic_symmetry_flags.md 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/doc/magnetic_symmetry_flags.md 2022-11-06 06:44:10.000000000 +0100 @@ -30,10 +30,10 @@ - `tensor_rank=1` - `with_time_reversal=true`: {math}`1' \circ \mathbf{m} = -\mathbf{m}` - `is_axial=true`: {math}`(\mathbf{R}, \mathbf{v}) \circ \mathbf{m} = (\mathrm{det} \mathbf{R}) \mathbf{R} \mathbf{m}` - - `is_axial=true`: {math}`(\mathbf{R}, \mathbf{v}) \circ \mathbf{m} = \mathbf{R} \mathbf{m}` + - `is_axial=false`: {math}`(\mathbf{R}, \mathbf{v}) \circ \mathbf{m} = \mathbf{R} \mathbf{m}` - `with_time_reversal=false`: {math}`1' \circ \mathbf{m} = \mathbf{m}` - `is_axial=true`: {math}`(\mathbf{R}, \mathbf{v}) \circ \mathbf{m} = (\mathrm{det} \mathbf{R}) \mathbf{R} \mathbf{m}` - - `is_axial=true`: {math}`(\mathbf{R}, \mathbf{v}) \circ \mathbf{m} = \mathbf{R} \mathbf{m}` + - `is_axial=false`: {math}`(\mathbf{R}, \mathbf{v}) \circ \mathbf{m} = \mathbf{R} \mathbf{m}` <!-- ### Correspondence diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/doc/releases.md new/spglib-2.0.2/doc/releases.md --- old/spglib-2.0.1/doc/releases.md 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/doc/releases.md 2022-11-06 06:44:10.000000000 +0100 @@ -1,6 +1,11 @@ # Summary of releases +## V2.0.2 (6 Nov. 2022) + +- Fix segmentation fault in `spgms_get_symmetry_with_site_tensors` with high symprec [[#195]](https://github.com/spglib/spglib/pull/195) +- Fix possible segmentation fault in `get_magnetic_dataset` with high symprec [[#196]](https://github.com/spglib/spglib/pull/196) + ## V2.0.1 (31 Aug. 2022) - Fix magnetic tolerance for judging type-II MSG (#187) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/python/pyproject.toml new/spglib-2.0.2/python/pyproject.toml --- old/spglib-2.0.1/python/pyproject.toml 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/python/pyproject.toml 2022-11-06 06:44:10.000000000 +0100 @@ -2,4 +2,6 @@ requires = ["setuptools", "wheel", "numpy"] [tool.cibuildwheel] -skip = ["pp*", "*-win32", "*-manylinux_i686"] +skip = ["pp*", "*-win32", "*-manylinux_i686", "*-musllinux*"] +manylinux-x86_64-image = "manylinux2014" +manylinux-aarch64-image = "manylinux2014" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/src/overlap.c new/spglib-2.0.2/src/overlap.c --- old/spglib-2.0.1/src/overlap.c 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/src/overlap.c 2022-11-06 06:44:10.000000000 +0100 @@ -641,7 +641,7 @@ search_start = 0; for (i_orig = 0; i_orig < num_pos; i_orig++) { /* Permanently skip positions filled near the beginning. */ - while (found[search_start]) { + while ((search_start < num_pos) && found[search_start]) { search_start++; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/src/spglib.c new/spglib-2.0.2/src/spglib.c --- old/spglib-2.0.1/src/spglib.c 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/src/spglib.c 2022-11-06 06:44:10.000000000 +0100 @@ -1316,6 +1316,7 @@ if (spglib_error_code == SPGLIB_SUCCESS) { return dataset; } else { + spg_free_magnetic_dataset(dataset); return NULL; } } @@ -1779,9 +1780,15 @@ spg_free_dataset(dataset); dataset = NULL; - magnetic_symmetry = spn_get_operations_with_site_tensors( - &equiv_atoms, permutations, primitive_lattice, sym_nonspin, cell, - with_time_reversal, is_axial, symprec, angle_tolerance, mag_symprec); + if ((magnetic_symmetry = spn_get_operations_with_site_tensors( + &equiv_atoms, permutations, primitive_lattice, sym_nonspin, cell, + with_time_reversal, is_axial, symprec, angle_tolerance, + mag_symprec)) == NULL) { + sym_free_symmetry(sym_nonspin); + sym_nonspin = NULL; + goto err; + } + /* Set equivalent_atoms */ for (i = 0; i < cell->size; i++) { equivalent_atoms[i] = equiv_atoms[i]; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/src/spin.c new/spglib-2.0.2/src/spin.c --- old/spglib-2.0.1/src/spin.c 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/src/spin.c 2022-11-06 06:44:10.000000000 +0100 @@ -408,8 +408,13 @@ } } if (k == cell->size) { - /* Unreachable here! */ - return NULL; + // Unreachable here in theory, but we rarely fail to overlap + // atoms possibly due to too high symprec. In that case, skip + // the symmetry operation. + debug_print("Failed to overlap atom-%d by operation-%d\n", j, + i); + found = 0; + break; } // Skip if relevant tensors are zeros because they have nothing to @@ -558,9 +563,9 @@ return NULL; } -/* Return permutation tables `permutations` such that the p-th operation */ -/* in `magnetic_symmetry` maps site-`i` to site-`permutations[p * cell->size + - * i]`. */ +// Return permutation tables `permutations` such that the p-th operation +// in `magnetic_symmetry` maps site-`i` to site-`permutations[p * cell->size + +// * i]`. If failed, return NULL. static int *get_symmetry_permutations(const MagneticSymmetry *magnetic_symmetry, const Cell *cell, const int with_time_reversal, @@ -655,7 +660,7 @@ return permutations; } -/* Return equivalent_atoms */ +// Return equivalent_atoms. If failed, return NULL. static int *get_orbits(const int *permutations, const int num_sym, const int num_atoms) { int s, i; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/src/version.h new/spglib-2.0.2/src/version.h --- old/spglib-2.0.1/src/version.h 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/src/version.h 2022-11-06 06:44:10.000000000 +0100 @@ -37,6 +37,6 @@ #define SPGLIB_MAJOR_VERSION 2 #define SPGLIB_MINOR_VERSION 0 -#define SPGLIB_MICRO_VERSION 1 +#define SPGLIB_MICRO_VERSION 2 #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/spglib-2.0.1/test/test_magnetic_symmetry.cpp new/spglib-2.0.2/test/test_magnetic_symmetry.cpp --- old/spglib-2.0.1/test/test_magnetic_symmetry.cpp 2022-08-31 08:40:48.000000000 +0200 +++ new/spglib-2.0.2/test/test_magnetic_symmetry.cpp 2022-11-06 06:44:10.000000000 +0100 @@ -360,6 +360,79 @@ free(time_reversals); } +TEST( + test_magnetic_symmetry, + test_with_broken_symmetry) { + // https://github.com/spglib/spglib/issues/194 + // Part of "mp-806965" in the Materials Project database + double lattice[][3] = { // column-wise! + {5.24191, -0.003459, -2.618402}, + {0, 5.600534, -1.87898}, + {0, 0, 11.148141}, + }; + double positions[][3] = { + {0.829407, 0.834674, 0.662821}, + {0.665078, 0.665214, 0.316142}, + {0.001174, 0.996383, 0.002809}, + {0.181127, 0.169218, 0.349259}, + }; + int types[] = {0, 0, 0, 0}; + double tensors[] = {1.927, 1.947, 1.928, 1.949}; + int num_atoms = 4; + int max_size = num_atoms * 96; + + double symprec = 0.1; // with very high symprec + double mag_symprec = symprec; + + int i, size; + int equivalent_atoms[4]; + double primitive_lattice[3][3]; + int(*rotations)[3][3]; + double(*translations)[3]; + int *spin_flips; + int *time_reversals; + + rotations = (int(*)[3][3])malloc(sizeof(int[3][3]) * max_size); + translations = (double(*)[3])malloc(sizeof(double[3]) * max_size); + spin_flips = (int *)malloc(sizeof(int *) * max_size); + time_reversals = (int *)malloc(sizeof(int *) * max_size); + + // Check magnetic symmetry search + // spg_get_symmetry returns four operations, but spgms_get_symmetry_with_site_tensors + // only returns three of them. This is due to too high symprec: detected operations + // in `sym_get_operation` follow `symprec`, but refined operations in + // `ref_get_exact_structure_and_symmetry` does not. + size = spgms_get_symmetry_with_site_tensors( + rotations, translations, equivalent_atoms, primitive_lattice, spin_flips, + max_size, lattice, positions, types, tensors, + 0 /* tensor_rank */ , num_atoms, + 1 /* with_time_reversal */, + 0 /* is_axial */, + symprec, -1 /* angle_tolerance */, mag_symprec); + + for (i = 0; i < size; i++) { + time_reversals[i] = (1 - spin_flips[i]) / 2; + } + show_magnetic_symmetry_operations(rotations, translations, time_reversals, size); + ASSERT_TRUE(size >= 1); + + // Check magnetic dataset construction + // Since detected magnetic symmetry operations do not form a group due to high symprec, + // we fail to get magnetic dataset for now. + SpglibMagneticDataset *dataset; + dataset = spg_get_magnetic_dataset(lattice, positions, types, tensors, + 0 /* tensor_rank */, num_atoms, + 0 /* is_axial */, symprec); + ASSERT_TRUE(dataset == NULL); + + free(rotations); + free(translations); + free(spin_flips); + free(time_reversals); + if (dataset != NULL) spg_free_magnetic_dataset(dataset); + free(dataset); +} + // TODO: test get_magnetic_dataset with distorted positions // ****************************************************************************