From fe8913dbf936e95b93f50a42dd19edcbc8c16827 Mon Sep 17 00:00:00 2001 From: paugier Date: Wed, 5 Jun 2024 08:45:18 +0200 Subject: [PATCH] Format with isort --- .../for_test_exterior_import_jit.py | 2 +- .../for_test_exterior_import_jit_2.py | 1 - .../src/_transonic_testing/for_test_init.py | 3 +- .../_transonic_testing/for_test_justintime.py | 5 +- doc/examples/bench_expr_broadcast/bench.py | 6 +- doc/examples/bench_proj_perp/bench.py | 3 +- doc/examples/bench_row_sum/bench.py | 2 +- doc/examples/bench_row_sum/row_sum_boost.py | 4 +- doc/examples/bench_row_sum/row_sum_jit.py | 4 +- doc/examples/bench_row_sum/util.py | 2 +- doc/examples/bench_trigo/bench.py | 2 +- doc/examples/blocks.py | 2 +- doc/examples/blocks_type_hints.py | 4 +- doc/examples/classic_func_using_func.py | 2 +- doc/examples/import_local_module/mod0.py | 4 +- doc/examples/import_local_module/mod1.py | 1 - doc/examples/inlined/bug_beniget.py | 9 ++- doc/examples/issues/issue29_blocks_classes.py | 3 +- doc/examples/issues/issue29_blocks_func.py | 3 +- doc/examples/local_module.py | 2 +- .../packages/package_cythran/check.py | 9 +-- .../package_cythran/_version.py | 3 +- .../package_cythran/package_cythran/calcul.py | 2 +- .../package_cythran/package_cythran/other.py | 2 +- .../package_cythran/package_cythran/util.py | 6 +- .../packages/package_cythran/setup.py | 9 ++- doc/examples/packages/package_simple/check.py | 7 +- .../package_simple/package_simple/_version.py | 3 +- .../package_simple/package_simple/calcul.py | 3 +- .../package_simple/package_simple/util.py | 7 +- doc/examples/packages/package_simple/setup.py | 9 ++- doc/examples/type_hints_notemplate.py | 3 +- doc/examples/using_jit_diff_types.py | 2 +- doc/examples/writing_benchmarks/bench_aot.py | 11 +-- doc/examples/writing_benchmarks/bench_jit.py | 14 ++-- .../cython_bugs/ctypedef_buffer/bug.pyx | 2 +- .../ctypedef_buffer/ctype_memview.pyx | 2 +- .../cython_bugs/ctypedef_buffer/pure.pxd | 2 +- .../ctypedef_buffer/pure_ctype_memview.pxd | 2 +- .../ctypedef_buffer/pure_ctype_memview.py | 3 +- .../cython_bugs/ctypedef_buffer/simpler.pyx | 2 +- .../cython_bugs/ctypedef_buffer/works.pyx | 2 +- .../cython_bugs/purepy_fusedtype/bug.py | 1 - .../purepy_nogil/pure_with_pxd.pxd | 1 + .../cython_bugs/purepy_nogil/pure_wo_pxd.py | 3 +- .../purepy_nogil/pure_wo_pxd_ccall.py | 2 + .../cython_bugs/purepy_nogil/simple.pyx | 1 + doc/for_dev/scikit-image/bench_one.py | 1 + doc/for_dev/scikit-image/bench_util.py | 2 +- .../scikit-image/future/_colormixer.py | 7 +- .../scikit-image/future/_convex_hull.py | 2 +- .../scikit-image/future/_greyreconstruct.py | 3 +- .../scikit-image/future/_moments_cy.py | 2 +- .../scikit-image/future/_radon_transform.py | 76 ++++++++++--------- doc/for_dev/scikit-image/future/cmorph.py | 2 +- .../scikit-image/pyx/_greyreconstruct.pyx | 2 +- .../scikit-image/pyx/_radon_transform.pyx | 4 +- doc/for_dev/scikit-image/pyx/cmorph.pyx | 3 +- doc/for_dev/scikit-image/setup.py | 2 +- .../_greyreconstruct_reconstruction_loop.py | 1 - .../setup_codes/cmorph__dilate.py | 2 +- doc/for_dev/scikit-image/setup_pyx.py | 2 +- noxfile.py | 2 +- pyproject.toml | 14 ++++ src/transonic/__init__.py | 18 ++--- src/transonic/aheadoftime.py | 21 +++-- src/transonic/analyses/__init__.py | 23 +++--- src/transonic/analyses/beniget.py | 7 +- src/transonic/analyses/capturex.py | 3 +- src/transonic/analyses/extast.py | 2 +- src/transonic/analyses/justintime.py | 10 ++- src/transonic/analyses/parser.py | 2 +- src/transonic/analyses/util.py | 3 +- src/transonic/backends/__init__.py | 2 +- src/transonic/backends/base.py | 20 +++-- src/transonic/backends/base_jit.py | 4 +- src/transonic/backends/cython.py | 5 +- src/transonic/backends/for_classes.py | 5 +- .../backends/for_test_set_backend.py | 2 +- src/transonic/backends/jax.py | 6 +- src/transonic/backends/numba.py | 2 +- src/transonic/backends/typing.py | 2 +- src/transonic/compiler.py | 14 ++-- src/transonic/dist.py | 11 ++- src/transonic/justintime.py | 22 +++--- src/transonic/log.py | 2 +- src/transonic/mpi.py | 2 +- src/transonic/progress.py | 3 +- src/transonic/run.py | 17 ++--- src/transonic/signatures.py | 2 +- src/transonic/typing.py | 2 +- src/transonic/util.py | 15 ++-- src/transonic_cl/cythonize.py | 2 +- src/transonic_cl/get_includes.py | 3 +- src/transonic_cl/init_meson.py | 2 - src/transonic_cl/run_backend.py | 8 +- tests/backends/test_backends.py | 3 +- tests/backends/test_backends_typing.py | 1 - tests/test_build_ext.py | 6 +- tests/test_clean_dir.py | 1 - tests/test_dist.py | 10 +-- tests/test_init.py | 2 +- tests/test_init_transonified.py | 12 +-- tests/test_justintime.py | 10 +-- tests/test_meson.py | 9 +-- tests/test_run.py | 3 +- tests/test_typing.py | 21 +++-- tests/test_util.py | 2 +- 108 files changed, 316 insertions(+), 310 deletions(-) diff --git a/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit.py b/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit.py index 66b6634..f3f0395 100644 --- a/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit.py +++ b/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit.py @@ -1,7 +1,7 @@ import gast import numpy as np -from .for_test_exterior_import_jit_2 import func_import_2 +from .for_test_exterior_import_jit_2 import func_import_2 const = 1 foo = 1 diff --git a/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit_2.py b/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit_2.py index b6e6e21..8dbaa89 100644 --- a/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit_2.py +++ b/_transonic_testing/src/_transonic_testing/for_test_exterior_import_jit_2.py @@ -1,7 +1,6 @@ import gast import numpy as np - const = 1 foo = 1 diff --git a/_transonic_testing/src/_transonic_testing/for_test_init.py b/_transonic_testing/src/_transonic_testing/for_test_init.py index be86e70..c7ce12d 100644 --- a/_transonic_testing/src/_transonic_testing/for_test_init.py +++ b/_transonic_testing/src/_transonic_testing/for_test_init.py @@ -1,7 +1,6 @@ import numpy as np -from transonic import Transonic, boost, Array, Union, const - +from transonic import Array, Transonic, Union, boost, const # transonic def func(int, float) diff --git a/_transonic_testing/src/_transonic_testing/for_test_justintime.py b/_transonic_testing/src/_transonic_testing/for_test_justintime.py index 2b62f91..6a422d4 100644 --- a/_transonic_testing/src/_transonic_testing/for_test_justintime.py +++ b/_transonic_testing/src/_transonic_testing/for_test_justintime.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import jit, boost +from transonic import boost, jit from transonic.mpi import Path @@ -71,9 +71,10 @@ def check(self): assert self.myfunc(1) == 3 +from numpy import pi + # FIXME support multilevel imported jitted function call in a jitted function from .for_test_exterior_import_jit import foo, func_import, func_import2 -from numpy import pi const = 1 diff --git a/doc/examples/bench_expr_broadcast/bench.py b/doc/examples/bench_expr_broadcast/bench.py index 5e6b669..b619a83 100644 --- a/doc/examples/bench_expr_broadcast/bench.py +++ b/doc/examples/bench_expr_broadcast/bench.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Array +from transonic import Array, boost A = Array[float, "3d"] A1 = Array[float, "1d"] @@ -51,4 +51,6 @@ def broadcast_loops(a: A, b: A1, out: A): for backend in ("numba", "pythran"): timeit_verbose(f"broadcast_{backend}(a, b, out)", globals=loc, norm=norm) - timeit_verbose(f"broadcast_loops_{backend}(a, b, out)", globals=loc, norm=norm) + timeit_verbose( + f"broadcast_loops_{backend}(a, b, out)", globals=loc, norm=norm + ) diff --git a/doc/examples/bench_proj_perp/bench.py b/doc/examples/bench_proj_perp/bench.py index 03114dc..1766b37 100644 --- a/doc/examples/bench_proj_perp/bench.py +++ b/doc/examples/bench_proj_perp/bench.py @@ -1,5 +1,6 @@ import numpy as np -from transonic import boost, Array, Type + +from transonic import Array, Type, boost A = Array[Type(np.float64, np.complex128), "3d"] Af = "float[:,:,:]" diff --git a/doc/examples/bench_row_sum/bench.py b/doc/examples/bench_row_sum/bench.py index 73139c3..36e8a30 100644 --- a/doc/examples/bench_row_sum/bench.py +++ b/doc/examples/bench_row_sum/bench.py @@ -1,5 +1,5 @@ -from subprocess import getoutput import sys +from subprocess import getoutput decorator = "boost" if "jit" in sys.argv: diff --git a/doc/examples/bench_row_sum/row_sum_boost.py b/doc/examples/bench_row_sum/row_sum_boost.py index 3ab3f10..490cde3 100644 --- a/doc/examples/bench_row_sum/row_sum_boost.py +++ b/doc/examples/bench_row_sum/row_sum_boost.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Array, const +from transonic import Array, boost, const T_index = np.int32 # we use a type variable because it can be replaced by a fused type. @@ -37,7 +37,7 @@ def row_sum_loops(arr: const(V2d), columns: const(V1d_i)): if __name__ == "__main__": - from util import check, bench + from util import bench, check functions = [row_sum, row_sum_loops] arr = np.arange(1_000_000).reshape(1_000, 1_000) diff --git a/doc/examples/bench_row_sum/row_sum_jit.py b/doc/examples/bench_row_sum/row_sum_jit.py index 8e1eca5..a1fe91b 100644 --- a/doc/examples/bench_row_sum/row_sum_jit.py +++ b/doc/examples/bench_row_sum/row_sum_jit.py @@ -21,9 +21,9 @@ def row_sum_loops(arr, columns): if __name__ == "__main__": - from transonic import wait_for_all_extensions + from util import bench, check - from util import check, bench + from transonic import wait_for_all_extensions functions = [row_sum, row_sum_loops] arr = np.arange(1_000_000).reshape(1_000, 1_000) diff --git a/doc/examples/bench_row_sum/util.py b/doc/examples/bench_row_sum/util.py index 9f1e821..0621953 100644 --- a/doc/examples/bench_row_sum/util.py +++ b/doc/examples/bench_row_sum/util.py @@ -1,7 +1,7 @@ import numpy as np -from transonic.util import timeit from transonic.config import backend_default +from transonic.util import timeit def check(functions, arr, columns): diff --git a/doc/examples/bench_trigo/bench.py b/doc/examples/bench_trigo/bench.py index 3d2895a..049e87e 100644 --- a/doc/examples/bench_trigo/bench.py +++ b/doc/examples/bench_trigo/bench.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Array +from transonic import Array, boost A = Array[float, "1d"] diff --git a/doc/examples/blocks.py b/doc/examples/blocks.py index 77b82cf..5987b4a 100644 --- a/doc/examples/blocks.py +++ b/doc/examples/blocks.py @@ -30,7 +30,7 @@ def compute(self, n): # ) result = np.zeros_like(a) for _ in range(n): - result += a ** 2 + b ** 3 + result += a**2 + b**3 return result diff --git a/doc/examples/blocks_type_hints.py b/doc/examples/blocks_type_hints.py index 81b02b1..6b7ccf2 100644 --- a/doc/examples/blocks_type_hints.py +++ b/doc/examples/blocks_type_hints.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import Transonic, Type, NDim, Array +from transonic import Array, NDim, Transonic, Type T = Type(float, complex) N = NDim(2, 3) @@ -28,7 +28,7 @@ def compute(self, n): result = np.zeros_like(a) for _ in range(n): - result += a ** 2 + b ** 3 + result += a**2 + b**3 return result diff --git a/doc/examples/classic_func_using_func.py b/doc/examples/classic_func_using_func.py index 63fb902..fb56663 100644 --- a/doc/examples/classic_func_using_func.py +++ b/doc/examples/classic_func_using_func.py @@ -13,5 +13,5 @@ def my_log(b): @boost def func(a, b): - c = multiply(a,b) + c = multiply(a, b) return (c * my_log(b)).max() diff --git a/doc/examples/import_local_module/mod0.py b/doc/examples/import_local_module/mod0.py index 57b59c2..1151387 100644 --- a/doc/examples/import_local_module/mod0.py +++ b/doc/examples/import_local_module/mod0.py @@ -1,8 +1,8 @@ import numpy as np +from mod1 import func_import -from transonic import jit, boost +from transonic import boost, jit -from mod1 import func_import @boost class MyClass2: diff --git a/doc/examples/import_local_module/mod1.py b/doc/examples/import_local_module/mod1.py index a677893..4fd59af 100644 --- a/doc/examples/import_local_module/mod1.py +++ b/doc/examples/import_local_module/mod1.py @@ -1,4 +1,3 @@ - import numpy as np const = 1 diff --git a/doc/examples/inlined/bug_beniget.py b/doc/examples/inlined/bug_beniget.py index da0b416..b89c0fd 100644 --- a/doc/examples/inlined/bug_beniget.py +++ b/doc/examples/inlined/bug_beniget.py @@ -1,12 +1,13 @@ - -import gast as ast import beniget +import gast as ast -mod = ast.parse(""" +mod = ast.parse( + """ T = int def func() -> T: return 1 -""") +""" +) fdef = mod.body[1] node = fdef.returns diff --git a/doc/examples/issues/issue29_blocks_classes.py b/doc/examples/issues/issue29_blocks_classes.py index 89f6898..bad049e 100644 --- a/doc/examples/issues/issue29_blocks_classes.py +++ b/doc/examples/issues/issue29_blocks_classes.py @@ -2,7 +2,8 @@ See https://foss.heptapod.net/fluiddyn/transonic/issues/6 """ -from transonic import boost, with_blocks, block + +from transonic import block, boost, with_blocks def non_pythranizable(arg): diff --git a/doc/examples/issues/issue29_blocks_func.py b/doc/examples/issues/issue29_blocks_func.py index c569c0d..3d9f60c 100644 --- a/doc/examples/issues/issue29_blocks_func.py +++ b/doc/examples/issues/issue29_blocks_func.py @@ -2,7 +2,8 @@ See https://foss.heptapod.net/fluiddyn/transonic/issues/6 """ -from transonic import with_blocks, block + +from transonic import block, with_blocks def non_pythranizable(arg): diff --git a/doc/examples/local_module.py b/doc/examples/local_module.py index 46134b0..387ae2c 100644 --- a/doc/examples/local_module.py +++ b/doc/examples/local_module.py @@ -1,2 +1,2 @@ def multiply(a, b): - return a * b \ No newline at end of file + return a * b diff --git a/doc/examples/packages/package_cythran/check.py b/doc/examples/packages/package_cythran/check.py index 239f352..55634d9 100644 --- a/doc/examples/packages/package_cythran/check.py +++ b/doc/examples/packages/package_cythran/check.py @@ -1,15 +1,14 @@ import numpy as np -from transonic.aheadoftime import modules_backends - from numba.targets.registry import CPUDispatcher - from package_cythran.calcul import laplace -from package_cythran.util import func from package_cythran.other import func_numba +from package_cythran.util import func + +from transonic.aheadoftime import modules_backends laplace(np.ones((2, 2), dtype=np.int32)) func(1) -func(2.) +func(2.0) ts = modules_backends["pythran"]["package_cythran.calcul"] assert ts.backend.name == "pythran" diff --git a/doc/examples/packages/package_cythran/package_cythran/_version.py b/doc/examples/packages/package_cythran/package_cythran/_version.py index f27aea8..f102a9c 100644 --- a/doc/examples/packages/package_cythran/package_cythran/_version.py +++ b/doc/examples/packages/package_cythran/package_cythran/_version.py @@ -1,2 +1 @@ - -__version__ = "0.0.1" \ No newline at end of file +__version__ = "0.0.1" diff --git a/doc/examples/packages/package_cythran/package_cythran/calcul.py b/doc/examples/packages/package_cythran/package_cythran/calcul.py index a8778a2..21f487e 100644 --- a/doc/examples/packages/package_cythran/package_cythran/calcul.py +++ b/doc/examples/packages/package_cythran/package_cythran/calcul.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Type, Array, NDim, set_backend_for_this_module +from transonic import Array, NDim, Type, boost, set_backend_for_this_module set_backend_for_this_module("pythran") diff --git a/doc/examples/packages/package_cythran/package_cythran/other.py b/doc/examples/packages/package_cythran/package_cythran/other.py index f8a1413..33433a5 100644 --- a/doc/examples/packages/package_cythran/package_cythran/other.py +++ b/doc/examples/packages/package_cythran/package_cythran/other.py @@ -5,4 +5,4 @@ @boost def func_numba(a): - return a ** 2 + return a**2 diff --git a/doc/examples/packages/package_cythran/package_cythran/util.py b/doc/examples/packages/package_cythran/package_cythran/util.py index 652aea3..575c274 100644 --- a/doc/examples/packages/package_cythran/package_cythran/util.py +++ b/doc/examples/packages/package_cythran/package_cythran/util.py @@ -1,13 +1,13 @@ - -import numpy as np import matplotlib.pyplot as plt +import numpy as np -from transonic import boost, Type, set_backend_for_this_module +from transonic import Type, boost, set_backend_for_this_module set_backend_for_this_module("cython") T = Type(float, int) + @boost def func(a: T): b = 1 diff --git a/doc/examples/packages/package_cythran/setup.py b/doc/examples/packages/package_cythran/setup.py index 8a56db0..7a7161a 100644 --- a/doc/examples/packages/package_cythran/setup.py +++ b/doc/examples/packages/package_cythran/setup.py @@ -2,14 +2,14 @@ No pyproject.toml file because in some cases, isolated build cannot be used. """ -import sys + import os +import sys from pathlib import Path - from runpy import run_path +from setuptools import find_packages, setup from setuptools.dist import Distribution -from setuptools import setup, find_packages if sys.version_info[:2] < (3, 6): raise RuntimeError("Python version >= 3.6 required.") @@ -25,9 +25,10 @@ def install_setup_requires(): install_setup_requires() -from transonic.dist import make_backend_files, init_transonic_extensions import numpy as np +from transonic.dist import init_transonic_extensions, make_backend_files + here = Path(__file__).parent.absolute() pack_name = "package_cythran" diff --git a/doc/examples/packages/package_simple/check.py b/doc/examples/packages/package_simple/check.py index 5bbbe62..f39ec8e 100644 --- a/doc/examples/packages/package_simple/check.py +++ b/doc/examples/packages/package_simple/check.py @@ -1,13 +1,12 @@ import numpy as np - -from transonic.aheadoftime import modules_backends - from package_simple.calcul import laplace from package_simple.util import func +from transonic.aheadoftime import modules_backends + laplace(np.ones((2, 2), dtype=np.int32)) func(1) -func(2.) +func(2.0) modules = modules_backends["pythran"] diff --git a/doc/examples/packages/package_simple/package_simple/_version.py b/doc/examples/packages/package_simple/package_simple/_version.py index f27aea8..f102a9c 100644 --- a/doc/examples/packages/package_simple/package_simple/_version.py +++ b/doc/examples/packages/package_simple/package_simple/_version.py @@ -1,2 +1 @@ - -__version__ = "0.0.1" \ No newline at end of file +__version__ = "0.0.1" diff --git a/doc/examples/packages/package_simple/package_simple/calcul.py b/doc/examples/packages/package_simple/package_simple/calcul.py index c996bbd..2613cc5 100644 --- a/doc/examples/packages/package_simple/package_simple/calcul.py +++ b/doc/examples/packages/package_simple/package_simple/calcul.py @@ -1,7 +1,6 @@ import numpy as np -from transonic import boost, Type, Array, NDim - +from transonic import Array, NDim, Type, boost T = Type(np.int32, np.float64, np.float32) A = Array[T, NDim(2)] diff --git a/doc/examples/packages/package_simple/package_simple/util.py b/doc/examples/packages/package_simple/package_simple/util.py index 1f0211d..2cd1f17 100644 --- a/doc/examples/packages/package_simple/package_simple/util.py +++ b/doc/examples/packages/package_simple/package_simple/util.py @@ -1,12 +1,11 @@ - -import numpy as np import matplotlib.pyplot as plt +import numpy as np -from transonic import boost, Type - +from transonic import Type, boost T = Type(float, int) + @boost def func(a: T): b = 1 diff --git a/doc/examples/packages/package_simple/setup.py b/doc/examples/packages/package_simple/setup.py index 546a02a..3b6ccf7 100644 --- a/doc/examples/packages/package_simple/setup.py +++ b/doc/examples/packages/package_simple/setup.py @@ -2,14 +2,14 @@ No pyproject.toml file because in some cases, isolated build cannot be used. """ -import sys + import os +import sys from pathlib import Path - from runpy import run_path +from setuptools import find_packages, setup from setuptools.dist import Distribution -from setuptools import setup, find_packages if sys.version_info[:2] < (3, 6): raise RuntimeError("Python version >= 3.6 required.") @@ -25,9 +25,10 @@ def install_setup_requires(): install_setup_requires() -from transonic.dist import make_backend_files, init_transonic_extensions import numpy as np +from transonic.dist import init_transonic_extensions, make_backend_files + here = Path(__file__).parent.absolute() pack_name = "package_simple" diff --git a/doc/examples/type_hints_notemplate.py b/doc/examples/type_hints_notemplate.py index 6677dd2..70f4aae 100644 --- a/doc/examples/type_hints_notemplate.py +++ b/doc/examples/type_hints_notemplate.py @@ -1,5 +1,6 @@ import numpy as np -from transonic import Type, NDim, Array, boost + +from transonic import Array, NDim, Type, boost T = Type(int, np.complex128) N = NDim(1, 3) diff --git a/doc/examples/using_jit_diff_types.py b/doc/examples/using_jit_diff_types.py index 9cd7843..1616e7b 100644 --- a/doc/examples/using_jit_diff_types.py +++ b/doc/examples/using_jit_diff_types.py @@ -1,4 +1,4 @@ -from transonic import jit, Type +from transonic import Type, jit T = Type(int, float) diff --git a/doc/examples/writing_benchmarks/bench_aot.py b/doc/examples/writing_benchmarks/bench_aot.py index 6e61a3e..c86488f 100644 --- a/doc/examples/writing_benchmarks/bench_aot.py +++ b/doc/examples/writing_benchmarks/bench_aot.py @@ -1,8 +1,8 @@ -from transonic import boost, Array import numba - import numpy as np +from transonic import Array, boost + Image = Array[np.float64, "2d", "C"] @@ -54,6 +54,7 @@ def laplace_loops(image: Image): # For Cython, we need to add more type annotations + @boost(backend="cython", boundscheck=False, wraparound=False) def laplace_loops_transonic_cython(image: Image): """Laplace operator for 2D images.""" @@ -79,8 +80,8 @@ def laplace_loops_transonic_cython(image: Image): if __name__ == "__main__": - from skimage.data import astronaut from skimage.color import rgb2gray + from skimage.data import astronaut image = astronaut() image = rgb2gray(image) @@ -91,9 +92,9 @@ def laplace_loops_transonic_cython(image: Image): laplace_numba(image) laplace_loops_numba(image) - from transonic.util import timeit - from transonic import __version__ import pythran + from transonic import __version__ + from transonic.util import timeit loc = locals() diff --git a/doc/examples/writing_benchmarks/bench_jit.py b/doc/examples/writing_benchmarks/bench_jit.py index 1f7ab78..1a46fc2 100644 --- a/doc/examples/writing_benchmarks/bench_jit.py +++ b/doc/examples/writing_benchmarks/bench_jit.py @@ -1,7 +1,7 @@ -from transonic import jit import numba +from pure_numpy import laplace_loops, laplace_numpy -from pure_numpy import laplace_numpy, laplace_loops +from transonic import jit laplace_transonic_pythran = jit(native=True, xsimd=True)(laplace_numpy) laplace_transonic_python = jit(backend="python")(laplace_numpy) @@ -14,10 +14,10 @@ laplace_numba_loops = numba.njit(laplace_loops) if __name__ == "__main__": - from transonic import wait_for_all_extensions - - from skimage.data import astronaut from skimage.color import rgb2gray + from skimage.data import astronaut + + from transonic import wait_for_all_extensions image = astronaut() image = rgb2gray(image) @@ -37,9 +37,9 @@ laplace_transonic_numba(image) laplace_transonic_numba_loops(image) - from transonic.util import timeit - from transonic import __version__ import pythran + from transonic import __version__ + from transonic.util import timeit loc = locals() diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/bug.pyx b/doc/for_dev/cython_bugs/ctypedef_buffer/bug.pyx index df70e85..a58b14d 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/bug.pyx +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/bug.pyx @@ -1,6 +1,6 @@ import cython - import numpy as np + cimport numpy as np ctypedef fused T0: diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/ctype_memview.pyx b/doc/for_dev/cython_bugs/ctypedef_buffer/ctype_memview.pyx index b5197df..1ea302c 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/ctype_memview.pyx +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/ctype_memview.pyx @@ -1,6 +1,6 @@ import cython - import numpy as np + cimport numpy as np ctypedef fused T0: diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/pure.pxd b/doc/for_dev/cython_bugs/ctypedef_buffer/pure.pxd index 30b317b..82dda7c 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/pure.pxd +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/pure.pxd @@ -1,6 +1,6 @@ import cython - import numpy as np + cimport numpy as np ctypedef fused T0: diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.pxd b/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.pxd index f7d73ca..7557012 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.pxd +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.pxd @@ -1,6 +1,6 @@ import cython - import numpy as np + cimport numpy as np ctypedef fused T0: diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.py b/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.py index 3149551..31a8c1f 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.py +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/pure_ctype_memview.py @@ -1,6 +1,5 @@ - def mysum(arr): ret = arr.dtype.type(0) for i in range(arr.shape[0]): ret += arr[i] - return ret \ No newline at end of file + return ret diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/simpler.pyx b/doc/for_dev/cython_bugs/ctypedef_buffer/simpler.pyx index 3a216e3..fdbcf5f 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/simpler.pyx +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/simpler.pyx @@ -1,6 +1,6 @@ import cython - import numpy as np + cimport numpy as np # not supported, see: https://github.com/cython/cython/issues/754 diff --git a/doc/for_dev/cython_bugs/ctypedef_buffer/works.pyx b/doc/for_dev/cython_bugs/ctypedef_buffer/works.pyx index 6d5a17e..d2e488f 100644 --- a/doc/for_dev/cython_bugs/ctypedef_buffer/works.pyx +++ b/doc/for_dev/cython_bugs/ctypedef_buffer/works.pyx @@ -1,6 +1,6 @@ import cython - import numpy as np + cimport numpy as np ctypedef fused T0: diff --git a/doc/for_dev/cython_bugs/purepy_fusedtype/bug.py b/doc/for_dev/cython_bugs/purepy_fusedtype/bug.py index 14b3dc0..9b2da1c 100644 --- a/doc/for_dev/cython_bugs/purepy_fusedtype/bug.py +++ b/doc/for_dev/cython_bugs/purepy_fusedtype/bug.py @@ -1,4 +1,3 @@ - def func(arg): arr = arg return arr diff --git a/doc/for_dev/cython_bugs/purepy_nogil/pure_with_pxd.pxd b/doc/for_dev/cython_bugs/purepy_nogil/pure_with_pxd.pxd index a11a298..7edc795 100644 --- a/doc/for_dev/cython_bugs/purepy_nogil/pure_with_pxd.pxd +++ b/doc/for_dev/cython_bugs/purepy_nogil/pure_with_pxd.pxd @@ -1,5 +1,6 @@ cimport cython + cdef inline int add(int a, int b) nogil @cython.locals(n=int, i=int, result=int) diff --git a/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd.py b/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd.py index ae67ce4..efbd292 100644 --- a/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd.py +++ b/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd.py @@ -2,6 +2,7 @@ import cython + # @cython.ccall @cython.cfunc @cython.inline @@ -19,4 +20,4 @@ def use_add(n): with cython.nogil: for i in range(n): result = add(result, result) - return result \ No newline at end of file + return result diff --git a/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd_ccall.py b/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd_ccall.py index a42169f..e65c1c6 100644 --- a/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd_ccall.py +++ b/doc/for_dev/cython_bugs/purepy_nogil/pure_wo_pxd_ccall.py @@ -2,6 +2,7 @@ import cython + @cython.ccall @cython.inline @cython.returns(cython.int) @@ -10,6 +11,7 @@ def add(a, b): return a + b + @cython.ccall @cython.locals(n=cython.int, i=Py_ssize_t, result=cython.int) def use_add(n): diff --git a/doc/for_dev/cython_bugs/purepy_nogil/simple.pyx b/doc/for_dev/cython_bugs/purepy_nogil/simple.pyx index 75d8e44..6d35dba 100644 --- a/doc/for_dev/cython_bugs/purepy_nogil/simple.pyx +++ b/doc/for_dev/cython_bugs/purepy_nogil/simple.pyx @@ -1,6 +1,7 @@ # cython: language_level=3 import cython + cpdef inline int add(int a, int b) nogil: return a + b diff --git a/doc/for_dev/scikit-image/bench_one.py b/doc/for_dev/scikit-image/bench_one.py index 4a3ed13..7afcdf5 100644 --- a/doc/for_dev/scikit-image/bench_one.py +++ b/doc/for_dev/scikit-image/bench_one.py @@ -1,4 +1,5 @@ import argparse + from bench_util import bench_one parser = argparse.ArgumentParser(description="Run one benchmark") diff --git a/doc/for_dev/scikit-image/bench_util.py b/doc/for_dev/scikit-image/bench_util.py index 9ebb778..2000b6b 100644 --- a/doc/for_dev/scikit-image/bench_util.py +++ b/doc/for_dev/scikit-image/bench_util.py @@ -1,5 +1,5 @@ -from subprocess import getoutput from pathlib import Path +from subprocess import getoutput from transonic.util import timeit diff --git a/doc/for_dev/scikit-image/future/_colormixer.py b/doc/for_dev/scikit-image/future/_colormixer.py index caad78a..68b37cf 100644 --- a/doc/for_dev/scikit-image/future/_colormixer.py +++ b/doc/for_dev/scikit-image/future/_colormixer.py @@ -9,7 +9,7 @@ import numpy as np -from transonic import boost, Array +from transonic import Array, boost Auint8 = "uint8[:,:,:]" A1dC = Array[np.uint8, "1d", "C"] @@ -131,7 +131,6 @@ def brightness(img: Auint8, stateimg: Auint8, factor: float, offset: int): img[i, j, 2] = lut[stateimg[i, j, 2]] - @boost(boundscheck=False, wraparound=False, cdivision=True, nonecheck=False) def sigmoid_gamma(img: Auint8, stateimg: Auint8, alpha: float, beta: float): height = img.shape[0] @@ -425,7 +424,9 @@ def hsv_add( @boost(boundscheck=False, wraparound=False, cdivision=True, nonecheck=False) -def hsv_multiply(img: Auint8, stateimg: Auint8, h_amt: float, s_amt: float, v_amt: float): +def hsv_multiply( + img: Auint8, stateimg: Auint8, h_amt: float, s_amt: float, v_amt: float +): """Modify the image color by specifying multiplicative HSV Values. Since the underlying images are RGB, all three values HSV diff --git a/doc/for_dev/scikit-image/future/_convex_hull.py b/doc/for_dev/scikit-image/future/_convex_hull.py index 1c76613..b31cb97 100644 --- a/doc/for_dev/scikit-image/future/_convex_hull.py +++ b/doc/for_dev/scikit-image/future/_convex_hull.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Array +from transonic import Array, boost @boost(wraparound=False, boundscheck=False, cdivision=True, nonecheck=False) diff --git a/doc/for_dev/scikit-image/future/_greyreconstruct.py b/doc/for_dev/scikit-image/future/_greyreconstruct.py index b8c3c2b..5d85158 100644 --- a/doc/for_dev/scikit-image/future/_greyreconstruct.py +++ b/doc/for_dev/scikit-image/future/_greyreconstruct.py @@ -9,9 +9,10 @@ Original author: Lee Kamentsky """ + import numpy as np -from transonic import boost, Array, const +from transonic import Array, boost, const Au = Array[np.uint32, "1d", "C", "positive_indices"] A = Array[np.int32, "1d", "C", "positive_indices"] diff --git a/doc/for_dev/scikit-image/future/_moments_cy.py b/doc/for_dev/scikit-image/future/_moments_cy.py index ba4bc26..5df7e40 100644 --- a/doc/for_dev/scikit-image/future/_moments_cy.py +++ b/doc/for_dev/scikit-image/future/_moments_cy.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Array +from transonic import Array, boost @boost(wraparound=False, cdivision=True, nonecheck=False) diff --git a/doc/for_dev/scikit-image/future/_radon_transform.py b/doc/for_dev/scikit-image/future/_radon_transform.py index 1745b9f..2dabc7b 100644 --- a/doc/for_dev/scikit-image/future/_radon_transform.py +++ b/doc/for_dev/scikit-image/future/_radon_transform.py @@ -1,8 +1,7 @@ import numpy as np -from numpy import cos, sin, floor, ceil, sqrt +from numpy import ceil, cos, floor, sin, sqrt - -from transonic import boost, Optional +from transonic import Optional, boost def bilinear_ray_sum(image, theta, ray_position): @@ -26,17 +25,17 @@ def bilinear_ray_sum(image, theta, ray_position): A measure of how long the ray's path through the reconstruction circle was """ - theta = theta / 180. * np.pi + theta = theta / 180.0 * np.pi radius = image.shape[0] // 2 - 1 projection_center = image.shape[0] // 2 rotation_center = image.shape[0] // 2 # (s, t) is the (x, y) system rotated by theta t = ray_position - projection_center # s0 is the half-length of the ray's path in the reconstruction circle - s0 = sqrt(radius * radius - t * t) if radius*radius >= t*t else 0. + s0 = sqrt(radius * radius - t * t) if radius * radius >= t * t else 0.0 Ns = 2 * int(ceil(2 * s0)) # number of steps along the ray - ray_sum = 0. - weight_norm = 0. + ray_sum = 0.0 + weight_norm = 0.0 if Ns > 0: # step length between samples @@ -58,27 +57,28 @@ def bilinear_ray_sum(image, theta, ray_position): # Use linear interpolation between values # Where values fall outside the array, assume zero if i > 0 and j > 0: - weight = (1. - di) * (1. - dj) * ds + weight = (1.0 - di) * (1.0 - dj) * ds ray_sum += weight * image[i, j] weight_norm += weight * weight if i > 0 and j < image.shape[1] - 1: - weight = (1. - di) * dj * ds - ray_sum += weight * image[i, j+1] + weight = (1.0 - di) * dj * ds + ray_sum += weight * image[i, j + 1] weight_norm += weight * weight if i < image.shape[0] - 1 and j > 0: weight = di * (1 - dj) * ds - ray_sum += weight * image[i+1, j] + ray_sum += weight * image[i + 1, j] weight_norm += weight * weight if i < image.shape[0] - 1 and j < image.shape[1] - 1: weight = di * dj * ds - ray_sum += weight * image[i+1, j+1] + ray_sum += weight * image[i + 1, j + 1] weight_norm += weight * weight return ray_sum, weight_norm -def bilinear_ray_update(image, image_update, theta, ray_position, - projected_value): +def bilinear_ray_update( + image, image_update, theta, ray_position, projected_value +): """Compute the update along a ray using bilinear interpolation. Parameters @@ -100,18 +100,18 @@ def bilinear_ray_update(image, image_update, theta, ray_position, Deviation before updating the image. """ ray_sum, weight_norm = bilinear_ray_sum(image, theta, ray_position) - if weight_norm > 0.: + if weight_norm > 0.0: deviation = -(ray_sum - projected_value) / weight_norm else: - deviation = 0. - theta = theta / 180. * np.pi + deviation = 0.0 + theta = theta / 180.0 * np.pi radius = image.shape[0] // 2 - 1 projection_center = image.shape[0] // 2 rotation_center = image.shape[0] // 2 # (s, t) is the (x, y) system rotated by theta t = ray_position - projection_center # s0 is the half-length of the ray's path in the reconstruction circle - s0 = sqrt(radius*radius - t*t) if radius*radius >= t*t else 0. + s0 = sqrt(radius * radius - t * t) if radius * radius >= t * t else 0.0 Ns = 2 * int(ceil(2 * s0)) # beta for equiripple Hamming window hamming_beta = 0.46164 @@ -133,29 +133,36 @@ def bilinear_ray_update(image, image_update, theta, ray_position, j = int(floor(index_j)) di = index_i - floor(index_i) dj = index_j - floor(index_j) - hamming_window = ((1 - hamming_beta) - - hamming_beta * cos(2 * np.pi * k / (Ns - 1))) + hamming_window = (1 - hamming_beta) - hamming_beta * cos( + 2 * np.pi * k / (Ns - 1) + ) if i > 0 and j > 0: - image_update[i, j] += (deviation * (1. - di) * (1. - dj) - * ds * hamming_window) + image_update[i, j] += ( + deviation * (1.0 - di) * (1.0 - dj) * ds * hamming_window + ) if i > 0 and j < image.shape[1] - 1: - image_update[i, j+1] += (deviation * (1. - di) * dj - * ds * hamming_window) + image_update[i, j + 1] += ( + deviation * (1.0 - di) * dj * ds * hamming_window + ) if i < image.shape[0] - 1 and j > 0: - image_update[i+1, j] += (deviation * di * (1 - dj) - * ds * hamming_window) + image_update[i + 1, j] += ( + deviation * di * (1 - dj) * ds * hamming_window + ) if i < image.shape[0] - 1 and j < image.shape[1] - 1: - image_update[i+1, j+1] += (deviation * di * dj - * ds * hamming_window) + image_update[i + 1, j + 1] += ( + deviation * di * dj * ds * hamming_window + ) return deviation @boost -def sart_projection_update(image: "float64[:,:]", - theta: float, - projection: "float64[:]", - projection_shift: float = 0.): +def sart_projection_update( + image: "float64[:,:]", + theta: float, + projection: "float64[:]", + projection_shift: float = 0.0, +): """ Compute update to a reconstruction estimate from a single projection using bilinear interpolation. @@ -181,6 +188,7 @@ def sart_projection_update(image: "float64[:,:]", image_update = np.zeros_like(image) for i in range(projection.shape[0]): ray_position = i + projection_shift - bilinear_ray_update(image, image_update, theta, ray_position, - projection[i]) + bilinear_ray_update( + image, image_update, theta, ray_position, projection[i] + ) return image_update diff --git a/doc/for_dev/scikit-image/future/cmorph.py b/doc/for_dev/scikit-image/future/cmorph.py index 3b82900..e6d31c7 100644 --- a/doc/for_dev/scikit-image/future/cmorph.py +++ b/doc/for_dev/scikit-image/future/cmorph.py @@ -1,6 +1,6 @@ import numpy as np -from transonic import boost, Optional, Array +from transonic import Array, Optional, boost A = Array[np.uint8, "2d", "memview"] diff --git a/doc/for_dev/scikit-image/pyx/_greyreconstruct.pyx b/doc/for_dev/scikit-image/pyx/_greyreconstruct.pyx index d2e0779..fd149fd 100644 --- a/doc/for_dev/scikit-image/pyx/_greyreconstruct.pyx +++ b/doc/for_dev/scikit-image/pyx/_greyreconstruct.pyx @@ -8,8 +8,8 @@ All rights reserved. Original author: Lee Kamentsky """ -cimport numpy as cnp cimport cython +cimport numpy as cnp @cython.boundscheck(False) diff --git a/doc/for_dev/scikit-image/pyx/_radon_transform.pyx b/doc/for_dev/scikit-image/pyx/_radon_transform.pyx index 5fbf11c..6b972ee 100644 --- a/doc/for_dev/scikit-image/pyx/_radon_transform.pyx +++ b/doc/for_dev/scikit-image/pyx/_radon_transform.pyx @@ -4,9 +4,9 @@ #cython: wraparound=False import numpy as np -cimport numpy as cnp cimport cython -from libc.math cimport cos, sin, floor, ceil, sqrt, abs, M_PI +cimport numpy as cnp +from libc.math cimport M_PI, abs, ceil, cos, floor, sin, sqrt cpdef bilinear_ray_sum(cnp.double_t[:, :] image, cnp.double_t theta, diff --git a/doc/for_dev/scikit-image/pyx/cmorph.pyx b/doc/for_dev/scikit-image/pyx/cmorph.pyx index a16a3b4..ca39c6d 100644 --- a/doc/for_dev/scikit-image/pyx/cmorph.pyx +++ b/doc/for_dev/scikit-image/pyx/cmorph.pyx @@ -4,8 +4,9 @@ #cython: wraparound=False import numpy as np + cimport numpy as np -from libc.stdlib cimport malloc, free +from libc.stdlib cimport free, malloc def _dilate(np.uint8_t[:, :] image, diff --git a/doc/for_dev/scikit-image/setup.py b/doc/for_dev/scikit-image/setup.py index 96e4982..a55fc92 100644 --- a/doc/for_dev/scikit-image/setup.py +++ b/doc/for_dev/scikit-image/setup.py @@ -5,7 +5,7 @@ import numpy as np -from transonic.dist import make_backend_files, init_transonic_extensions +from transonic.dist import init_transonic_extensions, make_backend_files path_here = Path(__file__).parent.absolute() include_dirs = [np.get_include()] diff --git a/doc/for_dev/scikit-image/setup_codes/_greyreconstruct_reconstruction_loop.py b/doc/for_dev/scikit-image/setup_codes/_greyreconstruct_reconstruction_loop.py index 61271b8..81e6bf2 100644 --- a/doc/for_dev/scikit-image/setup_codes/_greyreconstruct_reconstruction_loop.py +++ b/doc/for_dev/scikit-image/setup_codes/_greyreconstruct_reconstruction_loop.py @@ -1,6 +1,5 @@ import numpy as np from future._greyreconstruct import reconstruction_loop - from skimage.filters._rank_order import rank_order y, x = np.mgrid[:20:0.5, :20:0.5] diff --git a/doc/for_dev/scikit-image/setup_codes/cmorph__dilate.py b/doc/for_dev/scikit-image/setup_codes/cmorph__dilate.py index 790d8aa..381771c 100644 --- a/doc/for_dev/scikit-image/setup_codes/cmorph__dilate.py +++ b/doc/for_dev/scikit-image/setup_codes/cmorph__dilate.py @@ -14,4 +14,4 @@ ) out = np.zeros((rows, cols), dtype=np.uint8) shift_x = np.int8(2) -shift_y = np.int8(2) \ No newline at end of file +shift_y = np.int8(2) diff --git a/doc/for_dev/scikit-image/setup_pyx.py b/doc/for_dev/scikit-image/setup_pyx.py index 1eea419..0006e45 100644 --- a/doc/for_dev/scikit-image/setup_pyx.py +++ b/doc/for_dev/scikit-image/setup_pyx.py @@ -1,4 +1,4 @@ -from distutils.core import setup, Extension +from distutils.core import Extension, setup from pathlib import Path import numpy as np diff --git a/noxfile.py b/noxfile.py index 731c694..a66b96e 100644 --- a/noxfile.py +++ b/noxfile.py @@ -1,9 +1,9 @@ import os import sys -from packaging import version from pathlib import Path import nox +from packaging import version os.environ.update({"PDM_IGNORE_SAVED_PYTHON": "1"}) nox.options.reuse_existing_virtualenvs = 1 diff --git a/pyproject.toml b/pyproject.toml index 1f76b0a..1cbf1aa 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -78,6 +78,15 @@ doc = [ ] dev = ["pip", "build", "pylint", "twine"] +[tool.pdm.scripts] +black = "black src _transonic_testing data_tests tests doc noxfile.py" +isort = "isort --atomic --tc src _transonic_testing tests doc noxfile.py" +black_check = "black --check src _transonic_testing data_tests tests doc noxfile.py" +lint = {shell="pylint -rn --rcfile=pylintrc --jobs=$(nproc) src --exit-zero"} +validate_code = {composite = ["black_check", "lint"]} +format = {composite = ["black", "isort"]} + + [tool.pytest] addopts = "--doctest-modules" @@ -90,6 +99,11 @@ addopts = "--pdbcls=IPython.terminal.debugger:TerminalPdb" line-length = 82 target-version = ['py38'] +[tool.isort] +profile = "black" +line_length = 82 +src_paths = ["src", "_transonic_testing", "tests", "doc", "noxfile.py"] +known_first_party = ["pythran"] [tool.coverage.run] branch = true diff --git a/src/transonic/__init__.py b/src/transonic/__init__.py index 3329818..633fd87 100644 --- a/src/transonic/__init__.py +++ b/src/transonic/__init__.py @@ -1,26 +1,24 @@ from transonic._version import __version__ - from transonic.aheadoftime import Transonic, boost from transonic.backends import set_backend_for_this_module -from transonic.config import set_backend from transonic.compiler import wait_for_all_extensions +from transonic.config import set_backend from transonic.justintime import jit, set_compile_jit -from transonic.util import set_compile_at_import from transonic.typing import ( Array, + Dict, + List, NDim, + Optional, + Set, + Tuple, Type, Union, - List, - Tuple, - Dict, - Set, + const, str2type, typeof, - Optional, - const, ) - +from transonic.util import set_compile_at_import __all__ = [ "__version__", diff --git a/src/transonic/aheadoftime.py b/src/transonic/aheadoftime.py index 53b85ba..e65bdff 100644 --- a/src/transonic/aheadoftime.py +++ b/src/transonic/aheadoftime.py @@ -21,31 +21,30 @@ """ +import functools import inspect -import time -import subprocess import os -import functools +import subprocess import sys +import time from importlib import import_module +from transonic import mpi from transonic.backends import backends, get_backend_name_module -from transonic.config import has_to_replace, backend_default +from transonic.config import backend_default, has_to_replace from transonic.log import logger -from transonic import mpi from transonic.mpi import Path - from transonic.util import ( + _get_pathfile_from_frame, + find_module_name_from_path, + get_frame, get_module_name, + has_to_build, has_to_compile_at_import, import_from_path, - has_to_build, - modification_date, is_method, + modification_date, write_if_has_to_write, - find_module_name_from_path, - _get_pathfile_from_frame, - get_frame, ) if mpi.nb_proc == 1: diff --git a/src/transonic/analyses/__init__.py b/src/transonic/analyses/__init__.py index 975e73b..b341ad1 100644 --- a/src/transonic/analyses/__init__.py +++ b/src/transonic/analyses/__init__.py @@ -18,27 +18,26 @@ from pprint import pformat import gast as ast -from transonic.analyses import beniget +from transonic.analyses import beniget from transonic.log import logger +from ..config import SUPPORTED_BACKENDS +from . import extast +from .blocks_if import get_block_definitions +from .capturex import CaptureX +from .objects_from_str import replace_strings_by_objects +from .parser import parse_transonic_def_commands from .util import ( + extract_returns_annotation, + extract_variable_annotations, filter_code_typevars, + find_path, get_annotations, + get_exterior_code, print_dumped, print_unparsed, - find_path, - get_exterior_code, - extract_variable_annotations, - extract_returns_annotation, ) -from .capturex import CaptureX -from .blocks_if import get_block_definitions -from .parser import parse_transonic_def_commands -from .objects_from_str import replace_strings_by_objects -from . import extast -from ..config import SUPPORTED_BACKENDS - __all__ = ["print_dumped", "print_unparsed"] diff --git a/src/transonic/analyses/beniget.py b/src/transonic/analyses/beniget.py index f89c748..e1098c1 100644 --- a/src/transonic/analyses/beniget.py +++ b/src/transonic/analyses/beniget.py @@ -1,10 +1,9 @@ import gast as ast - -from beniget import Ancestors, DefUseChains as DUC, UseDefChains - +from beniget import Ancestors +from beniget import DefUseChains as DUC +from beniget import UseDefChains from beniget.beniget import Def - __all__ = ["Ancestors", "DefUseChains", "UseDefChains"] diff --git a/src/transonic/analyses/capturex.py b/src/transonic/analyses/capturex.py index 0400a9c..88e658d 100644 --- a/src/transonic/analyses/capturex.py +++ b/src/transonic/analyses/capturex.py @@ -4,8 +4,7 @@ import gast as ast -from transonic.analyses import beniget -from transonic.analyses import extast +from transonic.analyses import beniget, extast class CaptureX(ast.NodeVisitor): diff --git a/src/transonic/analyses/extast.py b/src/transonic/analyses/extast.py index f30c0cd..7561b32 100644 --- a/src/transonic/analyses/extast.py +++ b/src/transonic/analyses/extast.py @@ -3,8 +3,8 @@ """ -from io import StringIO from copy import deepcopy +from io import StringIO import gast from gast.ast3 import GAstToAst3 diff --git a/src/transonic/analyses/justintime.py b/src/transonic/analyses/justintime.py index 196c39c..26cf576 100644 --- a/src/transonic/analyses/justintime.py +++ b/src/transonic/analyses/justintime.py @@ -3,12 +3,14 @@ """ -from transonic.analyses import extast -from transonic.analyses import compute_ancestors_chains, get_decorated_dicts +from transonic.analyses import ( + compute_ancestors_chains, + extast, + get_decorated_dicts, +) from transonic.analyses.capturex import CaptureX - -from transonic.log import logger from transonic.analyses.util import get_exterior_code +from transonic.log import logger def analysis_jit(code, pathfile, backend_name): diff --git a/src/transonic/analyses/parser.py b/src/transonic/analyses/parser.py index 57fbb06..3734eff 100644 --- a/src/transonic/analyses/parser.py +++ b/src/transonic/analyses/parser.py @@ -3,8 +3,8 @@ """ -from tokenize import tokenize, COMMENT from io import BytesIO +from tokenize import COMMENT, tokenize def parse_transonic_def_commands(code: str): diff --git a/src/transonic/analyses/util.py b/src/transonic/analyses/util.py index 0e3fce2..75e9775 100644 --- a/src/transonic/analyses/util.py +++ b/src/transonic/analyses/util.py @@ -9,8 +9,7 @@ import gast as ast -from transonic.analyses import beniget -from transonic.analyses import extast +from transonic.analyses import beniget, extast try: import astunparse diff --git a/src/transonic/backends/__init__.py b/src/transonic/backends/__init__.py index e7cbb2d..beb84ed 100644 --- a/src/transonic/backends/__init__.py +++ b/src/transonic/backends/__init__.py @@ -29,7 +29,7 @@ from typing import Iterable from transonic.config import backend_default -from transonic.util import get_module_name, get_frame +from transonic.util import get_frame, get_module_name from .cython import CythonBackend from .jax import JaxBackend diff --git a/src/transonic/backends/base.py b/src/transonic/backends/base.py index fecc6cb..aa53e33 100644 --- a/src/transonic/backends/base.py +++ b/src/transonic/backends/base.py @@ -14,30 +14,28 @@ from textwrap import indent from typing import Iterable, Optional -# from pprint import pprint - import transonic - -from transonic.analyses import extast, analyse_aot, analyse_files -from transonic.log import logger -from transonic.compiler import compile_extension, ext_suffix from transonic import mpi +from transonic.analyses import analyse_aot, analyse_files, extast +from transonic.compiler import compile_extension, ext_suffix +from transonic.config import backend_default +from transonic.log import logger from transonic.mpi import PathSeq from transonic.signatures import compute_signatures_from_typeobjects -from transonic.config import backend_default - from transonic.util import ( - has_to_build, - format_str, - write_if_has_to_write, TypeHintRemover, + format_str, + has_to_build, make_hex, + write_if_has_to_write, ) from .base_jit import SubBackendJIT from .for_classes import make_new_code_method_from_nodes from .typing import TypeFormatter +# from pprint import pprint + class Backend: """Base class for the Transonic backends""" diff --git a/src/transonic/backends/base_jit.py b/src/transonic/backends/base_jit.py index 30968a5..e520aee 100644 --- a/src/transonic/backends/base_jit.py +++ b/src/transonic/backends/base_jit.py @@ -19,10 +19,10 @@ except ImportError: np = None +from transonic import mpi from transonic.analyses import extast -from transonic.signatures import make_signatures_from_typehinted_func from transonic.log import logger -from transonic import mpi +from transonic.signatures import make_signatures_from_typehinted_func from transonic.typing import format_type_as_backend_type, typeof from transonic.util import get_source_without_decorator, path_root diff --git a/src/transonic/backends/cython.py b/src/transonic/backends/cython.py index 21295a3..0b6a697 100644 --- a/src/transonic/backends/cython.py +++ b/src/transonic/backends/cython.py @@ -20,12 +20,11 @@ import copy import inspect - from warnings import warn -from transonic.analyses.extast import unparse, gast, FunctionDef, Name +from transonic.analyses.extast import FunctionDef, Name, gast, unparse from transonic.signatures import make_signatures_from_typehinted_func -from transonic.typing import format_type_as_backend_type, MemLayout +from transonic.typing import MemLayout, format_type_as_backend_type from .base import BackendAOT, TypeHintRemover, format_str from .base_jit import SubBackendJIT diff --git a/src/transonic/backends/for_classes.py b/src/transonic/backends/for_classes.py index 65a4f0f..4f0a937 100644 --- a/src/transonic/backends/for_classes.py +++ b/src/transonic/backends/for_classes.py @@ -3,18 +3,17 @@ """ -from tokenize import tokenize, untokenize, NAME, OP - # from token import tok_name import inspect from io import BytesIO +from tokenize import NAME, OP, tokenize, untokenize from transonic.signatures import compute_signatures_from_typeobjects # from transonic.log import logger from transonic.util import ( - get_source_without_decorator, format_str, + get_source_without_decorator, make_code_from_fdef_node, ) diff --git a/src/transonic/backends/for_test_set_backend.py b/src/transonic/backends/for_test_set_backend.py index 745b9e2..c5ab751 100644 --- a/src/transonic/backends/for_test_set_backend.py +++ b/src/transonic/backends/for_test_set_backend.py @@ -1,4 +1,4 @@ -from transonic import boost, jit, set_backend_for_this_module, Transonic +from transonic import Transonic, boost, jit, set_backend_for_this_module set_backend_for_this_module("python") diff --git a/src/transonic/backends/jax.py b/src/transonic/backends/jax.py index 8caf29d..5827e79 100644 --- a/src/transonic/backends/jax.py +++ b/src/transonic/backends/jax.py @@ -16,7 +16,7 @@ from typing import Optional -from transonic.analyses.extast import parse, unparse, CommentLine, gast +from transonic.analyses.extast import CommentLine, gast, parse, unparse from transonic.util import format_str from .py import PythonBackend, SubBackendJITPython @@ -32,7 +32,9 @@ def add_jax_comments(code): # Replace `import numpy as np` -> `import jax.numpy as np` if isinstance(node, gast.Import): if (alias := node.names[0]).name == "numpy": - g_alias = gast.alias(name="jax.numpy", asname=alias.asname or alias.name) + g_alias = gast.alias( + name="jax.numpy", asname=alias.asname or alias.name + ) node = gast.Import([g_alias]) # Replace `from numpy import eye` -> `from jax.numpy import eye` diff --git a/src/transonic/backends/numba.py b/src/transonic/backends/numba.py index 7e2c307..80e1c93 100644 --- a/src/transonic/backends/numba.py +++ b/src/transonic/backends/numba.py @@ -16,7 +16,7 @@ from typing import Optional -from transonic.analyses.extast import parse, unparse, CommentLine, gast +from transonic.analyses.extast import CommentLine, gast, parse, unparse from transonic.util import format_str from .py import PythonBackend, SubBackendJITPython diff --git a/src/transonic/backends/typing.py b/src/transonic/backends/typing.py index fa4e6f5..9b5f88d 100644 --- a/src/transonic/backends/typing.py +++ b/src/transonic/backends/typing.py @@ -1,4 +1,4 @@ -from transonic.typing import format_type_as_backend_type, MemLayout +from transonic.typing import MemLayout, format_type_as_backend_type normalized_types = {"float": "float64", "complex": "complex128", "bool_": "bool"} diff --git a/src/transonic/compiler.py b/src/transonic/compiler.py index 9cc9755..2bf0741 100644 --- a/src/transonic/compiler.py +++ b/src/transonic/compiler.py @@ -19,20 +19,20 @@ """ +import hashlib +import logging import multiprocessing +import os import subprocess -import time -from typing import Union, Optional -import sysconfig -import hashlib import sys -import os +import sysconfig +import time from datetime import datetime -import logging +from typing import Optional, Union from transonic import mpi -from transonic.mpi import Path, PathSeq from transonic.log import logger +from transonic.mpi import Path, PathSeq from transonic.progress import Progress ext_suffix = sysconfig.get_config_var("EXT_SUFFIX") or ".so" diff --git a/src/transonic/dist.py b/src/transonic/dist.py index 85f3ccb..d1f40fe 100644 --- a/src/transonic/dist.py +++ b/src/transonic/dist.py @@ -14,18 +14,18 @@ """ import os +import re import sys +from concurrent.futures import ThreadPoolExecutor as Pool from pathlib import Path from sysconfig import get_config_var from typing import Iterable -from concurrent.futures import ThreadPoolExecutor as Pool -import re from setuptools.command.build_ext import build_ext as SetuptoolsBuildExt try: - from Cython.Distutils.build_ext import build_ext as CythonBuildExt from Cython.Build import cythonize + from Cython.Distutils.build_ext import build_ext as CythonBuildExt except ImportError: build_ext_classes = [SetuptoolsBuildExt] can_import_cython = False @@ -43,11 +43,10 @@ build_ext_classes.insert(0, PythranBuildExt) can_import_pythran = True -from transonic.util import modification_date +from transonic.backends import backends, make_backend_files from transonic.config import backend_default -from transonic.backends import make_backend_files, backends -from transonic.util import can_import_accelerator from transonic.log import get_logger +from transonic.util import can_import_accelerator, modification_date __all__ = [ "PythranBuildExt", diff --git a/src/transonic/justintime.py b/src/transonic/justintime.py index f9cd0ec..079ae43 100644 --- a/src/transonic/justintime.py +++ b/src/transonic/justintime.py @@ -54,27 +54,27 @@ from functools import wraps from pathlib import Path -from transonic.analyses.justintime import analysis_jit +from transonic import mpi from transonic.aheadoftime import TransonicTemporaryJITMethod +from transonic.analyses.justintime import analysis_jit from transonic.backends import backends, get_backend_name_module -from transonic.config import has_to_replace, backend_default +from transonic.config import backend_default, has_to_replace from transonic.log import logger -from transonic import mpi from transonic.util import ( + _get_pathfile_from_frame, + can_import_accelerator, + format_str, + get_frame, + get_info_from_ipython, get_module_name, has_to_build, - path_root, - get_info_from_ipython, - make_hex, has_to_compile_at_import, import_from_path, is_method, - write_if_has_to_write, - can_import_accelerator, - format_str, + make_hex, + path_root, strtobool, - get_frame, - _get_pathfile_from_frame, + write_if_has_to_write, ) modules_backends = {backend_name: {} for backend_name in backends.keys()} diff --git a/src/transonic/log.py b/src/transonic/log.py index 89f46e9..1918c70 100644 --- a/src/transonic/log.py +++ b/src/transonic/log.py @@ -6,8 +6,8 @@ """ import logging -from types import MethodType import os +from types import MethodType def create_logger(name, show_time=False, show_path=False): diff --git a/src/transonic/mpi.py b/src/transonic/mpi.py index e2523dd..fa3a150 100644 --- a/src/transonic/mpi.py +++ b/src/transonic/mpi.py @@ -5,7 +5,7 @@ import os from pathlib import Path -from time import time, sleep +from time import sleep, time mpi_timeout = float(os.environ.get("TRANSONIC_MPI_TIMEOUT", "5")) diff --git a/src/transonic/progress.py b/src/transonic/progress.py index a13ed20..9f95caa 100644 --- a/src/transonic/progress.py +++ b/src/transonic/progress.py @@ -8,7 +8,6 @@ from transonic.log import logger - try: import rich except ImportError: @@ -28,4 +27,4 @@ def Progress(*args, **kwargs): logger.debug("Install rich for tracking progress.") else: logger.debug("Using rich for tracking progress.") - from rich.progress import track, Progress + from rich.progress import Progress, track diff --git a/src/transonic/run.py b/src/transonic/run.py index 04e6904..2608896 100644 --- a/src/transonic/run.py +++ b/src/transonic/run.py @@ -11,23 +11,22 @@ """ import argparse -from pathlib import Path -from glob import glob import sys +from glob import glob +from pathlib import Path from transonic import __version__ - -from transonic.compiler import wait_for_all_extensions, scheduler - -from .backends import backends +from transonic.analyses import analyse_files +from transonic.compiler import scheduler, wait_for_all_extensions from transonic.config import backend_default from transonic.log import logger from transonic.util import ( - has_to_build, - clear_cached_extensions, can_import_accelerator, + clear_cached_extensions, + has_to_build, ) -from transonic.analyses import analyse_files + +from .backends import backends doc = """ transonic: easily speedup your Python code with Pythran diff --git a/src/transonic/signatures.py b/src/transonic/signatures.py index 602f876..2f060c3 100644 --- a/src/transonic/signatures.py +++ b/src/transonic/signatures.py @@ -14,8 +14,8 @@ """ -import itertools import inspect +import itertools from typing import List from transonic.typing import format_type_as_backend_type, str2type diff --git a/src/transonic/typing.py b/src/transonic/typing.py index 128cd65..7f1b6d8 100644 --- a/src/transonic/typing.py +++ b/src/transonic/typing.py @@ -67,9 +67,9 @@ """ +import itertools import re from enum import Enum, auto -import itertools import numpy as np diff --git a/src/transonic/util.py b/src/transonic/util.py index 05cdc03..60d4287 100644 --- a/src/transonic/util.py +++ b/src/transonic/util.py @@ -45,13 +45,13 @@ """ -import os -import sys +import importlib.util import inspect +import os import re -from pathlib import Path -import importlib.util import shutil +import sys +from pathlib import Path from textwrap import dedent from typing import Callable @@ -101,17 +101,14 @@ def format_str(src_contents: str): from transonic import __version__ from transonic.analyses import extast - from transonic.compiler import ( ext_suffix, + has_to_build, make_hex, modification_date, - has_to_build, ) - from transonic.config import path_root, strtobool - __all__ = ["modification_date", "has_to_build", "path_root"] @@ -406,8 +403,8 @@ def query_yes_no(question: str, default: str = None, force: bool = False): def clear_cached_extensions(module_name: str, force: bool, backend: str): """Delete the cached extensions related to a module""" - from transonic.backends import backends from transonic import mpi + from transonic.backends import backends backend = backends[backend] path_jit = mpi.Path(backend.jit.path_base) diff --git a/src/transonic_cl/cythonize.py b/src/transonic_cl/cythonize.py index 626f7d4..e35af81 100644 --- a/src/transonic_cl/cythonize.py +++ b/src/transonic_cl/cythonize.py @@ -1,8 +1,8 @@ import sys from distutils.core import setup -from Cython.Build import cythonize import numpy as np +from Cython.Build import cythonize path = sys.argv.pop() sys.argv.extend(("build_ext", "--inplace")) diff --git a/src/transonic_cl/get_includes.py b/src/transonic_cl/get_includes.py index a5fd7db..b2c6008 100644 --- a/src/transonic_cl/get_includes.py +++ b/src/transonic_cl/get_includes.py @@ -1,8 +1,7 @@ import argparse import sys -from pathlib import Path - from importlib import import_module +from pathlib import Path def main(): diff --git a/src/transonic_cl/init_meson.py b/src/transonic_cl/init_meson.py index aba456a..4883f27 100644 --- a/src/transonic_cl/init_meson.py +++ b/src/transonic_cl/init_meson.py @@ -1,9 +1,7 @@ import argparse import sys - from pathlib import Path, PurePosixPath - template = """ python_sources = [ {sources} diff --git a/src/transonic_cl/run_backend.py b/src/transonic_cl/run_backend.py index 2b0cd37..402d644 100644 --- a/src/transonic_cl/run_backend.py +++ b/src/transonic_cl/run_backend.py @@ -8,14 +8,14 @@ """ +import logging +import os import subprocess import sys -import logging -from pathlib import Path import sysconfig -from time import time, sleep +from pathlib import Path from shutil import copyfile -import os +from time import sleep, time logger = logging.getLogger("transonic") logger.setLevel(logging.INFO) diff --git a/tests/backends/test_backends.py b/tests/backends/test_backends.py index f711125..a0d5717 100644 --- a/tests/backends/test_backends.py +++ b/tests/backends/test_backends.py @@ -1,10 +1,9 @@ from transonic.config import backend_default - from transonic.justintime import modules_backends def test_set_backend_for_this_module(): - from transonic.backends.for_test_set_backend import ts, func + from transonic.backends.for_test_set_backend import func, ts assert ts.backend.name == "python" assert func() == 0 diff --git a/tests/backends/test_backends_typing.py b/tests/backends/test_backends_typing.py index 188d358..b753054 100644 --- a/tests/backends/test_backends_typing.py +++ b/tests/backends/test_backends_typing.py @@ -1,7 +1,6 @@ import numpy as np from transonic import Array - from transonic.backends.typing import base_type_formatter diff --git a/tests/test_build_ext.py b/tests/test_build_ext.py index b0eed83..518db2b 100644 --- a/tests/test_build_ext.py +++ b/tests/test_build_ext.py @@ -1,16 +1,16 @@ import os -import sys -from pathlib import Path import runpy import shutil +import sys from contextlib import suppress +from pathlib import Path import pytest +from transonic.config import backend_default from transonic.dist import make_backend_files from transonic.mpi import nb_proc from transonic.path_data_tests import path_data_tests -from transonic.config import backend_default cwd = Path.cwd().absolute() setup_dir = path_data_tests / "test_packaging" diff --git a/tests/test_clean_dir.py b/tests/test_clean_dir.py index 1455179..97145f4 100644 --- a/tests/test_clean_dir.py +++ b/tests/test_clean_dir.py @@ -1,7 +1,6 @@ from unittest.mock import patch from transonic.backends import backends - from transonic_cl.clean_dir import main cmd = "transonic-clean-dir" diff --git a/tests/test_dist.py b/tests/test_dist.py index b2328b4..4c750cc 100644 --- a/tests/test_dist.py +++ b/tests/test_dist.py @@ -1,19 +1,17 @@ import shutil -from setuptools import Distribution from pprint import pformat import pytest +from setuptools import Distribution from transonic.config import backend_default - from transonic.dist import ( - detect_transonic_extensions, - modification_date, - make_backend_files, ParallelBuildExt, + detect_transonic_extensions, get_logger, + make_backend_files, + modification_date, ) - from transonic.mpi import nb_proc from transonic.path_data_tests import path_data_tests from transonic.util import can_import_accelerator diff --git a/tests/test_init.py b/tests/test_init.py index 06189f6..10ac91a 100644 --- a/tests/test_init.py +++ b/tests/test_init.py @@ -27,7 +27,7 @@ def test_not_transonified(): importlib.reload(for_test_init) - from _transonic_testing.for_test_init import func, func1, check_class + from _transonic_testing.for_test_init import check_class, func, func1 func(1, 3.14) func1(1.1, 2.2) diff --git a/tests/test_init_transonified.py b/tests/test_init_transonified.py index cc3c870..d2728bd 100644 --- a/tests/test_init_transonified.py +++ b/tests/test_init_transonified.py @@ -1,18 +1,18 @@ import importlib -import unittest import os -import time import sys +import time +import unittest +from transonic import mpi +from transonic.aheadoftime import modules from transonic.backends import backends from transonic.config import backend_default from transonic.util import ( - has_to_compile_at_import, - ext_suffix, can_import_accelerator, + ext_suffix, + has_to_compile_at_import, ) -from transonic.aheadoftime import modules -from transonic import mpi backend = backends[backend_default] diff --git a/tests/test_justintime.py b/tests/test_justintime.py index a402d81..8dc811f 100644 --- a/tests/test_justintime.py +++ b/tests/test_justintime.py @@ -1,17 +1,17 @@ -import sys import os -from time import sleep +import sys from shutil import rmtree +from time import sleep import numpy as np import pytest +from transonic import mpi from transonic.backends import backends from transonic.compiler import scheduler, wait_for_all_extensions +from transonic.config import backend_default from transonic.justintime import modules -from transonic import mpi from transonic.util import can_import_accelerator -from transonic.config import backend_default backend = backends[backend_default] scheduler.nb_cpus = 2 @@ -188,8 +188,8 @@ def test_main(): def test_jit_imported(): from _transonic_testing.for_test_justintime import ( - jitted_func_import, func_import, + jitted_func_import, ) result = jitted_func_import() diff --git a/tests/test_meson.py b/tests/test_meson.py index e243df1..f16cc2a 100644 --- a/tests/test_meson.py +++ b/tests/test_meson.py @@ -2,19 +2,18 @@ """ -import sys -import subprocess import os - -from shutil import copy +import subprocess +import sys from pathlib import Path +from shutil import copy from unittest.mock import patch import pytest -from transonic.run import run from transonic.config import backend_default from transonic.mpi import nb_proc +from transonic.run import run test_dir = Path(__file__).absolute().parent diff --git a/tests/test_run.py b/tests/test_run.py index 4308e00..203d844 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -1,6 +1,6 @@ +import os import sys import time -import os from shutil import rmtree import pytest @@ -11,7 +11,6 @@ from transonic.path_data_tests import path_data_tests from transonic.run import run - path_dir_out = path_data_tests / f"__{backend_default}__" header_suffixes = {"pythran": ".pythran", "cython": ".pxd"} diff --git a/tests/test_typing.py b/tests/test_typing.py index f55462c..227a4d8 100644 --- a/tests/test_typing.py +++ b/tests/test_typing.py @@ -1,25 +1,24 @@ import numpy as np +from transonic.backends.typing import base_type_formatter from transonic.typing import ( Array, - NDim, - str2type, - UnionMeta, - List, - ListMeta, Dict, DictMeta, - Set, - SetMeta, - typeof, - str2shape, + List, + ListMeta, MemLayout, + NDim, Optional, + Set, + SetMeta, + UnionMeta, const, + str2shape, + str2type, + typeof, ) -from transonic.backends.typing import base_type_formatter - def compare_array_types(A0, A1): assert A0.dtype == A1.dtype diff --git a/tests/test_util.py b/tests/test_util.py index edce53f..116266d 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -1,5 +1,5 @@ from transonic import util -from transonic.util import query_yes_no, timeit, print_versions, timeit_verbose +from transonic.util import print_versions, query_yes_no, timeit, timeit_verbose def test_query_yes_no():