Skip to content

Commit 0391975

Browse files
committed
Fix some linter issues
Original NumPy Commit: 8e2af026d9ee4fe919f77ec52a86ddc2de55705f
1 parent b8db551 commit 0391975

File tree

6 files changed

+16
-8
lines changed

6 files changed

+16
-8
lines changed

array_api_strict/_array_object.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
class _cpu_device:
4646
def __repr__(self):
4747
return "CPU_DEVICE"
48+
4849
CPU_DEVICE = _cpu_device()
4950

5051
class Array:
@@ -186,6 +187,7 @@ def _promote_scalar(self, scalar):
186187
TypeError when the scalar type is incompatible with the dtype of self.
187188
"""
188189
from ._data_type_functions import iinfo
190+
189191
# Note: Only Python scalar types that match the array dtype are
190192
# allowed.
191193
if isinstance(scalar, bool):

array_api_strict/_creation_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
def _check_valid_dtype(dtype):
2121
# Note: Only spelling dtypes as the dtype objects is supported.
22-
if not dtype in (None,) + _all_dtypes:
22+
if dtype not in (None,) + _all_dtypes:
2323
raise ValueError("dtype must be one of the supported dtypes")
2424

2525

array_api_strict/_dtypes.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,15 @@ def __eq__(self, other):
1818
# Avoid the user error of array_api_strict.float32 == numpy.float32,
1919
# which gives False. Making == error is probably too egregious, so
2020
# warn instead.
21-
if isinstance(other, np.dtype) or (isinstance(other, type) and issubclass(other, np.generic)):
22-
warnings.warn("""You are comparing a array_api_strict dtype against \
21+
if isinstance(other, np.dtype) or (
22+
isinstance(other, type) and issubclass(other, np.generic)
23+
):
24+
warnings.warn(
25+
"""You are comparing a array_api_strict dtype against \
2326
a NumPy native dtype object, but you probably don't want to do this. \
24-
array_api_strict dtype objects compare unequal to their NumPy equivalents. Such \
25-
cross-library comparison is not supported by the standard.""")
27+
array_api_strict dtype objects compare unequal to their NumPy equivalents. \
28+
Such cross-library comparison is not supported by the standard."""
29+
)
2630
if not isinstance(other, _DType):
2731
return NotImplemented
2832
return self._np_dtype == other._np_dtype
@@ -34,6 +38,7 @@ def __hash__(self):
3438
# can be used as dict keys.
3539
return hash(self._np_dtype)
3640

41+
3742
int8 = _DType("int8")
3843
int16 = _DType("int16")
3944
int32 = _DType("int32")

array_api_strict/_typing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,10 @@ class NestedSequence(Protocol[_T_co]):
3838
def __getitem__(self, key: int, /) -> _T_co | NestedSequence[_T_co]: ...
3939
def __len__(self, /) -> int: ...
4040

41+
4142
Device = _cpu_device
4243

43-
Dtype =_DType
44+
Dtype = _DType
4445

4546
if sys.version_info >= (3, 12):
4647
from collections.abc import Buffer as SupportsBufferProtocol

array_api_strict/linalg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
float32,
77
float64,
88
complex64,
9-
complex128
9+
complex128,
1010
)
1111
from ._data_type_functions import finfo
1212
from ._manipulation_functions import reshape

array_api_strict/tests/test_indexing_functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
@pytest.mark.parametrize(
77
"x, indices, axis, expected",
88
[
9-
([2, 3], [1, 1, 0], 0, [3, 3, 2]),
9+
([2, 3], [1, 1, 0], 0, [3, 3, 2]),
1010
([2, 3], [1, 1, 0], -1, [3, 3, 2]),
1111
([[2, 3]], [1], -1, [[3]]),
1212
([[2, 3]], [0, 0], 0, [[2, 3], [2, 3]]),

0 commit comments

Comments
 (0)