提交 306ee2c8 authored 作者: Iban Harlouchet's avatar Iban Harlouchet

numpydoc for theano/tensor/sort.py

上级 a8983c95
......@@ -5,7 +5,8 @@ from theano.tensor.basic import mul, arange
class SortOp(theano.Op):
"""
This class is a wrapper for numpy sort function
This class is a wrapper for numpy sort function.
"""
__props__ = ("kind", "order")
......@@ -62,12 +63,15 @@ class SortOp(theano.Op):
return index_val
def __get_argsort_indices(self, a, axis):
"""Calculates indices which can be used to reverse
sorting operation of "a" tensor along "axis"
"""
Calculates indices which can be used to reverse sorting operation of
"a" tensor along "axis".
returns:
Returns
-------
1d array if axis is None
list of lenght len(a.shape) otherwise
"""
# The goal is to get gradient wrt input from gradient
......@@ -99,24 +103,24 @@ class SortOp(theano.Op):
def sort(a, axis=-1, kind='quicksort', order=None):
"""
Return a sorted copy of an array.
Parameters
----------
a : Tensor
Tensor to be sorted
axis : Tensor
Axis along which to sort. If None, the array is
flattened before sorting.
Axis along which to sort. If None, the array is flattened before
sorting.
kind : {'quicksort', 'mergesort', 'heapsort'}, optional
Sorting algorithm. Default is 'quicksort'.
order : list, optional
When `a` is a structured array, this argument specifies which
fields to compare first, second, and so on. This list does not
need to include all of the fields.
Returns
-------
A sorted copy of an array.
"""
if axis is None:
a = a.flatten()
......@@ -126,7 +130,8 @@ def sort(a, axis=-1, kind='quicksort', order=None):
class ArgSortOp(theano.Op):
"""
This class is a wrapper for numpy argsort function
This class is a wrapper for numpy argsort function.
"""
__props__ = ("kind", "order")
......@@ -196,6 +201,7 @@ def argsort(a, axis=-1, kind='quicksort', order=None):
specified by the kind keyword. It returns an array of indices of
the same shape as a that index data along the given axis in sorted
order.
"""
if axis is None:
a = a.flatten()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论