Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CodeStyle][Ruff][BUAA][F-[21-27]] Fix ruff FURB diagnostic for 7 files in test/{legacy_test, xpu} and tools/ #67279

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/legacy_test/test_dist_fleet_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ def is_listen_failed(logx):
listen_rgx = "Fail to listen"

with open(logx, "r") as rb:
for line in rb.readlines():
for line in rb:
if listen_rgx in line:
is_lf = True
break
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_hsigmoid_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def find_latest_set(num):
return 1 + int(math.floor(math.log(num, 2)))
return 1 + int(math.floor(math.log2(num)))


class CodeTable:
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_imperative_deepcf.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def load_data(self):
num_users = -1
num_items = -1
with open(self.data_path, 'r') as f:
for l in f.readlines():
for l in f:
uid, iid, rating = (int(v) for v in l.split('\t'))
num_users = max(num_users, uid + 1)
num_items = max(num_items, iid + 1)
Expand Down
2 changes: 1 addition & 1 deletion test/legacy_test/test_nan_inf.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def check_op_count(self, log, expected_op_count=None):
expected_value,
f"The number of operator < {op_type} > is expected to be {expected_value}, but received {actual_value}.",
)
print("")
print()

def run_check_nan_inf(self, cmd, expected_op_count=None):
returncode, out, err = self.run_command(cmd)
Expand Down
32 changes: 12 additions & 20 deletions test/legacy_test/test_put_along_axis_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,11 +409,9 @@ def setUp(self):
for i in range(5):
for j in range(5):
for k in range(5):
self.target[i, self.index[i, j, k], k] = (
self.value[i, j, k]
if self.value[i, j, k]
< self.target[i, self.index[i, j, k], k]
else self.target[i, self.index[i, j, k], k]
self.target[i, self.index[i, j, k], k] = min(
self.target[i, self.index[i, j, k], k],
self.value[i, j, k],
)
self.inputs = {
'Input': self.xnp,
Expand Down Expand Up @@ -458,11 +456,9 @@ def setUp(self):
for i in range(5):
for j in range(5):
for k in range(5):
self.target[i, self.index[i, j, k], k] = (
self.value[i, j, k]
if self.value[i, j, k]
< self.target[i, self.index[i, j, k], k]
else self.target[i, self.index[i, j, k], k]
self.target[i, self.index[i, j, k], k] = min(
self.target[i, self.index[i, j, k], k],
self.value[i, j, k],
)
self.inputs = {
'Input': self.xnp,
Expand Down Expand Up @@ -503,11 +499,9 @@ def setUp(self):
for i in range(5):
for j in range(5):
for k in range(5):
self.target[i, self.index[i, j, k], k] = (
self.value[i, j, k]
if self.value[i, j, k]
> self.target[i, self.index[i, j, k], k]
else self.target[i, self.index[i, j, k], k]
self.target[i, self.index[i, j, k], k] = max(
self.target[i, self.index[i, j, k], k],
self.value[i, j, k],
)
self.inputs = {
'Input': self.xnp,
Expand Down Expand Up @@ -552,11 +546,9 @@ def setUp(self):
for i in range(5):
for j in range(5):
for k in range(5):
self.target[i, self.index[i, j, k], k] = (
self.value[i, j, k]
if self.value[i, j, k]
> self.target[i, self.index[i, j, k], k]
else self.target[i, self.index[i, j, k], k]
self.target[i, self.index[i, j, k], k] = max(
self.target[i, self.index[i, j, k], k],
self.value[i, j, k],
)
self.inputs = {
'Input': self.xnp,
Expand Down
4 changes: 1 addition & 3 deletions test/xpu/test_concat_op_xpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ def setUp(self):
self.attrs = {'axis': self.axis}
if self.axis < 0:
self.actual_axis = self.axis + len(self.x0.shape)
self.actual_axis = (
self.actual_axis if self.actual_axis > 0 else 0
)
self.actual_axis = max(0, self.actual_axis)
else:
self.actual_axis = self.axis

Expand Down
2 changes: 1 addition & 1 deletion tools/check_ctest_hung.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main():
started = set()
passed = set()
with open(logfile, "r") as fn:
for l in fn.readlines():
for l in fn:
if l.find("Test ") != -1 and l.find("Passed") != -1:
m = re.search(r"Test\s+#[0-9]*\:\s([a-z0-9_]+)", escape(l))
passed.add(m.group(1))
Expand Down