Skip to content

Commit

Permalink
Added test for issue #13
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Nov 30, 2022
1 parent 0330714 commit d3ccabd
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crystals/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__author__ = "Laurent P. René de Cotret"
__email__ = "laurent.renedecotret@mail.mcgill.ca"
__license__ = "GPLv3"
__version__ = "1.6.0"
__version__ = "1.6.1"

from .atom import Atom
from .atom import Element
Expand Down
26 changes: 23 additions & 3 deletions crystals/tests/test_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import tempfile
from itertools import islice
from pathlib import Path
from random import choice, randint

import numpy as np
from tempfile import TemporaryDirectory

import pytest
from crystals import Crystal
from crystals import Crystal, Atom

try:
import ase
Expand Down Expand Up @@ -53,6 +53,26 @@ def test_cif_writer_idempotence(name):
assert cryst == cryst2


def test_supercell_preserved_in_cif():
"""See issue #13."""
a = np.asfarray([3, 0.2, 0])
b = np.asfarray([0.4, 8, 0])
c = np.asfarray([0, 0, 9])

dimer = Crystal(
unitcell=[Atom("C", coords=(0.5, 0, 0)), Atom("C", coords=(0, 0, 0))],
lattice_vectors=[a * 2, b, c],
)
with TemporaryDirectory() as tmpdir:

dimer.to_cif(Path(tmpdir) / "dimer.cif")
from_file = Crystal.from_cif(Path(tmpdir) / "dimer.cif")

assert set(tuple(atm.coords_fractional) for atm in dimer.unitcell) == set(
tuple(atm.coords_fractional) for atm in from_file.unitcell
)


@pytest.mark.parametrize("name", Crystal.builtins)
def test_vasp_writer_idempotence(name):
"""Test that conversion to VASP of a structure loaded from VASP is idempotent."""
Expand Down

0 comments on commit d3ccabd

Please sign in to comment.