Skip to content

Fix doc build by disallowing numpydoc v1.9.0 #571

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from
Open
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ jobs:

- name: Run tests
run: |
pytest --pyargs orix --runslow --reruns 2 -n 2 --cov=orix
pytest --pyargs orix --slow --reruns 2 -n 2 --cov=orix

- name: Generate line coverage
if: ${{ matrix.os == 'ubuntu-latest' }}
Expand Down
22 changes: 21 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
#
# Copyright 2019-2025 the orix developers
#
# This file is part of orix.
#
# orix is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# orix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with orix. If not, see <http://www.gnu.org/licenses/>.
#

# Configuration file for the Sphinx documentation app.
# See the documentation for a full list of configuration options:
# https://www.sphinx-doc.org/en/master/usage/configuration.html
Expand Down Expand Up @@ -64,9 +83,10 @@
"numpydoc": ("https://numpydoc.readthedocs.io/en/latest", None),
"pooch": ("https://www.fatiando.org/pooch/latest", None),
"pytest": ("https://docs.pytest.org/en/stable", None),
"pytest-xdist": ("https://pytest-xdist.readthedocs.io/en/stable/", None),
"python": ("https://docs.python.org/3", None),
"pyxem": ("https://pyxem.readthedocs.io/en/latest", None),
"readthedocs": ("https://docs.readthedocs.io/en/stable", None),
"readthedocs": ("https://docs.readthedocs.com/platform/stable/", None),
"scipy": ("https://docs.scipy.org/doc/scipy", None),
"sklearn": ("https://scikit-learn.org/stable", None),
"sphinx": ("https://www.sphinx-doc.org/en/master", None),
Expand Down
32 changes: 16 additions & 16 deletions doc/dev/running_writing_tests.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ Run and write tests

All functionality in orix is tested with :doc:`pytest <pytest:index>`.
The tests reside in a ``tests`` module.
Tests are short methods that call functions in ``orix`` and compare resulting output
values with known answers.
Tests are short methods that call functions in orix and compare resulting output values
with known answers.

Install necessary dependencies to run the tests::

pip install --editable ".[tests]"
pip install -e ".[tests]"

Some useful :doc:`fixtures <pytest:explanation/fixtures>` are available in the
``conftest.py`` file.
Expand All @@ -22,29 +23,28 @@ Some useful :doc:`fixtures <pytest:explanation/fixtures>` are available in the

To run the tests::

pytest --cov --pyargs orix -n auto
pytest --cov --pyargs orix -n auto

The ``-n auto`` is an optional flag to enable parallelized testing.
The ``--cov`` flag makes :doc:`coverage.py <coverage:index>` print a nice report.
For an even nicer presentation, you can use ``coverage.py`` directly::
The ``-n auto`` is an optional flag to enable parallelized testing with
:doc:`pytest-xdist <pytest-xdist:index>`.
We aim to cover all lines when all :ref:`dependencies` are installed.
The ``--cov`` flag makes :doc:`coverage.py <coverage:index>` print a nice coverage
report.
For an even nicer presentation, you can use coverage.py directly::

coverage html
coverage html

Coverage can then be inspected in the browser by opening ``htmlcov/index.html``.

We strive for 100% test coverage of lines when all dependencies are installed.

If you have a test that takes a long time to run, you can mark it to skip it from running by default

.. code-block:: Python
If a test takes a long time to run, you can mark it to skip it from running by default::

@pytest.mark.slow
def test_slow_function():
pass
...

Then you can run the tests with the ``--runslow`` option to skip slow tests::
To run tests marked as slow, add the flag when running pytest::

pytest --runslow
pytest --slow

Docstring examples are tested with :doc:`pytest <pytest:how-to/doctest>` as well.
:mod:`numpy` and :mod:`matplotlib.pyplot` should not be imported in examples as they are
Expand Down
34 changes: 23 additions & 11 deletions orix/crystal_map/phase_list.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Copyright 2018-2024 the orix developers
#
# Copyright 2019-2025 the orix developers
#
# This file is part of orix.
#
Expand All @@ -9,11 +10,12 @@
#
# orix is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with orix. If not, see <http://www.gnu.org/licenses/>.
# along with orix. If not, see <http://www.gnu.org/licenses/>.
#

from __future__ import annotations

Expand All @@ -37,7 +39,8 @@
_groups,
get_point_group,
)
from orix.vector import Miller, Vector3d
from orix.vector.miller import Miller
from orix.vector.vector3d import Vector3d

# All named Matplotlib colors (tableau and xkcd already lower case hex)
ALL_COLORS = mcolors.TABLEAU_COLORS
Expand Down Expand Up @@ -366,18 +369,26 @@ def deepcopy(self) -> Phase:
return copy.deepcopy(self)

def expand_asymmetric_unit(self) -> Phase:
"""Return new instance with all symmetrically equivalent atoms.
"""Return a new phase with all symmetrically equivalent atoms.

Returns
-------
expanded_phase
New phase with the a :attr:`structure` with the unit cell
filled with symmetrically equivalent atoms.

Examples
--------
>>> from diffpy.structure import Atom, Lattice, Structure
>>> import orix.crystal_map as ocm
>>> atoms = [Atom("Si", xyz=(0, 0, 1))]
>>> lattice = Lattice(4.04, 4.04, 4.04, 90, 90, 90)
>>> structure = Structure(atoms = atoms,lattice=lattice)
>>> phase = Phase(structure=structure, space_group=227)
>>> phase = ocm.Phase(structure=structure, space_group=227)
>>> phase.structure
[Si 0.000000 0.000000 1.000000 1.0000]
>>> expanded = phase.expand_asymmetric_unit()
>>> expanded.structure
>>> expanded_phase = phase.expand_asymmetric_unit()
>>> expanded_phase.structure
[Si 0.000000 0.000000 0.000000 1.0000,
Si 0.000000 0.500000 0.500000 1.0000,
Si 0.500000 0.500000 0.000000 1.0000,
Expand Down Expand Up @@ -411,9 +422,10 @@ def expand_asymmetric_unit(self) -> Phase:
diffpy_structure.append(new_atom)

# This handles conversion back to correct alignment
out = Phase(self)
out.structure = diffpy_structure
return out
expanded_phase = self.__class__(self)
expanded_phase.structure = diffpy_structure

return expanded_phase


class PhaseList:
Expand Down
Loading
Loading