[docs]defunique_all(x:Array,/)->UniqueAllResult:""" Return a tuple of arrays containing: - the unique values in `x` - the indices of the first occurrence of each unique value - the inverse indices that reconstruct `x` from the unique values - the counts of each unique value """resp=cast(str,generic_msg(cmd=f"uniqueAll{x.ndim}D",args={"name":x._array},),)arrays=[Array._new(create_pdarray(r))forrinresp.split("+")]returnUniqueAllResult(values=arrays[0],indices=arrays[1],inverse_indices=arrays[2],counts=arrays[3],)
[docs]defunique_counts(x:Array,/)->UniqueCountsResult:""" Return a tuple of arrays containing: - the unique values in `x` - the counts of each unique value """resp=cast(str,generic_msg(cmd=f"uniqueCounts{x.ndim}D",args={"name":x._array},),)arrays=[Array._new(create_pdarray(r))forrinresp.split("+")]returnUniqueCountsResult(values=arrays[0],counts=arrays[1],)
[docs]defunique_inverse(x:Array,/)->UniqueInverseResult:""" Return a tuple of arrays containing: - the unique values in `x` - the inverse indices that reconstruct `x` from the unique values """resp=cast(str,generic_msg(cmd=f"uniqueInverse{x.ndim}D",args={"name":x._array},),)arrays=[Array._new(create_pdarray(r))forrinresp.split("+")]returnUniqueInverseResult(values=arrays[0],inverse_indices=arrays[1],)
[docs]defunique_values(x:Array,/)->Array:""" Return an array containing the unique values from `x`. """returnArray._new(create_pdarray(cast(str,generic_msg(cmd=f"uniqueValues{x.ndim}D",args={"name":x._array},),)))