@simtest-js/funnel 1.0.0-beta.10 → 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
@@ -20,7 +20,7 @@ pnpm add @simtest-js/funnel
20
20
  ## Quick start
21
21
 
22
22
  ```ts
23
- import { compare, Status } from "@simtest-js/funnel";
23
+ import { compare, Status } from '@simtest-js/funnel';
24
24
 
25
25
  const tRef = Float64Array.from({ length: 101 }, (_, i) => i / 100);
26
26
  const yRef = tRef.map((t) => Math.sin(2 * Math.PI * t));
@@ -31,9 +31,9 @@ const result = compare(tRef, yRef, tRef, yTest, {
31
31
  });
32
32
 
33
33
  if (result.status === Status.Pass) {
34
- console.log("inside funnel");
34
+ console.log('inside funnel');
35
35
  } else {
36
- console.log("status:", result.status, "signed errors:", result.errorsY);
36
+ console.log('status:', result.status, 'signed errors:', result.errorsY);
37
37
  }
38
38
  ```
39
39
 
@@ -41,21 +41,97 @@ 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`:
47
123
 
48
- | Name | Code |
49
- |---------------------|-----:|
50
- | `Pass` | 0 |
51
- | `Fail` | -1 |
52
- | `MissingReference` | 1 |
53
- | `MissingTest` | 2 |
54
- | `NonMonotonic` | 10 |
55
- | `LengthMismatch` | 11 |
56
- | `EmptyRange` | 12 |
57
- | `BufferTooSmall` | 13 |
58
- | `InsufficientData` | 14 |
124
+ | Name | Code |
125
+ | ------------------ | ---: |
126
+ | `Pass` | 0 |
127
+ | `Fail` | -1 |
128
+ | `MissingReference` | 1 |
129
+ | `MissingTest` | 2 |
130
+ | `NonMonotonic` | 10 |
131
+ | `LengthMismatch` | 11 |
132
+ | `EmptyRange` | 12 |
133
+ | `BufferTooSmall` | 13 |
134
+ | `InsufficientData` | 14 |
59
135
 
60
136
  ## Reference documentation
61
137
 
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,GAAG,IAAI,CAAC,OAAO,CACtB,KAAK,CAAC,UAAU,CAAC,EACjB,KAAK,CAAC,UAAU,CAAC,EACjB,KAAK,CAAC,KAAK,CAAC,EACZ,KAAK,CAAC,KAAK,CAAC;IACZ,sEAAsE;IACtE,CAAC,OAAO,IAAI,IAAI,CAAQ,CACzB,CAAC;IACF,MAAM,CAAC,GAAG,GAQT,CAAC;IACF,OAAO;QACL,MAAM,EAAE,CAAC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AE,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}
@@ -40,7 +82,7 @@ export function version() {
40
82
  wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
41
83
  }
42
84
  }
43
- export function __wbg_Error_960c155d3d49e4c2(arg0, arg1) {
85
+ export function __wbg_Error_208446807d0d1e30(arg0, arg1) {
44
86
  const ret = Error(getStringFromWasm0(arg0, arg1));
45
87
  return ret;
46
88
  }
@@ -48,64 +90,64 @@ export function __wbg_String_8564e559799eccda(arg0, arg1) {
48
90
  const ret = String(arg1);
49
91
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
50
92
  const len1 = WASM_VECTOR_LEN;
51
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
52
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
93
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
94
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
53
95
  }
54
- export function __wbg___wbindgen_boolean_get_6ea149f0a8dcc5ff(arg0) {
96
+ export function __wbg___wbindgen_boolean_get_4f1baf9a00be3c74(arg0) {
55
97
  const v = arg0;
56
98
  const ret = typeof(v) === 'boolean' ? v : undefined;
57
99
  return isLikeNone(ret) ? 0xFFFFFF : ret ? 1 : 0;
58
100
  }
59
- export function __wbg___wbindgen_debug_string_ab4b34d23d6778bd(arg0, arg1) {
101
+ export function __wbg___wbindgen_debug_string_f249a2a76caa9a55(arg0, arg1) {
60
102
  const ret = debugString(arg1);
61
103
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
62
104
  const len1 = WASM_VECTOR_LEN;
63
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
64
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
105
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
106
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
65
107
  }
66
- export function __wbg___wbindgen_in_a5d8b22e52b24dd1(arg0, arg1) {
108
+ export function __wbg___wbindgen_in_3f58a9d3b3a7eed2(arg0, arg1) {
67
109
  const ret = arg0 in arg1;
68
110
  return ret;
69
111
  }
70
- export function __wbg___wbindgen_is_null_52ff4ec04186736f(arg0) {
112
+ export function __wbg___wbindgen_is_null_c22311b1cc228e3a(arg0) {
71
113
  const ret = arg0 === null;
72
114
  return ret;
73
115
  }
74
- export function __wbg___wbindgen_is_object_63322ec0cd6ea4ef(arg0) {
116
+ export function __wbg___wbindgen_is_object_8b968c3ab8e96595(arg0) {
75
117
  const val = arg0;
76
118
  const ret = typeof(val) === 'object' && val !== null;
77
119
  return ret;
78
120
  }
79
- export function __wbg___wbindgen_is_undefined_29a43b4d42920abd(arg0) {
121
+ export function __wbg___wbindgen_is_undefined_be5b34249ff1fc15(arg0) {
80
122
  const ret = arg0 === undefined;
81
123
  return ret;
82
124
  }
83
- export function __wbg___wbindgen_jsval_loose_eq_cac3565e89b4134c(arg0, arg1) {
125
+ export function __wbg___wbindgen_jsval_loose_eq_b2f214e2e4b30e36(arg0, arg1) {
84
126
  const ret = arg0 == arg1;
85
127
  return ret;
86
128
  }
87
- export function __wbg___wbindgen_number_get_c7f42aed0525c451(arg0, arg1) {
129
+ export function __wbg___wbindgen_number_get_934b640d0889af78(arg0, arg1) {
88
130
  const obj = arg1;
89
131
  const ret = typeof(obj) === 'number' ? obj : undefined;
90
- getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
91
- getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true);
132
+ getDataViewMemory0().setFloat64((arg0 >>> 0) + 8 * 1, isLikeNone(ret) ? 0 : ret, true);
133
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, !isLikeNone(ret), true);
92
134
  }
93
- export function __wbg___wbindgen_string_get_7ed5322991caaec5(arg0, arg1) {
135
+ export function __wbg___wbindgen_string_get_7ce8eee7fd327545(arg0, arg1) {
94
136
  const obj = arg1;
95
137
  const ret = typeof(obj) === 'string' ? obj : undefined;
96
138
  var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
97
139
  var len1 = WASM_VECTOR_LEN;
98
- getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
99
- getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
140
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 1, len1, true);
141
+ getDataViewMemory0().setInt32((arg0 >>> 0) + 4 * 0, ptr1, true);
100
142
  }
101
- export function __wbg___wbindgen_throw_6b64449b9b9ed33c(arg0, arg1) {
143
+ export function __wbg___wbindgen_throw_4c88d8bf264fd984(arg0, arg1) {
102
144
  throw new Error(getStringFromWasm0(arg0, arg1));
103
145
  }
104
- export function __wbg_get_with_ref_key_6412cf3094599694(arg0, arg1) {
146
+ export function __wbg_get_with_ref_key_fc601247060b7204(arg0, arg1) {
105
147
  const ret = arg0[arg1];
106
148
  return ret;
107
149
  }
108
- export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
150
+ export function __wbg_instanceof_ArrayBuffer_12cdaa4161423e6b(arg0) {
109
151
  let result;
110
152
  try {
111
153
  result = arg0 instanceof ArrayBuffer;
@@ -115,7 +157,7 @@ export function __wbg_instanceof_ArrayBuffer_7c8433c6ed14ffe3(arg0) {
115
157
  const ret = result;
116
158
  return ret;
117
159
  }
118
- export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
160
+ export function __wbg_instanceof_Uint8Array_d7aeb0dcb3108fea(arg0) {
119
161
  let result;
120
162
  try {
121
163
  result = arg0 instanceof Uint8Array;
@@ -125,120 +167,135 @@ export function __wbg_instanceof_Uint8Array_152ba1f289edcf3f(arg0) {
125
167
  const ret = result;
126
168
  return ret;
127
169
  }
128
- export function __wbg_length_9f1775224cf1d815(arg0) {
170
+ export function __wbg_length_186163212ffe79c3(arg0) {
129
171
  const ret = arg0.length;
130
172
  return ret;
131
173
  }
132
- export function __wbg_length_d807629e96c741b8(arg0) {
174
+ export function __wbg_length_5a8bb8abe1e54e15(arg0) {
133
175
  const ret = arg0.length;
134
176
  return ret;
135
177
  }
136
- export function __wbg_new_0c7403db6e782f19(arg0) {
178
+ export function __wbg_new_13de428334042d26(arg0) {
137
179
  const ret = new Uint8Array(arg0);
138
180
  return ret;
139
181
  }
140
- export function __wbg_new_682678e2f47e32bc() {
182
+ export function __wbg_new_37eb45aaf5eeb820() {
141
183
  const ret = new Array();
142
184
  return ret;
143
185
  }
144
- export function __wbg_new_aa8d0fa9762c29bd() {
186
+ export function __wbg_new_cd4348290afae586() {
145
187
  const ret = new Object();
146
188
  return ret;
147
189
  }
148
- export function __wbg_prototypesetcall_a6b02eb00b0f4ce2(arg0, arg1, arg2) {
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
+ }
198
+ export function __wbg_prototypesetcall_13162965d1fe7aa3(arg0, arg1, arg2) {
149
199
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), arg2);
150
200
  }
151
- export function __wbg_prototypesetcall_c5875dab42ff6b97(arg0, arg1, arg2) {
201
+ export function __wbg_prototypesetcall_a366c038a3918afa(arg0, arg1, arg2) {
152
202
  Float64Array.prototype.set.call(getArrayF64FromWasm0(arg0, arg1), arg2);
153
203
  }
154
- export function __wbg_set_3bf1de9fab0cd644(arg0, arg1, arg2) {
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); }
208
+ export function __wbg_set_d2d33b52458e984a(arg0, arg1, arg2) {
155
209
  arg0[arg1 >>> 0] = arg2;
156
210
  }
157
- export function __wbg_set_6be42768c690e380(arg0, arg1, arg2) {
211
+ export function __wbg_set_e4b9a833d288759a(arg0, arg1, arg2) {
158
212
  arg0[arg1] = arg2;
159
213
  }
160
- export function __wbindgen_cast_0000000000000001(arg0) {
214
+ export function __wbindgen_generic_0000000000000001(arg0) {
161
215
  // Cast intrinsic for `F64 -> Externref`.
162
216
  const ret = arg0;
163
217
  return ret;
164
218
  }
165
- export function __wbindgen_cast_0000000000000002(arg0, arg1) {
219
+ export function __wbindgen_generic_0000000000000002(arg0, arg1) {
166
220
  // Cast intrinsic for `Ref(String) -> Externref`.
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
- const offset = table.grow(4);
173
231
  table.set(0, undefined);
174
- table.set(offset + 0, undefined);
175
- table.set(offset + 1, null);
176
- table.set(offset + 2, true);
177
- table.set(offset + 3, false);
232
+ table.set(1024, undefined);
233
+ table.set(1025, null);
234
+ table.set(1026, true);
235
+ table.set(1027, false);
236
+ }
237
+ function addToExternrefTable0(obj) {
238
+ const idx = wasm.__externref_table_alloc();
239
+ wasm.__wbindgen_externrefs.set(idx, obj);
240
+ return idx;
178
241
  }
242
+
179
243
  function debugString(val) {
180
- // primitive types
181
- const type = typeof val;
182
- if (type == 'number' || type == 'boolean' || val == null) {
183
- return `${val}`;
184
- }
185
- if (type == 'string') {
186
- return `"${val}"`;
187
- }
188
- if (type == 'symbol') {
189
- const description = val.description;
190
- if (description == null) {
191
- return 'Symbol';
192
- } else {
193
- return `Symbol(${description})`;
194
- }
195
- }
196
- if (type == 'function') {
197
- const name = val.name;
198
- if (typeof name == 'string' && name.length > 0) {
199
- return `Function(${name})`;
200
- } else {
201
- return 'Function';
202
- }
203
- }
204
- // objects
205
- if (Array.isArray(val)) {
206
- const length = val.length;
207
- let debug = '[';
208
- if (length > 0) {
209
- debug += debugString(val[0]);
210
- }
211
- for(let i = 1; i < length; i++) {
212
- debug += ', ' + debugString(val[i]);
213
- }
214
- debug += ']';
215
- return debug;
216
- }
217
- // Test for built-in
218
- const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val));
219
- let className;
220
- if (builtInMatches && builtInMatches.length > 1) {
221
- className = builtInMatches[1];
222
- } else {
223
- // Failed to match the standard '[object ClassName]'
224
- return toString.call(val);
225
- }
226
- if (className == 'Object') {
227
- // we're a user defined class or Object
228
- // JSON.stringify avoids problems with cycles, and is generally much
229
- // easier than looping through ownProperties of `val`.
230
- try {
231
- return 'Object(' + JSON.stringify(val) + ')';
232
- } catch (_) {
233
- return 'Object';
244
+ switch (typeof val) {
245
+ // primitive types
246
+ case 'number':
247
+ case 'boolean':
248
+ case 'undefined':
249
+ return `${val}`;
250
+ case 'string':
251
+ return JSON.stringify(val);
252
+ case 'bigint':
253
+ return `${val}n`;
254
+ case 'symbol':
255
+ return val.description !== undefined
256
+ ? `Symbol(${val.description})`
257
+ : 'Symbol';
258
+ case 'function':
259
+ return typeof val.name === 'string' && val.name !== ''
260
+ ? `Function(${val.name})`
261
+ : 'Function';
262
+ case 'object': {
263
+ if (val === null) {
264
+ return 'null';
265
+ }
266
+ // objects
267
+ if (Array.isArray(val)) {
268
+ return '[' + Array.from(val, debugString).join(', ') + ']';
269
+ }
270
+ // errors
271
+ if (val instanceof Error) {
272
+ return `${val.name}: ${val.message}\n${val.stack}`;
273
+ }
274
+
275
+ const toStringOutput = toString.call(val);
276
+ // Test for built-in
277
+ const className = /\[object ([^\]]+)\]/.exec(toStringOutput)?.[1];
278
+
279
+ // Failed to match the standard '[object ClassName]'
280
+ if (className === undefined) {
281
+ return toStringOutput;
282
+ }
283
+ if (className === 'Object') {
284
+ // we're a user defined class or Object
285
+ // JSON.stringify avoids problems with cycles, and is generally much
286
+ // easier than looping through ownProperties of `val`.
287
+ try {
288
+ return 'Object(' + JSON.stringify(val) + ')';
289
+ } catch (_) {
290
+ return 'Object';
291
+ }
292
+ }
293
+ // TODO we could test for more things here, like `Set`s and `Map`s.
294
+ return className;
234
295
  }
296
+ // Per MDN: 'This list of values is exhaustive.'
297
+ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof#description
235
298
  }
236
- // errors
237
- if (val instanceof Error) {
238
- return `${val.name}: ${val.message}\n${val.stack}`;
239
- }
240
- // TODO we could test for more things here, like `Set`s and `Map`s.
241
- return className;
242
299
  }
243
300
 
244
301
  function getArrayF64FromWasm0(ptr, len) {
@@ -246,6 +303,11 @@ function getArrayF64FromWasm0(ptr, len) {
246
303
  return getFloat64ArrayMemory0().subarray(ptr / 8, ptr / 8 + len);
247
304
  }
248
305
 
306
+ function getArrayU32FromWasm0(ptr, len) {
307
+ ptr = ptr >>> 0;
308
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
309
+ }
310
+
249
311
  function getArrayU8FromWasm0(ptr, len) {
250
312
  ptr = ptr >>> 0;
251
313
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -269,7 +331,15 @@ function getFloat64ArrayMemory0() {
269
331
 
270
332
  function getStringFromWasm0(ptr, len) {
271
333
  ptr = ptr >>> 0;
272
- return decodeText(ptr, len);
334
+ return decodeText(getUint8ArrayMemory0().subarray(ptr, ptr + len));
335
+ }
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;
273
343
  }
274
344
 
275
345
  let cachedUint8ArrayMemory0 = null;
@@ -280,6 +350,15 @@ function getUint8ArrayMemory0() {
280
350
  return cachedUint8ArrayMemory0;
281
351
  }
282
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
+
283
362
  function isLikeNone(x) {
284
363
  return x === undefined || x === null;
285
364
  }
@@ -327,18 +406,18 @@ function takeFromExternrefTable0(idx) {
327
406
  return value;
328
407
  }
329
408
 
330
- let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
409
+ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
331
410
  cachedTextDecoder.decode();
332
411
  const MAX_SAFARI_DECODE_BYTES = 2146435072;
333
412
  let numBytesDecoded = 0;
334
- function decodeText(ptr, len) {
335
- numBytesDecoded += len;
413
+ function decodeText(bytes) {
414
+ numBytesDecoded += bytes.length;
336
415
  if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
337
- cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
416
+ cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true });
338
417
  cachedTextDecoder.decode();
339
- numBytesDecoded = len;
418
+ numBytesDecoded = bytes.length;
340
419
  }
341
- return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
420
+ return cachedTextDecoder.decode(bytes);
342
421
  }
343
422
 
344
423
  const cachedTextEncoder = new TextEncoder();
@@ -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;
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;
9
14
  export const __wbindgen_externrefs: WebAssembly.Table;
10
15
  export const __externref_table_dealloc: (a: number) => void;
11
- export const __wbindgen_free: (a: number, b: number, c: 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.10",
3
+ "version": "1.0.0-beta.12",
4
4
  "description": "Trajectory comparison library (WASM + TypeScript)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -26,11 +26,10 @@
26
26
  "docs": "typedoc src/index.ts --out ../../target/doc/js"
27
27
  },
28
28
  "devDependencies": {
29
- "@biomejs/biome": "^1.7.0",
30
- "typedoc": "^0.28.0",
31
- "typescript": "^5.3.0",
32
- "vite-plugin-wasm": "^3.3.0",
33
- "vite-plugin-top-level-await": "^1.4.0",
34
- "vitest": "^1.0.0"
29
+ "@biomejs/biome": "^2.6.8",
30
+ "typedoc": "^0.28.20",
31
+ "typescript": "^6.0.3",
32
+ "vite-plugin-wasm": "^3.6.0",
33
+ "vitest": "^5.1.0"
35
34
  }
36
35
  }