Skip to content

Commit 5b0d0e9

Browse files
committed
Revert lxml since for our use case, it is a bit slower.
1 parent c5eda1c commit 5b0d0e9

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ dependencies = [
7777
# NumPy documentation suggests pinning the current major version as the C API is used
7878
# https://numpy.org/devdocs/dev/depending_on_numpy.html#runtime-dependency-version-ranges
7979
"numpy>=1.25.0,<3",
80-
"lxml>=5.3.1",
8180
]
8281
version = "2025.5.1"
8382

src/pymatgen/io/vasp/outputs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
from io import BytesIO
1616
from pathlib import Path
1717
from typing import TYPE_CHECKING, Any, cast
18+
from xml.etree import ElementTree as ET
1819

1920
import numpy as np
20-
from lxml import etree as ET
2121
from monty.dev import requires
2222
from monty.io import reverse_readfile, zopen
2323
from monty.json import MSONable, jsanitize
@@ -331,10 +331,10 @@ def __init__(
331331
self.separate_spins = separate_spins
332332
self.exception_on_bad_xml = exception_on_bad_xml
333333

334-
with zopen(filename, mode="rb") as file:
334+
with zopen(filename, mode="rt", encoding="utf-8") as file:
335335
if ionic_step_skip or ionic_step_offset:
336336
# Remove parts of the xml file and parse the string
337-
content: str = file.read().decode("utf-8")
337+
content: str = file.read()
338338
steps: list[str] = content.split("<calculation>")
339339

340340
# The text before the first <calculation> is the preamble!
@@ -408,7 +408,7 @@ def _parse(
408408
# whether they are nested within another block. This is why we
409409
# must read both start and end tags and have flags to tell us
410410
# when we have entered or left a block. (2024-01-26)
411-
for event, elem in ET.iterparse(stream, events=["start", "end"], remove_blank_text=True):
411+
for event, elem in ET.iterparse(stream, events=["start", "end"]):
412412
tag = elem.tag
413413
if event == "start":
414414
# The start event tells us when we have entered blocks
@@ -1799,13 +1799,13 @@ def __init__(
17991799
self.occu_tol = occu_tol
18001800
self.separate_spins = separate_spins
18011801

1802-
with zopen(filename, mode="rb") as file:
1802+
with zopen(filename, mode="rt", encoding="utf-8") as file:
18031803
self.efermi = None
18041804
parsed_header = False
18051805
in_kpoints_opt = False
18061806
self.eigenvalues = self.projected_eigenvalues = None
18071807
self.kpoints_opt_props = None
1808-
for event, elem in ET.iterparse(file, events=["start", "end"], remove_blank_text=True):
1808+
for event, elem in ET.iterparse(file, events=["start", "end"]):
18091809
tag = elem.tag
18101810
if event == "start":
18111811
# The start event tells us when we have entered blocks

uv.lock

Lines changed: 0 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)