Python version
3.11.7
Pymatgen version
2024.2.20
Operating system version
Any
Current behavior
I observed this in a fresh virtual environment when trying to install and use mp_api. Before #3619 (or related follow-up commits, can't tell) you were able to import the AseAtomsAdaptor without an error, even if you didn't have ASE installed. This was changed by the creation of the MSONAtoms class which uses Atoms via inheritance and thus is loaded at import time.
Example as posted in #3619 (comment)
>>> from mp_api.client.mprester import MPRester
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/mp_api/client/__init__.py", line 8, in <module>
from .mprester import MPRester
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/mp_api/client/mprester.py", line 10, in <module>
from emmet.core.electronic_structure import BSPathType
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/emmet/core/electronic_structure.py", line 11, in <module>
from pymatgen.analysis.magnetism.analyzer import (
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/pymatgen/analysis/magnetism/__init__.py", line 5, in <module>
from pymatgen.analysis.magnetism.analyzer import (
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/pymatgen/analysis/magnetism/analyzer.py", line 24, in <module>
from pymatgen.transformations.advanced_transformations import MagOrderingTransformation, MagOrderParameterConstraint
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/pymatgen/transformations/advanced_transformations.py", line 33, in <module>
from pymatgen.io.ase import AseAtomsAdaptor
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-mp-api/lib/python3.11/site-packages/pymatgen/io/ase.py", line 44, in <module>
class MSONAtoms(Atoms, MSONable):
^^^^^
NameError: name 'Atoms' is not defined
Expected Behavior
The module should still be importable in cases where ase is not available, as it was before.
Minimal example
python -m venv .venv
. .venv/bin/activate
pip install pymatgen
$ python -c "from pymatgen.analysis.magnetism.analyzer import *"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-pymatgen/lib/python3.11/site-packages/pymatgen/analysis/magnetism/__init__.py", line 5, in <module>
from pymatgen.analysis.magnetism.analyzer import (
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-pymatgen/lib/python3.11/site-packages/pymatgen/analysis/magnetism/analyzer.py", line 24, in <module>
from pymatgen.transformations.advanced_transformations import MagOrderingTransformation, MagOrderParameterConstraint
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-pymatgen/lib/python3.11/site-packages/pymatgen/transformations/advanced_transformations.py", line 33, in <module>
from pymatgen.io.ase import AseAtomsAdaptor
File "/home/mevans/repos/re2fractive/re2fractive/experiments/2_featurizing_refractive_index_data/.venv-pymatgen/lib/python3.11/site-packages/pymatgen/io/ase.py", line 44, in <module>
class MSONAtoms(Atoms, MSONable):
^^^^^
NameError: name 'Atoms' is not defined
which runs correctly if you pip install pymatgen==2024.2.8.
Relevant files to reproduce this bug
No response
Python version
3.11.7
Pymatgen version
2024.2.20
Operating system version
Any
Current behavior
I observed this in a fresh virtual environment when trying to install and use
mp_api. Before #3619 (or related follow-up commits, can't tell) you were able to import the AseAtomsAdaptor without an error, even if you didn't have ASE installed. This was changed by the creation of theMSONAtomsclass which usesAtomsvia inheritance and thus is loaded at import time.Example as posted in #3619 (comment)
Expected Behavior
The module should still be importable in cases where
aseis not available, as it was before.Minimal example
which runs correctly if you
pip install pymatgen==2024.2.8.Relevant files to reproduce this bug
No response