Skip to content

Commit 91a8755

Browse files
authored
Merge pull request #209 from ICAMS/ordering_bug
Ordering bug
2 parents bf7a756 + 180bd63 commit 91a8755

File tree

6 files changed

+22
-6
lines changed

6 files changed

+22
-6
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 1.4.12
2+
current_version = 1.4.13
33
commit = True
44
tag = True
55

calphy/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from calphy.alchemy import Alchemy
55
from calphy.routines import MeltingTemp
66

7-
__version__ = "1.4.12"
7+
__version__ = "1.4.13"
88

99
def addtest(a,b):
1010
return a+b

calphy/composition_transformation.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,10 +532,12 @@ def write_structure(self, outfilename):
532532
lines = f.readlines()
533533

534534
# Find the Atoms section and replace type numbers
535+
# Support different ASE formats: "Atoms # atomic", "Atoms # full", or just "Atoms"
535536
in_atoms_section = False
536537
atom_idx = 0
537538
for i, line in enumerate(lines):
538-
if "Atoms" in line and "#" in line:
539+
# More flexible detection of Atoms section header
540+
if "Atoms" in line:
539541
in_atoms_section = True
540542
continue
541543

@@ -550,6 +552,15 @@ def write_structure(self, outfilename):
550552
if atom_idx >= len(self.pyscal_structure.atoms.types):
551553
break
552554

555+
# Verify all atoms were updated
556+
expected_atoms = len(self.pyscal_structure.atoms.types)
557+
if atom_idx != expected_atoms:
558+
raise RuntimeError(
559+
f"Failed to update all atoms in {outfilename}. "
560+
f"Expected {expected_atoms} atoms but only updated {atom_idx}. "
561+
f"This may indicate a problem with ASE LAMMPS file formatting."
562+
)
563+
553564
# Update the number of atom types in the header
554565
required_ntypes = len(self.pair_list_old)
555566
for i, line in enumerate(lines):

calphy/input.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
from ase.io import read, write
5050
import shutil
5151

52-
__version__ = "1.4.12"
52+
__version__ = "1.4.13"
5353

5454

5555
def _check_equal(val):

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
packages=find_packages(include=['calphy', 'calphy.*']),
5454
test_suite='tests',
5555
url='https://github.com/ICAMS/calphy',
56-
version='1.4.12',
56+
version='1.4.13',
5757
zip_safe=False,
5858
entry_points={
5959
'console_scripts': [

tests/test_composition_transformation_bug.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,14 @@ def test_composition_transformation_single_type_file(mg_structure_file):
203203
assert os.path.exists(output_structure)
204204

205205
# Read and verify the written structure
206+
import re
207+
206208
with open(output_structure, "r") as f:
207209
content = f.read()
208-
assert "2048 atoms" in content
210+
# Check for "2048 atoms" with flexible whitespace (space or tab)
211+
assert re.search(
212+
r"2048\s+atoms", content
213+
), "Expected '2048 atoms' in output file"
209214

210215
# Verify entropy contribution calculation
211216
entropy = comp.entropy_contribution

0 commit comments

Comments
 (0)