Skip to content

Commit

Permalink
Format with isort
Browse files Browse the repository at this point in the history
  • Loading branch information
paugier committed Jun 5, 2024
1 parent 661e839 commit fe8913d
Show file tree
Hide file tree
Showing 108 changed files with 316 additions and 310 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import gast
import numpy as np


const = 1
foo = 1

Expand Down
3 changes: 1 addition & 2 deletions _transonic_testing/src/_transonic_testing/for_test_init.py
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from transonic import jit, boost
from transonic import boost, jit
from transonic.mpi import Path


Expand Down Expand Up @@ -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

Expand Down
6 changes: 4 additions & 2 deletions doc/examples/bench_expr_broadcast/bench.py
Original file line number Diff line number Diff line change
@@ -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"]
Expand Down Expand Up @@ -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
)
3 changes: 2 additions & 1 deletion doc/examples/bench_proj_perp/bench.py
Original file line number Diff line number Diff line change
@@ -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[:,:,:]"
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/bench_row_sum/bench.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from subprocess import getoutput
import sys
from subprocess import getoutput

decorator = "boost"
if "jit" in sys.argv:
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/bench_row_sum/row_sum_boost.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions doc/examples/bench_row_sum/row_sum_jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/bench_row_sum/util.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/bench_trigo/bench.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np

from transonic import boost, Array
from transonic import Array, boost

A = Array[float, "1d"]

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions doc/examples/blocks_type_hints.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion doc/examples/classic_func_using_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
4 changes: 2 additions & 2 deletions doc/examples/import_local_module/mod0.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
1 change: 0 additions & 1 deletion doc/examples/import_local_module/mod1.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import numpy as np

const = 1
Expand Down
9 changes: 5 additions & 4 deletions doc/examples/inlined/bug_beniget.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion doc/examples/issues/issue29_blocks_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion doc/examples/issues/issue29_blocks_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/local_module.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def multiply(a, b):
return a * b
return a * b
9 changes: 4 additions & 5 deletions doc/examples/packages/package_cythran/check.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

__version__ = "0.0.1"
__version__ = "0.0.1"
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

@boost
def func_numba(a):
return a ** 2
return a**2
6 changes: 3 additions & 3 deletions doc/examples/packages/package_cythran/package_cythran/util.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions doc/examples/packages/package_cythran/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions doc/examples/packages/package_simple/check.py
Original file line number Diff line number Diff line change
@@ -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"]

Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

__version__ = "0.0.1"
__version__ = "0.0.1"
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
7 changes: 3 additions & 4 deletions doc/examples/packages/package_simple/package_simple/util.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
9 changes: 5 additions & 4 deletions doc/examples/packages/package_simple/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand All @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion doc/examples/type_hints_notemplate.py
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion doc/examples/using_jit_diff_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from transonic import jit, Type
from transonic import Type, jit

T = Type(int, float)

Expand Down
Loading

0 comments on commit fe8913d

Please sign in to comment.