Skip to content

Commit

Permalink
Enable ruff.isort, apply fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Jul 9, 2024
1 parent f48cc34 commit 6745d1a
Show file tree
Hide file tree
Showing 118 changed files with 1,812 additions and 1,172 deletions.
3 changes: 2 additions & 1 deletion contrib/c-integer-semantics.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python

from os import system
import ctypes
from os import system


C_SRC = """
#include <stdlib.h>
Expand Down
5 changes: 3 additions & 2 deletions contrib/mem-pattern-explorer/pattern_vis.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np


# Inspired by a visualization used in the Halide tutorial
# https://www.youtube.com/watch?v=3uiEyEKji0M

Expand All @@ -9,8 +10,8 @@ def div_ceil(nr, dr):


def product(iterable):
from operator import mul
from functools import reduce
from operator import mul
return reduce(mul, iterable, 1)


Expand Down Expand Up @@ -42,8 +43,8 @@ def nsubgroups(self):
return div_ceil(product(self.lsize), self.subgroup_size)

def animate(self, f, interval=200):
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import matplotlib.pyplot as plt

fig = plt.figure()

Expand Down
3 changes: 3 additions & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from urllib.request import urlopen


_conf_url = "https://raw.githubusercontent.com/inducer/sphinxconfig/main/sphinxconfig.py" # noqa
with urlopen(_conf_url) as _inf:
exec(compile(_inf.read(), _conf_url, "exec"), globals())
Expand Down Expand Up @@ -44,6 +45,8 @@
# this needs a setting of the same name across all packages involved, that's
# why this name is as global-sounding as it is.
import sys


sys._BUILDING_SPHINX_DOCS = True

nitpicky = True
Expand Down
2 changes: 2 additions & 0 deletions examples/fortran/matmul-driver.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import numpy as np
import numpy.linalg as la

import pyopencl as cl
import pyopencl.array
import pyopencl.clrandom

import loopy as lp


Expand Down
3 changes: 2 additions & 1 deletion examples/python/call-external.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import loopy as lp
import numpy as np

import loopy as lp
from loopy.diagnostic import LoopyError
from loopy.target.c import CTarget
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401
Expand Down
2 changes: 2 additions & 0 deletions examples/python/find-centers.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import numpy as np

import pyopencl as cl

import loopy as lp
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


cl_ctx = cl.create_some_context()

knl = lp.make_kernel(
Expand Down
6 changes: 6 additions & 0 deletions examples/python/global_barrier_removal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import numpy as np

import loopy as lp
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


knl = lp.make_kernel(
"{ [i,k]: 0<=i<n and 0<=k<3 }",
"""
Expand All @@ -20,9 +22,13 @@

# schedule
from loopy.preprocess import preprocess_kernel


knl = preprocess_kernel(knl)

from loopy.schedule import get_one_linearized_kernel


knl = knl.with_kernel(get_one_linearized_kernel(knl["loopy_kernel"],
knl.callables_table))

Expand Down
5 changes: 4 additions & 1 deletion examples/python/hello-loopy.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import numpy as np
import loopy as lp

import pyopencl as cl
import pyopencl.array

import loopy as lp
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


# setup
# -----
ctx = cl.create_some_context()
Expand Down
17 changes: 11 additions & 6 deletions examples/python/ispc-stream-harness.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import loopy as lp
import numpy as np
import numpy.linalg as la
import ctypes
import ctypes.util
import os
from time import time
from tempfile import TemporaryDirectory
from time import time

from loopy.tools import (empty_aligned, address_from_numpy,
build_ispc_shared_lib, cptr_from_numpy)
import numpy as np
import numpy.linalg as la

import loopy as lp
from loopy.tools import (
address_from_numpy,
build_ispc_shared_lib,
cptr_from_numpy,
empty_aligned,
)
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


Expand Down
2 changes: 2 additions & 0 deletions examples/python/rank-one.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# SETUPBEGIN
import numpy as np

import pyopencl as cl

import loopy as lp
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

Expand Down
1 change: 1 addition & 0 deletions examples/python/sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import loopy as lp
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


k = lp.make_kernel([
"{ [i] : 0 <= i < m }",
"{ [j] : 0 <= j < length }"],
Expand Down
2 changes: 2 additions & 0 deletions examples/python/vector-types.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import numpy as np

import pyopencl as cl
import pyopencl.array

import loopy as lp
from loopy.version import LOOPY_USE_LANGUAGE_VERSION_2018_2 # noqa: F401


ctx = cl.create_some_context()
queue = cl.CommandQueue(ctx)

Expand Down
Loading

0 comments on commit 6745d1a

Please sign in to comment.