numbl 0.4.2 → 0.4.4

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.
Files changed (28) hide show
  1. package/dist-cli/cli.js +11359 -8530
  2. package/dist-lib/graphics/axisLimits.d.ts +23 -0
  3. package/dist-lib/graphics/figuresReducer.d.ts +77 -0
  4. package/dist-lib/graphics/types.d.ts +66 -0
  5. package/dist-lib/lib.js +24909 -22080
  6. package/dist-lib/numbl-core/executors/handleInline.d.ts +18 -2
  7. package/dist-lib/numbl-core/executors/jit/valueAdapter.d.ts +16 -9
  8. package/dist-lib/numbl-core/helpers/eigs-select.d.ts +25 -0
  9. package/dist-lib/numbl-core/jit/compileSpecC.d.ts +7 -0
  10. package/dist-lib/numbl-core/jit/lowering/definiteAssign.d.ts +42 -0
  11. package/dist-lib/numbl-core/lexer/types.d.ts +62 -61
  12. package/dist-lib/numbl-core/native/ts-lapack-eig-complex.d.ts +32 -0
  13. package/dist-lib/numbl-core/runtime/axisCommand.d.ts +34 -0
  14. package/dist-lib/numbl-core/runtime/plotUtils.d.ts +55 -2
  15. package/dist-lib/numbl-core/runtime/runtime.d.ts +8 -0
  16. package/dist-lib/numbl-core/runtime/runtimePlot.d.ts +6 -0
  17. package/dist-lib/numbl-core/runtime/struct-access.d.ts +4 -0
  18. package/dist-lib/numbl-core/version.d.ts +1 -1
  19. package/dist-plot-viewer/assets/index-Ct51ZiF1.js +4426 -0
  20. package/dist-plot-viewer/index.html +1 -1
  21. package/dist-site-viewer/assets/index-USrK1-DZ.js +4748 -0
  22. package/dist-site-viewer/assets/numbl-worker-s3tsbJJ2.js +12003 -0
  23. package/dist-site-viewer/index.html +1 -1
  24. package/dist-site-viewer/numbl-embed.js +76 -5
  25. package/package.json +1 -1
  26. package/dist-plot-viewer/assets/index-DfxsWeyf.js +0 -4426
  27. package/dist-site-viewer/assets/index-D0XGPdHU.js +0 -4748
  28. package/dist-site-viewer/assets/numbl-worker-B18l6dfh.js +0 -11993
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Pure computation of the current axis limits for an `AxesState`.
3
+ *
4
+ * This is the source of truth for the query form `lim = axis`: the numbl
5
+ * runtime reduces its accumulated plot instructions into an `AxesState` and
6
+ * asks this module for the limit vector. It is deliberately rendering-free
7
+ * (no canvas, no DOM) so numbl-core can import it.
8
+ *
9
+ * For an axis with an explicit limit, that limit is returned verbatim (a
10
+ * `null` bound falls back to the data-derived bound). For a fully automatic
11
+ * axis the data extent is computed across every trace type and padded the
12
+ * same way `drawPlot` pads a default 2-D view, so the reported limits track
13
+ * what is drawn.
14
+ */
15
+ import type { AxesState } from "./figuresReducer.js";
16
+ /** Does this axes hold any 3-D content (so limits are a 6-vector)? */
17
+ export declare function axesIs3D(axes: AxesState): boolean;
18
+ /**
19
+ * Compute the limit vector for `lim = axis`.
20
+ * Returns 4 elements `[xmin xmax ymin ymax]` for a 2-D view, or 6 elements
21
+ * `[xmin xmax ymin ymax zmin zmax]` when the axes holds 3-D content.
22
+ */
23
+ export declare function computeAxisLimits(axes: AxesState): number[];
@@ -0,0 +1,77 @@
1
+ import type { PlotTrace, Plot3Trace, PatchTrace, SurfTrace, ImagescTrace, PcolorTrace, ContourTrace, BarTrace, Bar3Trace, ErrorBarTrace, BoxTrace, PieTrace, HeatmapTrace, QuiverTrace, Quiver3Trace, PlotInstruction } from "./types.js";
2
+ export type AxesState = {
3
+ holdOn: boolean;
4
+ traces: PlotTrace[];
5
+ plot3Traces: Plot3Trace[];
6
+ surfTraces: SurfTrace[];
7
+ imagescTrace?: ImagescTrace;
8
+ pcolorTraces: PcolorTrace[];
9
+ contourTraces: ContourTrace[];
10
+ barTraces: BarTrace[];
11
+ barhTraces: BarTrace[];
12
+ bar3Traces: Bar3Trace[];
13
+ bar3hTraces: Bar3Trace[];
14
+ errorBarTraces: ErrorBarTrace[];
15
+ boxTraces: BoxTrace[];
16
+ pieTrace?: PieTrace;
17
+ heatmapTrace?: HeatmapTrace;
18
+ quiverTraces: QuiverTrace[];
19
+ quiver3Traces: Quiver3Trace[];
20
+ areaTraces: PlotTrace[];
21
+ areaBaseValue: number;
22
+ patchTraces: PatchTrace[];
23
+ title?: string;
24
+ xlabel?: string;
25
+ ylabel?: string;
26
+ zlabel?: string;
27
+ shading?: "faceted" | "flat" | "interp";
28
+ legend?: string[];
29
+ gridOn?: boolean;
30
+ /** Axes border. Undefined/true → full rectangle (numbl's default, matching
31
+ * MATLAB `box on`); false → only the left and bottom axis lines (`box off`). */
32
+ boxOn?: boolean;
33
+ colorbar?: boolean;
34
+ colorbarLocation?: string;
35
+ colormap?: string;
36
+ colormapData?: number[][];
37
+ view?: {
38
+ az: number;
39
+ el: number;
40
+ };
41
+ axisMode?: string;
42
+ axisScale?: "linear" | "semilogx" | "semilogy" | "loglog";
43
+ caxis?: [number, number];
44
+ /** Explicit axis limits from `axis([...])` / `xlim` / `ylim`. Each bound
45
+ * may be `null`, meaning "use the data-derived bound" (partial limits). An
46
+ * absent field means the whole axis is automatic. */
47
+ xlim?: [number | null, number | null];
48
+ ylim?: [number | null, number | null];
49
+ zlim?: [number | null, number | null];
50
+ /** y-axis direction: "reverse" is `axis ij` (origin at top-left). */
51
+ yDir?: "normal" | "reverse";
52
+ /** Axes lines/background visibility (`axis off` sets this false). */
53
+ axisVisible?: boolean;
54
+ };
55
+ export type FigureState = {
56
+ subplotGrid?: {
57
+ rows: number;
58
+ cols: number;
59
+ };
60
+ currentAxesIndex: number;
61
+ sgtitle?: string;
62
+ axes: {
63
+ [index: number]: AxesState;
64
+ };
65
+ };
66
+ export type FiguresState = {
67
+ currentHandle: number;
68
+ figs: {
69
+ [handle: number]: FigureState;
70
+ };
71
+ };
72
+ /** Actions accepted by the figures reducer: any PlotInstruction, plus "clear" for UI resets. */
73
+ export type FiguresAction = PlotInstruction | {
74
+ type: "clear";
75
+ };
76
+ export declare const initialFiguresState: FiguresState;
77
+ export declare const figuresReducer: (state: FiguresState, action: FiguresAction) => FiguresState;
@@ -19,6 +19,10 @@ export interface PlotTrace {
19
19
  markerEdgeColor?: [number, number, number];
20
20
  markerFaceColor?: [number, number, number];
21
21
  markerIndices?: number[];
22
+ /** Stable identity for a trace returned as a graphics handle (e.g. from
23
+ * `line`). Lets `set(h,'XData',...)` / `update_trace` find and mutate this
24
+ * exact trace in the renderer's accumulated state across `drawnow`. */
25
+ id?: number;
22
26
  }
23
27
  export interface Plot3Trace {
24
28
  x: number[];
@@ -32,6 +36,35 @@ export interface Plot3Trace {
32
36
  markerEdgeColor?: [number, number, number];
33
37
  markerFaceColor?: [number, number, number];
34
38
  markerIndices?: number[];
39
+ /** See PlotTrace.id. */
40
+ id?: number;
41
+ }
42
+ /** A patch object: one or more colored polygons sharing a single set of
43
+ * vertices. Mirrors MATLAB's Faces/Vertices model — `patch(X,Y,C)` and the
44
+ * name-value forms are all canonicalized to this shape at parse time. */
45
+ export interface PatchTrace {
46
+ /** Unique vertices: `vertices[k] = [x, y]` (2-D) or `[x, y, z]` (3-D). */
47
+ vertices: number[][];
48
+ /** Faces as 0-based vertex-index arrays — one polygon per face. */
49
+ faces: number[][];
50
+ /** Single RGB for all faces, a colormap keyword, or 'none'. */
51
+ faceColor?: [number, number, number] | "flat" | "interp" | "none";
52
+ /** Edge color (default black [0,0,0]). */
53
+ edgeColor?: [number, number, number] | "flat" | "interp" | "none";
54
+ /** Face transparency in [0,1]. */
55
+ faceAlpha?: number;
56
+ lineWidth?: number;
57
+ lineStyle?: string;
58
+ marker?: string;
59
+ markerFaceColor?: [number, number, number] | "flat" | "none";
60
+ /** Color data driving 'flat'/'interp': one entry per face (flat) or per
61
+ * vertex (interp). Each entry is a scalar (mapped through the colormap) or
62
+ * an RGB triplet. */
63
+ faceVertexCData?: (number | [number, number, number])[];
64
+ /** True when vertices carry a z-coordinate (3-D patch). */
65
+ is3D?: boolean;
66
+ /** See PlotTrace.id — lets `set(p,...)` live-update this patch. */
67
+ id?: number;
35
68
  }
36
69
  export interface SurfTrace {
37
70
  /** X coordinates: flat array of length rows*cols (column-major) */
@@ -219,6 +252,12 @@ export interface HeatmapTrace {
219
252
  /** Y-axis labels (one per row) */
220
253
  yLabels?: string[];
221
254
  }
255
+ /** A single axis's limit request from `axis([...])` / `axis auto`.
256
+ * - A `[lo, hi]` pair, where either bound may be `null` to mean "keep the
257
+ * automatically-chosen bound" (from `inf`/`-inf` in the limits vector).
258
+ * - The string `"auto"` clears any explicit limit so the axis refits to its
259
+ * data (from `axis auto` / `axis 'auto x'`). */
260
+ export type AxisLimitSpec = [number | null, number | null] | "auto";
222
261
  export type PlotInstruction = {
223
262
  type: "set_figure_handle";
224
263
  handle: number;
@@ -228,6 +267,19 @@ export type PlotInstruction = {
228
267
  } | {
229
268
  type: "plot3";
230
269
  traces: Plot3Trace[];
270
+ } | {
271
+ type: "line";
272
+ traces: PlotTrace[];
273
+ } | {
274
+ type: "line3";
275
+ traces: Plot3Trace[];
276
+ } | {
277
+ type: "patch";
278
+ trace: PatchTrace;
279
+ } | {
280
+ type: "update_trace";
281
+ id: number;
282
+ props: Record<string, unknown>;
231
283
  } | {
232
284
  type: "surf";
233
285
  trace: SurfTrace;
@@ -321,6 +373,9 @@ export type PlotInstruction = {
321
373
  } | {
322
374
  type: "set_grid";
323
375
  value: boolean;
376
+ } | {
377
+ type: "set_box";
378
+ value: boolean;
324
379
  } | {
325
380
  type: "set_colorbar";
326
381
  value: string;
@@ -332,6 +387,17 @@ export type PlotInstruction = {
332
387
  } | {
333
388
  type: "set_axis";
334
389
  value: string;
390
+ } | {
391
+ type: "set_axis_limits";
392
+ xlim?: AxisLimitSpec;
393
+ ylim?: AxisLimitSpec;
394
+ zlim?: AxisLimitSpec;
395
+ } | {
396
+ type: "set_axis_ydir";
397
+ dir: "normal" | "reverse";
398
+ } | {
399
+ type: "set_axis_visible";
400
+ value: boolean;
335
401
  } | {
336
402
  type: "set_axis_scale";
337
403
  value: "linear" | "semilogx" | "semilogy" | "loglog";