Skip to content

Commit

Permalink
Merge pull request #689 from hakonanes/remove-38-39-compat
Browse files Browse the repository at this point in the history
Remove Python 3.8 and 3.9 compatibility
  • Loading branch information
hakonanes authored Oct 5, 2024
2 parents d5db481 + 4ab1d6f commit a016c0a
Show file tree
Hide file tree
Showing 67 changed files with 1,064 additions and 1,033 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ jobs:
python-version: ['3.11', '3.12']
include:
- os: ubuntu-latest
python-version: 3.8
python-version: '3.10'
DEPENDENCIES: dask==2021.8.1 diffsims==0.5.2 hyperspy==1.7.3 matplotlib==3.5 numba==0.57 numpy==1.23.0 orix==0.12.1 pooch==1.3.0 pyebsdindex==0.2.0 scikit-image==0.21.0
LABEL: -oldest
- os: ubuntu-latest
python-version: 3.12
python-version: '3.12'
LABEL: -minimum_requirement
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Added

Changed
-------
- Minimum Python version is now 3.10.
(`#? <https://github.com/pyxem/kikuchipy/pull/?>`_)

Removed
-------
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ library.
.. |tests_status| image:: https://github.com/pyxem/kikuchipy/actions/workflows/tests.yml/badge.svg
:target: https://github.com/pyxem/kikuchipy/actions/workflows/tests.yml

.. |python| image:: https://img.shields.io/badge/python-3.8+-blue.svg
.. |python| image:: https://img.shields.io/badge/python-3.10+-blue.svg
:target: https://www.python.org/downloads/

.. |Coveralls| image:: https://coveralls.io/repos/github/pyxem/kikuchipy/badge.svg?branch=develop
Expand Down
7 changes: 4 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import os
from pathlib import Path
import tempfile
from typing import Callable, Generator, List
from typing import Callable, Generator

import dask.array as da
from diffpy.structure import Atom, Lattice, Structure
Expand All @@ -39,10 +39,11 @@
import skimage.color as skc

import kikuchipy as kp
from kikuchipy import constants
from kikuchipy.data._data import marshall
from kikuchipy.io.plugins._h5ebsd import _dict2hdf5group

if kp.constants.installed["pyvista"]:
if constants.installed["pyvista"]:
import pyvista as pv

pv.OFF_SCREEN = True
Expand Down Expand Up @@ -227,7 +228,7 @@ def nickel_phase(nickel_structure) -> Generator[Phase, None, None]:


@pytest.fixture
def pc1() -> Generator[List[float], None, None]:
def pc1() -> Generator[list[float], None, None]:
"""One projection center (PC) in TSL convention."""
yield [0.4210, 0.7794, 0.5049]

Expand Down
2 changes: 1 addition & 1 deletion doc/dev/code_style.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Package imports should be structured into three blocks with blank lines between
We use type hints in the function definition without type duplication in the function
docstring, for example::

def my_function(a: int, b: Optional[bool] = None) -> Tuple[float, np.ndarray]:
def my_function(a: int, b: bool | None = None) -> tuple[float, np.ndarray]:
"""This is a new function.

Parameters
Expand Down
2 changes: 1 addition & 1 deletion doc/dev/handling_deprecations.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The decorator should be placed right above the object signature to be deprecated
Parameters can be deprecated as well::

@deprecate_argument(name="n", since=0.8, removal=0.9, alternative="m")
def foo(self, n: Optional[int] = None, m: int: Optional[int] = None) -> int:
def foo(self, n: int | None = None, m: int: int | None = None) -> int:
if m is None:
m = n
return m + 1
Expand Down
2 changes: 1 addition & 1 deletion doc/user/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Installation

kikuchipy can be installed with `pip <https://pypi.org/project/kikuchipy/>`__,
`conda <https://anaconda.org/conda-forge/kikuchipy>`__, the
:ref:`hyperspy:hyperspy-bundle`, or from source, and supports Python >= 3.8.
:ref:`hyperspy:hyperspy-bundle`, or from source, and supports Python >= 3.10.
All alternatives are available on Windows, macOS and Linux.

.. _install-with-pip:
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ description = "Processing, simulating, and indexing of electron backscatter diff
license = {file = "LICENSE"}
readme = {file = "README.rst", content-type = "text/x-rst"}
dynamic = ["version"]
requires-python = ">= 3.8"
requires-python = ">= 3.10"
classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down Expand Up @@ -50,7 +48,8 @@ dependencies = [
"lazy_loader",
"matplotlib >= 3.5",
"numba >= 0.57",
"numpy >= 1.23.0",
# TODO: Remove pinning of NumPy <2 once HyperSpy 2.0 is supported
"numpy >= 1.23.0, <2",
"orix >= 0.12.1",
"pooch >= 1.3.0",
"pyyaml",
Expand Down
2 changes: 1 addition & 1 deletion src/kikuchipy/_rotation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _rotation_from_rodrigues(rx: float, ry: float, rz: float) -> np.ndarray:
d = s * rz / norm
rot = np.array([a, b, c, d], dtype="float64")

if rot[0] < 0: # pragma: no cover
if rot[0] < 0:
rot = -rot

return rot
Expand Down
24 changes: 15 additions & 9 deletions src/kikuchipy/_util/_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import functools
import inspect
from typing import Callable, Optional, Union
from typing import Callable
import warnings

import numpy as np
Expand All @@ -47,11 +47,11 @@ class deprecated:

def __init__(
self,
since: Union[str, int, float],
alternative: Optional[str] = None,
since: str | int | float,
alternative: str | None = None,
alternative_is_function: bool = True,
removal: Union[str, int, float, None] = None,
):
removal: str | int | float | None = None,
) -> None:
"""Visible deprecation warning.
Parameters
Expand All @@ -71,7 +71,7 @@ def __init__(
self.alternative_is_function = alternative_is_function
self.removal = removal

def __call__(self, func: Callable):
def __call__(self, func: Callable) -> None:
# Wrap function to raise warning when called, and add warning to
# docstring
if self.alternative is not None:
Expand All @@ -91,7 +91,7 @@ def __call__(self, func: Callable):
msg = f"Attribute `{func.__name__}` is deprecated{rm_msg}.{alt_msg}"

@functools.wraps(func)
def wrapped(*args, **kwargs):
def wrapped(*args, **kwargs) -> Callable:
warnings.simplefilter(
action="always", category=np.VisibleDeprecationWarning, append=True
)
Expand Down Expand Up @@ -126,13 +126,19 @@ class deprecated_argument:
<https://github.com/scikit-image/scikit-image/blob/main/skimage/_shared/utils.py#L115>`_.
"""

def __init__(self, name, since, removal, alternative=None):
def __init__(
self,
name: str,
since: str | float,
removal: str | float,
alternative: str | None = None,
) -> None:
self.name = name
self.since = since
self.removal = removal
self.alternative = alternative

def __call__(self, func):
def __call__(self, func: Callable) -> Callable:
@functools.wraps(func)
def wrapped(*args, **kwargs):
if self.name in kwargs.keys():
Expand Down
11 changes: 8 additions & 3 deletions src/kikuchipy/_util/_transfer_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,16 @@
# You should have received a copy of the GNU General Public License
# along with kikuchipy. If not, see <http://www.gnu.org/licenses/>.

from hyperspy.axes import AxesManager

def _transfer_navigation_axes_to_signal_axes(new_axes, old_axes):

def _transfer_navigation_axes_to_signal_axes(
new_axes: AxesManager, old_axes: AxesManager
) -> AxesManager:
"""Transfer navigation axis calibrations from an old signal to the
signal axes of a new signal produced from it by a generator. Used
from methods that generate a signal with a single value at each
signal axes of a new signal produced from it by a generator.
Used from methods that generate a signal with a single value at each
navigation position.
Adapted from the pyxem package.
Expand Down
5 changes: 2 additions & 3 deletions src/kikuchipy/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
"""Constants and such useful across modules."""

from importlib.metadata import version
from typing import Dict, List

# NB! Update project config file if this list is updated!
optional_deps: List[str] = [
optional_deps: list[str] = [
"pyvista",
"nlopt",
"pyebsdindex",
]
installed: Dict[str, bool] = {}
installed: dict[str, bool] = {}
for pkg in optional_deps:
try:
_ = version(pkg)
Expand Down
Loading

0 comments on commit a016c0a

Please sign in to comment.