diff --git a/benchmarks/test_differentiation.py b/benchmarks/test_differentiation.py index 52dca41..0966417 100644 --- a/benchmarks/test_differentiation.py +++ b/benchmarks/test_differentiation.py @@ -4,6 +4,7 @@ SymPy's and SymEngine's symbolic differentiation. """ + from typing import Callable, TypeVar import pytest diff --git a/docs/conf.py b/docs/conf.py index ee62d47..dc8116a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,5 @@ """Sphinx configuration.""" + from datetime import datetime project = "ProtoSym" diff --git a/noxfile.py b/noxfile.py index 8defc0b..5b276c4 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,4 +1,5 @@ """Nox sessions.""" + import shutil import sys from pathlib import Path diff --git a/src/protosym/__main__.py b/src/protosym/__main__.py index 07f0110..a06c898 100644 --- a/src/protosym/__main__.py +++ b/src/protosym/__main__.py @@ -1,4 +1,5 @@ """Command-line interface.""" + import sys diff --git a/src/protosym/core/atom.py b/src/protosym/core/atom.py index 51c2d14..1cc69de 100644 --- a/src/protosym/core/atom.py +++ b/src/protosym/core/atom.py @@ -2,6 +2,7 @@ This module defines the :class:`AtomType` and :class:`Atom` types. """ + from __future__ import annotations from typing import TYPE_CHECKING as _TYPE_CHECKING diff --git a/src/protosym/core/differentiate.py b/src/protosym/core/differentiate.py index afa8e91..91b65ce 100644 --- a/src/protosym/core/differentiate.py +++ b/src/protosym/core/differentiate.py @@ -4,6 +4,7 @@ level code in the sym module wraps this to make a nicer pattern-matching style interface for specifying differentiation rules. """ + from __future__ import annotations from dataclasses import dataclass, field @@ -143,4 +144,4 @@ def chain_rule_forward( rust_protosym = None if rust_protosym is not None: # pragma: no cover - from rust_protosym import DiffProperties, diff_forward # type:ignore # noqa + from rust_protosym import DiffProperties, diff_forward # type:ignore diff --git a/src/protosym/core/evaluate.py b/src/protosym/core/evaluate.py index 49ae8b9..a961cdd 100644 --- a/src/protosym/core/evaluate.py +++ b/src/protosym/core/evaluate.py @@ -1,4 +1,5 @@ """Define the core evaluation code.""" + from __future__ import annotations from typing import TYPE_CHECKING as _TYPE_CHECKING diff --git a/src/protosym/core/sym.py b/src/protosym/core/sym.py index a8ae6b7..eed2500 100644 --- a/src/protosym/core/sym.py +++ b/src/protosym/core/sym.py @@ -7,6 +7,7 @@ build a nicer syntax over the lower-level classes that can be inherited for use by user-facing classes that derive from :class:`Sym`. """ + from __future__ import annotations from typing import Any, Callable, Generic, Sequence, TypeVar, overload @@ -489,11 +490,12 @@ def __init__(self, name: str): def __setitem__( self, pattern: T_sym, - call: WildCall[T_sym, PyOp1[T_val]] - | WildCall[T_sym, PyOp2[T_val]] - | WildCall[T_sym, PyOpN[T_val]], - ) -> None: - ... + call: ( + WildCall[T_sym, PyOp1[T_val]] + | WildCall[T_sym, PyOp2[T_val]] + | WildCall[T_sym, PyOpN[T_val]] + ), + ) -> None: ... # e.g. eval_f64[Integer[a]] = f64_from_int @overload @@ -501,8 +503,7 @@ def __setitem__( self, pattern: SymAtomValue[T_sym, S_val], call: WildCall[T_sym, PyFunc1[S_val, T_val]], - ) -> None: - ... + ) -> None: ... # e.g. eval_repr[AtomRule[a]] = AtomFunc(repr) @overload @@ -510,8 +511,7 @@ def __setitem__( self, pattern: AtomRuleType[T_sym], call: WildCall[T_sym, AtomFunc[T_val]], - ) -> None: - ... + ) -> None: ... # e.g. eval_repr[HeadRule(a, b)] = HeadOp(...) @overload @@ -519,21 +519,24 @@ def __setitem__( self, pattern: HeadRuleType[T_sym], call: WildCall[T_sym, HeadOp[T_val]], - ) -> None: - ... + ) -> None: ... def __setitem__( # noqa [C901] self, - pattern: T_sym - | SymAtomValue[T_sym, S_val] - | AtomRuleType[T_sym] - | HeadRuleType[T_sym], - call: WildCall[T_sym, PyOp1[T_val]] - | WildCall[T_sym, PyOp2[T_val]] - | WildCall[T_sym, PyOpN[T_val]] - | WildCall[T_sym, PyFunc1[S_val, T_val]] - | WildCall[T_sym, AtomFunc[T_val]] - | WildCall[T_sym, HeadOp[T_val]], + pattern: ( + T_sym + | SymAtomValue[T_sym, S_val] + | AtomRuleType[T_sym] + | HeadRuleType[T_sym] + ), + call: ( + WildCall[T_sym, PyOp1[T_val]] + | WildCall[T_sym, PyOp2[T_val]] + | WildCall[T_sym, PyOpN[T_val]] + | WildCall[T_sym, PyFunc1[S_val, T_val]] + | WildCall[T_sym, AtomFunc[T_val]] + | WildCall[T_sym, HeadOp[T_val]] + ), ) -> None: """Add an evaluation rule.""" if not isinstance(call, WildCall): diff --git a/src/protosym/core/tree.py b/src/protosym/core/tree.py index 0a160b9..b89365a 100644 --- a/src/protosym/core/tree.py +++ b/src/protosym/core/tree.py @@ -2,6 +2,7 @@ This module defines classes for representing expressions in top-down tree form. """ + from __future__ import annotations from dataclasses import dataclass diff --git a/src/protosym/simplecas/__init__.py b/src/protosym/simplecas/__init__.py index 8a6dc55..1412a3a 100644 --- a/src/protosym/simplecas/__init__.py +++ b/src/protosym/simplecas/__init__.py @@ -1,4 +1,5 @@ """Demonstration of putting together a simple CAS.""" + from __future__ import annotations import protosym.simplecas.functions # noqa diff --git a/src/protosym/simplecas/exceptions.py b/src/protosym/simplecas/exceptions.py index 04f2f5c..d73b134 100644 --- a/src/protosym/simplecas/exceptions.py +++ b/src/protosym/simplecas/exceptions.py @@ -1,4 +1,5 @@ """Exception types raised in simplecas.""" + from protosym.core.exceptions import ProtoSymError diff --git a/src/protosym/simplecas/expr.py b/src/protosym/simplecas/expr.py index 70f9a52..dcfe686 100644 --- a/src/protosym/simplecas/expr.py +++ b/src/protosym/simplecas/expr.py @@ -1,4 +1,5 @@ """The Expr class.""" + from __future__ import annotations from functools import reduce, wraps diff --git a/src/protosym/simplecas/functions.py b/src/protosym/simplecas/functions.py index f82b03a..5041347 100644 --- a/src/protosym/simplecas/functions.py +++ b/src/protosym/simplecas/functions.py @@ -1,4 +1,5 @@ """Basic functions and operations.""" + import math from protosym.core.sym import ( diff --git a/src/protosym/simplecas/lambdification.py b/src/protosym/simplecas/lambdification.py index 1bbf359..ea74f71 100644 --- a/src/protosym/simplecas/lambdification.py +++ b/src/protosym/simplecas/lambdification.py @@ -1,4 +1,5 @@ """lambdification with LLVM.""" + from __future__ import annotations import ctypes diff --git a/src/protosym/simplecas/matrix.py b/src/protosym/simplecas/matrix.py index d6f7c25..9dc7c5c 100644 --- a/src/protosym/simplecas/matrix.py +++ b/src/protosym/simplecas/matrix.py @@ -1,4 +1,5 @@ """Simple Matrix class.""" + from __future__ import annotations from typing import TYPE_CHECKING as _TYPE_CHECKING diff --git a/src/protosym/simplecas/sympy_conversions.py b/src/protosym/simplecas/sympy_conversions.py index f212d3a..e4a3289 100644 --- a/src/protosym/simplecas/sympy_conversions.py +++ b/src/protosym/simplecas/sympy_conversions.py @@ -3,6 +3,7 @@ These are defined in their own module so that SymPy will not imported if it is not needed. """ + from __future__ import annotations from typing import Any diff --git a/tests/core/test_sym.py b/tests/core/test_sym.py index a2395ff..5d95f3e 100644 --- a/tests/core/test_sym.py +++ b/tests/core/test_sym.py @@ -41,19 +41,17 @@ def __call__(self, *args: Expr) -> Expr: return Expr(self.rep(*args_rep)) -def _make_atoms() -> ( - tuple[ - SymAtomType[Expr, int], - SymAtomType[Expr, str], - Expr, - Expr, - Expr, - Expr, - Expr, - Expr, - Expr, - ] -): +def _make_atoms() -> tuple[ + SymAtomType[Expr, int], + SymAtomType[Expr, str], + Expr, + Expr, + Expr, + Expr, + Expr, + Expr, + Expr, +]: """Set up a Sym subclass and create some atoms etc.""" Integer = Expr.new_atom("Integer", int) Function = Expr.new_atom("Function", str) diff --git a/tests/test_main.py b/tests/test_main.py index 9243a9f..5f14a6f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,4 +1,5 @@ """Test cases for the __main__ module.""" + from protosym import __main__