Skip to content

Commit 1db02ae

Browse files
authoredMar 1, 2024
Merge pull request #140 from oscarbenjamin/pr_update
Reformat due to black changes
2 parents 74bc621 + 6d9ed4a commit 1db02ae

18 files changed

+52
-35
lines changed
 

Diff for: ‎benchmarks/test_differentiation.py

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
SymPy's and SymEngine's symbolic differentiation.
55
66
"""
7+
78
from typing import Callable, TypeVar
89

910
import pytest

Diff for: ‎docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Sphinx configuration."""
2+
23
from datetime import datetime
34

45
project = "ProtoSym"

Diff for: ‎noxfile.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Nox sessions."""
2+
23
import shutil
34
import sys
45
from pathlib import Path

Diff for: ‎src/protosym/__main__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Command-line interface."""
2+
23
import sys
34

45

Diff for: ‎src/protosym/core/atom.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This module defines the :class:`AtomType` and :class:`Atom` types.
44
"""
5+
56
from __future__ import annotations
67

78
from typing import TYPE_CHECKING as _TYPE_CHECKING

Diff for: ‎src/protosym/core/differentiate.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
level code in the sym module wraps this to make a nicer pattern-matching style
55
interface for specifying differentiation rules.
66
"""
7+
78
from __future__ import annotations
89

910
from dataclasses import dataclass, field
@@ -143,4 +144,4 @@ def chain_rule_forward(
143144
rust_protosym = None
144145

145146
if rust_protosym is not None: # pragma: no cover
146-
from rust_protosym import DiffProperties, diff_forward # type:ignore # noqa
147+
from rust_protosym import DiffProperties, diff_forward # type:ignore

Diff for: ‎src/protosym/core/evaluate.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Define the core evaluation code."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING as _TYPE_CHECKING

Diff for: ‎src/protosym/core/sym.py

+24-21
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
build a nicer syntax over the lower-level classes that can be inherited for use
88
by user-facing classes that derive from :class:`Sym`.
99
"""
10+
1011
from __future__ import annotations
1112

1213
from typing import Any, Callable, Generic, Sequence, TypeVar, overload
@@ -489,51 +490,53 @@ def __init__(self, name: str):
489490
def __setitem__(
490491
self,
491492
pattern: T_sym,
492-
call: WildCall[T_sym, PyOp1[T_val]]
493-
| WildCall[T_sym, PyOp2[T_val]]
494-
| WildCall[T_sym, PyOpN[T_val]],
495-
) -> None:
496-
...
493+
call: (
494+
WildCall[T_sym, PyOp1[T_val]]
495+
| WildCall[T_sym, PyOp2[T_val]]
496+
| WildCall[T_sym, PyOpN[T_val]]
497+
),
498+
) -> None: ...
497499

498500
# e.g. eval_f64[Integer[a]] = f64_from_int
499501
@overload
500502
def __setitem__(
501503
self,
502504
pattern: SymAtomValue[T_sym, S_val],
503505
call: WildCall[T_sym, PyFunc1[S_val, T_val]],
504-
) -> None:
505-
...
506+
) -> None: ...
506507

507508
# e.g. eval_repr[AtomRule[a]] = AtomFunc(repr)
508509
@overload
509510
def __setitem__(
510511
self,
511512
pattern: AtomRuleType[T_sym],
512513
call: WildCall[T_sym, AtomFunc[T_val]],
513-
) -> None:
514-
...
514+
) -> None: ...
515515

516516
# e.g. eval_repr[HeadRule(a, b)] = HeadOp(...)
517517
@overload
518518
def __setitem__(
519519
self,
520520
pattern: HeadRuleType[T_sym],
521521
call: WildCall[T_sym, HeadOp[T_val]],
522-
) -> None:
523-
...
522+
) -> None: ...
524523

525524
def __setitem__( # noqa [C901]
526525
self,
527-
pattern: T_sym
528-
| SymAtomValue[T_sym, S_val]
529-
| AtomRuleType[T_sym]
530-
| HeadRuleType[T_sym],
531-
call: WildCall[T_sym, PyOp1[T_val]]
532-
| WildCall[T_sym, PyOp2[T_val]]
533-
| WildCall[T_sym, PyOpN[T_val]]
534-
| WildCall[T_sym, PyFunc1[S_val, T_val]]
535-
| WildCall[T_sym, AtomFunc[T_val]]
536-
| WildCall[T_sym, HeadOp[T_val]],
526+
pattern: (
527+
T_sym
528+
| SymAtomValue[T_sym, S_val]
529+
| AtomRuleType[T_sym]
530+
| HeadRuleType[T_sym]
531+
),
532+
call: (
533+
WildCall[T_sym, PyOp1[T_val]]
534+
| WildCall[T_sym, PyOp2[T_val]]
535+
| WildCall[T_sym, PyOpN[T_val]]
536+
| WildCall[T_sym, PyFunc1[S_val, T_val]]
537+
| WildCall[T_sym, AtomFunc[T_val]]
538+
| WildCall[T_sym, HeadOp[T_val]]
539+
),
537540
) -> None:
538541
"""Add an evaluation rule."""
539542
if not isinstance(call, WildCall):

Diff for: ‎src/protosym/core/tree.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
This module defines classes for representing expressions in top-down tree form.
44
"""
5+
56
from __future__ import annotations
67

78
from dataclasses import dataclass

Diff for: ‎src/protosym/simplecas/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Demonstration of putting together a simple CAS."""
2+
23
from __future__ import annotations
34

45
import protosym.simplecas.functions # noqa

Diff for: ‎src/protosym/simplecas/exceptions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Exception types raised in simplecas."""
2+
23
from protosym.core.exceptions import ProtoSymError
34

45

Diff for: ‎src/protosym/simplecas/expr.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""The Expr class."""
2+
23
from __future__ import annotations
34

45
from functools import reduce, wraps

Diff for: ‎src/protosym/simplecas/functions.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Basic functions and operations."""
2+
23
import math
34

45
from protosym.core.sym import (

Diff for: ‎src/protosym/simplecas/lambdification.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""lambdification with LLVM."""
2+
23
from __future__ import annotations
34

45
import ctypes

Diff for: ‎src/protosym/simplecas/matrix.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Simple Matrix class."""
2+
23
from __future__ import annotations
34

45
from typing import TYPE_CHECKING as _TYPE_CHECKING

Diff for: ‎src/protosym/simplecas/sympy_conversions.py

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
These are defined in their own module so that SymPy will not imported if it is
44
not needed.
55
"""
6+
67
from __future__ import annotations
78

89
from typing import Any

Diff for: ‎tests/core/test_sym.py

+11-13
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,17 @@ def __call__(self, *args: Expr) -> Expr:
4141
return Expr(self.rep(*args_rep))
4242

4343

44-
def _make_atoms() -> (
45-
tuple[
46-
SymAtomType[Expr, int],
47-
SymAtomType[Expr, str],
48-
Expr,
49-
Expr,
50-
Expr,
51-
Expr,
52-
Expr,
53-
Expr,
54-
Expr,
55-
]
56-
):
44+
def _make_atoms() -> tuple[
45+
SymAtomType[Expr, int],
46+
SymAtomType[Expr, str],
47+
Expr,
48+
Expr,
49+
Expr,
50+
Expr,
51+
Expr,
52+
Expr,
53+
Expr,
54+
]:
5755
"""Set up a Sym subclass and create some atoms etc."""
5856
Integer = Expr.new_atom("Integer", int)
5957
Function = Expr.new_atom("Function", str)

Diff for: ‎tests/test_main.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Test cases for the __main__ module."""
2+
23
from protosym import __main__
34

45

0 commit comments

Comments
 (0)
Please sign in to comment.