Skip to content

Commit f4dc6fb

Browse files
committed
[API-Compat] Fixed Doc test
1 parent 303a117 commit f4dc6fb

File tree

1 file changed

+17
-36
lines changed

1 file changed

+17
-36
lines changed

python/paddle/tensor/compat.py

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -285,47 +285,28 @@ def sort(
285285
286286
>>> import paddle
287287
288-
>>> x = paddle.to_tensor([[[5,8,9,5],
289-
... [0,0,1,7],
290-
... [6,9,2,4]],
291-
... [[5,2,4,2],
292-
... [4,7,7,9],
293-
... [1,7,0,6]]],
288+
>>> x = paddle.to_tensor([[5,8,9,5],
289+
... [0,0,1,7],
290+
... [6,9,2,4]],
294291
... dtype='float32')
295292
>>> out1 = paddle.compat.sort(input=x, dim=-1)
296293
>>> out2 = paddle.compat.sort(x, 1, descending=True)
297294
>>> out1
298-
SortRetType(values=Tensor(shape=[2, 3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
299-
[[[5., 5., 8., 9.],
300-
[0., 0., 1., 7.],
301-
[2., 4., 6., 9.]],
302-
303-
[[2., 2., 4., 5.],
304-
[4., 7., 7., 9.],
305-
[0., 1., 6., 7.]]]), indices=Tensor(shape=[2, 3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
306-
[[[0, 3, 1, 2],
307-
[0, 1, 2, 3],
308-
[2, 3, 0, 1]],
309-
310-
[[1, 3, 2, 0],
311-
[0, 1, 2, 3],
312-
[2, 0, 3, 1]]]))
295+
SortRetType(values=Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
296+
[[5., 5., 8., 9.],
297+
[0., 0., 1., 7.],
298+
[2., 4., 6., 9.]]), indices=Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
299+
[[0, 3, 1, 2],
300+
[0, 1, 2, 3],
301+
[2, 3, 0, 1]]))
313302
>>> out2
314-
SortRetType(values=Tensor(shape=[2, 3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
315-
[[[6., 9., 9., 7.],
316-
[5., 8., 2., 5.],
317-
[0., 0., 1., 4.]],
318-
319-
[[5., 7., 7., 9.],
320-
[4., 7., 4., 6.],
321-
[1., 2., 0., 2.]]]), indices=Tensor(shape=[2, 3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
322-
[[[2, 2, 0, 1],
323-
[0, 0, 2, 0],
324-
[1, 1, 1, 2]],
325-
326-
[[0, 1, 1, 1],
327-
[1, 2, 0, 2],
328-
[2, 0, 2, 0]]]))
303+
SortRetType(values=Tensor(shape=[3, 4], dtype=float32, place=Place(cpu), stop_gradient=True,
304+
[[9., 8., 5., 5.],
305+
[7., 1., 0., 0.],
306+
[9., 6., 4., 2.]]), indices=Tensor(shape=[3, 4], dtype=int64, place=Place(cpu), stop_gradient=True,
307+
[[2, 1, 0, 3],
308+
[3, 2, 0, 1],
309+
[1, 0, 3, 2]]))
329310
"""
330311
_check_out_status(out, expect_multiple=True)
331312
outputs, indices = _C_ops.argsort(input, dim, descending, stable)

0 commit comments

Comments
 (0)