Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Atoms.cluster_from_file() in io.feff.inputs giving wrong number of atoms #3426

Merged
merged 51 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
1dc8c43
Update test_sets.py
kaifengZheng Aug 19, 2023
bb74a32
add test file
kaifengZheng Aug 19, 2023
fac911d
fix a bug in inputs.py
kaifengZheng Aug 19, 2023
0018837
pre-commit auto-fixes
pre-commit-ci[bot] Aug 19, 2023
8112068
files
kaifengZheng Aug 19, 2023
943cbd4
Revert "files"
kaifengZheng Aug 19, 2023
46fbf47
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 19, 2023
09f0642
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 19, 2023
2550e26
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 20, 2023
d2c35c2
Merge branch 'master' into master
kaifengZheng Aug 20, 2023
c5020c1
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 20, 2023
18e23bd
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 20, 2023
1679411
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 21, 2023
ae62a3a
Merge branch 'master' into master
janosh Aug 21, 2023
3fd1904
remove test file and modify the test method
kaifengZheng Aug 22, 2023
84392b8
pre-commit auto-fixes
pre-commit-ci[bot] Aug 22, 2023
81c1ac5
Merge branch 'master' of https://github.com/materialsproject/pymatgen
kaifengZheng Aug 22, 2023
ccb5106
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
19896dc
Merge branch 'master' of https://github.com/kaifengZheng/pymatgen
kaifengZheng Aug 22, 2023
91fab3c
i->idx
janosh Aug 22, 2023
ebcedfe
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
f036f0a
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
00da9c8
forgot to negate check_occu after inverting semantics from skip_occu_…
janosh Aug 22, 2023
cde0422
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
bd25993
Update test_sets.py
kaifengZheng Aug 22, 2023
95c0b56
pre-commit auto-fixes
pre-commit-ci[bot] Aug 22, 2023
80b2ad4
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
c915adb
pre-commit auto-fixes
pre-commit-ci[bot] Aug 22, 2023
844336e
Update testing.py resolve conflict
kaifengZheng Aug 22, 2023
61b5914
Merge branch 'master' into master
kaifengZheng Aug 22, 2023
6607fa7
add PR link to new test
janosh Aug 22, 2023
e9c3d82
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
f8ef114
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 22, 2023
d2cfa6a
Merge branch 'materialsproject:master' into master
kaifengZheng Aug 28, 2023
cb05b84
fix Atom.input miss atoms problem
kaifengZheng Oct 26, 2023
6b14744
Merge branch 'master' of https://github.com/kaifengZheng/pymatgen
kaifengZheng Oct 26, 2023
432a166
pre-commit auto-fixes
pre-commit-ci[bot] Oct 26, 2023
4a03535
Update inputs.py
kaifengZheng Oct 26, 2023
9151dbd
Update inputs.py
kaifengZheng Oct 26, 2023
fcc2751
Update inputs.py
kaifengZheng Oct 26, 2023
4417107
Merge branch 'master' into master
kaifengZheng Oct 27, 2023
9f40a5b
Merge branch 'materialsproject:master' into master
kaifengZheng Oct 27, 2023
bae05b1
Update test_inputs.py
kaifengZheng Oct 27, 2023
0d3846a
pre-commit auto-fixes
pre-commit-ci[bot] Oct 27, 2023
47022dc
Merge branch 'master' into master
kaifengZheng Oct 27, 2023
883deeb
Merge branch 'master' into master
kaifengZheng Oct 31, 2023
dcf190c
Merge branch 'master' into master
kaifengZheng Oct 31, 2023
614cc85
Update test_inputs.py
kaifengZheng Oct 31, 2023
1d5214b
fix AttributeError: 'list' object has no attribute 'startswith'
janosh Nov 2, 2023
c346c00
gzip tests/files/ATOMS_test.inp
janosh Nov 2, 2023
dc1b939
improve test
janosh Nov 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pymatgen/io/feff/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,13 @@ def cluster_from_file(filename):
is the one at the origin.
"""
atoms_string = Atoms.atoms_string_from_file(filename)
lines = [line.split() for line in atoms_string.splitlines()[3:]]
lines = [line.split() for line in atoms_string.splitlines()[1:]]
coords = []
symbols = []
for line in lines:
if line:
coords.append([float(val) for val in line[:3]])
symbols.append(line[4])
for tokens in lines:
if tokens and not tokens[0].startswith("*"):
coords.append([float(val) for val in tokens[:3]])
symbols.append(tokens[4])
return Molecule(symbols, coords)

def get_lines(self) -> list[list[str | int]]:
Expand Down
Binary file added tests/files/Pt37_atoms.inp.gz
Binary file not shown.
6 changes: 6 additions & 0 deletions tests/io/feff/test_inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ def test_cluster_from_file(self):
assert len(mol_1) == len(mol_2)
os.remove("ATOMS_test")

def test_atom_num(self):
filepath = f"{TEST_FILES_DIR}/Pt37_atoms.inp.gz"
atoms = Atoms.cluster_from_file(filepath)
assert len(atoms) == 37
assert atoms.formula == "Pt37"


class TestFeffTags(unittest.TestCase):
def test_init(self):
Expand Down