Skip to content

Commit 53135a6

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent d0f5f82 commit 53135a6

2 files changed

Lines changed: 26 additions & 17 deletions

File tree

play.ipynb

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,40 @@
2020
"\n",
2121
"from __future__ import annotations\n",
2222
"\n",
23-
"import numpy as np\n",
24-
"import pytest # type: ignore[import]\n",
25-
"import numba\n",
26-
"import dask.array as da\n",
27-
"from typing import Callable\n",
23+
"from collections.abc import Callable\n",
2824
"from functools import partial\n",
2925
"\n",
30-
"from squidpy._utils import parallelize, Signal\n",
31-
"\n",
26+
"import dask.array as da\n",
27+
"import numba\n",
28+
"import numpy as np\n",
29+
"import pytest # type: ignore[import]\n",
3230
"\n",
31+
"from squidpy._utils import Signal, parallelize\n",
3332
"\n",
3433
"# Functions to be parallelized\n",
3534
"\n",
35+
"\n",
3636
"@numba.njit(parallel=True)\n",
3737
"def numba_parallel_func(x, y) -> np.ndarray:\n",
3838
" return x * 2 + y\n",
3939
"\n",
40+
"\n",
4041
"@numba.njit(parallel=False)\n",
4142
"def numba_serial_func(x, y) -> np.ndarray:\n",
4243
" return x * 2 + y\n",
4344
"\n",
45+
"\n",
4446
"def dask_func(x, y) -> np.ndarray:\n",
4547
" return (da.from_array(x) * 2 + y).compute()\n",
4648
"\n",
49+
"\n",
4750
"def vanilla_func(x, y) -> np.ndarray:\n",
4851
" return x * 2 + y\n",
4952
"\n",
53+
"\n",
5054
"# Mock runner function\n",
5155
"\n",
56+
"\n",
5257
"def mock_runner(x, y, queue, func):\n",
5358
" for i in range(len(x)):\n",
5459
" x[i] = func(x[i], y)\n",
@@ -66,8 +71,7 @@
6671
" \"numba_serial\": numba_serial_func,\n",
6772
" \"dask\": dask_func,\n",
6873
" \"vanilla\": vanilla_func,\n",
69-
" }[request.param]\n",
70-
"\n"
74+
" }[request.param]"
7175
]
7276
},
7377
{
@@ -140,7 +144,7 @@
140144
"result = p_func(arr2)[0]\n",
141145
"assert len(result) == len(expected), f\"Expected: {expected} but got {result}. Length mismatch\"\n",
142146
"for i in range(len(arr1)):\n",
143-
" assert np.all(result[i] == expected[i]), f\"Expected {expected[i]} but got {result[i]}\"\n"
147+
" assert np.all(result[i] == expected[i]), f\"Expected {expected[i]} but got {result[i]}\""
144148
]
145149
},
146150
{

tests/utils/test_parallelize.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,40 @@
22

33
from __future__ import annotations
44

5-
import numpy as np
6-
import pytest # type: ignore[import]
7-
import numba
8-
import dask.array as da
9-
from typing import Callable
5+
from collections.abc import Callable
106
from functools import partial
117

12-
from squidpy._utils import parallelize, Signal
13-
8+
import dask.array as da
9+
import numba
10+
import numpy as np
11+
import pytest # type: ignore[import]
1412

13+
from squidpy._utils import Signal, parallelize
1514

1615
# Functions to be parallelized
1716

17+
1818
@numba.njit(parallel=True)
1919
def numba_parallel_func(x, y) -> np.ndarray:
2020
return x * 2 + y
2121

22+
2223
@numba.njit(parallel=False)
2324
def numba_serial_func(x, y) -> np.ndarray:
2425
return x * 2 + y
2526

27+
2628
def dask_func(x, y) -> np.ndarray:
2729
return (da.from_array(x) * 2 + y).compute()
2830

31+
2932
def vanilla_func(x, y) -> np.ndarray:
3033
return x * 2 + y
3134

35+
3236
# Mock runner function
3337

38+
3439
def mock_runner(x, y, queue, func):
3540
for i in range(len(x)):
3641
print(len(x[i]), len(y))

0 commit comments

Comments
 (0)