mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Enable ruff rule E721 (#165162)
`E721` checks for object type comparisons using == and other comparison operators. This is useful because it is recommended to use `is` for type comparisons. Pull Request resolved: https://github.com/pytorch/pytorch/pull/165162 Approved by: https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
a33f85e791
commit
8de85896e0
@ -4162,7 +4162,7 @@ class TestBinaryUfuncs(TestCase):
|
||||
for i in complex_exponents if exp_dtype.is_complex else exponents:
|
||||
out_dtype_scalar_exp = (
|
||||
torch.complex128
|
||||
if base_dtype.is_complex or type(i) == complex
|
||||
if base_dtype.is_complex or type(i) is complex
|
||||
else torch.float64
|
||||
)
|
||||
expected_scalar_exp = torch.from_numpy(np.float_power(to_np(base), i))
|
||||
@ -4190,7 +4190,7 @@ class TestBinaryUfuncs(TestCase):
|
||||
for i in complex_exponents if base_dtype.is_complex else exponents:
|
||||
out_dtype_scalar_base = (
|
||||
torch.complex128
|
||||
if exp_dtype.is_complex or type(i) == complex
|
||||
if exp_dtype.is_complex or type(i) is complex
|
||||
else torch.float64
|
||||
)
|
||||
expected_scalar_base = torch.from_numpy(np.float_power(i, to_np(exp)))
|
||||
@ -4205,9 +4205,9 @@ class TestBinaryUfuncs(TestCase):
|
||||
def test_float_power_exceptions(self, device):
|
||||
def _promo_helper(x, y):
|
||||
for i in (x, y):
|
||||
if type(i) == complex:
|
||||
if type(i) is complex:
|
||||
return torch.complex128
|
||||
elif type(i) == torch.Tensor and i.is_complex():
|
||||
elif type(i) is torch.Tensor and i.is_complex():
|
||||
return torch.complex128
|
||||
return torch.double
|
||||
|
||||
|
Reference in New Issue
Block a user