@simtest-js/funnel 1.0.0-beta.11 → 1.0.0-beta.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,6 +41,82 @@ if (result.status === Status.Pass) {
41
41
  returns a `CompareResult` whose `errorsY` array is **signed** — positive
42
42
  above the upper bound, negative below the lower bound.
43
43
 
44
+ ## Tolerances
45
+
46
+ A tolerance field that is omitted, `undefined` or `null` is "not
47
+ given". The given coefficients are resolved **per axis** by the Rust
48
+ core — the same rule as the Rust, Python and CLI front ends, so
49
+ identical inputs give identical verdicts everywhere:
50
+
51
+ - x axis: `atolx`, `ltolx`, `rtolx`; y axis: `atoly`, `ltoly`, `rtoly`.
52
+ - An axis with **no** coefficient given gets the default `rtol = 2e-3`
53
+ (other coefficients `0`).
54
+ - An axis with **at least one** coefficient given uses the given values
55
+ and `0` for the rest of that axis.
56
+ - An explicit `0` counts as given.
57
+
58
+ | You pass | Effective tolerances |
59
+ | ------------------------------------------- | ---------------------------------------- |
60
+ | no `options`, `{}`, `{ tolerances: {} }` | `rtolx = rtoly = 2e-3`, rest `0` |
61
+ | `{ tolerances: { atoly: 0.05 } }` | `atoly = 0.05`, `rtolx = 2e-3`, rest `0` |
62
+ | `{ tolerances: { atolx: 0, atoly: 0.05 } }` | `atoly = 0.05`, rest `0` |
63
+
64
+ `defaultOptions()` returns the six default values explicitly (passing
65
+ them is identical to omitting `options`), and `summarize()` echoes the
66
+ six resolved values (`ResolvedTolerances`).
67
+
68
+ ## Violation summary
69
+
70
+ `summarize()` condenses an existing comparison into how much the given
71
+ tolerances were violated: violation intervals, the worst deviation with
72
+ the tube half-width at that x, and the share of test points and of the
73
+ compared x-span outside the tube. It is computed by the Rust core, so
74
+ the numbers match the Rust and Python APIs exactly.
75
+
76
+ ```ts
77
+ import { compare, summarize } from '@simtest-js/funnel';
78
+
79
+ const options = { tolerances: { atoly: 0.005 } };
80
+ const result = compare(tRef, yRef, tRef, yTest, options);
81
+ const s = summarize(result, tRef, options); // same reference x and options
82
+ for (const iv of s.intervals) {
83
+ console.log(iv.startX, iv.endX, iv.direction, iv.worstDeviation);
84
+ }
85
+ console.log(s.worst, s.fractionOfPointsOutside, s.fractionOfSpanOutside);
86
+ ```
87
+
88
+ Only test points inside the compared range (`xRange` intersected with
89
+ the reference x-extent) count. For validation statuses (e.g.
90
+ `NonMonotonic`) `worst`, `comparedRange` and both fractions are `null`.
91
+
92
+ ## Downsampling for plots
93
+
94
+ `downsampleMinMax(x, y, buckets, pinnedX?)` reduces a long signal for
95
+ plotting or reporting. It is post-processing only: `compare()` and
96
+ `summarize()` always use the full signal. `createFunnelPlot()` does not
97
+ downsample; pass downsampled traces yourself if needed.
98
+
99
+ ```ts
100
+ import { downsampleMinMax } from '@simtest-js/funnel';
101
+
102
+ const s = summarize(result, tRef, options);
103
+ const pins = s.intervals.map((iv) => iv.worstX); // keep every violation visible
104
+ const d = downsampleMinMax(tTest, yTest, 500, pins);
105
+ // d.x, d.y: Float64Array; d.indices: Uint32Array into the input
106
+ const errorsKept = Array.from(d.indices, (i) => result.errorsY[i]);
107
+ ```
108
+
109
+ The x-extent is split into `buckets` buckets of equal x-width; the
110
+ lowest and highest sample of each bucket are kept (first occurrence on
111
+ ties, `NaN` y never selected), plus the first and last sample. Each
112
+ finite pin keeps the sample with the nearest x (ties go to the lower x)
113
+ and every sample sharing that x; `NaN` pins are ignored. At most
114
+ `min(n, 2 * buckets + 2 + M)` samples are returned (`M` = samples
115
+ selected by pins); signals with `n <= 2 * buckets` are returned
116
+ unchanged. An `Error` is thrown for a length mismatch, a non-finite or
117
+ decreasing x, a non-integer `buckets` or `buckets < 1`. Results are
118
+ identical to the Rust and Python APIs.
119
+
44
120
  ## Status codes
45
121
 
46
122
  Mirror `simtest_funnel_core::Status`:
package/dist/index.d.ts CHANGED
@@ -1,22 +1,51 @@
1
- /** Tolerances passed to {@link compare}. */
1
+ /**
2
+ * Tolerances passed to {@link compare} / {@link summarize}. A field that is
3
+ * omitted, `undefined` or `null` is "not given"; any number (including `0`)
4
+ * is given.
5
+ *
6
+ * Coefficients are resolved per axis by the Rust core, identically in every
7
+ * simtest-funnel API (x axis: `atolx`/`ltolx`/`rtolx`; y axis:
8
+ * `atoly`/`ltoly`/`rtoly`):
9
+ *
10
+ * - an axis with no coefficient given gets the default `rtol = 2e-3`
11
+ * (other coefficients `0`);
12
+ * - an axis with at least one coefficient given uses the given values and
13
+ * `0` for its other coefficients;
14
+ * - an explicit `0` counts as given.
15
+ *
16
+ * So `{ atoly: 0.05 }` means `atoly = 0.05`, `rtoly = 0` and
17
+ * `rtolx = 2e-3`; use `{ atolx: 0, atoly: 0.05 }` for zero x tolerance.
18
+ */
2
19
  export interface Tolerances {
3
- atolx?: number;
4
- atoly?: number;
5
- ltolx?: number;
6
- ltoly?: number;
7
- rtolx?: number;
8
- rtoly?: number;
20
+ atolx?: number | null;
21
+ atoly?: number | null;
22
+ ltolx?: number | null;
23
+ ltoly?: number | null;
24
+ rtolx?: number | null;
25
+ rtoly?: number | null;
9
26
  }
27
+ /** The six effective tolerance coefficients after resolution. */
28
+ export type ResolvedTolerances = {
29
+ [K in keyof Tolerances]-?: number;
30
+ };
10
31
  /** X-range filter. */
11
32
  export interface XRange {
12
33
  lo: number;
13
34
  hi: number;
14
35
  }
15
- /** Options for {@link compare}. */
36
+ /**
37
+ * Options for {@link compare}. Omitting `options`, or omitting
38
+ * `tolerances`, means the default tolerances (`rtolx = rtoly = 2e-3`).
39
+ */
16
40
  export interface Options {
17
41
  tolerances?: Tolerances;
18
42
  xRange?: XRange;
19
43
  }
44
+ /** Fully explicit options, as returned by {@link defaultOptions}. */
45
+ export interface ResolvedOptions {
46
+ tolerances: ResolvedTolerances;
47
+ xRange: XRange;
48
+ }
20
49
  /** Status codes (mirror `simtest_funnel_core::Status`). */
21
50
  export declare const Status: {
22
51
  readonly Pass: 0;
@@ -42,11 +71,105 @@ export interface CompareResult {
42
71
  }
43
72
  /**
44
73
  * Compare a test trajectory against a reference. Errors are signed
45
- * (positive above upper, negative below lower).
74
+ * (positive above upper, negative below lower). Partially specified
75
+ * tolerances are resolved per axis (see {@link Tolerances}); `options`
76
+ * omitted means the defaults reported by {@link defaultOptions}.
46
77
  */
47
78
  export declare function compare(referenceX: ArrayLike<number> | Float64Array, referenceY: ArrayLike<number> | Float64Array, testX: ArrayLike<number> | Float64Array, testY: ArrayLike<number> | Float64Array, options?: Options): CompareResult;
48
- /** Returns the default options. */
49
- export declare function defaultOptions(): Options;
79
+ /** Side of the tube on which a violation lies. */
80
+ export type ViolationDirection = 'above' | 'below';
81
+ /**
82
+ * A maximal run of consecutive judged test points outside the tube on the
83
+ * same side. `startX` / `endX` are the x of the first / last test point of
84
+ * the run (equal for a single-point violation).
85
+ */
86
+ export interface ViolationInterval {
87
+ startX: number;
88
+ endX: number;
89
+ direction: ViolationDirection;
90
+ pointCount: number;
91
+ /** Signed deviation with the largest magnitude in the run. */
92
+ worstDeviation: number;
93
+ worstX: number;
94
+ }
95
+ /** Overall worst deviation of a comparison. */
96
+ export interface WorstDeviation {
97
+ x: number;
98
+ /** Signed deviation with the largest magnitude (first on ties). */
99
+ deviation: number;
100
+ /** Half the distance between upper and lower bound at `x`. */
101
+ tubeHalfWidthY: number;
102
+ }
103
+ /**
104
+ * How much a comparison violated the tolerances it was run with. Only
105
+ * judged test points (x inside `xRange` intersected with the reference
106
+ * x-extent) contribute. For validation statuses, or when no point is
107
+ * judged, `comparedRange`, `worst` and both fractions are `null`.
108
+ */
109
+ export interface ViolationSummary {
110
+ status: StatusCode;
111
+ /** The six resolved tolerance values used. */
112
+ tolerances: ResolvedTolerances;
113
+ xRange: XRange;
114
+ /** First to last judged test point. */
115
+ comparedRange: XRange | null;
116
+ intervals: ViolationInterval[];
117
+ worst: WorstDeviation | null;
118
+ pointsCompared: number;
119
+ pointsOutside: number;
120
+ fractionOfPointsOutside: number | null;
121
+ /**
122
+ * Each judged point represents the x-length halfway to its neighbours;
123
+ * share of that length lying outside the tube.
124
+ */
125
+ fractionOfSpanOutside: number | null;
126
+ }
127
+ /**
128
+ * Summarize how much `result` violated its tolerances. `referenceX` and
129
+ * `options` must be the reference x-values and options passed to
130
+ * {@link compare} for `result` (`undefined` means the same defaults
131
+ * `compare` uses). Computed by the Rust core, so numbers are identical to
132
+ * the Rust and Python APIs.
133
+ */
134
+ export declare function summarize(result: CompareResult, referenceX: ArrayLike<number> | Float64Array, options?: Options): ViolationSummary;
135
+ /**
136
+ * Samples kept by {@link downsampleMinMax}, in input order:
137
+ * `x[k] === inputX[indices[k]]` and `y[k] === inputY[indices[k]]`. Use
138
+ * `indices` to select the same samples from further arrays on the same
139
+ * x-grid (e.g. `result.errorsY` of a comparison).
140
+ */
141
+ export interface Downsampled {
142
+ indices: Uint32Array;
143
+ x: Float64Array;
144
+ y: Float64Array;
145
+ }
146
+ /**
147
+ * Reduce a signal to the extremes of `buckets` equal-width x-buckets, for
148
+ * output only (plots, reports); never feed the result back into
149
+ * {@link compare}.
150
+ *
151
+ * The lowest and highest sample of each bucket are kept (first occurrence
152
+ * on ties, `NaN` y never selected), plus the first and last sample. Each
153
+ * finite value of `pinnedX` keeps the sample with the nearest x (ties go to
154
+ * the lower x) and every sample sharing that x; `NaN` pins are ignored. Pin
155
+ * the `worstX` of every interval of {@link summarize} so a plot never hides
156
+ * a violation.
157
+ *
158
+ * At most `min(n, 2 * buckets + 2 + M)` samples are returned (`M` = samples
159
+ * selected by pins); if `n <= 2 * buckets` every sample is returned.
160
+ * Computed by the Rust core, so results are identical to the Rust and
161
+ * Python APIs.
162
+ *
163
+ * @throws Error for a length mismatch, a non-finite or decreasing x, a
164
+ * non-integer `buckets` or `buckets < 1`.
165
+ */
166
+ export declare function downsampleMinMax(x: ArrayLike<number> | Float64Array, y: ArrayLike<number> | Float64Array, buckets: number, pinnedX?: ArrayLike<number> | Float64Array): Downsampled;
167
+ /**
168
+ * Returns the default options with all six tolerances explicit
169
+ * (`rtolx = rtoly = 2e-3`, others `0`). Passing them to {@link compare}
170
+ * is identical to omitting `options`.
171
+ */
172
+ export declare function defaultOptions(): ResolvedOptions;
50
173
  /** Returns the core crate version. */
51
174
  export declare function version(): string;
52
175
  /**
package/dist/index.js CHANGED
@@ -18,7 +18,9 @@ function toF64(v) {
18
18
  }
19
19
  /**
20
20
  * Compare a test trajectory against a reference. Errors are signed
21
- * (positive above upper, negative below lower).
21
+ * (positive above upper, negative below lower). Partially specified
22
+ * tolerances are resolved per axis (see {@link Tolerances}); `options`
23
+ * omitted means the defaults reported by {@link defaultOptions}.
22
24
  */
23
25
  export function compare(referenceX, referenceY, testX, testY, options) {
24
26
  const raw = wasm.compare(toF64(referenceX), toF64(referenceY), toF64(testX), toF64(testY),
@@ -35,7 +37,50 @@ export function compare(referenceX, referenceY, testX, testY, options) {
35
37
  errorsY: Float64Array.from(r.errorsY),
36
38
  };
37
39
  }
38
- /** Returns the default options. */
40
+ /**
41
+ * Summarize how much `result` violated its tolerances. `referenceX` and
42
+ * `options` must be the reference x-values and options passed to
43
+ * {@link compare} for `result` (`undefined` means the same defaults
44
+ * `compare` uses). Computed by the Rust core, so numbers are identical to
45
+ * the Rust and Python APIs.
46
+ */
47
+ export function summarize(result, referenceX, options) {
48
+ return wasm.summarize(toF64(referenceX), result.status, result.lowerX, result.lowerY, result.upperX, result.upperY, result.errorsX, result.errorsY, options ?? null);
49
+ }
50
+ /**
51
+ * Reduce a signal to the extremes of `buckets` equal-width x-buckets, for
52
+ * output only (plots, reports); never feed the result back into
53
+ * {@link compare}.
54
+ *
55
+ * The lowest and highest sample of each bucket are kept (first occurrence
56
+ * on ties, `NaN` y never selected), plus the first and last sample. Each
57
+ * finite value of `pinnedX` keeps the sample with the nearest x (ties go to
58
+ * the lower x) and every sample sharing that x; `NaN` pins are ignored. Pin
59
+ * the `worstX` of every interval of {@link summarize} so a plot never hides
60
+ * a violation.
61
+ *
62
+ * At most `min(n, 2 * buckets + 2 + M)` samples are returned (`M` = samples
63
+ * selected by pins); if `n <= 2 * buckets` every sample is returned.
64
+ * Computed by the Rust core, so results are identical to the Rust and
65
+ * Python APIs.
66
+ *
67
+ * @throws Error for a length mismatch, a non-finite or decreasing x, a
68
+ * non-integer `buckets` or `buckets < 1`.
69
+ */
70
+ export function downsampleMinMax(x, y, buckets, pinnedX) {
71
+ try {
72
+ return wasm.downsampleMinMax(toF64(x), toF64(y), buckets, toF64(pinnedX ?? []));
73
+ }
74
+ catch (e) {
75
+ // The WASM glue throws the core's message as a plain string.
76
+ throw e instanceof Error ? e : new Error(String(e));
77
+ }
78
+ }
79
+ /**
80
+ * Returns the default options with all six tolerances explicit
81
+ * (`rtolx = rtoly = 2e-3`, others `0`). Passing them to {@link compare}
82
+ * is identical to omitting `options`.
83
+ */
39
84
  export function defaultOptions() {
40
85
  return wasm.defaultOptions();
41
86
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,+BAA+B,CAAC;AAwBtD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC,CAAC;IACR,gBAAgB,EAAE,CAAC;IACnB,WAAW,EAAE,CAAC;IACd,YAAY,EAAE,EAAE;IAChB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,EAAE;IACd,cAAc,EAAE,EAAE;IAClB,gBAAgB,EAAE,EAAE;CACZ,CAAC;AAcX,SAAS,KAAK,CAAC,CAAmC;IAChD,OAAO,CAAC,YAAY,YAAY;QAC9B,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAsB,CAAC,CAAC;AAChD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CACrB,UAA4C,EAC5C,UAA4C,EAC5C,KAAuC,EACvC,KAAuC,EACvC,OAAiB;IAEjB,MAAM,GAAG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;YACb,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACrB,IAAI,EAAE,SAAS;SAChB;QACD;YACE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YACnC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC;YACnC,IAAI,EAAE,aAAa;YACnB,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE;YACrB,IAAI,EAAE,SAAS;SAChB;QACD;YACE,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC;YACpC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YAC5D,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,OAAO;YACb,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,IAAI;SACZ;KACF,CAAC;IACF,MAAM,WAAW,GAAG;QAClB,KAAK,EAAE,mBAAmB;QAC1B,KAAK,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;QACzB,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE;QAC5D,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC;KAClB,CAAC;IACF,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACjD,CAAC"}
@@ -7,10 +7,25 @@
7
7
  export function compare(reference_x: Float64Array, reference_y: Float64Array, test_x: Float64Array, test_y: Float64Array, options: any): any;
8
8
 
9
9
  /**
10
- * Returns default Options as a JS object.
10
+ * Returns the default options as a JS object with all six tolerance
11
+ * values explicit (`Options::default_options()` from the core).
11
12
  */
12
13
  export function defaultOptions(): any;
13
14
 
15
+ /**
16
+ * Min/max-per-bucket downsampling of a signal, computed by the core.
17
+ * Returns `{ indices: Uint32Array, x: Float64Array, y: Float64Array }`;
18
+ * invalid input throws with the core's error message.
19
+ */
20
+ export function downsampleMinMax(x: Float64Array, y: Float64Array, buckets: number, pinned_x: Float64Array): any;
21
+
22
+ /**
23
+ * Violation summary of an existing comparison. The result arrays are
24
+ * marshalled back into a core `CompareResult`; the summary itself is
25
+ * computed by the Rust core. Absent values are `null`.
26
+ */
27
+ export function summarize(reference_x: Float64Array, status: number, lower_x: Float64Array, lower_y: Float64Array, upper_x: Float64Array, upper_y: Float64Array, errors_x: Float64Array, errors_y: Float64Array, options: any): any;
28
+
14
29
  /**
15
30
  * Returns the core crate version.
16
31
  */
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./simtest_funnel_wasm_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
  wasm.__wbindgen_start();
7
7
  export {
8
- compare, defaultOptions, version
8
+ compare, defaultOptions, downsampleMinMax, summarize, version
9
9
  } from "./simtest_funnel_wasm_bg.js";
@@ -16,7 +16,8 @@ export function compare(reference_x, reference_y, test_x, test_y, options) {
16
16
  }
17
17
 
18
18
  /**
19
- * Returns default Options as a JS object.
19
+ * Returns the default options as a JS object with all six tolerance
20
+ * values explicit (`Options::default_options()` from the core).
20
21
  * @returns {any}
21
22
  */
22
23
  export function defaultOptions() {
@@ -24,6 +25,47 @@ export function defaultOptions() {
24
25
  return ret;
25
26
  }
26
27
 
28
+ /**
29
+ * Min/max-per-bucket downsampling of a signal, computed by the core.
30
+ * Returns `{ indices: Uint32Array, x: Float64Array, y: Float64Array }`;
31
+ * invalid input throws with the core's error message.
32
+ * @param {Float64Array} x
33
+ * @param {Float64Array} y
34
+ * @param {number} buckets
35
+ * @param {Float64Array} pinned_x
36
+ * @returns {any}
37
+ */
38
+ export function downsampleMinMax(x, y, buckets, pinned_x) {
39
+ const ret = wasm.downsampleMinMax(x, y, buckets, pinned_x);
40
+ if (ret[2]) {
41
+ throw takeFromExternrefTable0(ret[1]);
42
+ }
43
+ return takeFromExternrefTable0(ret[0]);
44
+ }
45
+
46
+ /**
47
+ * Violation summary of an existing comparison. The result arrays are
48
+ * marshalled back into a core `CompareResult`; the summary itself is
49
+ * computed by the Rust core. Absent values are `null`.
50
+ * @param {Float64Array} reference_x
51
+ * @param {number} status
52
+ * @param {Float64Array} lower_x
53
+ * @param {Float64Array} lower_y
54
+ * @param {Float64Array} upper_x
55
+ * @param {Float64Array} upper_y
56
+ * @param {Float64Array} errors_x
57
+ * @param {Float64Array} errors_y
58
+ * @param {any} options
59
+ * @returns {any}
60
+ */
61
+ export function summarize(reference_x, status, lower_x, lower_y, upper_x, upper_y, errors_x, errors_y, options) {
62
+ const ret = wasm.summarize(reference_x, status, lower_x, lower_y, upper_x, upper_y, errors_x, errors_y, options);
63
+ if (ret[2]) {
64
+ throw takeFromExternrefTable0(ret[1]);
65
+ }
66
+ return takeFromExternrefTable0(ret[0]);
67
+ }
68
+
27
69
  /**
28
70
  * Returns the core crate version.
29
71
  * @returns {string}
@@ -145,12 +187,24 @@ export function __wbg_new_cd4348290afae586() {
145
187
  const ret = new Object();
146
188
  return ret;
147
189
  }
190
+ export function __wbg_new_from_slice_3512352010266e02(arg0, arg1) {
191
+ const ret = new Uint32Array(getArrayU32FromWasm0(arg0, arg1));
192
+ return ret;
193
+ }
194
+ export function __wbg_new_from_slice_aaf85a9746711968(arg0, arg1) {
195
+ const ret = new Float64Array(getArrayF64FromWasm0(arg0, arg1));
196
+ return ret;
197
+ }
148
198
  export function __wbg_prototypesetcall_13162965d1fe7aa3(arg0, arg1, arg2) {
149
199
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
150
200
  }
151
201
  export function __wbg_prototypesetcall_a366c038a3918afa(arg0, arg1, arg2) {
152
202
  Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
153
203
  }
204
+ export function __wbg_set_2793479888329cb6() { return handleError(function (arg0, arg1, arg2) {
205
+ const ret = Reflect.set(arg0, arg1, arg2);
206
+ return ret;
207
+ }, arguments); }
154
208
  export function __wbg_set_d2d33b52458e984a(arg0, arg1, arg2) {
155
209
  arg0[arg1 >>> 0] = arg2;
156
210
  }
@@ -167,6 +221,11 @@ export function __wbindgen_generic_0000000000000002(arg0, arg1) {
167
221
  const ret = getStringFromWasm0(arg0, arg1);
168
222
  return ret;
169
223
  }
224
+ export function __wbindgen_generic_0000000000000003(arg0) {
225
+ // Cast intrinsic for `U64 -> Externref`.
226
+ const ret = BigInt.asUintN(64, arg0);
227
+ return ret;
228
+ }
170
229
  export function __wbindgen_init_externref_table() {
171
230
  const table = wasm.__wbindgen_externrefs;
172
231
  table.set(0, undefined);
@@ -175,6 +234,12 @@ export function __wbindgen_init_externref_table() {
175
234
  table.set(1026, true);
176
235
  table.set(1027, false);
177
236
  }
237
+ function addToExternrefTable0(obj) {
238
+ const idx = wasm.__externref_table_alloc();
239
+ wasm.__wbindgen_externrefs.set(idx, obj);
240
+ return idx;
241
+ }
242
+
178
243
  function debugString(val) {
179
244
  switch (typeof val) {
180
245
  // primitive types
@@ -238,6 +303,11 @@ function getArrayF64FromWasm0(ptr, len) {
238
303
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
239
304
  }
240
305
 
306
+ function getArrayU32FromWasm0(ptr, len) {
307
+ ptr = ptr >>> 0;
308
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
309
+ }
310
+
241
311
  function getArrayU8FromWasm0(ptr, len) {
242
312
  ptr = ptr >>> 0;
243
313
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -264,6 +334,14 @@ function getStringFromWasm0(ptr, len) {
264
334
  return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
265
335
  }
266
336
 
337
+ let cachedUint32ArrayMemory0 = null;
338
+ function getUint32ArrayMemory0() {
339
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
340
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
341
+ }
342
+ return cachedUint32ArrayMemory0;
343
+ }
344
+
267
345
  let cachedUint8ArrayMemory0 = null;
268
346
  function getUint8ArrayMemory0() {
269
347
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -272,6 +350,15 @@ function getUint8ArrayMemory0() {
272
350
  return cachedUint8ArrayMemory0;
273
351
  }
274
352
 
353
+ function handleError(f, args) {
354
+ try {
355
+ return f.apply(this, args);
356
+ } catch (e) {
357
+ const idx = addToExternrefTable0(e);
358
+ wasm.__wbindgen_exn_store(idx);
359
+ }
360
+ }
361
+
275
362
  function isLikeNone(x) {
276
363
  return x === undefined || x === null;
277
364
  }
@@ -3,10 +3,14 @@
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const compare: (a: any, b: any, c: any, d: any, e: any) => [number, number, number];
5
5
  export const defaultOptions: () => any;
6
+ export const downsampleMinMax: (a: any, b: any, c: number, d: any) => [number, number, number];
7
+ export const summarize: (a: any, b: number, c: any, d: any, e: any, f: any, g: any, h: any, i: any) => [number, number, number];
6
8
  export const version: () => [number, number];
7
9
  export const __wbindgen_malloc: (a: number, b: number) => number;
8
10
  export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
9
11
  export const __wbindgen_free: (a: number, b: number, c: number) => void;
12
+ export const __wbindgen_exn_store: (a: number) => void;
13
+ export const __externref_table_alloc: () => number;
10
14
  export const __wbindgen_externrefs: WebAssembly.Table;
11
15
  export const __externref_table_dealloc: (a: number) => void;
12
16
  export const __wbindgen_start: () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simtest-js/funnel",
3
- "version": "1.0.0-beta.11",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "Trajectory comparison library (WASM + TypeScript)",
5
5
  "type": "module",
6
6
  "license": "MIT",