Skip to content

Commit bc6ebce

Browse files
committed
lint
1 parent 5b7f588 commit bc6ebce

File tree

6 files changed

+12
-16
lines changed

6 files changed

+12
-16
lines changed

torch_np/_dtypes_impl.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ def result_type_impl(*tensors):
5555

5656
SCALAR_TYPES = (int, bool, float, complex)
5757

58+
5859
def _dtype_for_scalar(py_type):
59-
return {bool: torch.bool, int: torch.int64, float: torch.float64, complex: torch.complex128}[py_type]
60+
return {
61+
bool: torch.bool,
62+
int: torch.int64,
63+
float: torch.float64,
64+
complex: torch.complex128,
65+
}[py_type]
6066

6167

6268
categories = [
@@ -86,7 +92,7 @@ def nep50_to_tensors(x1, x2):
8692
x1 = torch.as_tensor(x1, dtype=_dtype_for_scalar(x1_type))
8793
x2 = torch.as_tensor(x2, dtype=_dtype_for_scalar(x2_type))
8894
return x1, x2
89-
elif not(x1_is_weak or x2_is_weak):
95+
elif not (x1_is_weak or x2_is_weak):
9096
# two tensors: nothing to do here
9197
return x1, x2
9298
else:
@@ -99,11 +105,7 @@ def nep50_to_tensors(x1, x2):
99105
cat_weak = category(weak_dtype)
100106
cat_not_weak = category(not_weak.dtype)
101107

102-
dt = (
103-
not_weak.dtype
104-
if cat_weak <= cat_not_weak
105-
else dtype_for_cat[cat_weak]
106-
)
108+
dt = not_weak.dtype if cat_weak <= cat_not_weak else dtype_for_cat[cat_weak]
107109

108110
# special-case complex + float32
109111
if weak_dtype.is_complex and not_weak.dtype == torch.float32:

torch_np/_ndarray.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -501,9 +501,7 @@ def array(
501501

502502
def asarray(a, dtype=None, order="K", *, like=None):
503503
# The result of the public `np.asarray(obj)` is not weakly typed.
504-
return array(
505-
a, dtype=dtype, order=order, like=like, copy=False, ndmin=0
506-
)
504+
return array(a, dtype=dtype, order=order, like=like, copy=False, ndmin=0)
507505

508506

509507
def from_dlpack(x, /):

torch_np/_normalizations.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
NotImplementedType = typing.TypeVar("NotImplementedType")
4141

4242

43-
4443
def normalize_array_like(x, parm=None):
4544
from ._ndarray import asarray
4645

torch_np/_ufuncs.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from . import _binary_ufuncs_impl, _dtypes_impl, _helpers, _unary_ufuncs_impl, _util
88
from ._normalizations import (
99
ArrayLike,
10-
Scalar,
1110
CastingModes,
1211
DTypeLike,
1312
NotImplementedType,
1413
OutArray,
14+
Scalar,
1515
normalizer,
1616
)
1717

@@ -77,7 +77,7 @@ def wrapped(
7777
# matmul's signature is _slightly_ different from other ufuncs:
7878
# - no where=...
7979
# - additional axis=..., axes=...
80-
# - no NEP50 scalars in or out
80+
# - no NEP50 scalars in or out
8181
#
8282
@normalizer
8383
def matmul(

torch_np/_util.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,5 +226,3 @@ def _coerce_to_tensor(obj, dtype=None, copy=False, ndmin=0):
226226
tensor = tensor.clone()
227227

228228
return tensor
229-
230-

torch_np/tests/test_nep50_examples.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,4 +91,3 @@ def test_nep50_exceptions(example):
9191

9292
assert_allclose(result, new, atol=1e-16)
9393
assert result.dtype == new.dtype
94-

0 commit comments

Comments
 (0)