Skip to content

Commit

Permalink
Add docstring to array take, mimic numpy take signature.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleaoman committed Dec 23, 2024
1 parent 3c16a8e commit e889370
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions unyt/_array_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ def in1d(ar1, ar2, *args, **kwargs):


@implements(np.take)
def take(a, indices, axis=None, out=None, *args, **kwargs):
def take(a, indices, axis=None, out=None, mode="raise"):
ret_units = getattr(a, "units", NULL_UNIT)

if out is not None:
Expand All @@ -1232,7 +1232,7 @@ def take(a, indices, axis=None, out=None, *args, **kwargs):
out_view = None

res = np.take._implementation(
np.asarray(a), indices, axis=axis, out=out_view, *args, **kwargs
np.asarray(a), indices, axis=axis, out=out_view, mode=mode
)

if getattr(out, "units", None) is not None:
Expand Down
10 changes: 10 additions & 0 deletions unyt/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -2126,6 +2126,16 @@ def dot(self, b, out=None):
return ret

def take(self, *args, **kwargs):
"""method
Return an array formed from the elements of `a` at the given indices.
Refer to :func:`numpy.take` for full documentation.
See also
--------
numpy.take : equivalent function
"""
from ._array_functions import take

return take(self, *args, **kwargs)
Expand Down

0 comments on commit e889370

Please sign in to comment.