Skip to content

Commit 03b9388

Browse files
ivy-branchjacksondm33
authored andcommitted
🤖 Lint code
1 parent c226046 commit 03b9388

File tree

2 files changed

+60
-78
lines changed

2 files changed

+60
-78
lines changed

‎ivy/functional/ivy/creation.py

+57-76
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ def _asarray_handle_nestable(fn: Callable) -> Callable:
4444

4545
@functools.wraps(fn)
4646
def _asarray_handle_nestable_wrapper(*args, **kwargs):
47-
"""
48-
Call `fn` with the *nestable* property of the function correctly handled. This
49-
means mapping the function to the container leaves if any containers are passed
50-
in the input.
47+
"""Call `fn` with the *nestable* property of the function correctly
48+
handled. This means mapping the function to the container leaves if any
49+
containers are passed in the input.
5150
5251
Parameters
5352
----------
@@ -139,9 +138,9 @@ def _remove_np_bfloat16(obj):
139138
def _asarray_to_native_arrays_and_back(fn: Callable) -> Callable:
140139
@functools.wraps(fn)
141140
def _asarray_to_native_arrays_and_back_wrapper(*args, dtype=None, **kwargs):
142-
"""
143-
Wrap `fn` so that input arrays are all converted to `ivy.NativeArray` instances
144-
and return arrays are all converted to `ivy.Array` instances.
141+
"""Wrap `fn` so that input arrays are all converted to
142+
`ivy.NativeArray` instances and return arrays are all converted to
143+
`ivy.Array` instances.
145144
146145
This wrapper is specifically for the backend implementations of
147146
asarray.
@@ -164,10 +163,9 @@ def _asarray_to_native_arrays_and_back_wrapper(*args, dtype=None, **kwargs):
164163
def _asarray_infer_dtype(fn: Callable) -> Callable:
165164
@functools.wraps(fn)
166165
def _asarray_infer_dtype_wrapper(*args, dtype=None, **kwargs):
167-
"""
168-
Determine the correct `dtype`, and then calls the function with the `dtype`
169-
passed explicitly. This wrapper is specifically for the backend implementations
170-
of asarray.
166+
"""Determine the correct `dtype`, and then calls the function with the
167+
`dtype` passed explicitly. This wrapper is specifically for the backend
168+
implementations of asarray.
171169
172170
Parameters
173171
----------
@@ -222,10 +220,9 @@ def _infer_dtype(obj):
222220
def _asarray_infer_device(fn: Callable) -> Callable:
223221
@functools.wraps(fn)
224222
def _asarray_infer_device_wrapper(*args, device=None, **kwargs):
225-
"""
226-
Determine the correct `device`, and then calls the function with the `device`
227-
passed explicitly. This wrapper is specifically for the backend implementations
228-
of asarray.
223+
"""Determine the correct `device`, and then calls the function with the
224+
`device` passed explicitly. This wrapper is specifically for the
225+
backend implementations of asarray.
229226
230227
Parameters
231228
----------
@@ -303,9 +300,8 @@ def arange(
303300
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
304301
out: Optional[ivy.Array] = None,
305302
) -> ivy.Array:
306-
"""
307-
Return evenly spaced values within a given interval, with the spacing being
308-
specified.
303+
"""Return evenly spaced values within a given interval, with the spacing
304+
being specified.
309305
310306
Values are generated within the half-open interval [start, stop) (in other words,
311307
the interval including start but excluding stop). For integer arguments the function
@@ -415,8 +411,7 @@ def asarray(
415411
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
416412
out: Optional[ivy.Array] = None,
417413
) -> ivy.Array:
418-
"""
419-
Convert the input to an array.
414+
"""Convert the input to an array.
420415
421416
Parameters
422417
----------
@@ -501,8 +496,7 @@ def zeros(
501496
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
502497
out: Optional[ivy.Array] = None,
503498
) -> ivy.Array:
504-
"""
505-
Return a new array having a specified ``shape`` and filled with zeros.
499+
"""Return a new array having a specified ``shape`` and filled with zeros.
506500
507501
Parameters
508502
----------
@@ -566,8 +560,7 @@ def ones(
566560
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
567561
out: Optional[ivy.Array] = None,
568562
) -> ivy.Array:
569-
"""
570-
Return a new array having a specified ``shape`` and filled with ones.
563+
"""Return a new array having a specified ``shape`` and filled with ones.
571564
572565
.. note::
573566
@@ -665,9 +658,8 @@ def full_like(
665658
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
666659
out: Optional[ivy.Array] = None,
667660
) -> ivy.Array:
668-
"""
669-
Return a new array filled with ``fill_value`` and having the same ``shape`` as an
670-
input array ``x`` .
661+
"""Return a new array filled with ``fill_value`` and having the same
662+
``shape`` as an input array ``x`` .
671663
672664
Parameters
673665
----------
@@ -773,9 +765,8 @@ def ones_like(
773765
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
774766
out: Optional[ivy.Array] = None,
775767
) -> ivy.Array:
776-
"""
777-
Return a new array filled with ones and having the same shape as an input array
778-
``x``.
768+
"""Return a new array filled with ones and having the same shape as an
769+
input array ``x``.
779770
780771
.. note::
781772
@@ -893,9 +884,8 @@ def zeros_like(
893884
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
894885
out: Optional[ivy.Array] = None,
895886
) -> ivy.Array:
896-
"""
897-
Return a new array filled with zeros and having the same ``shape`` as an input array
898-
``x``.
887+
"""Return a new array filled with zeros and having the same ``shape`` as an
888+
input array ``x``.
899889
900890
Parameters
901891
----------
@@ -1006,8 +996,8 @@ def tril(
1006996
k: int = 0,
1007997
out: Optional[ivy.Array] = None,
1008998
) -> ivy.Array:
1009-
"""
1010-
Return the lower triangular part of a matrix (or a stack of matrices) ``x``.
999+
"""Return the lower triangular part of a matrix (or a stack of matrices)
1000+
``x``.
10111001
10121002
.. note::
10131003
@@ -1062,8 +1052,8 @@ def triu(
10621052
k: int = 0,
10631053
out: Optional[ivy.Array] = None,
10641054
) -> ivy.Array:
1065-
"""
1066-
Return the upper triangular part of a matrix (or a stack of matrices) ``x``.
1055+
"""Return the upper triangular part of a matrix (or a stack of matrices)
1056+
``x``.
10671057
10681058
.. note::
10691059
@@ -1120,8 +1110,7 @@ def empty(
11201110
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
11211111
out: Optional[ivy.Array] = None,
11221112
) -> ivy.Array:
1123-
"""
1124-
Return a new array of given shape and type, filled with zeros.
1113+
"""Return a new array of given shape and type, filled with zeros.
11251114
11261115
Parameters
11271116
----------
@@ -1171,8 +1160,7 @@ def empty_like(
11711160
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
11721161
out: Optional[ivy.Array] = None,
11731162
) -> ivy.Array:
1174-
"""
1175-
Return an uninitialized array with the same shape as an input array x.
1163+
"""Return an uninitialized array with the same shape as an input array x.
11761164
11771165
Parameters
11781166
----------
@@ -1226,8 +1214,8 @@ def eye(
12261214
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
12271215
out: Optional[ivy.Array] = None,
12281216
) -> ivy.Array:
1229-
"""
1230-
Return a two-dimensional array with ones on the k diagonal and zeros elsewhere.
1217+
"""Return a two-dimensional array with ones on the k diagonal and zeros
1218+
elsewhere.
12311219
12321220
Parameters
12331221
----------
@@ -1369,8 +1357,8 @@ def linspace(
13691357
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
13701358
out: Optional[ivy.Array] = None,
13711359
) -> ivy.Array:
1372-
"""
1373-
Generate a certain number of evenly-spaced values in an interval along a given axis.
1360+
"""Generate a certain number of evenly-spaced values in an interval along a
1361+
given axis.
13741362
13751363
See :math:`arange` that allows to specify the step size of evenly spaced values in
13761364
an interval.
@@ -1472,8 +1460,7 @@ def meshgrid(
14721460
indexing: str = "xy",
14731461
out: Optional[ivy.Array] = None,
14741462
) -> List[ivy.Array]:
1475-
"""
1476-
Return coordinate matrices from coordinate vectors.
1463+
"""Return coordinate matrices from coordinate vectors.
14771464
14781465
Parameters
14791466
----------
@@ -1597,8 +1584,8 @@ def full(
15971584
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
15981585
out: Optional[ivy.Array] = None,
15991586
) -> ivy.Array:
1600-
"""
1601-
Return a new array having a specified ``shape`` and filled with ``fill_value``.
1587+
"""Return a new array having a specified ``shape`` and filled with
1588+
``fill_value``.
16021589
16031590
Parameters
16041591
----------
@@ -1700,8 +1687,7 @@ def full(
17001687
def to_dlpack(
17011688
x: Union[ivy.Array, ivy.NativeArray], /, *, out: Optional[ivy.Array] = None
17021689
):
1703-
"""
1704-
Return PyCapsule Object.
1690+
"""Return PyCapsule Object.
17051691
17061692
Parameters
17071693
----------
@@ -1740,9 +1726,8 @@ def to_dlpack(
17401726
def from_dlpack(
17411727
x: Union[ivy.Array, ivy.NativeArray], /, *, out: Optional[ivy.Array] = None
17421728
) -> ivy.Array:
1743-
"""
1744-
Return a new array containing the data from another (array) object with a
1745-
``__dlpack__`` method or PyCapsule Object.
1729+
"""Return a new array containing the data from another (array) object with
1730+
a ``__dlpack__`` method or PyCapsule Object.
17461731
17471732
Parameters
17481733
----------
@@ -1798,8 +1783,7 @@ def copy_array(
17981783
to_ivy_array: bool = True,
17991784
out: Optional[ivy.Array] = None,
18001785
) -> ivy.Array:
1801-
"""
1802-
Copy an array.
1786+
"""Copy an array.
18031787
18041788
Parameters
18051789
----------
@@ -1904,8 +1888,7 @@ def native_array(
19041888
dtype: Optional[Union[ivy.Dtype, ivy.NativeDtype]] = None,
19051889
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
19061890
) -> ivy.NativeArray:
1907-
"""
1908-
Convert the input to a native array.
1891+
"""Convert the input to a native array.
19091892
19101893
Parameters
19111894
----------
@@ -1969,9 +1952,9 @@ def one_hot(
19691952
device: Union[ivy.Device, ivy.NativeDevice] = None,
19701953
out: Optional[ivy.Array] = None,
19711954
) -> ivy.Array:
1972-
"""
1973-
Return a one-hot array. The locations represented by indices in the parameter
1974-
indices take value on_value, while all other locations take value off_value.
1955+
"""Return a one-hot array. The locations represented by indices in the
1956+
parameter indices take value on_value, while all other locations take value
1957+
off_value.
19751958
19761959
Parameters
19771960
----------
@@ -2085,9 +2068,8 @@ def logspace(
20852068
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
20862069
out: Optional[ivy.Array] = None,
20872070
) -> ivy.Array:
2088-
"""
2089-
Generate a certain number of evenly-spaced values in log space, in an interval along
2090-
a given axis.
2071+
"""Generate a certain number of evenly-spaced values in log space, in an
2072+
interval along a given axis.
20912073
20922074
Parameters
20932075
----------
@@ -2190,8 +2172,7 @@ def frombuffer(
21902172
count: Optional[int] = -1,
21912173
offset: Optional[int] = 0,
21922174
) -> ivy.Array:
2193-
r"""
2194-
Interpret a buffer as a 1-dimensional array.
2175+
r"""Interpret a buffer as a 1-dimensional array.
21952176
21962177
.. note::
21972178
Note that either of the following must be true:
@@ -2256,16 +2237,16 @@ def triu_indices(
22562237
*,
22572238
device: Optional[Union[ivy.Device, ivy.NativeDevice]] = None,
22582239
) -> Tuple[ivy.Array]:
2259-
"""
2260-
Return the indices of the upper triangular part of a row by col matrix in a 2-by-N
2261-
shape (tuple of two N dimensional arrays), where the first row contains row
2262-
coordinates of all indices and the second row contains column coordinates. Indices
2263-
are ordered based on rows and then columns. The upper triangular part of the matrix
2264-
is defined as the elements on and above the diagonal. The argument k controls which
2265-
diagonal to consider. If k = 0, all elements on and above the main diagonal are
2266-
retained. A positive value excludes just as many diagonals above the main diagonal,
2267-
and similarly a negative value includes just as many diagonals below the main
2268-
diagonal. The main diagonal are the set of indices {(i,i)} for i∈[0,min{n_rows,
2240+
"""Return the indices of the upper triangular part of a row by col matrix
2241+
in a 2-by-N shape (tuple of two N dimensional arrays), where the first row
2242+
contains row coordinates of all indices and the second row contains column
2243+
coordinates. Indices are ordered based on rows and then columns. The upper
2244+
triangular part of the matrix is defined as the elements on and above the
2245+
diagonal. The argument k controls which diagonal to consider. If k = 0,
2246+
all elements on and above the main diagonal are retained. A positive value
2247+
excludes just as many diagonals above the main diagonal, and similarly a
2248+
negative value includes just as many diagonals below the main diagonal. The
2249+
main diagonal are the set of indices {(i,i)} for i∈[0,min{n_rows,
22692250
n_cols}−1].
22702251
22712252
Notes

‎ivy_tests/test_ivy/test_functional/test_core/test_manipulation.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,9 @@ def _get_splits(
152152
allow_array_indices=True,
153153
is_mod_split=False,
154154
):
155-
"""Generate valid splits, either by generating an integer that evenly divides the
156-
axis or a list of splits that sum to the length of the axis being split."""
155+
"""Generate valid splits, either by generating an integer that evenly
156+
divides the axis or a list of splits that sum to the length of the axis
157+
being split."""
157158
shape = draw(
158159
st.shared(helpers.get_shape(min_num_dims=min_num_dims), key="value_shape")
159160
)

0 commit comments

Comments
 (0)