Skip to content

Commit

Permalink
fix a bug in from_tabular
Browse files Browse the repository at this point in the history
  • Loading branch information
qzhu2017 committed Aug 18, 2024
1 parent f228944 commit d5498b6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pyxtal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3649,16 +3649,22 @@ def from_tabular_representation(self, rep, max_abc=50.0, max_angle=180, normaliz
np.degrees(beta),
np.degrees(gamma),
)
lattice = Lattice.from_para(
a,
b,
c,
alpha,
beta,
gamma,
ltype=group.lattice_type,
force_symmetry=True,
)
try:
lattice = Lattice.from_para(
a,
b,
c,
alpha,
beta,
gamma,
ltype=group.lattice_type,
force_symmetry=True,
)
except ValueError:
print('Input lattice from rep is incorrect', number, a, b, c, alpha, beta, gamma)
self.valid = False
return

sites_info = np.reshape(rep[7:], (int((len(rep) - 7) / 4), 4))
sites = []
numIons = 0
Expand Down
9 changes: 9 additions & 0 deletions tests/test_crystal.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ def test_read_by_HN(self):
pmg_struc = struc.to_pymatgen()
assert sm.StructureMatcher().fit(pmg_struc, pmg1)

def test_from_tabular(self):
xtal = pyxtal()
rep = [116,10.5754,10.7203,4.47208,1.5705,2.6561,2.0943,1,0.4447,0.3762,0.7526]
xtal.from_tabular_representation(rep, normalize=False)
assert xtal.valid == False
rep = [116,10.5754,10.7203,4.47208,1.5705,1.5705,1.5705,0,0.4447,0.3762,0.7526]
xtal.from_tabular_representation(rep, normalize=False)
assert xtal.valid == True


class TestAtomic2D(unittest.TestCase):
def test_single_specie(self):
Expand Down

0 comments on commit d5498b6

Please sign in to comment.