Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielYang59 committed Nov 26, 2024
1 parent c2ccd92 commit 13e58d6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/core/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from pymatgen.electronic_structure.core import Magmom
from pymatgen.io.ase import AseAtomsAdaptor
from pymatgen.io.cif import CifParser
from pymatgen.io.vasp.inputs import Poscar
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
from pymatgen.util.testing import TEST_FILES_DIR, VASP_IN_DIR, PymatgenTest

Expand Down Expand Up @@ -1684,6 +1685,37 @@ def test_merge_sites(self):
assert len(struct_navs2) == 12
assert any(math.isclose(site.properties["prop1"], 51.5) for site in struct_navs2)

# Test property handling for np.array (selective dynamics)
poscar_str_0 = """Test POSCAR
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
Selective dynamics
direct
0.000000 0.000000 0.000000 T T T Si
0.750000 0.500000 0.750000 F F F O
"""
poscar_str_1 = """offset a bit
1.0
3.840198 0.000000 0.000000
1.920099 3.325710 0.000000
0.000000 -2.217138 3.135509
1 1
Selective dynamics
direct
0.100000 0.000000 0.000000 T T T Si
0.750000 0.500000 0.750000 F F F O
"""

struct_0 = Poscar.from_str(poscar_str_0).structure
struct_1 = Poscar.from_str(poscar_str_1).structure

for site in struct_0:
struct_1.append(site.species, site.frac_coords, properties=site.properties)
struct_1.merge_sites(mode="average")

def test_properties(self):
assert self.struct.num_sites == len(self.struct)
self.struct.make_supercell(2)
Expand Down

0 comments on commit 13e58d6

Please sign in to comment.