@platforma-sdk/model 1.53.11 → 1.53.13
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/dist/annotations/converter.cjs +11 -11
- package/dist/annotations/converter.cjs.map +1 -1
- package/dist/annotations/converter.d.ts +1 -1
- package/dist/annotations/converter.d.ts.map +1 -1
- package/dist/annotations/converter.js +11 -11
- package/dist/annotations/converter.js.map +1 -1
- package/dist/annotations/index.d.ts +2 -2
- package/dist/annotations/types.d.ts +4 -4
- package/dist/bconfig/index.d.ts +5 -5
- package/dist/bconfig/lambdas.d.ts +7 -7
- package/dist/bconfig/lambdas.d.ts.map +1 -1
- package/dist/bconfig/normalization.cjs.map +1 -1
- package/dist/bconfig/normalization.d.ts +3 -3
- package/dist/bconfig/normalization.js.map +1 -1
- package/dist/bconfig/types.cjs.map +1 -1
- package/dist/bconfig/types.d.ts +2 -2
- package/dist/bconfig/types.d.ts.map +1 -1
- package/dist/bconfig/types.js.map +1 -1
- package/dist/bconfig/util.d.ts +4 -4
- package/dist/bconfig/v3.d.ts +3 -3
- package/dist/block_api_v1.d.ts +2 -2
- package/dist/block_api_v1.d.ts.map +1 -1
- package/dist/block_api_v2.d.ts +2 -2
- package/dist/block_api_v2.d.ts.map +1 -1
- package/dist/block_api_v3.d.ts +3 -3
- package/dist/block_migrations.cjs +10 -10
- package/dist/block_migrations.cjs.map +1 -1
- package/dist/block_migrations.d.ts.map +1 -1
- package/dist/block_migrations.js +10 -10
- package/dist/block_migrations.js.map +1 -1
- package/dist/block_model.cjs +11 -11
- package/dist/block_model.cjs.map +1 -1
- package/dist/block_model.d.ts +8 -8
- package/dist/block_model.d.ts.map +1 -1
- package/dist/block_model.js +11 -11
- package/dist/block_model.js.map +1 -1
- package/dist/block_state_patch.d.ts +2 -2
- package/dist/block_state_util.cjs +1 -1
- package/dist/block_state_util.cjs.map +1 -1
- package/dist/block_state_util.d.ts +3 -3
- package/dist/block_state_util.js +1 -1
- package/dist/block_state_util.js.map +1 -1
- package/dist/block_storage.cjs +10 -10
- package/dist/block_storage.cjs.map +1 -1
- package/dist/block_storage.d.ts +2 -2
- package/dist/block_storage.d.ts.map +1 -1
- package/dist/block_storage.js +10 -10
- package/dist/block_storage.js.map +1 -1
- package/dist/block_storage_vm.cjs +22 -22
- package/dist/block_storage_vm.cjs.map +1 -1
- package/dist/block_storage_vm.d.ts +1 -1
- package/dist/block_storage_vm.d.ts.map +1 -1
- package/dist/block_storage_vm.js +22 -22
- package/dist/block_storage_vm.js.map +1 -1
- package/dist/builder.cjs +32 -23
- package/dist/builder.cjs.map +1 -1
- package/dist/builder.d.ts +7 -7
- package/dist/builder.d.ts.map +1 -1
- package/dist/builder.js +32 -23
- package/dist/builder.js.map +1 -1
- package/dist/components/PFrameForGraphs.cjs +7 -6
- package/dist/components/PFrameForGraphs.cjs.map +1 -1
- package/dist/components/PFrameForGraphs.d.ts +4 -4
- package/dist/components/PFrameForGraphs.d.ts.map +1 -1
- package/dist/components/PFrameForGraphs.js +7 -6
- package/dist/components/PFrameForGraphs.js.map +1 -1
- package/dist/components/PlAnnotations/filter.d.ts +14 -14
- package/dist/components/PlAnnotations/filter.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.cjs +46 -46
- package/dist/components/PlAnnotations/filters_ui.cjs.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.d.ts +10 -34
- package/dist/components/PlAnnotations/filters_ui.d.ts.map +1 -1
- package/dist/components/PlAnnotations/filters_ui.js +46 -46
- package/dist/components/PlAnnotations/filters_ui.js.map +1 -1
- package/dist/components/PlAnnotations/index.d.ts +2 -2
- package/dist/components/PlAnnotations/types.d.ts +2 -2
- package/dist/components/PlDataTable.cjs +19 -20
- package/dist/components/PlDataTable.cjs.map +1 -1
- package/dist/components/PlDataTable.d.ts +27 -27
- package/dist/components/PlDataTable.d.ts.map +1 -1
- package/dist/components/PlDataTable.js +19 -20
- package/dist/components/PlDataTable.js.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.cjs +2 -2
- package/dist/components/PlMultiSequenceAlignment.cjs.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.d.ts +6 -6
- package/dist/components/PlMultiSequenceAlignment.d.ts.map +1 -1
- package/dist/components/PlMultiSequenceAlignment.js +2 -2
- package/dist/components/PlMultiSequenceAlignment.js.map +1 -1
- package/dist/components/PlSelectionModel.cjs.map +1 -1
- package/dist/components/PlSelectionModel.d.ts +1 -1
- package/dist/components/PlSelectionModel.js.map +1 -1
- package/dist/components/index.d.ts +5 -5
- package/dist/config/actions.cjs +39 -39
- package/dist/config/actions.cjs.map +1 -1
- package/dist/config/actions.d.ts +9 -9
- package/dist/config/actions.d.ts.map +1 -1
- package/dist/config/actions.js +39 -39
- package/dist/config/actions.js.map +1 -1
- package/dist/config/actions_kinds.d.ts +30 -30
- package/dist/config/actions_kinds.d.ts.map +1 -1
- package/dist/config/index.d.ts +6 -6
- package/dist/config/model.d.ts +28 -28
- package/dist/config/model_meta.d.ts +1 -1
- package/dist/config/type_engine.d.ts +3 -3
- package/dist/config/type_util.d.ts +2 -2
- package/dist/env_value.cjs +1 -1
- package/dist/env_value.cjs.map +1 -1
- package/dist/env_value.js +1 -1
- package/dist/env_value.js.map +1 -1
- package/dist/filters/converter.cjs +36 -32
- package/dist/filters/converter.cjs.map +1 -1
- package/dist/filters/converter.d.ts +2 -2
- package/dist/filters/converter.d.ts.map +1 -1
- package/dist/filters/converter.js +36 -32
- package/dist/filters/converter.js.map +1 -1
- package/dist/filters/index.d.ts +2 -2
- package/dist/filters/types.d.ts +33 -33
- package/dist/filters/types.d.ts.map +1 -1
- package/dist/index.d.ts +24 -24
- package/dist/internal.cjs +7 -7
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.ts +4 -4
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.js +7 -7
- package/dist/internal.js.map +1 -1
- package/dist/package.json.cjs +1 -1
- package/dist/package.json.js +1 -1
- package/dist/pframe.cjs +1 -1
- package/dist/pframe.cjs.map +1 -1
- package/dist/pframe.d.ts +1 -1
- package/dist/pframe.js +1 -1
- package/dist/pframe.js.map +1 -1
- package/dist/pframe_utils/columns.cjs +23 -15
- package/dist/pframe_utils/columns.cjs.map +1 -1
- package/dist/pframe_utils/columns.d.ts +3 -3
- package/dist/pframe_utils/columns.d.ts.map +1 -1
- package/dist/pframe_utils/columns.js +23 -15
- package/dist/pframe_utils/columns.js.map +1 -1
- package/dist/pframe_utils/index.cjs +25 -25
- package/dist/pframe_utils/index.cjs.map +1 -1
- package/dist/pframe_utils/index.d.ts +3 -3
- package/dist/pframe_utils/index.d.ts.map +1 -1
- package/dist/pframe_utils/index.js +25 -25
- package/dist/pframe_utils/index.js.map +1 -1
- package/dist/platforma.d.ts +7 -7
- package/dist/platforma.d.ts.map +1 -1
- package/dist/raw_globals.cjs +4 -1
- package/dist/raw_globals.cjs.map +1 -1
- package/dist/raw_globals.d.ts +2 -2
- package/dist/raw_globals.d.ts.map +1 -1
- package/dist/raw_globals.js +4 -1
- package/dist/raw_globals.js.map +1 -1
- package/dist/ref_util.cjs +4 -4
- package/dist/ref_util.cjs.map +1 -1
- package/dist/ref_util.d.ts +1 -1
- package/dist/ref_util.js +4 -4
- package/dist/ref_util.js.map +1 -1
- package/dist/render/accessor.cjs +24 -24
- package/dist/render/accessor.cjs.map +1 -1
- package/dist/render/accessor.d.ts +10 -10
- package/dist/render/accessor.d.ts.map +1 -1
- package/dist/render/accessor.js +24 -24
- package/dist/render/accessor.js.map +1 -1
- package/dist/render/api.cjs +23 -23
- package/dist/render/api.cjs.map +1 -1
- package/dist/render/api.d.ts +11 -11
- package/dist/render/api.d.ts.map +1 -1
- package/dist/render/api.js +23 -23
- package/dist/render/api.js.map +1 -1
- package/dist/render/future.cjs.map +1 -1
- package/dist/render/future.d.ts +1 -1
- package/dist/render/future.js.map +1 -1
- package/dist/render/index.d.ts +6 -6
- package/dist/render/internal.cjs +4 -4
- package/dist/render/internal.cjs.map +1 -1
- package/dist/render/internal.d.ts +7 -7
- package/dist/render/internal.d.ts.map +1 -1
- package/dist/render/internal.js +4 -4
- package/dist/render/internal.js.map +1 -1
- package/dist/render/traversal_ops.d.ts +1 -1
- package/dist/render/util/axis_filtering.cjs +48 -44
- package/dist/render/util/axis_filtering.cjs.map +1 -1
- package/dist/render/util/axis_filtering.d.ts +2 -2
- package/dist/render/util/axis_filtering.js +48 -44
- package/dist/render/util/axis_filtering.js.map +1 -1
- package/dist/render/util/column_collection.cjs +42 -35
- package/dist/render/util/column_collection.cjs.map +1 -1
- package/dist/render/util/column_collection.d.ts +4 -4
- package/dist/render/util/column_collection.d.ts.map +1 -1
- package/dist/render/util/column_collection.js +42 -35
- package/dist/render/util/column_collection.js.map +1 -1
- package/dist/render/util/index.d.ts +4 -4
- package/dist/render/util/label.cjs +15 -21
- package/dist/render/util/label.cjs.map +1 -1
- package/dist/render/util/label.d.ts +2 -2
- package/dist/render/util/label.d.ts.map +1 -1
- package/dist/render/util/label.js +15 -21
- package/dist/render/util/label.js.map +1 -1
- package/dist/render/util/pcolumn_data.cjs +56 -54
- package/dist/render/util/pcolumn_data.cjs.map +1 -1
- package/dist/render/util/pcolumn_data.d.ts +5 -5
- package/dist/render/util/pcolumn_data.d.ts.map +1 -1
- package/dist/render/util/pcolumn_data.js +56 -54
- package/dist/render/util/pcolumn_data.js.map +1 -1
- package/dist/render/util/pframe_upgraders.cjs +6 -6
- package/dist/render/util/pframe_upgraders.cjs.map +1 -1
- package/dist/render/util/pframe_upgraders.d.ts +1 -1
- package/dist/render/util/pframe_upgraders.d.ts.map +1 -1
- package/dist/render/util/pframe_upgraders.js +6 -6
- package/dist/render/util/pframe_upgraders.js.map +1 -1
- package/dist/render/util/split_selectors.d.ts +1 -1
- package/dist/render/util/split_selectors.d.ts.map +1 -1
- package/dist/sdk_info.cjs.map +1 -1
- package/dist/sdk_info.js.map +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +24 -22
- package/src/annotations/converter.test.ts +98 -101
- package/src/annotations/converter.ts +21 -17
- package/src/annotations/index.ts +2 -2
- package/src/annotations/types.ts +4 -4
- package/src/bconfig/index.ts +5 -5
- package/src/bconfig/lambdas.ts +10 -12
- package/src/bconfig/normalization.ts +5 -5
- package/src/bconfig/types.ts +3 -5
- package/src/bconfig/util.ts +3 -3
- package/src/bconfig/v3.ts +3 -3
- package/src/block_api_v1.ts +7 -3
- package/src/block_api_v2.ts +7 -3
- package/src/block_api_v3.ts +3 -3
- package/src/block_migrations.test.ts +66 -67
- package/src/block_migrations.ts +16 -16
- package/src/block_model.ts +76 -140
- package/src/block_state_patch.ts +2 -2
- package/src/block_state_util.ts +4 -4
- package/src/block_storage.test.ts +106 -99
- package/src/block_storage.ts +22 -25
- package/src/block_storage_vm.ts +41 -35
- package/src/builder.ts +107 -95
- package/src/components/PFrameForGraphs.test.ts +261 -255
- package/src/components/PFrameForGraphs.ts +35 -22
- package/src/components/PlAnnotations/filter.ts +21 -15
- package/src/components/PlAnnotations/filters_ui.test.ts +230 -73
- package/src/components/PlAnnotations/filters_ui.ts +138 -105
- package/src/components/PlAnnotations/index.ts +2 -2
- package/src/components/PlAnnotations/types.ts +2 -2
- package/src/components/PlDataTable.ts +177 -164
- package/src/components/PlMultiSequenceAlignment.ts +11 -18
- package/src/components/PlSelectionModel.ts +1 -1
- package/src/components/index.ts +5 -5
- package/src/config/actions.ts +64 -59
- package/src/config/actions_kinds.ts +38 -34
- package/src/config/index.ts +6 -6
- package/src/config/model.ts +28 -28
- package/src/config/model_meta.ts +1 -1
- package/src/config/type_engine.ts +3 -3
- package/src/config/type_util.ts +2 -2
- package/src/env_value.ts +2 -2
- package/src/filters/converter.test.ts +185 -144
- package/src/filters/converter.ts +47 -35
- package/src/filters/index.ts +2 -2
- package/src/filters/types.ts +44 -39
- package/src/global.d.ts +1 -1
- package/src/index.ts +24 -24
- package/src/internal.ts +27 -17
- package/src/pframe.ts +3 -3
- package/src/pframe_utils/columns.ts +81 -31
- package/src/pframe_utils/index.ts +65 -43
- package/src/platforma.ts +44 -21
- package/src/raw_globals.ts +13 -7
- package/src/ref_util.ts +6 -6
- package/src/render/accessor.ts +43 -44
- package/src/render/api.ts +102 -78
- package/src/render/future.ts +2 -2
- package/src/render/index.ts +6 -6
- package/src/render/internal.ts +11 -12
- package/src/render/traversal_ops.ts +1 -1
- package/src/render/util/axis_filtering.ts +67 -52
- package/src/render/util/column_collection.ts +171 -91
- package/src/render/util/index.ts +4 -4
- package/src/render/util/label.test.ts +139 -139
- package/src/render/util/label.ts +42 -33
- package/src/render/util/pcolumn_data.ts +111 -75
- package/src/render/util/pframe_upgraders.ts +24 -13
- package/src/render/util/split_selectors.ts +6 -1
- package/src/sdk_info.ts +1 -1
- package/src/typing.test.ts +56 -56
- package/src/version.ts +1 -1
|
@@ -1,279 +1,279 @@
|
|
|
1
|
-
import { Annotation, PColumnSpec } from
|
|
2
|
-
import { expect, test } from
|
|
3
|
-
import { deriveLabels, Trace } from
|
|
1
|
+
import { Annotation, PColumnSpec } from "@milaboratories/pl-model-common";
|
|
2
|
+
import { expect, test } from "vitest";
|
|
3
|
+
import { deriveLabels, Trace } from "./label";
|
|
4
4
|
|
|
5
5
|
function tracesToSpecs(traces: Trace[]) {
|
|
6
6
|
return traces.map(
|
|
7
7
|
(t) =>
|
|
8
8
|
({
|
|
9
|
-
kind:
|
|
10
|
-
name:
|
|
11
|
-
valueType:
|
|
9
|
+
kind: "PColumn",
|
|
10
|
+
name: "name",
|
|
11
|
+
valueType: "Int",
|
|
12
12
|
annotations: {
|
|
13
13
|
[Annotation.Trace]: JSON.stringify(t),
|
|
14
|
-
[Annotation.Label]:
|
|
14
|
+
[Annotation.Label]: "Label",
|
|
15
15
|
},
|
|
16
|
-
axesSpec: []
|
|
17
|
-
}) satisfies PColumnSpec
|
|
16
|
+
axesSpec: [],
|
|
17
|
+
}) satisfies PColumnSpec,
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
20
|
test.each<{ name: string; traces: Trace[]; labels: string[] }>([
|
|
21
21
|
{
|
|
22
|
-
name:
|
|
23
|
-
traces: [[{ type:
|
|
24
|
-
labels: [
|
|
22
|
+
name: "simple",
|
|
23
|
+
traces: [[{ type: "t1", label: "L1" }], [{ type: "t1", label: "L2" }]],
|
|
24
|
+
labels: ["L1", "L2"],
|
|
25
25
|
},
|
|
26
26
|
{
|
|
27
|
-
name:
|
|
27
|
+
name: "later wins",
|
|
28
28
|
traces: [
|
|
29
29
|
[
|
|
30
|
-
{ type:
|
|
31
|
-
{ type:
|
|
30
|
+
{ type: "t1", label: "T1L1" },
|
|
31
|
+
{ type: "t2", label: "T2L1" },
|
|
32
32
|
],
|
|
33
33
|
[
|
|
34
|
-
{ type:
|
|
35
|
-
{ type:
|
|
36
|
-
]
|
|
34
|
+
{ type: "t1", label: "T1L2" },
|
|
35
|
+
{ type: "t2", label: "T2L2" },
|
|
36
|
+
],
|
|
37
37
|
],
|
|
38
|
-
labels: [
|
|
38
|
+
labels: ["T2L1", "T2L2"],
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
|
-
name:
|
|
41
|
+
name: "importance wins",
|
|
42
42
|
traces: [
|
|
43
43
|
[
|
|
44
|
-
{ type:
|
|
45
|
-
{ type:
|
|
44
|
+
{ type: "t1", importance: 100, label: "T1L1" },
|
|
45
|
+
{ type: "t2", label: "T2L1" },
|
|
46
46
|
],
|
|
47
47
|
[
|
|
48
|
-
{ type:
|
|
49
|
-
{ type:
|
|
50
|
-
]
|
|
48
|
+
{ type: "t1", importance: 100, label: "T1L2" },
|
|
49
|
+
{ type: "t2", label: "T2L2" },
|
|
50
|
+
],
|
|
51
51
|
],
|
|
52
|
-
labels: [
|
|
52
|
+
labels: ["T1L1", "T1L2"],
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
name:
|
|
55
|
+
name: "uniqueness wins",
|
|
56
56
|
traces: [
|
|
57
57
|
[
|
|
58
|
-
{ type:
|
|
59
|
-
{ type:
|
|
58
|
+
{ type: "t1", label: "T1L1" },
|
|
59
|
+
{ type: "t2", label: "T2L1" },
|
|
60
60
|
],
|
|
61
61
|
[
|
|
62
|
-
{ type:
|
|
63
|
-
{ type:
|
|
64
|
-
]
|
|
62
|
+
{ type: "t1", label: "T1L2" },
|
|
63
|
+
{ type: "t2", label: "T2L1" },
|
|
64
|
+
],
|
|
65
65
|
],
|
|
66
|
-
labels: [
|
|
66
|
+
labels: ["T1L1", "T1L2"],
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
|
-
name:
|
|
69
|
+
name: "combinatoric solution",
|
|
70
70
|
traces: [
|
|
71
71
|
[
|
|
72
|
-
{ type:
|
|
73
|
-
{ type:
|
|
72
|
+
{ type: "t1", label: "T1L1" },
|
|
73
|
+
{ type: "t2", label: "T2L1" },
|
|
74
74
|
],
|
|
75
75
|
[
|
|
76
|
-
{ type:
|
|
77
|
-
{ type:
|
|
76
|
+
{ type: "t1", label: "T1L1" },
|
|
77
|
+
{ type: "t2", label: "T2L2" },
|
|
78
78
|
],
|
|
79
79
|
[
|
|
80
|
-
{ type:
|
|
81
|
-
{ type:
|
|
82
|
-
]
|
|
80
|
+
{ type: "t1", label: "T1L2" },
|
|
81
|
+
{ type: "t2", label: "T2L2" },
|
|
82
|
+
],
|
|
83
83
|
],
|
|
84
|
-
labels: [
|
|
84
|
+
labels: ["T1L1 / T2L1", "T1L1 / T2L2", "T1L2 / T2L2"],
|
|
85
85
|
},
|
|
86
86
|
{
|
|
87
|
-
name:
|
|
87
|
+
name: "different importance and id",
|
|
88
88
|
traces: [
|
|
89
|
-
[{ type:
|
|
90
|
-
[{ type:
|
|
89
|
+
[{ type: "sameType", importance: 10, id: "id1", label: "High importance" }],
|
|
90
|
+
[{ type: "sameType", importance: 5, id: "id2", label: "Low importance" }],
|
|
91
91
|
],
|
|
92
|
-
labels: [
|
|
92
|
+
labels: ["High importance", "Low importance"],
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
|
-
name:
|
|
95
|
+
name: "mixed common and different entries",
|
|
96
96
|
traces: [
|
|
97
97
|
[
|
|
98
|
-
{ type:
|
|
99
|
-
{ type:
|
|
98
|
+
{ type: "commonType", importance: 1, id: "common", label: "Common entry" },
|
|
99
|
+
{ type: "uniqueType", importance: 10, id: "id1", label: "Unique entry 1" },
|
|
100
100
|
],
|
|
101
101
|
[
|
|
102
|
-
{ type:
|
|
103
|
-
{ type:
|
|
104
|
-
]
|
|
102
|
+
{ type: "commonType", importance: 1, id: "common", label: "Common entry" },
|
|
103
|
+
{ type: "uniqueType", importance: 5, id: "id2", label: "Unique entry 2" },
|
|
104
|
+
],
|
|
105
105
|
],
|
|
106
|
-
labels: [
|
|
107
|
-
}
|
|
108
|
-
])(
|
|
106
|
+
labels: ["Unique entry 1", "Unique entry 2"],
|
|
107
|
+
},
|
|
108
|
+
])("test label derivation: $name", ({ traces, labels }) => {
|
|
109
109
|
expect(deriveLabels(tracesToSpecs(traces), (s) => s).map((r) => r.label)).toEqual(labels);
|
|
110
110
|
expect(
|
|
111
|
-
deriveLabels(tracesToSpecs(traces), (s) => s, { includeNativeLabel: true }).map((r) => r.label)
|
|
112
|
-
).toEqual(labels.map((l) =>
|
|
111
|
+
deriveLabels(tracesToSpecs(traces), (s) => s, { includeNativeLabel: true }).map((r) => r.label),
|
|
112
|
+
).toEqual(labels.map((l) => "Label / " + l));
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
test(
|
|
115
|
+
test("test fallback to native labels in label derivation", () => {
|
|
116
116
|
expect(deriveLabels(tracesToSpecs([[], []]), (s) => s).map((r) => r.label)).toEqual([
|
|
117
|
-
|
|
118
|
-
|
|
117
|
+
"Label",
|
|
118
|
+
"Label",
|
|
119
119
|
]);
|
|
120
120
|
});
|
|
121
121
|
|
|
122
122
|
test.each<{ name: string; traces: Trace[]; labels: string[] }>([
|
|
123
123
|
{
|
|
124
|
-
name:
|
|
124
|
+
name: "removes redundant low-importance type when high-importance alone suffices",
|
|
125
125
|
traces: [
|
|
126
126
|
[
|
|
127
|
-
{ type:
|
|
128
|
-
{ type:
|
|
127
|
+
{ type: "t1", importance: 10, label: "High1" },
|
|
128
|
+
{ type: "t2", importance: 1, label: "Low1" },
|
|
129
129
|
],
|
|
130
130
|
[
|
|
131
|
-
{ type:
|
|
132
|
-
{ type:
|
|
133
|
-
]
|
|
131
|
+
{ type: "t1", importance: 10, label: "High2" },
|
|
132
|
+
{ type: "t2", importance: 1, label: "Low2" },
|
|
133
|
+
],
|
|
134
134
|
],
|
|
135
135
|
// Both t1 and t2 distinguish, but t2 (low importance) should be removed since t1 alone suffices
|
|
136
|
-
labels: [
|
|
136
|
+
labels: ["High1", "High2"],
|
|
137
137
|
},
|
|
138
138
|
{
|
|
139
|
-
name:
|
|
139
|
+
name: "keeps both types when both are needed for uniqueness",
|
|
140
140
|
traces: [
|
|
141
141
|
[
|
|
142
|
-
{ type:
|
|
143
|
-
{ type:
|
|
142
|
+
{ type: "t1", importance: 10, label: "A" },
|
|
143
|
+
{ type: "t2", importance: 1, label: "X" },
|
|
144
144
|
],
|
|
145
145
|
[
|
|
146
|
-
{ type:
|
|
147
|
-
{ type:
|
|
146
|
+
{ type: "t1", importance: 10, label: "A" },
|
|
147
|
+
{ type: "t2", importance: 1, label: "Y" },
|
|
148
148
|
],
|
|
149
149
|
[
|
|
150
|
-
{ type:
|
|
151
|
-
{ type:
|
|
152
|
-
]
|
|
150
|
+
{ type: "t1", importance: 10, label: "B" },
|
|
151
|
+
{ type: "t2", importance: 1, label: "Y" },
|
|
152
|
+
],
|
|
153
153
|
],
|
|
154
154
|
// Neither t1 nor t2 alone can distinguish all three, need both
|
|
155
|
-
labels: [
|
|
155
|
+
labels: ["A / X", "A / Y", "B / Y"],
|
|
156
156
|
},
|
|
157
157
|
{
|
|
158
|
-
name:
|
|
158
|
+
name: "removes multiple redundant types greedily",
|
|
159
159
|
traces: [
|
|
160
160
|
[
|
|
161
|
-
{ type:
|
|
162
|
-
{ type:
|
|
163
|
-
{ type:
|
|
161
|
+
{ type: "t1", importance: 100, label: "Unique1" },
|
|
162
|
+
{ type: "t2", importance: 10, label: "Same" },
|
|
163
|
+
{ type: "t3", importance: 1, label: "Same" },
|
|
164
164
|
],
|
|
165
165
|
[
|
|
166
|
-
{ type:
|
|
167
|
-
{ type:
|
|
168
|
-
{ type:
|
|
169
|
-
]
|
|
166
|
+
{ type: "t1", importance: 100, label: "Unique2" },
|
|
167
|
+
{ type: "t2", importance: 10, label: "Same" },
|
|
168
|
+
{ type: "t3", importance: 1, label: "Same" },
|
|
169
|
+
],
|
|
170
170
|
],
|
|
171
171
|
// t1 alone distinguishes; t2 and t3 are redundant and should be removed
|
|
172
|
-
labels: [
|
|
172
|
+
labels: ["Unique1", "Unique2"],
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
|
-
name:
|
|
175
|
+
name: "fallback case: removes types that do not reduce cardinality",
|
|
176
176
|
traces: [
|
|
177
177
|
// Two columns with identical traces - cannot be distinguished
|
|
178
178
|
[
|
|
179
|
-
{ type:
|
|
180
|
-
{ type:
|
|
181
|
-
{ type:
|
|
179
|
+
{ type: "t1", importance: 100, label: "A" },
|
|
180
|
+
{ type: "t2", importance: 10, label: "X" },
|
|
181
|
+
{ type: "t3", importance: 1, label: "Same" },
|
|
182
182
|
],
|
|
183
183
|
[
|
|
184
|
-
{ type:
|
|
185
|
-
{ type:
|
|
186
|
-
{ type:
|
|
184
|
+
{ type: "t1", importance: 100, label: "A" },
|
|
185
|
+
{ type: "t2", importance: 10, label: "X" },
|
|
186
|
+
{ type: "t3", importance: 1, label: "Same" },
|
|
187
187
|
],
|
|
188
188
|
// Third column is different
|
|
189
189
|
[
|
|
190
|
-
{ type:
|
|
191
|
-
{ type:
|
|
192
|
-
{ type:
|
|
193
|
-
]
|
|
190
|
+
{ type: "t1", importance: 100, label: "B" },
|
|
191
|
+
{ type: "t2", importance: 10, label: "Y" },
|
|
192
|
+
{ type: "t3", importance: 1, label: "Same" },
|
|
193
|
+
],
|
|
194
194
|
],
|
|
195
195
|
// Cannot achieve full uniqueness (2 columns are identical), but t3 (Same) can be removed
|
|
196
196
|
// since it doesn't help distinguish anything. t1 alone gives cardinality 2.
|
|
197
|
-
labels: [
|
|
198
|
-
}
|
|
199
|
-
])(
|
|
197
|
+
labels: ["A", "A", "B"],
|
|
198
|
+
},
|
|
199
|
+
])("test label minimization: $name", ({ traces, labels }) => {
|
|
200
200
|
expect(deriveLabels(tracesToSpecs(traces), (s) => s).map((r) => r.label)).toEqual(labels);
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
test.each<{ name: string; traces: Trace[]; labels: string[]; forceTraceElements: string[] }>([
|
|
204
204
|
{
|
|
205
|
-
name:
|
|
205
|
+
name: "force one element",
|
|
206
206
|
traces: [
|
|
207
207
|
[
|
|
208
|
-
{ type:
|
|
209
|
-
{ type:
|
|
208
|
+
{ type: "t1", label: "T1L1" },
|
|
209
|
+
{ type: "t2", label: "T2L1" },
|
|
210
210
|
],
|
|
211
211
|
[
|
|
212
|
-
{ type:
|
|
213
|
-
{ type:
|
|
214
|
-
]
|
|
212
|
+
{ type: "t1", label: "T1L2" },
|
|
213
|
+
{ type: "t2", label: "T2L2" },
|
|
214
|
+
],
|
|
215
215
|
],
|
|
216
|
-
labels: [
|
|
217
|
-
forceTraceElements: [
|
|
216
|
+
labels: ["T1L1", "T1L2"],
|
|
217
|
+
forceTraceElements: ["t1"],
|
|
218
218
|
},
|
|
219
219
|
{
|
|
220
|
-
name:
|
|
220
|
+
name: "force multiple elements",
|
|
221
221
|
traces: [
|
|
222
222
|
[
|
|
223
|
-
{ type:
|
|
224
|
-
{ type:
|
|
225
|
-
{ type:
|
|
223
|
+
{ type: "t1", label: "T1L1" },
|
|
224
|
+
{ type: "t2", label: "T2L1" },
|
|
225
|
+
{ type: "t3", label: "T3L1" },
|
|
226
226
|
],
|
|
227
227
|
[
|
|
228
|
-
{ type:
|
|
229
|
-
{ type:
|
|
230
|
-
{ type:
|
|
231
|
-
]
|
|
228
|
+
{ type: "t1", label: "T1L2" },
|
|
229
|
+
{ type: "t2", label: "T2L2" },
|
|
230
|
+
{ type: "t3", label: "T3L2" },
|
|
231
|
+
],
|
|
232
232
|
],
|
|
233
|
-
labels: [
|
|
234
|
-
forceTraceElements: [
|
|
233
|
+
labels: ["T1L1 / T3L1", "T1L2 / T3L2"],
|
|
234
|
+
forceTraceElements: ["t1", "t3"],
|
|
235
235
|
},
|
|
236
236
|
{
|
|
237
|
-
name:
|
|
237
|
+
name: "force element not in all traces",
|
|
238
238
|
traces: [
|
|
239
239
|
[
|
|
240
|
-
{ type:
|
|
241
|
-
{ type:
|
|
240
|
+
{ type: "t1", label: "T1L1" },
|
|
241
|
+
{ type: "t2", label: "T2L1" },
|
|
242
242
|
],
|
|
243
|
-
[{ type:
|
|
243
|
+
[{ type: "t2", label: "T2L2" }],
|
|
244
244
|
],
|
|
245
|
-
labels: [
|
|
246
|
-
forceTraceElements: [
|
|
245
|
+
labels: ["T1L1 / T2L1", "T2L2"],
|
|
246
|
+
forceTraceElements: ["t1"],
|
|
247
247
|
},
|
|
248
248
|
{
|
|
249
|
-
name:
|
|
249
|
+
name: "force element with includeNativeLabel",
|
|
250
250
|
traces: [
|
|
251
251
|
[
|
|
252
|
-
{ type:
|
|
253
|
-
{ type:
|
|
252
|
+
{ type: "t1", label: "T1L1" },
|
|
253
|
+
{ type: "t2", label: "T2L1" },
|
|
254
254
|
],
|
|
255
255
|
[
|
|
256
|
-
{ type:
|
|
257
|
-
{ type:
|
|
258
|
-
]
|
|
256
|
+
{ type: "t1", label: "T1L2" },
|
|
257
|
+
{ type: "t2", label: "T2L2" },
|
|
258
|
+
],
|
|
259
259
|
],
|
|
260
|
-
labels: [
|
|
261
|
-
forceTraceElements: [
|
|
262
|
-
}
|
|
260
|
+
labels: ["T1L1", "T1L2"],
|
|
261
|
+
forceTraceElements: ["t1"],
|
|
262
|
+
},
|
|
263
263
|
])(
|
|
264
|
-
|
|
264
|
+
"test label derivation with forceTraceElements: $name",
|
|
265
265
|
({ name, traces, labels, forceTraceElements }) => {
|
|
266
266
|
expect(
|
|
267
|
-
deriveLabels(tracesToSpecs(traces), (s) => s, { forceTraceElements }).map((r) => r.label)
|
|
267
|
+
deriveLabels(tracesToSpecs(traces), (s) => s, { forceTraceElements }).map((r) => r.label),
|
|
268
268
|
).toEqual(labels);
|
|
269
269
|
|
|
270
|
-
if (name ===
|
|
270
|
+
if (name === "force element with includeNativeLabel") {
|
|
271
271
|
expect(
|
|
272
272
|
deriveLabels(tracesToSpecs(traces), (s) => s, {
|
|
273
273
|
forceTraceElements,
|
|
274
|
-
includeNativeLabel: true
|
|
275
|
-
}).map((r) => r.label)
|
|
276
|
-
).toEqual(labels.map(l =>
|
|
274
|
+
includeNativeLabel: true,
|
|
275
|
+
}).map((r) => r.label),
|
|
276
|
+
).toEqual(labels.map((l) => "Label / " + l));
|
|
277
277
|
}
|
|
278
|
-
}
|
|
278
|
+
},
|
|
279
279
|
);
|
package/src/render/util/label.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {
|
|
2
|
+
Annotation,
|
|
3
|
+
parseJson,
|
|
4
|
+
readAnnotation,
|
|
5
|
+
type PObjectSpec,
|
|
6
|
+
} from "@milaboratories/pl-model-common";
|
|
7
|
+
import { z } from "zod";
|
|
3
8
|
|
|
4
9
|
export type RecordsWithLabel<T> = {
|
|
5
10
|
value: T;
|
|
@@ -31,16 +36,18 @@ export type Trace = z.infer<typeof Trace>;
|
|
|
31
36
|
type FullTrace = FullTraceEntry[];
|
|
32
37
|
|
|
33
38
|
// Define the possible return types for the specExtractor function
|
|
34
|
-
type SpecExtractorResult =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
+
type SpecExtractorResult =
|
|
40
|
+
| PObjectSpec
|
|
41
|
+
| {
|
|
42
|
+
spec: PObjectSpec;
|
|
43
|
+
prefixTrace?: TraceEntry[];
|
|
44
|
+
suffixTrace?: TraceEntry[];
|
|
45
|
+
};
|
|
39
46
|
|
|
40
47
|
const DistancePenalty = 0.001;
|
|
41
48
|
|
|
42
|
-
const LabelType =
|
|
43
|
-
const LabelTypeFull =
|
|
49
|
+
const LabelType = "__LABEL__";
|
|
50
|
+
const LabelTypeFull = "__LABEL__@1";
|
|
44
51
|
|
|
45
52
|
export function deriveLabels<T>(
|
|
46
53
|
values: T[],
|
|
@@ -49,9 +56,10 @@ export function deriveLabels<T>(
|
|
|
49
56
|
): RecordsWithLabel<T>[] {
|
|
50
57
|
const importances = new Map<string, number>();
|
|
51
58
|
|
|
52
|
-
const forceTraceElements =
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
const forceTraceElements =
|
|
60
|
+
ops.forceTraceElements !== undefined && ops.forceTraceElements.length > 0
|
|
61
|
+
? new Set(ops.forceTraceElements)
|
|
62
|
+
: undefined;
|
|
55
63
|
|
|
56
64
|
// number of times certain type occurred among all of the
|
|
57
65
|
const numberOfRecordsWithType = new Map<string, number>();
|
|
@@ -63,7 +71,7 @@ export function deriveLabels<T>(
|
|
|
63
71
|
let suffixTrace: TraceEntry[] | undefined;
|
|
64
72
|
|
|
65
73
|
// Check if the result is the new structure or just PObjectSpec
|
|
66
|
-
if (
|
|
74
|
+
if ("spec" in extractorResult && typeof extractorResult.spec === "object") {
|
|
67
75
|
// It's the new structure { spec, prefixTrace?, suffixTrace? }
|
|
68
76
|
spec = extractorResult.spec;
|
|
69
77
|
prefixTrace = extractorResult.prefixTrace;
|
|
@@ -77,11 +85,7 @@ export function deriveLabels<T>(
|
|
|
77
85
|
const traceStr = readAnnotation(spec, Annotation.Trace);
|
|
78
86
|
const baseTrace = (traceStr ? Trace.safeParse(parseJson(traceStr)).data : undefined) ?? [];
|
|
79
87
|
|
|
80
|
-
const trace = [
|
|
81
|
-
...(prefixTrace ?? []),
|
|
82
|
-
...baseTrace,
|
|
83
|
-
...(suffixTrace ?? []),
|
|
84
|
-
];
|
|
88
|
+
const trace = [...(prefixTrace ?? []), ...baseTrace, ...(suffixTrace ?? [])];
|
|
85
89
|
|
|
86
90
|
if (label !== undefined) {
|
|
87
91
|
const labelEntry = { label, type: LabelType, importance: -2 };
|
|
@@ -127,7 +131,7 @@ export function deriveLabels<T>(
|
|
|
127
131
|
allTypeRecords.sort(([, i1], [, i2]) => i2 - i1);
|
|
128
132
|
|
|
129
133
|
for (const [typeName] of allTypeRecords) {
|
|
130
|
-
if (typeName.endsWith(
|
|
134
|
+
if (typeName.endsWith("@1") || numberOfRecordsWithType.get(typeName) === values.length)
|
|
131
135
|
mainTypes.push(typeName);
|
|
132
136
|
else secondaryTypes.push(typeName);
|
|
133
137
|
}
|
|
@@ -136,20 +140,20 @@ export function deriveLabels<T>(
|
|
|
136
140
|
const result: RecordsWithLabel<T>[] = [];
|
|
137
141
|
for (let i = 0; i < enrichedRecords.length; i++) {
|
|
138
142
|
const r = enrichedRecords[i];
|
|
139
|
-
const includedTrace = r.fullTrace
|
|
140
|
-
|
|
141
|
-
|| (forceTraceElements && forceTraceElements.has(fm.type))
|
|
143
|
+
const includedTrace = r.fullTrace.filter(
|
|
144
|
+
(fm) =>
|
|
145
|
+
includedTypes.has(fm.fullType) || (forceTraceElements && forceTraceElements.has(fm.type)),
|
|
146
|
+
);
|
|
142
147
|
if (includedTrace.length === 0) {
|
|
143
148
|
if (force)
|
|
144
149
|
result.push({
|
|
145
|
-
label:
|
|
150
|
+
label: "Unlabeled",
|
|
146
151
|
value: r.value,
|
|
147
152
|
} satisfies RecordsWithLabel<T>);
|
|
148
153
|
else return undefined;
|
|
149
154
|
}
|
|
150
|
-
const labelSet = includedTrace
|
|
151
|
-
|
|
152
|
-
const sep = ops.separator ?? ' / ';
|
|
155
|
+
const labelSet = includedTrace.map((fm) => fm.label);
|
|
156
|
+
const sep = ops.separator ?? " / ";
|
|
153
157
|
result.push({
|
|
154
158
|
label: labelSet.join(sep),
|
|
155
159
|
value: r.value,
|
|
@@ -172,16 +176,21 @@ export function deriveLabels<T>(
|
|
|
172
176
|
|
|
173
177
|
// Get types sorted by importance ascending (lowest first), excluding forced elements
|
|
174
178
|
const removableSorted = [...typeSet]
|
|
175
|
-
.filter(
|
|
176
|
-
|
|
177
|
-
|
|
179
|
+
.filter(
|
|
180
|
+
(t) =>
|
|
181
|
+
!forceTraceElements?.has(t.split("@")[0]) &&
|
|
182
|
+
!(ops.includeNativeLabel && t === LabelTypeFull),
|
|
183
|
+
)
|
|
178
184
|
.sort((a, b) => (importances.get(a) ?? 0) - (importances.get(b) ?? 0));
|
|
179
185
|
|
|
180
186
|
for (const typeToRemove of removableSorted) {
|
|
181
187
|
const reducedSet = new Set(typeSet);
|
|
182
188
|
reducedSet.delete(typeToRemove);
|
|
183
189
|
const candidateResult = calculate(reducedSet);
|
|
184
|
-
if (
|
|
190
|
+
if (
|
|
191
|
+
candidateResult !== undefined &&
|
|
192
|
+
countUniqueLabels(candidateResult) >= currentCardinality
|
|
193
|
+
) {
|
|
185
194
|
typeSet.delete(typeToRemove);
|
|
186
195
|
}
|
|
187
196
|
}
|
|
@@ -189,7 +198,8 @@ export function deriveLabels<T>(
|
|
|
189
198
|
};
|
|
190
199
|
|
|
191
200
|
if (mainTypes.length === 0) {
|
|
192
|
-
if (secondaryTypes.length !== 0)
|
|
201
|
+
if (secondaryTypes.length !== 0)
|
|
202
|
+
throw new Error("Non-empty secondary types list while main types list is empty.");
|
|
193
203
|
return calculate(new Set(LabelTypeFull), true)!;
|
|
194
204
|
}
|
|
195
205
|
|
|
@@ -208,8 +218,7 @@ export function deriveLabels<T>(
|
|
|
208
218
|
const currentSet = new Set<string>();
|
|
209
219
|
if (ops.includeNativeLabel) currentSet.add(LabelTypeFull);
|
|
210
220
|
for (let i = 0; i < includedTypes; ++i) currentSet.add(mainTypes[i]);
|
|
211
|
-
if (additionalType >= 0)
|
|
212
|
-
currentSet.add(mainTypes[additionalType]);
|
|
221
|
+
if (additionalType >= 0) currentSet.add(mainTypes[additionalType]);
|
|
213
222
|
|
|
214
223
|
const candidateResult = calculate(currentSet);
|
|
215
224
|
|