mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[BE][CI] bump ruff
to 0.9.2: multiline assert
statements (#144546)
Reference: https://docs.astral.sh/ruff/formatter/black/#assert-statements > Unlike Black, Ruff prefers breaking the message over breaking the assertion, similar to how both Ruff and Black prefer breaking the assignment value over breaking the assignment target: > > ```python > # Input > assert ( > len(policy_types) >= priority + num_duplicates > ), f"This tests needs at least {priority+num_duplicates} many types." > > > # Black > assert ( > len(policy_types) >= priority + num_duplicates > ), f"This tests needs at least {priority+num_duplicates} many types." > > # Ruff > assert len(policy_types) >= priority + num_duplicates, ( > f"This tests needs at least {priority + num_duplicates} many types." > ) > ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/144546 Approved by: https://github.com/malfet
This commit is contained in:
committed by
PyTorch MergeBot
parent
f0d00421cf
commit
c73a92fbf5
@ -52,17 +52,17 @@ FP16_REDUCED_PRECISION = {"atol": 1e-5, "rtol": 1e-4}
|
||||
|
||||
|
||||
def rosenbrock(tensor):
|
||||
assert tensor.size() == torch.Size(
|
||||
[2]
|
||||
), f"Requires tensor with 2 scalars but got {tensor.size()}"
|
||||
assert tensor.size() == torch.Size([2]), (
|
||||
f"Requires tensor with 2 scalars but got {tensor.size()}"
|
||||
)
|
||||
x, y = tensor
|
||||
return (1 - x) ** 2 + 100 * (y - x**2) ** 2
|
||||
|
||||
|
||||
def drosenbrock(tensor):
|
||||
assert tensor.size() == torch.Size(
|
||||
[2]
|
||||
), f"Requires tensor with 2 scalars but got {tensor.size()}"
|
||||
assert tensor.size() == torch.Size([2]), (
|
||||
f"Requires tensor with 2 scalars but got {tensor.size()}"
|
||||
)
|
||||
x, y = tensor
|
||||
return torch.stack((-400 * x * (y - x**2) - 2 * (1 - x), 200 * (y - x**2)))
|
||||
|
||||
|
Reference in New Issue
Block a user