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][G-6,G-7,G-8,G-9,G-10] Fix ruff RUF005 diagnostic for 5 files in python/paddle/ #67128

Merged
merged 5 commits into from
Aug 8, 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 python/paddle/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@
if not path_patched:
prev_path = os.environ['PATH']
os.environ['PATH'] = ';'.join(
dll_paths + [os.environ['PATH']]
[*dll_paths, os.environ['PATH']]
)
path_patched = True
res = kernel32.LoadLibraryW(dll)
Expand Down
2 changes: 1 addition & 1 deletion python/paddle/audio/functional/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,6 @@ def get_window(
except KeyError as e:
raise ValueError("Unknown window type.") from e

params = (win_length,) + args
params = (win_length, *args)
kwargs = {'sym': sym}
return winfunc(*params, dtype=dtype, **kwargs)
2 changes: 1 addition & 1 deletion python/paddle/base/backward.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ def _append_backward_ops_with_checkpoints_(
start_idx += 1

if segments != [] and segments[0][0] != 0:
recompute_segments = [[0, segments[0][0]]] + segments
recompute_segments = [[0, segments[0][0]], *segments]
else:
recompute_segments = segments

Expand Down
4 changes: 2 additions & 2 deletions python/paddle/base/lod_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_lod_tensor(data, recursive_seq_lens, place):
# FIXME(zjl): the original logic of create_lod_tensor would append
# 1 to the shape. Maybe it is not a right way? Currently, we only
# follow the previous logic
arr = arr.reshape(arr.shape + (1,))
arr = arr.reshape((*arr.shape, 1))
tensor = core.LoDTensor()
tensor.set(arr, place)
tensor.set_recursive_sequence_lengths(recursive_seq_lens)
Expand Down Expand Up @@ -166,7 +166,7 @@ def create_random_int_lodtensor(
"""
assert isinstance(base_shape, list), "base_shape should be a list"
# append the total number of basic elements to the front of its shape
overall_shape = [sum(recursive_seq_lens[-1])] + base_shape
overall_shape = [sum(recursive_seq_lens[-1]), *base_shape]
# the range of integer data elements is [low, high]
data = np.random.random_integers(low, high, overall_shape).astype("int64")
return create_lod_tensor(data, recursive_seq_lens, place)
6 changes: 3 additions & 3 deletions python/paddle/dataset/imikolov.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,16 @@ def reader():
for l in f:
if DataType.NGRAM == data_type:
assert n > -1, 'Invalid gram length'
l = ['<s>'] + l.strip().split() + ['<e>']
l = ['<s>', *l.strip().split(), '<e>']
if len(l) >= n:
l = [word_idx.get(w, UNK) for w in l]
for i in range(n, len(l) + 1):
yield tuple(l[i - n : i])
elif DataType.SEQ == data_type:
l = l.strip().split()
l = [word_idx.get(w, UNK) for w in l]
src_seq = [word_idx['<s>']] + l
trg_seq = l + [word_idx['<e>']]
src_seq = [word_idx['<s>'], *l]
trg_seq = [*l, word_idx['<e>']]
if n > 0 and len(src_seq) > n:
continue
yield src_seq, trg_seq
Expand Down