Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jul 1, 2024
1 parent 54ff4c1 commit e7f4fd0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 30 deletions.
12 changes: 4 additions & 8 deletions examples/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@


class Timer(Protocol):
def start(self):
...
def start(self): ...

def stop(self):
"""
Expand Down Expand Up @@ -70,14 +69,11 @@ def stop(self):
# manager so that we can run both CuPy and SciPy
# programs with resource scoping.
class DummyScope:
def __init__(self):
...
def __init__(self): ...

def __enter__(self):
...
def __enter__(self): ...

def __exit__(self, _, __, ___):
...
def __exit__(self, _, __, ___): ...

def __getitem__(self, item):
return self
Expand Down
8 changes: 3 additions & 5 deletions examples/pde.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@
# Compute the rhs. Note that we non-dimensionalize the coordinates
# x and y with the size of the domain in their respective dire-
# ctions.
b = np.sin(np.pi * X) * np.cos(np.pi * Y) + np.sin(5.0 * np.pi * X) * np.cos(
5.0 * np.pi * Y
)
b = np.sin(np.pi * X) * np.cos(np.pi * Y) + np.sin(
5.0 * np.pi * X
) * np.cos(5.0 * np.pi * Y)

# b is currently a 2D array. We need to convert it to a column-major
# ordered 1D array. This is done with the flatten numpy function.
Expand All @@ -98,7 +98,6 @@
# Allocate array for the (full) solution, including boundary values
p = np.empty((nx, ny))


def d2_mat_dirichlet_2d(nx, ny, dx, dy):
"""
Constructs the matrix for the centered second-order accurate
Expand Down Expand Up @@ -165,7 +164,6 @@ def d2_mat_dirichlet_2d(nx, ny, dx, dy):
# Return the final array
return d2mat


def p_exact_2d(X, Y):
"""Computes the exact solution of the Poisson equation in the domain
[0, 1]x[-0.5, 0.5] with rhs:
Expand Down
8 changes: 5 additions & 3 deletions install.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ def flatten(list):

option_strings = flatten(
[
[opt, "--no-" + opt[2:], "--no" + opt[2:]]
if opt.startswith("--")
else [opt]
(
[opt, "--no-" + opt[2:], "--no" + opt[2:]]
if opt.startswith("--")
else [opt]
)
for opt in option_strings
]
)
Expand Down
3 changes: 1 addition & 2 deletions sparse/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ def should_wrap(obj: object) -> bool:


class AnyCallable(Protocol):
def __call__(self, *args: Any, **kwargs: Any) -> Any:
...
def __call__(self, *args: Any, **kwargs: Any) -> Any: ...


def wrap(func: AnyCallable) -> Any:
Expand Down
6 changes: 2 additions & 4 deletions src/sparse/array/csc/spmm_template.inl
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,13 @@ struct SpMMCSCImpl {

// If we're running with OMP's, then we need to use an non-exclusive
// accessor instead of an exclusive one.
auto A_vals = [&args]() -> auto
{
auto A_vals = [&args]() -> auto {
if constexpr (KIND == VariantKind::CPU) {
return args.A_vals.reduce_accessor<SumReduction<VAL_TY>, true, 2>();
} else {
return args.A_vals.reduce_accessor<SumReduction<VAL_TY>, false, 2>();
}
}
();
}();
auto B_pos = args.B_pos.read_accessor<Rect<1>, 1>();
auto B_crd = args.B_crd.read_accessor<INDEX_TY, 1>();
auto B_vals = args.B_vals.read_accessor<VAL_TY, 1>();
Expand Down
6 changes: 2 additions & 4 deletions src/sparse/array/csc/spmv_template.inl
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ struct CSCSpMVColSplitImpl {
using INDEX_TY = legate_type_of<INDEX_CODE>;
using VAL_TY = legate_type_of<VAL_CODE>;

auto y = [&args]() -> auto
{
auto y = [&args]() -> auto {
if constexpr (KIND == VariantKind::CPU) {
return args.y.reduce_accessor<SumReduction<VAL_TY>, true /* exclusive */, 1>();
} else {
Expand All @@ -50,8 +49,7 @@ struct CSCSpMVColSplitImpl {
// back into CSR up front.
return args.y.reduce_accessor<SumReduction<VAL_TY>, false /* exclusive */, 1>();
}
}
();
}();
auto A_pos = args.A_pos.read_accessor<Rect<1>, 1>();
auto A_crd = args.A_crd.read_accessor<INDEX_TY, 1>();
auto A_vals = args.A_vals.read_accessor<VAL_TY, 1>();
Expand Down
6 changes: 2 additions & 4 deletions src/sparse/array/csr/add.cu
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,7 @@ struct AddCSRCSRImpl<VariantKind::GPU> {
CHECK_CUSPARSE(cusparseSetMatIndexBase(C, index_base));
CHECK_CUSPARSE(cusparseSetMatType(C, CUSPARSE_MATRIX_TYPE_GENERAL));

auto funcs = []() -> auto
{
auto funcs = []() -> auto {
if constexpr (VAL_CODE == Type::Code::FLOAT32) {
return std::make_pair(cusparseScsrgeam2_bufferSizeExt, cusparseScsrgeam2);
} else if constexpr (VAL_CODE == Type::Code::FLOAT64) {
Expand All @@ -289,8 +288,7 @@ struct AddCSRCSRImpl<VariantKind::GPU> {
} else {
return std::make_pair(cusparseZcsrgeam2_bufferSizeExt, cusparseZcsrgeam2);
}
}
();
}();

using cusparse_val_ty = old_cusparse_type_of<VAL_CODE>;

Expand Down

0 comments on commit e7f4fd0

Please sign in to comment.