Skip to content

Commit

Permalink
format doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick-Star125 committed Nov 26, 2023
1 parent ba2f97d commit 6976300
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions python/paddle/tensor/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -7075,17 +7075,22 @@ def hypot_(x, y, name=None):

def combinations(x, r=2, with_replacement=False, name=None):
"""
Compute combinations of length r of the given tensor. The behavior is similar to python’s itertools.combinations
Compute combinations of length r of the given tensor. The behavior is similar to python's itertools.combinations
when with_replacement is set to False, and itertools.combinations_with_replacement when with_replacement is set to True.
Args:
x (Tensor): 1-D input Tensor, the data type is float16, float32, float64, int32 or int64.
r (int, optional): number of elements to combine, default value is 2.
with_replacement (bool, optional): whether to allow duplication in combination, default value is False.
name (str, optional): Name for the operation (optional, default is None).For more information, please refer to :ref:`api_guide_Name`.
Returns:
out (Tensor): tensor concatenated by combinations, same dtype with x
out (Tensor). Tensor concatenated by combinations, same dtype with x.
Examples:
.. code-block:: python
>>> import paddle
>>> x = paddle.to_tensor([1, 2, 3], dtype='int32')
>>> res = paddle.combinations(x)
Expand All @@ -7094,6 +7099,7 @@ def combinations(x, r=2, with_replacement=False, name=None):
[[1, 2],
[1, 3],
[2, 3]])
"""
if len(x.shape) != 1:
raise TypeError(f"Expect a 1-D vector, but got x shape {x.shape}")
Expand Down

0 comments on commit 6976300

Please sign in to comment.