MCPcopy Create free account
hub / github.com/cortex-js/compute-engine / collectionSubset

Function collectionSubset

src/compute-engine/collection-utils.ts:119–140  ·  view source on GitHub ↗
(
  a: Expression,
  b: Expression,
  strict: boolean
)

Source from the content-addressed store, hash-verified

117 * `MAX_SIZE_EAGER_COLLECTION`, the result is a Union expression
118 *
119 */
120export const MAX_SIZE_EAGER_COLLECTION = 100;
121
122/**
123 * True when `col` is a finite indexed collection whose elements can be
124 * walked. A finite collection whose elements cannot be computed (see
125 * {@link isWalkableFiniteCollection}) is excluded, because most callers of
126 * this predicate read the elements with `at()` or `each()`, and they would
127 * read such a collection as empty.
128 *
129 * Some callers do not walk `col` when this predicate is `false`: they keep
130 * `col` as one element instead (`flattenToDepth()` keeps a scalar as a
131 * leaf). Such a caller must not keep a finite collection with no computable
132 * elements as a leaf, because it would give a list with the wrong elements
133 * and the wrong count. It must test for that case itself and decline.
134 */
135export function isFiniteIndexedCollection(col: Expression): boolean {
136 return isWalkableFiniteCollection(col) && col.isIndexedCollection;
137}
138
139/**
140 * True when `col` is a finite collection whose elements can be walked.
141 *
142 * A finite collection can know its size and still have no computable
143 * elements. `Linspace(a, 1, 3)` with a symbolic `a` has `count` 3 and

Callers

nothing calls this directly

Calls 2

eachMethod · 0.65
containsMethod · 0.65

Tested by

no test coverage detected