Skip to content

Commit 10ded7f

Browse files
committed
Improved docstrings for several functions
1 parent eef0646 commit 10ded7f

File tree

2 files changed

+1118
-105
lines changed

2 files changed

+1118
-105
lines changed

pytensor/tensor/basic.py

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -846,7 +846,23 @@ def zeros_like(model, dtype=None, opt=False):
846846

847847

848848
def zeros(shape, dtype=None):
849-
"""Create a `TensorVariable` filled with zeros, closer to NumPy's syntax than ``alloc``."""
849+
"""
850+
Create a `TensorVariable` filled with zeros, closer to NumPy's syntax than `alloc`.
851+
852+
Parameters
853+
----------
854+
shape : int or tuple of int
855+
Shape of the empty array, e.g., ``(2, 3)`` or ``2``.
856+
dtype : data-type, optional
857+
Desired output data-type for the array, e.g, `numpy.int8`. Default is
858+
`numpy.float64`.
859+
860+
Returns
861+
-------
862+
tensor
863+
Tensor the shape of shape containing zeros of the type of dtype.
864+
"""
865+
# Check if shape is a single integer or a sequence
850866
if not (
851867
isinstance(shape, np.ndarray | Sequence)
852868
or (isinstance(shape, TensorVariable) and shape.ndim > 0)
@@ -858,7 +874,23 @@ def zeros(shape, dtype=None):
858874

859875

860876
def ones(shape, dtype=None):
861-
"""Create a `TensorVariable` filled with ones, closer to NumPy's syntax than ``alloc``."""
877+
"""
878+
Create a `TensorVariable` filled with ones, closer to NumPy's syntax than `alloc`.
879+
880+
Parameters
881+
----------
882+
shape : int or tuple of int
883+
Shape of the empty array, e.g., ``(2, 3)`` or ``2``.
884+
dtype : data-type, optional
885+
Desired output data-type for the array, e.g, `numpy.int8`. Default is
886+
`numpy.float64`.
887+
888+
Returns
889+
-------
890+
tensor
891+
Tensor the shape of shape containing ones of the type of dtype.
892+
"""
893+
# Check if shape is a single integer or a sequence
862894
if not (
863895
isinstance(shape, np.ndarray | Sequence)
864896
or (isinstance(shape, TensorVariable) and shape.ndim > 0)

0 commit comments

Comments
 (0)