tech.v3.datatype.argops

Index-space algorithms. Implements a subset of the jvm-version.

argfilter

(argfilter pred options data)(argfilter pred data)(argfilter data)

Return an array of indexes that pass the filter.

arggroup

(arggroup data)

Return a map from value->indexes that hold that value.

arglast-every

(arglast-every rdr pred)

Return the last index where (pred (rdr idx) (rdr (dec idx))) was true by comparing every value and keeping track of the last index where pred was true.

argmax

(argmax rdr)

Return the last index of the max item in the reader.

argmin

(argmin rdr)

Return the last index of the min item in the reader.

argsort

(argsort compare-fn options data)(argsort compare-fn data)(argsort data)

Return an array of indexes that order the provided data by compare-fn. compare-fn must be a boolean function such as < or >. You can use a full custom comparator returning -1,0 or 1 by using the :comparator option.

  • compare-fn - Boolean binary predicate such as < or >.

Options:

  • :nan-strategy - defaults to :last - if the data has a numeric elemwise-datatype, a nan-aware comparsing will be used that will place nan data first, last, or throw an exception as specified by the three possible options - :first, :last, and :exception.
  • :comparator - comparator to use. This overrides compare-fn and takes two arguments but returns a number.

Examples:

cljs.user> ;;Persistent vectors do not indicate datatype so nan-aware comparison is disabled.
cljs.user> (argops/argsort [##NaN 1 2 3 ##NaN])
#typed-buffer[[:int32 5][0 1 2 3 4]
cljs.user> ;;But with a container that indicates datatype nan will be handled
cljs.user> (argops/argsort (dtype/make-container :float32 [##NaN 1 2 3 ##NaN]))
 #typed-buffer[[:int32 5][1 2 3 4 0]
cljs.user> ;;example setting nan strategy and using custom comparator.
cljs.user> (argops/argsort nil  ;;no compare fn
                           {:nan-strategy :first
                            :comparator #(compare %2 %1)}
                           (dtype/make-container :float32 [##NaN 1 2 3 ##NaN]))
#typed-buffer[[:int32 5][0 4 3 2 1]

index-reducer

(index-reducer)

index-reducer-rf

(index-reducer-rf)(index-reducer-rf acc v)(index-reducer-rf acc)

Return a transduce-compatible index scanning rf.

IndexReducer

numeric-truthy

(numeric-truthy val)