Skip to content

Commit

Permalink
Loosen spglib requirement slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
kavanase committed May 13, 2024
1 parent 49edad6 commit af3ab8a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 29 deletions.
63 changes: 36 additions & 27 deletions docs/Troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,46 +41,55 @@ error traceback.

``numpy`` Errors
-------------------
- A previous known issue with ``numpy``/``pymatgen`` is that it could give an error similar to this:
A previous known issue with ``numpy``/``pymatgen`` is that it could give an error similar to this:

.. code:: python
.. code:: python
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 88 from C header, got 80 from PyObject
This should be avoided with current versions of ``doped``, due to the package installation
requirements (handled automatically by ``pip``), but depending on your ``python`` environment and
previously-installed packages, it could possibly still arise. It occurs due to a recent change in the
``numpy`` C API in version ``1.20.0``, see
`here <https://stackoverflow.com/questions/66060487/valueerror-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-exp>`_
for details.
It should be fixed by reinstalling ``numpy`` and ``pymatgen`` (so that they play nice together), so
that it is rebuilt with the new ``numpy`` C API:
This should be avoided with current versions of ``doped``, due to the package installation
requirements (handled automatically by ``pip``), but depending on your ``python`` environment and
previously-installed packages, it could possibly still arise. It occurs due to a recent change in the
``numpy`` C API in version ``1.20.0``, see
`here <https://stackoverflow.com/questions/66060487/valueerror-numpy-ndarray-size-changed-may-indicate-binary-incompatibility-exp>`_
for details.
It should be fixed by reinstalling ``numpy`` and ``pymatgen`` (so that they play nice together), so
that it is rebuilt with the new ``numpy`` C API:

.. code:: bash
.. code:: bash
pip install --force --no-cache-dir numpy==1.23
pip uninstall pymatgen
pip install pymatgen
pip install --force --no-cache-dir numpy==1.23
pip uninstall pymatgen
pip install pymatgen
``spglib`` Errors/Warnings
--------------------------
- A previous known issue with ``spglib`` is that it could give an error or warnings similar to:
A previous known issue with ``spglib`` is that it could give an error or warnings similar to:

.. code:: python
spglib: ssm_get_exact_positions failed (attempt=0).
spglib: No point group was found (line 405, ...).
...
spglib: ssm_get_exact_positions failed (attempt=4).
spglib: get_bravais_exact_positions_and_lattice failed
spglib: ref_get_exact_structure_and_symmetry failed.
This can be fixed by reinstalling ``spglib`` with ``conda install -c conda-forge spglib==2.0.2``.
Sometimes installation with ``conda`` rather than ``pip`` is required, as ``conda`` will bundle the C
and Fortran libraries, while using version ``2.0.2`` for now avoids some unnecessary warnings (see this
`Issue <https://github.com/spglib/spglib/issues/338>`_ on the ``spglib`` GitHub for details).

.. code:: python
.. If this still does not remove these warnings, then setting the environment variable: ``SPGLIB_WARNING=OFF``
and re-installing ``spglib`` with:

spglib: ssm_get_exact_positions failed (attempt=0).
spglib: No point group was found (line 405, ...).
...
spglib: ssm_get_exact_positions failed (attempt=4).
spglib: get_bravais_exact_positions_and_lattice failed
spglib: ref_get_exact_structure_and_symmetry failed.
.. .. code:: bash
This can be fixed by reinstalling ``spglib`` with ``conda install -c conda-forge spglib==2.0.2``.
Sometimes installation with ``conda`` rather than ``pip`` is required, as ``conda`` will bundle the C
and Fortran libraries, while using version ``2.0.2`` for now avoids some unnecessary warnings (see this
`Issue <https://github.com/spglib/spglib/issues/338>`_ on the ``spglib`` GitHub for details).
.. pip uninstall spglib
pip install git+https://github.com/spglib/spglib --config-settings=cmake.define.SPGLIB_SHARED_LIBS=OFF
.. should fix it. – STILL DOESN'T FULLY FIX IT YET (see doped_spglib_warnings.ipynb)
``ShakeNBreak``
-------------------
Expand Down
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies = [
"matplotlib>=3.5.2",
"numpy>=1.21.0",
"pymatgen>=2023.11.12", # limiting factor: POTCAR_STATS_PATH available from pymatgen.io.vasp.inputs
"spglib==2.0.2", # dependent of pymatgen, but explicitly set to 2.0.2 here to avoid unnecessary warnings
"spglib<=2.0.2", # dependent of pymatgen, but explicitly set to <=2.0.2 here to avoid unnecessary warnings
# see https://github.com/spglib/spglib/issues/338; remove this limit when issue resolved
"pymatgen-analysis-defects>=2023.8.22",
"shakenbreak>=3.3.1",
Expand All @@ -41,7 +41,10 @@ Package = "https://pypi.org/project/doped/"
Repository = "https://github.com/SMTG-Bham/doped"

[project.optional-dependencies]
tests = ["pytest<8.2", "pytest-mpl>=0.16.1"]
tests = [
"pytest<8.2", # with pytest==8.2.0, seemed to cause memory issue on GH Actions mpl tests, python=3.10
"pytest-mpl>=0.16.1"
]
docs = ["sphinx", "sphinx-book-theme", "sphinx_design"]
analysis = [
"easyunfold",
Expand Down

0 comments on commit af3ab8a

Please sign in to comment.