Skip to content

Commit

Permalink
fix the bug and not pyxtal accepts the input of array for lattice in …
Browse files Browse the repository at this point in the history
…the build function
  • Loading branch information
qzhu2017 committed Jan 24, 2024
1 parent 8097099 commit 2d574e1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
9 changes: 5 additions & 4 deletions pyxtal/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1479,7 +1479,7 @@ def build(self, group, species, numIons, lattice, sites, tol=1e-2, use_hall=Fals
self.group = Group(group, use_hall=use_hall)

# Lattica needs some special handling heree
if not isinstance(lattice, Lattice):
if type(lattice) != Lattice:
if type(lattice) == np.ndarray:
ltype = self.group.lattice_type
if len(lattice) == 3:
Expand All @@ -1493,9 +1493,10 @@ def build(self, group, species, numIons, lattice, sites, tol=1e-2, use_hall=Fals
else:
msg = 'Cannot convert the input array to pyxtal.lattice.Lattice'
raise ValueError(msg, lattice)
else:
msg = 'The input lattice needs to be a pyxtal.lattice.Lattice class'
raise ValueError(msg)
#else:
# print(lattice, type(lattice), type(lattice)==Lattice, type(lattice)!=Lattice)
# msg = 'The input lattice needs to be a pyxtal.lattice.Lattice class'
# raise ValueError(msg, lattice)
self.lattice = lattice

self.dim = 3
Expand Down
30 changes: 15 additions & 15 deletions pyxtal/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,21 +1140,21 @@ class Test_operations(unittest.TestCase):
def test_inverse(self):
coord0 = [0.35, 0.1, 0.4]
coords = np.array([
[0.350, 0.100, 0.400],
[0.350, 0.100, 0.000],
[0.350, 0.100, 0.000],
[0.350, 0.000, 0.667],
[0.350, 0.000, 0.250],
[0.350, 0.350, 0.400],
[0.350, 0.350, 0.500],
[0.350, 0.350, 0.000],
[0.350, 0.350, 0.350],
[0.100, 0.100, 0.100],
[0.400, 0.400, 0.400],
[0.350, 0.000, 0.000],
[0.000, 0.100, 0.400],
[0.350, 0.000, 0.400],
])
[0.350, 0.100, 0.400],
[0.350, 0.100, 0.000],
[0.350, 0.100, 0.000],
[0.350, 0.000, 0.667],
[0.350, 0.000, 0.250],
[0.350, 0.350, 0.400],
[0.350, 0.350, 0.500],
[0.350, 0.350, 0.000],
[0.350, 0.350, 0.350],
[0.100, 0.100, 0.100],
[0.400, 0.400, 0.400],
[0.350, 0.000, 0.000],
[0.000, 0.100, 0.400],
[0.350, 0.000, 0.400],
])
xyzs = ['x,y,z',
'x,y,0',
'y,x,0',
Expand Down

0 comments on commit 2d574e1

Please sign in to comment.