Skip to content

Commit

Permalink
🤖 Lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
ivy-branch committed Feb 22, 2024
1 parent be5768e commit c0ae5f7
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 78 deletions.
133 changes: 57 additions & 76 deletions ivy/functional/ivy/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,9 @@ def _asarray_handle_nestable(fn: Callable) -> Callable:

@functools.wraps(fn)
def _asarray_handle_nestable_wrapper(*args, **kwargs):
"""
Call `fn` with the *nestable* property of the function correctly handled. This
means mapping the function to the container leaves if any containers are passed
in the input.
"""Call `fn` with the *nestable* property of the function correctly
handled. This means mapping the function to the container leaves if any
containers are passed in the input.
Parameters
----------
Expand Down Expand Up @@ -139,9 +138,9 @@ def _remove_np_bfloat16(obj):
def _asarray_to_native_arrays_and_back(fn: Callable) -> Callable:
@functools.wraps(fn)
def _asarray_to_native_arrays_and_back_wrapper(*args, dtype=None, **kwargs):
"""
Wrap `fn` so that input arrays are all converted to `ivy.NativeArray` instances
and return arrays are all converted to `ivy.Array` instances.
"""Wrap `fn` so that input arrays are all converted to
`ivy.NativeArray` instances and return arrays are all converted to
`ivy.Array` instances.
This wrapper is specifically for the backend implementations of
asarray.
Expand All @@ -164,10 +163,9 @@ def _asarray_to_native_arrays_and_back_wrapper(*args, dtype=None, **kwargs):
def _asarray_infer_dtype(fn: Callable) -> Callable:
@functools.wraps(fn)
def _asarray_infer_dtype_wrapper(*args, dtype=None, **kwargs):
"""
Determine the correct `dtype`, and then calls the function with the `dtype`
passed explicitly. This wrapper is specifically for the backend implementations
of asarray.
"""Determine the correct `dtype`, and then calls the function with the
`dtype` passed explicitly. This wrapper is specifically for the backend
implementations of asarray.
Parameters
----------
Expand Down Expand Up @@ -222,10 +220,9 @@ def _infer_dtype(obj):
def _asarray_infer_device(fn: Callable) -> Callable:
@functools.wraps(fn)
def _asarray_infer_device_wrapper(*args, device=None, **kwargs):
"""
Determine the correct `device`, and then calls the function with the `device`
passed explicitly. This wrapper is specifically for the backend implementations
of asarray.
"""Determine the correct `device`, and then calls the function with the
`device` passed explicitly. This wrapper is specifically for the
backend implementations of asarray.
Parameters
----------
Expand Down Expand Up @@ -303,9 +300,8 @@ def arange(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return evenly spaced values within a given interval, with the spacing being
specified.
"""Return evenly spaced values within a given interval, with the spacing
being specified.
Values are generated within the half-open interval [start, stop) (in other words,
the interval including start but excluding stop). For integer arguments the function
Expand Down Expand Up @@ -415,8 +411,7 @@ def asarray(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Convert the input to an array.
"""Convert the input to an array.
Parameters
----------
Expand Down Expand Up @@ -501,8 +496,7 @@ def zeros(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array having a specified ``shape`` and filled with zeros.
"""Return a new array having a specified ``shape`` and filled with zeros.
Parameters
----------
Expand Down Expand Up @@ -566,8 +560,7 @@ def ones(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array having a specified ``shape`` and filled with ones.
"""Return a new array having a specified ``shape`` and filled with ones.
.. note::
Expand Down Expand Up @@ -665,9 +658,8 @@ def full_like(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array filled with ``fill_value`` and having the same ``shape`` as an
input array ``x`` .
"""Return a new array filled with ``fill_value`` and having the same
``shape`` as an input array ``x`` .
Parameters
----------
Expand Down Expand Up @@ -773,9 +765,8 @@ def ones_like(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array filled with ones and having the same shape as an input array
``x``.
"""Return a new array filled with ones and having the same shape as an
input array ``x``.
.. note::
Expand Down Expand Up @@ -893,9 +884,8 @@ def zeros_like(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array filled with zeros and having the same ``shape`` as an input array
``x``.
"""Return a new array filled with zeros and having the same ``shape`` as an
input array ``x``.
Parameters
----------
Expand Down Expand Up @@ -1006,8 +996,8 @@ def tril(
k: int = 0,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return the lower triangular part of a matrix (or a stack of matrices) ``x``.
"""Return the lower triangular part of a matrix (or a stack of matrices)
``x``.
.. note::
Expand Down Expand Up @@ -1062,8 +1052,8 @@ def triu(
k: int = 0,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return the upper triangular part of a matrix (or a stack of matrices) ``x``.
"""Return the upper triangular part of a matrix (or a stack of matrices)
``x``.
.. note::
Expand Down Expand Up @@ -1120,8 +1110,7 @@ def empty(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array of given shape and type, filled with zeros.
"""Return a new array of given shape and type, filled with zeros.
Parameters
----------
Expand Down Expand Up @@ -1171,8 +1160,7 @@ def empty_like(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return an uninitialized array with the same shape as an input array x.
"""Return an uninitialized array with the same shape as an input array x.
Parameters
----------
Expand Down Expand Up @@ -1226,8 +1214,8 @@ def eye(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a two-dimensional array with ones on the k diagonal and zeros elsewhere.
"""Return a two-dimensional array with ones on the k diagonal and zeros
elsewhere.
Parameters
----------
Expand Down Expand Up @@ -1369,8 +1357,8 @@ def linspace(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Generate a certain number of evenly-spaced values in an interval along a given axis.
"""Generate a certain number of evenly-spaced values in an interval along a
given axis.
See :math:`arange` that allows to specify the step size of evenly spaced values in
an interval.
Expand Down Expand Up @@ -1472,8 +1460,7 @@ def meshgrid(
indexing: str = "xy",
out: Optional[ivy.Array] = None,
) -> List[ivy.Array]:
"""
Return coordinate matrices from coordinate vectors.
"""Return coordinate matrices from coordinate vectors.
Parameters
----------
Expand Down Expand Up @@ -1597,8 +1584,8 @@ def full(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a new array having a specified ``shape`` and filled with ``fill_value``.
"""Return a new array having a specified ``shape`` and filled with
``fill_value``.
Parameters
----------
Expand Down Expand Up @@ -1700,8 +1687,7 @@ def full(
def to_dlpack(
x: Union[ivy.Array, ivy.NativeArray], /, *, out: Optional[ivy.Array] = None
):
"""
Return PyCapsule Object.
"""Return PyCapsule Object.
Parameters
----------
Expand Down Expand Up @@ -1740,9 +1726,8 @@ def to_dlpack(
def from_dlpack(
x: Union[ivy.Array, ivy.NativeArray], /, *, out: Optional[ivy.Array] = None
) -> ivy.Array:
"""
Return a new array containing the data from another (array) object with a
``__dlpack__`` method or PyCapsule Object.
"""Return a new array containing the data from another (array) object with
a ``__dlpack__`` method or PyCapsule Object.
Parameters
----------
Expand Down Expand Up @@ -1798,8 +1783,7 @@ def copy_array(
to_ivy_array: bool = True,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Copy an array.
"""Copy an array.
Parameters
----------
Expand Down Expand Up @@ -1904,8 +1888,7 @@ def native_array(
dtype: Optional[Union[ivy.Dtype, ivy.NativeDtype]] = None,
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
) -> ivy.NativeArray:
"""
Convert the input to a native array.
"""Convert the input to a native array.
Parameters
----------
Expand Down Expand Up @@ -1969,9 +1952,9 @@ def one_hot(
device: Union[ivy.Device, ivy.NativeDevice] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Return a one-hot array. The locations represented by indices in the parameter
indices take value on_value, while all other locations take value off_value.
"""Return a one-hot array. The locations represented by indices in the
parameter indices take value on_value, while all other locations take value
off_value.
Parameters
----------
Expand Down Expand Up @@ -2085,9 +2068,8 @@ def logspace(
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
out: Optional[ivy.Array] = None,
) -> ivy.Array:
"""
Generate a certain number of evenly-spaced values in log space, in an interval along
a given axis.
"""Generate a certain number of evenly-spaced values in log space, in an
interval along a given axis.
Parameters
----------
Expand Down Expand Up @@ -2190,8 +2172,7 @@ def frombuffer(
count: Optional[int] = -1,
offset: Optional[int] = 0,
) -> ivy.Array:
r"""
Interpret a buffer as a 1-dimensional array.
r"""Interpret a buffer as a 1-dimensional array.
.. note::
Note that either of the following must be true:
Expand Down Expand Up @@ -2256,16 +2237,16 @@ def triu_indices(
*,
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
) -> Tuple[ivy.Array]:
"""
Return the indices of the upper triangular part of a row by col matrix in a 2-by-N
shape (tuple of two N dimensional arrays), where the first row contains row
coordinates of all indices and the second row contains column coordinates. Indices
are ordered based on rows and then columns. The upper triangular part of the matrix
is defined as the elements on and above the diagonal. The argument k controls which
diagonal to consider. If k = 0, all elements on and above the main diagonal are
retained. A positive value excludes just as many diagonals above the main diagonal,
and similarly a negative value includes just as many diagonals below the main
diagonal. The main diagonal are the set of indices {(i,i)} for i∈[0,min{n_rows,
"""Return the indices of the upper triangular part of a row by col matrix
in a 2-by-N shape (tuple of two N dimensional arrays), where the first row
contains row coordinates of all indices and the second row contains column
coordinates. Indices are ordered based on rows and then columns. The upper
triangular part of the matrix is defined as the elements on and above the
diagonal. The argument k controls which diagonal to consider. If k = 0,
all elements on and above the main diagonal are retained. A positive value
excludes just as many diagonals above the main diagonal, and similarly a
negative value includes just as many diagonals below the main diagonal. The
main diagonal are the set of indices {(i,i)} for i∈[0,min{n_rows,
n_cols}−1].
Notes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ def _get_splits(
allow_array_indices=True,
is_mod_split=False,
):
"""Generate valid splits, either by generating an integer that evenly divides the
axis or a list of splits that sum to the length of the axis being split."""
"""Generate valid splits, either by generating an integer that evenly
divides the axis or a list of splits that sum to the length of the axis
being split."""
shape = draw(
st.shared(helpers.get_shape(min_num_dims=min_num_dims), key="value_shape")
)
Expand Down

0 comments on commit c0ae5f7

Please sign in to comment.