Skip to content

Commit

Permalink
Raised minimal python version to 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
david-zwicker committed Feb 2, 2024
1 parent e4c7c4d commit d88eb60
Show file tree
Hide file tree
Showing 35 changed files with 72 additions and 65 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release_pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'

- name: Install dependencies
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_minversion.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
python-version: '3.9'

- name: Install dependencies
# install packages in the exact version given in requirements.txt
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
pyversion: ['3.8', '3.12']
pyversion: ['3.9', '3.12']
timeout-minutes: 30

steps:
Expand Down
2 changes: 1 addition & 1 deletion pde/fields/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def _data_flat(self) -> np.ndarray:
# flatten the first dimension of the internal data by creating a view and then
# setting the new shape. This disallows accidental copying of the data
data_flat = self._data_full.view()
data_flat.shape = (-1, *self.grid._shape_full) # type: ignore
data_flat.shape = (-1, *self.grid._shape_full)
return data_flat

@_data_flat.setter
Expand Down
4 changes: 2 additions & 2 deletions pde/fields/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import json
import logging
import warnings
from typing import Any, Callable, Iterator, Literal, Mapping, Sequence, overload
from collections.abc import Iterator, Mapping, Sequence
from typing import Any, Callable, Literal, overload

import numpy as np
from matplotlib import cm
Expand All @@ -21,7 +22,6 @@
except ImportError:
from matplotlib.cm import get_cmap


from ..grids.base import GridBase
from ..tools.docstrings import fill_in_docstring
from ..tools.misc import Number, number_array
Expand Down
3 changes: 2 additions & 1 deletion pde/fields/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from __future__ import annotations

import numbers
from collections.abc import Sequence
from pathlib import Path
from typing import TYPE_CHECKING, Callable, Literal, Sequence
from typing import TYPE_CHECKING, Callable, Literal

import numpy as np
from numpy.typing import DTypeLike
Expand Down
3 changes: 2 additions & 1 deletion pde/fields/tensorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Callable, Sequence
from collections.abc import Sequence
from typing import TYPE_CHECKING, Callable

import numpy as np
from numpy.typing import DTypeLike
Expand Down
3 changes: 2 additions & 1 deletion pde/fields/vectorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, Literal, Sequence
from collections.abc import Sequence
from typing import TYPE_CHECKING, Any, Callable, Literal

import numba as nb
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion pde/grids/_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
from __future__ import annotations

import math
from collections.abc import Sequence
from enum import IntEnum
from typing import Any, Sequence, TypeVar
from typing import Any, TypeVar

import numpy as np

Expand Down
13 changes: 2 additions & 11 deletions pde/grids/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,8 @@
import math
import warnings
from abc import ABCMeta, abstractmethod
from typing import (
TYPE_CHECKING,
Any,
Callable,
Generator,
Iterator,
Literal,
NamedTuple,
Sequence,
overload,
)
from collections.abc import Generator, Iterator, Sequence
from typing import TYPE_CHECKING, Any, Callable, Literal, NamedTuple, overload

import numba as nb
import numpy as np
Expand Down
3 changes: 2 additions & 1 deletion pde/grids/boundaries/axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

from __future__ import annotations

from typing import Sequence, Union
from collections.abc import Sequence
from typing import Union

import numpy as np
from numba.extending import register_jitable
Expand Down
6 changes: 3 additions & 3 deletions pde/grids/boundaries/axis.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Dict, Tuple, Union
from typing import TYPE_CHECKING, Union

import numpy as np
from numba.extending import register_jitable
Expand All @@ -24,9 +24,9 @@
from .._mesh import GridMesh

BoundaryPairData = Union[
Dict[str, BoundaryData],
dict[str, BoundaryData],
BoundaryData,
Tuple[BoundaryData, BoundaryData],
tuple[BoundaryData, BoundaryData],
"BoundaryAxisBase",
]

Expand Down
6 changes: 3 additions & 3 deletions pde/grids/boundaries/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import warnings
from abc import ABCMeta, abstractmethod
from numbers import Number
from typing import TYPE_CHECKING, Any, Callable, Dict, Literal, Tuple, TypeVar, Union
from typing import TYPE_CHECKING, Any, Callable, Literal, TypeVar, Union

import numba as nb
import numpy as np
Expand All @@ -86,7 +86,7 @@
from .._mesh import GridMesh


BoundaryData = Union[Dict, str, "BCBase"]
BoundaryData = Union[dict, str, "BCBase"]


class BCDataError(ValueError):
Expand Down Expand Up @@ -166,7 +166,7 @@ def _make_get_arr_1d(
Consequently, `i = idx[axis]` and `arr[..., idx] == arr_1d[..., i]`.
"""
assert 0 <= axis < dim
ResultType = Tuple[np.ndarray, int, Tuple]
ResultType = tuple[np.ndarray, int, tuple]

# extract the correct indices
if dim == 1:
Expand Down
3 changes: 2 additions & 1 deletion pde/grids/cartesian.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
from __future__ import annotations

import itertools
from typing import TYPE_CHECKING, Any, Generator, Sequence
from collections.abc import Generator, Sequence
from typing import TYPE_CHECKING, Any

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion pde/grids/cylindrical.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

from __future__ import annotations

from typing import TYPE_CHECKING, Any, Generator, Literal, Sequence
from collections.abc import Generator, Sequence
from typing import TYPE_CHECKING, Any, Literal

import numpy as np

Expand Down
2 changes: 1 addition & 1 deletion pde/solvers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
ExplicitMPISolver = None # type: ignore


def registered_solvers() -> List[str]:
def registered_solvers() -> list[str]:
"""returns all solvers that are currently registered
Returns:
Expand Down
4 changes: 2 additions & 2 deletions pde/solvers/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import datetime
import logging
import time
from typing import TYPE_CHECKING, Any, Callable, Tuple, TypeVar, Union
from typing import TYPE_CHECKING, Any, Callable, TypeVar, Union

from .. import __version__
from ..tools import mpi
Expand All @@ -25,7 +25,7 @@
from ..fields.base import FieldBase


TRangeType = Union[float, Tuple[float, float]]
TRangeType = Union[float, tuple[float, float]]
TState = TypeVar("TState", bound="FieldBase")


Expand Down
3 changes: 2 additions & 1 deletion pde/storage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@

import logging
from abc import ABCMeta, abstractmethod
from collections.abc import Iterator, Sequence
from inspect import signature
from typing import TYPE_CHECKING, Any, Callable, Iterator, Literal, Sequence
from typing import TYPE_CHECKING, Any, Callable, Literal

import numpy as np
from numpy.typing import DTypeLike
Expand Down
2 changes: 1 addition & 1 deletion pde/storage/memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

from __future__ import annotations

from collections.abc import Sequence
from contextlib import contextmanager
from typing import Sequence

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion pde/tools/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@
import functools
import logging
import numbers
from collections.abc import Iterable
from hashlib import sha1
from typing import Callable, Iterable, Literal, TypeVar
from typing import Callable, Literal, TypeVar

import numpy as np
from scipy import sparse
Expand Down
3 changes: 2 additions & 1 deletion pde/tools/expressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
import numbers
import re
from abc import ABCMeta, abstractmethod
from typing import Any, Callable, Mapping, Sequence, Union
from collections.abc import Mapping, Sequence
from typing import Any, Callable, Union

import numpy as np
import sympy
Expand Down
3 changes: 2 additions & 1 deletion pde/tools/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
import os
import unittest
import warnings
from collections.abc import Sequence
from pathlib import Path
from typing import Any, Callable, Sequence, TypeVar
from typing import Any, Callable, TypeVar

import numpy as np
from numpy.typing import DTypeLike
Expand Down
3 changes: 2 additions & 1 deletion pde/tools/parameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import logging
import warnings
from typing import Any, Sequence, Union
from collections.abc import Sequence
from typing import Any, Union

import numpy as np

Expand Down
3 changes: 2 additions & 1 deletion pde/tools/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import logging
import sys
import warnings
from typing import TYPE_CHECKING, Any, Generator, Literal
from collections.abc import Generator
from typing import TYPE_CHECKING, Any, Literal

from ..tools.docstrings import replace_in_docstring

Expand Down
8 changes: 5 additions & 3 deletions pde/tools/spectral.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
.. codeauthor:: David Zwicker <[email protected]>
"""

from typing import Callable, Optional, Tuple
from __future__ import annotations

from typing import Callable, Optional

import numpy as np

Expand All @@ -22,11 +24,11 @@


def make_colored_noise(
shape: Tuple[int, ...],
shape: tuple[int, ...],
dx=1.0,
exponent: float = 0,
scale: float = 1,
rng: Optional[np.random.Generator] = None,
rng: np.random.Generator | None = None,
) -> Callable[[], np.ndarray]:
r"""Return a function creating an array of random values that obey
Expand Down
5 changes: 3 additions & 2 deletions pde/trackers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
import math
import warnings
from abc import ABCMeta, abstractmethod
from typing import Any, Dict, Optional, Sequence, Union
from collections.abc import Sequence
from typing import Any, Optional, Union

import numpy as np

Expand All @@ -19,7 +20,7 @@
from ..tools.misc import module_available
from .interrupts import InterruptData, parse_interrupt

InfoDict = Optional[Dict[str, Any]]
InfoDict = Optional[dict[str, Any]]
TrackerDataType = Union["TrackerBase", str]


Expand Down
5 changes: 3 additions & 2 deletions pde/trackers/interrupts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
import math
import time
from abc import ABCMeta, abstractmethod
from typing import Any, Dict, Optional, Sequence, TypeVar, Union
from collections.abc import Sequence
from typing import Any, Optional, TypeVar, Union

import numpy as np

from ..tools.parse_duration import parse_duration

InfoDict = Optional[Dict[str, Any]]
InfoDict = Optional[dict[str, Any]]
TInterrupt = TypeVar("TInterrupt", bound="InterruptsBase")


Expand Down
2 changes: 1 addition & 1 deletion pde/visualization/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
)

_logger = logging.getLogger(__name__)
ScaleData = Union[str, float, Tuple[float, float]]
ScaleData = Union[str, float, tuple[float, float]]


def _add_horizontal_colorbar(im, ax, num_loc: int = 5) -> None:
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ authors = [
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.8,<3.13"
requires-python = ">=3.9,<3.13"
dynamic = ["version"]

keywords = ["pdes", "partial-differential-equations", "dynamical-systems"]
Expand All @@ -20,7 +20,6 @@ classifiers = [
"Topic :: Scientific/Engineering",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand Down Expand Up @@ -60,7 +59,7 @@ namespaces = false
write_to = "pde/_version.py"

[tool.black]
target_version = ["py38"]
target_version = ["py39"]
exclude = "scripts/templates"

[tool.isort]
Expand All @@ -78,7 +77,7 @@ filterwarnings = [
]

[tool.mypy]
python_version = "3.8"
python_version = "3.9"
plugins = "numpy.typing.mypy_plugin"
warn_return_any = true
warn_unused_configs = true
Expand Down
Loading

0 comments on commit d88eb60

Please sign in to comment.