diff --git a/ServerModulesArrayApi.cfg b/ServerModulesArrayApi.cfg index a878d0c8fc..a96adacc20 100644 --- a/ServerModulesArrayApi.cfg +++ b/ServerModulesArrayApi.cfg @@ -2,37 +2,21 @@ # a module from a build ArgSortMsg -ArraySetopsMsg -BroadcastMsg CastMsg -ConcatenateMsg -CSVMsg -DataFrameIndexingMsg EfuncMsg -EncodingMsg -FlattenMsg -HashMsg -HDF5Msg -HistogramMsg -In1dMsg IndexingMsg -JoinEqWithDTMsg -KExtremeMsg -# LinalgMsg +LinalgMsg LogMsg ManipulationMsg OperatorMsg -ParquetMsg RandMsg ReductionMsg RegistrationMsg -SegmentedMsg SequenceMsg +SetMsg SortMsg StatsMsg -TimeClassMsg TransferMsg -UniqueMsg # Add additional modules located outside # of the Arkouda src/ directory below. diff --git a/arkouda/array_api/_set_functions.py b/arkouda/array_api/_set_functions.py index 8ae37b59e6..672b54cadd 100644 --- a/arkouda/array_api/_set_functions.py +++ b/arkouda/array_api/_set_functions.py @@ -2,9 +2,10 @@ from ._array_object import Array -from typing import NamedTuple +from typing import NamedTuple, cast -import arkouda as ak +from arkouda.client import generic_msg +from arkouda.pdarrayclass import create_pdarray class UniqueAllResult(NamedTuple): @@ -25,22 +26,67 @@ class UniqueInverseResult(NamedTuple): def unique_all(x: Array, /) -> UniqueAllResult: - raise ValueError("unique_all not implemented") + resp = cast( + str, + generic_msg( + cmd=f"uniqueAll{x.ndim}D", + args={"name": x._array}, + ), + ) + + arrays = [Array._new(create_pdarray(r)) for r in resp.split('+')] + + return UniqueAllResult( + values=arrays[0], + indices=arrays[1], + inverse_indices=arrays[2], + counts=arrays[3], + ) def unique_counts(x: Array, /) -> UniqueCountsResult: - raise ValueError("unique_counts not implemented") + resp = cast( + str, + generic_msg( + cmd=f"uniqueCounts{x.ndim}D", + args={"name": x._array}, + ), + ) + + arrays = [Array._new(create_pdarray(r)) for r in resp.split('+')] + + return UniqueCountsResult( + values=arrays[0], + counts=arrays[1], + ) def unique_inverse(x: Array, /) -> UniqueInverseResult: - raise ValueError("unique_inverse not implemented") + resp = cast( + str, + generic_msg( + cmd=f"uniqueInverse{x.ndim}D", + args={"name": x._array}, + ), + ) + arrays = [Array._new(create_pdarray(r)) for r in resp.split('+')] + + return UniqueInverseResult( + values=arrays[0], + inverse_indices=arrays[1], + ) -def unique_values(x: Array, /) -> Array: - """ - Array API compatible wrapper for :py:func:`np.unique `. - See its docstring for more information. - """ - res = ak.unique(x._array) - return Array._new(res) +def unique_values(x: Array, /) -> Array: + return Array._new( + create_pdarray( + cast( + str, + generic_msg( + cmd=f"uniqueValues{x.ndim}D", + args={"name": x._array}, + ), + ) + ) + ) diff --git a/src/AryUtil.chpl b/src/AryUtil.chpl index 9b8e6cc35e..db2eca7f26 100644 --- a/src/AryUtil.chpl +++ b/src/AryUtil.chpl @@ -669,7 +669,7 @@ module AryUtil */ proc broadcastShape(sa: ?Na*int, sb: ?Nb*int, param N: int): N*int throws { var s: N*int; - for param i in 0.. 1 + { + var flat = makeDistArray({0.. order for the input array's indices + // e.g., order = k + (nz * j) + (nz * ny * i) + inline proc indexToOrder(idx: rank*int): int { + var order = 0; + for param i in 0..