Skip to content

Commit c44f000

Browse files
alexfiklinducer
authored andcommitted
fix: some non-enabled ruff errors
1 parent 9f03eb9 commit c44f000

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

arraycontext/impl/pytato/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -796,9 +796,9 @@ def call_loopy(self, program, **kwargs):
796796
elif isinstance(arg, TaggableCLArray):
797797
arg = self.thaw(arg)
798798
else:
799-
raise ValueError(f"call_loopy argument '{kw}' expected to be an"
800-
" instance of 'pytato.Array', 'Number' or"
801-
f"'TaggableCLArray', got '{type(arg)}'")
799+
raise TypeError(f"call_loopy argument '{kw}' expected to be an"
800+
" instance of 'pytato.Array', 'Number' or"
801+
f"'TaggableCLArray', got '{type(arg)}'")
802802

803803
processed_kwargs[kw] = arg
804804

arraycontext/impl/pytato/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,8 @@ def map_data_wrapper(self, expr: DataWrapper) -> Array:
213213
import numpy as np
214214

215215
if not isinstance(expr.data, np.ndarray):
216-
raise ValueError("TransferFromNumpyMapper: tried to transfer data that "
217-
"is already on the device")
216+
raise ValueError(f"{type(self).__name__}: tried to transfer data that "
217+
"is already on the device")
218218

219219
# Ideally, this code should just do
220220
# return self.actx.from_numpy(expr.data).tagged(expr.tags),
@@ -245,7 +245,7 @@ def map_data_wrapper(self, expr: DataWrapper) -> Array:
245245

246246
import arraycontext.impl.pyopencl.taggable_cl_array as tga
247247
if not isinstance(expr.data, tga.TaggableCLArray):
248-
raise ValueError("TransferToNumpyMapper: tried to transfer data that "
248+
raise ValueError(f"{type(self).__name__}: tried to transfer data that "
249249
"is already on the host")
250250

251251
np_data = self.actx.to_numpy(expr.data)

arraycontext/pytest.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ def __init__(self, device: cl.Device) -> None:
7979
def is_available(cls) -> bool:
8080
try:
8181
import pyopencl # noqa: F401 # pyright: ignore[reportUnusedImport]
82-
return True
8382
except ImportError:
8483
return False
84+
else:
85+
return True
8586

8687
def get_command_queue(self) -> tuple[cl.Context, cl.CommandQueue]:
8788
# Get rid of leftovers from past tests.
@@ -155,9 +156,10 @@ def is_available(cls) -> bool:
155156
try:
156157
import pyopencl # noqa: F401 # pyright: ignore[reportUnusedImport]
157158
import pytato # noqa: F401 # pyright: ignore[reportUnusedImport]
158-
return True
159159
except ImportError:
160160
return False
161+
else:
162+
return True
161163

162164
@property
163165
def actx_class(self) -> type[ArrayContext]:
@@ -203,9 +205,10 @@ def __init__(self, *args, **kwargs) -> None:
203205
def is_available(cls) -> bool:
204206
try:
205207
import jax # noqa: F401 # pyright: ignore[reportUnusedImport]
206-
return True
207208
except ImportError:
208209
return False
210+
else:
211+
return True
209212

210213
@override
211214
def __call__(self) -> ArrayContext:
@@ -231,9 +234,10 @@ def is_available(cls) -> bool:
231234
try:
232235
import jax # noqa: F401 # pyright: ignore[reportUnusedImport]
233236
import pytato # noqa: F401 # pyright: ignore[reportUnusedImport]
234-
return True
235237
except ImportError:
236238
return False
239+
else:
240+
return True
237241

238242
@override
239243
def __call__(self) -> ArrayContext:

0 commit comments

Comments
 (0)