Skip to content

Commit

Permalink
fix windows path issues in parse_lammps_dumps()
Browse files Browse the repository at this point in the history
  • Loading branch information
janosh committed Aug 7, 2023
1 parent 669acec commit 7f25574
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pymatgen/io/lammps/outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import os
import re
from glob import glob
from io import StringIO
Expand Down Expand Up @@ -108,11 +109,12 @@ def parse_lammps_dumps(file_pattern):
Yields:
LammpsDump for each available snapshot.
"""
files = glob(file_pattern)
if len(files) > 1:
pattern = file_pattern.replace("*", "([0-9]+)").replace("\\", "\\\\")
pattern = file_pattern.replace("*", "([0-9]+)")
pattern = os.path.normpath(pattern) # normalize the path separator
pattern = re.escape(pattern) # escape special regex characters
files = sorted(files, key=lambda f: int(re.match(pattern, f).group(1)))

for fname in files:
Expand Down Expand Up @@ -144,7 +146,6 @@ def parse_lammps_log(filename="log.lammps"):
Returns:
[pd.DataFrame] containing thermo data for each completed run.
"""
with zopen(filename, "rt") as f:
lines = f.readlines()
Expand Down

0 comments on commit 7f25574

Please sign in to comment.