Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
EMMET_USE_EMMET_MODELS: true
run: python${{ matrix.python-version }} -m pytest -n auto --cov=emmet --cov-report=xml ${{ matrix.package }}/tests

- uses: codecov/codecov-action@v5.5.1
- uses: codecov/codecov-action@v5.5.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ./coverage.xml
3 changes: 2 additions & 1 deletion emmet-core/emmet/core/trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,10 +740,11 @@ def from_vasprun(
):
kwargs["time_step"] = vasprun.parameters.get("POTIM")

istep_attr = "md_data" if vasprun.incar.get("ML_LMLFF") else "ionic_steps"
return cls._from_dict(
{
remap.get(k, k): [
ionic_step.get(k) for ionic_step in vasprun.ionic_steps
ionic_step.get(k) for ionic_step in getattr(vasprun, istep_attr, [])
]
for k in ionic_step_data
},
Expand Down
15 changes: 13 additions & 2 deletions emmet-core/emmet/core/types/pymatgen_types/xas_adapter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import Annotated, TypeVar
from typing import Any, Annotated, TypeVar

import numpy as np
from pydantic import BeforeValidator, WrapSerializer
from pymatgen.analysis.xas.spectrum import XAS
from typing_extensions import TypedDict
Expand Down Expand Up @@ -45,8 +46,18 @@ def pop_xas_empty_structure_fields(xas: XASTypeVar, eps: float = 1e-12):
return xas


def _serialize_xas(xas: XAS) -> dict[str, Any]:
xas_dct = xas.as_dict()
for k in ("x", "y"):
if isinstance(xas_dct[k], np.ndarray):
xas_dct[k] = xas_dct[k].tolist()
return xas_dct


XASType = Annotated[
XASTypeVar,
BeforeValidator(pop_xas_empty_structure_fields),
WrapSerializer(lambda x, nxt, info: x.as_dict(), return_type=TypedXASSpectrumDict),
WrapSerializer(
lambda x, nxt, info: _serialize_xas(x), return_type=TypedXASSpectrumDict
),
]
Loading