提交 52bad109 authored 作者: Brandon T. Willard's avatar Brandon T. Willard 提交者: Brandon T. Willard

Add missing NumPy functions to aesara.tensor

上级 06c17926
...@@ -63,13 +63,18 @@ from aesara.tensor.blas import batched_dot, batched_tensordot ...@@ -63,13 +63,18 @@ from aesara.tensor.blas import batched_dot, batched_tensordot
from aesara.tensor.extra_ops import ( from aesara.tensor.extra_ops import (
bartlett, bartlett,
bincount, bincount,
broadcast_shape,
broadcast_shape_iter,
broadcast_to,
cumprod, cumprod,
cumsum, cumsum,
diff,
fill_diagonal, fill_diagonal,
fill_diagonal_offset, fill_diagonal_offset,
ravel_multi_index, ravel_multi_index,
repeat, repeat,
squeeze, squeeze,
unique,
unravel_index, unravel_index,
) )
from aesara.tensor.io import * from aesara.tensor.io import *
......
...@@ -1295,6 +1295,21 @@ class Unique(Op): ...@@ -1295,6 +1295,21 @@ class Unique(Op):
self.axis = None self.axis = None
def unique(
ar, return_index=False, return_inverse=False, return_counts=False, axis=None
):
"""Find the unique elements of an array.
Returns the sorted unique elements of an array. There are three optional
outputs in addition to the unique elements:
* the indices of the input array that give the unique values
* the indices of the unique array that reconstruct the input array
* the number of times each unique value comes up in the input array
"""
return Unique(return_index, return_inverse, return_counts, axis)(ar)
class UnravelIndex(Op): class UnravelIndex(Op):
__props__ = ("order",) __props__ = ("order",)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论