@datagrok/curves 1.13.3 → 1.14.0
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/.grokignore +2 -0
- package/.turbo/turbo-build.log +5 -4
- package/CHANGELOG.md +18 -0
- package/README.md +2 -2
- package/bdd/bdd.config.json +1 -0
- package/bdd/bindings/curves.ts +28 -0
- package/bdd/features/MISSING.md +20 -0
- package/bdd/features/data/curve-json-columns.feature +66 -0
- package/bdd/features/data/data-to-curves.feature +50 -0
- package/bdd/features/data/pzfx-files.feature +25 -0
- package/bdd/features/grid/curve-cells.feature +55 -0
- package/bdd/features/grid/curve-options.feature +52 -0
- package/bdd/features/grid/statistic-columns.feature +47 -0
- package/bdd/features/guides/INDEX.md +8 -0
- package/bdd/features/guides/curves-legend-cells.feature +37 -0
- package/bdd/features/guides/curves-legend.feature +42 -0
- package/bdd/features/viewers/curves-in-trellis.feature +90 -0
- package/bdd/features/viewers/multi-curve-viewer.feature +92 -0
- package/bdd/generated/data/curve-json-columns.test.ts +75 -0
- package/bdd/generated/data/data-to-curves.test.ts +45 -0
- package/bdd/generated/data/pzfx-files.test.ts +50 -0
- package/bdd/generated/grid/curve-cells.test.ts +67 -0
- package/bdd/generated/grid/curve-options.test.ts +66 -0
- package/bdd/generated/grid/statistic-columns.test.ts +64 -0
- package/bdd/generated/guides/curves-legend-cells.test.ts +48 -0
- package/bdd/generated/guides/curves-legend.test.ts +48 -0
- package/bdd/generated/viewers/curves-in-trellis.test.ts +98 -0
- package/bdd/generated/viewers/multi-curve-viewer.test.ts +103 -0
- package/bdd/package.json +1 -0
- package/bdd/tsconfig.json +13 -0
- package/detectors.js +4 -4
- package/dist/package-test.js +28 -16
- package/dist/package-test.js.map +1 -1
- package/dist/package.js +1 -1
- package/dist/package.js.map +1 -1
- package/package.json +12 -5
- package/src/fit/fit-grid-cell-handler.ts +29 -4
- package/src/fit/fit-interaction.ts +15 -9
- package/src/fit/fit-legend.ts +35 -9
- package/src/fit/fit-renderer.ts +24 -9
- package/src/fit/multi-curve-viewer.ts +82 -19
- package/src/package-test.ts +1 -0
- package/src/package.g.ts +1 -0
- package/src/package.ts +1 -1
- package/src/tests/calculated-columns-tests.ts +3 -3
- package/src/tests/curve-data.ts +5 -1
- package/src/tests/curves-cell-renderer-tests.ts +10 -10
- package/src/tests/data-to-curves-tests.ts +34 -0
- package/src/tests/detector-tests.ts +26 -0
- package/src/tests/fit-tests.ts +12 -0
- package/src/tests/legend-tests.ts +24 -1
- package/src/tests/multi-curve-viewer-tests.ts +90 -17
- package/src/tests/panel-renderer-tests.ts +75 -30
- package/src/tests/project-tests.ts +30 -12
- package/test-console-output-1.log +366 -332
- package/test-record-1.mp4 +0 -0
package/src/tests/fit-tests.ts
CHANGED
|
@@ -241,6 +241,18 @@ category('fit', () => {
|
|
|
241
241
|
expect(fit.bottom, curve.parameters[3]);
|
|
242
242
|
});
|
|
243
243
|
|
|
244
|
+
test('4PL dose-response fits the Hill slope of a dilution series', async () => {
|
|
245
|
+
// a falling curve sampled at 3-fold dilutions: started at a Hill slope of 10, the fit stayed a step
|
|
246
|
+
const series: IFitSeries = {fitFunction: FIT_FUNCTION_4PL_DOSE_RESPONSE, points: Array.from({length: 8}, (_, i) => {
|
|
247
|
+
const x = 10 / Math.pow(3, i);
|
|
248
|
+
return {x, y: 600 + 3600 / (1 + Math.pow(x / 0.3, 1.2))};
|
|
249
|
+
})};
|
|
250
|
+
const fitFunc = fitFunctions[FIT_FUNCTION_4PL_DOSE_RESPONSE];
|
|
251
|
+
const curve = fitSeries(series, fitFunc, undefined, {logX: true, logY: false});
|
|
252
|
+
expectFloat(curve.parameters[1], -1.2, 0.05);
|
|
253
|
+
expectFloat(Math.pow(10, curve.parameters[2]), 0.3, 0.01);
|
|
254
|
+
});
|
|
255
|
+
|
|
244
256
|
test('fillParams custom function', async () => {
|
|
245
257
|
const curve = fitSeries(polynomialSeries, polynomialFitFunc);
|
|
246
258
|
const fit = polynomialFitFunc.fillParams(curve, polynomialSeries) as JSFunctionFit;
|
|
@@ -3,9 +3,12 @@ import * as ui from 'datagrok-api/ui';
|
|
|
3
3
|
|
|
4
4
|
import {category, test, expect, expectArray} from '@datagrok-libraries/test/src/test';
|
|
5
5
|
import {IFitChartData} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
6
|
+
import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
|
|
6
7
|
import {chooseLegendCorner, legendEntries, legendTooltip, legendTooltipElement, maxTooltipRows} from '../fit/fit-legend';
|
|
8
|
+
import {getOrCreateParsedChartData} from '../fit/fit-chart-data';
|
|
9
|
+
import {changeCurvesOptions} from '../fit/fit-options';
|
|
7
10
|
|
|
8
|
-
import {sigmoidPoints, renderedTexts, renderedRows} from './curve-data';
|
|
11
|
+
import {sigmoidPoints, renderedTexts, renderedRows, renderedDataRows} from './curve-data';
|
|
9
12
|
|
|
10
13
|
/** Curves spread over several columns, the way the multi curve viewer hands them over. */
|
|
11
14
|
function multiColumnJson(columns: {column: string, series: string[]}[], showColumnLabel: boolean = true): string {
|
|
@@ -177,6 +180,26 @@ category('legend', () => {
|
|
|
177
180
|
expect(off.some((t) => t === 'Conc.' || t === 'Activity' || t.length > 0), true);
|
|
178
181
|
});
|
|
179
182
|
|
|
183
|
+
test('Show Legend set for the column names no curve, set for one cell names that one again', async () => {
|
|
184
|
+
const json = multiColumnJson([{column: 'curve', series: ['Run:2023-08-08']}], false);
|
|
185
|
+
const col = DG.Column.fromStrings('curve', [json, json]);
|
|
186
|
+
col.semType = FitConstants.FIT_SEM_TYPE;
|
|
187
|
+
const df = DG.DataFrame.fromColumns([col]);
|
|
188
|
+
df.name = 'legendLevels';
|
|
189
|
+
const grid = DG.Viewer.grid(df);
|
|
190
|
+
const showLegend = (value: boolean) => ({property: {name: 'showLegend'}, value: value}) as unknown as DG.InputBase;
|
|
191
|
+
const named = (row: number) => renderedDataRows(getOrCreateParsedChartData(df.cell(row, 'curve')), 500, 400)
|
|
192
|
+
.rows.some((r) => r.text === 'Run:2023-08-08');
|
|
193
|
+
expect(named(0) && named(1), true, 'every cell names its curve to begin with');
|
|
194
|
+
|
|
195
|
+
changeCurvesOptions(grid.cell('curve', 0), showLegend(false), 'chartOptions', 'Column');
|
|
196
|
+
expect(named(0) || named(1), false, 'off for the column, no cell names its curve');
|
|
197
|
+
|
|
198
|
+
changeCurvesOptions(grid.cell('curve', 1), showLegend(true), 'chartOptions', 'Cell');
|
|
199
|
+
expect(named(1), true, 'on for one cell, that cell names its curve');
|
|
200
|
+
expect(named(0), false, 'and the rest of the column stays as the column says');
|
|
201
|
+
});
|
|
202
|
+
|
|
180
203
|
test('hovering what did not fit gives the whole legend', async () => {
|
|
181
204
|
const names = Array.from({length: 40}, (_, i) => `series ${i}`);
|
|
182
205
|
const drawn = renderedRows(multiColumnJson([{column: 'curve', series: names}]), 'legendMoreHover', 500, 400);
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
|
+
import * as ui from 'datagrok-api/ui';
|
|
3
4
|
|
|
4
|
-
import {category, test, expect,
|
|
5
|
+
import {category, test, expect, testEvent, settled, waitUntil} from '@datagrok-libraries/test/src/test';
|
|
5
6
|
import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
|
|
6
7
|
import {getOrCreateParsedChartData} from '../fit/fit-chart-data';
|
|
7
8
|
import {MultiCurveViewer} from '../fit/multi-curve-viewer';
|
|
@@ -15,28 +16,33 @@ function curveTable(name: string): DG.DataFrame {
|
|
|
15
16
|
return df;
|
|
16
17
|
}
|
|
17
18
|
|
|
19
|
+
async function addMultiCurveViewer(tv: DG.TableView, curvesColumnNames: string[]): Promise<MultiCurveViewer> {
|
|
20
|
+
const viewer = await tv.dataFrame.plot.fromType('MultiCurveViewer', {curvesColumnNames}) as MultiCurveViewer;
|
|
21
|
+
// most of the view, whatever the window: a legend is drawn only on a chart of MIN_LEGEND_PX_WIDTH x HEIGHT
|
|
22
|
+
tv.dockManager.dock(viewer, DG.DOCK_TYPE.FILL, null, 'Curves');
|
|
23
|
+
// the canvas takes the size of its panel a task after the layout (ui.tools.handleResize)
|
|
24
|
+
await waitUntil(() => viewer.root.clientWidth > 0 && viewer.canvas.width === viewer.root.clientWidth &&
|
|
25
|
+
viewer.canvas.height === viewer.root.clientHeight, 'the multi curve viewer did not take the size of its panel');
|
|
26
|
+
await settled(viewer);
|
|
27
|
+
return viewer;
|
|
28
|
+
}
|
|
29
|
+
|
|
18
30
|
category('multi curve viewer', () => {
|
|
19
31
|
test('merging cell series leaves the cell alone, and unmerging comes back', async () => {
|
|
20
32
|
const df = curveTable('multiCurveMerge');
|
|
21
33
|
const tv = grok.shell.addTableView(df);
|
|
22
34
|
try {
|
|
23
35
|
df.currentRowIdx = 0;
|
|
24
|
-
tv
|
|
25
|
-
await delay(1000);
|
|
26
|
-
// addViewer hands back the host wrapper, and the merge happens on the JS instance behind it
|
|
27
|
-
const viewer = Array.from(tv.viewers).find((v) => v.type === 'MultiCurveViewer') as MultiCurveViewer;
|
|
28
|
-
expect(viewer !== undefined, true, 'the viewer was not added');
|
|
36
|
+
const viewer = await addMultiCurveViewer(tv, ['curve']);
|
|
29
37
|
expect(viewer.data?.series?.length, 2, 'the current row carries two curves');
|
|
30
38
|
|
|
31
39
|
viewer.props.set('mergeCellSeries', true as unknown as object);
|
|
32
|
-
await delay(500);
|
|
33
40
|
expect(viewer.data?.series?.length, 1, 'merging should leave one curve in the viewer');
|
|
34
41
|
// the parsed data is cached and shared with the grid - merging into it used to rewrite the cell
|
|
35
42
|
expect(getOrCreateParsedChartData(df.cell(0, 'curve')).series!.length, 2,
|
|
36
43
|
'the cell itself must still hold both curves');
|
|
37
44
|
|
|
38
45
|
viewer.props.set('mergeCellSeries', false as unknown as object);
|
|
39
|
-
await delay(500);
|
|
40
46
|
expect(viewer.data?.series?.length, 2, 'unmerging should bring both curves back');
|
|
41
47
|
} finally {
|
|
42
48
|
tv.close();
|
|
@@ -48,10 +54,8 @@ category('multi curve viewer', () => {
|
|
|
48
54
|
const tv = grok.shell.addTableView(df);
|
|
49
55
|
try {
|
|
50
56
|
df.currentRowIdx = 0;
|
|
51
|
-
tv
|
|
52
|
-
|
|
53
|
-
const viewer = Array.from(tv.viewers).find((v) => v.type === 'MultiCurveViewer') as any;
|
|
54
|
-
expect(viewer.fitIdentities.length, viewer.data.series.length,
|
|
57
|
+
const viewer = await addMultiCurveViewer(tv, ['curve']);
|
|
58
|
+
expect(viewer.fitIdentities.length, viewer.data.series!.length,
|
|
55
59
|
'every series should carry an identity, in the order they are drawn');
|
|
56
60
|
expect(viewer.fitIdentities.every((id: string | undefined) => id !== undefined), true,
|
|
57
61
|
'and none of them should be missing');
|
|
@@ -69,13 +73,11 @@ category('multi curve viewer', () => {
|
|
|
69
73
|
const tv = grok.shell.addTableView(df);
|
|
70
74
|
try {
|
|
71
75
|
df.currentRowIdx = 0;
|
|
72
|
-
tv
|
|
73
|
-
|
|
74
|
-
const viewer = Array.from(tv.viewers).find((v) => v.type === 'MultiCurveViewer') as any;
|
|
75
|
-
expect(viewer.data.series.length, 40, 'the current row carries all the curves');
|
|
76
|
+
const viewer = await addMultiCurveViewer(tv, ['curve']);
|
|
77
|
+
expect(viewer.data.series!.length, 40, 'the current row carries all the curves');
|
|
76
78
|
|
|
77
79
|
// the grid routes mouse moves to the cell renderer; the viewer has to do it itself
|
|
78
|
-
const canvas
|
|
80
|
+
const canvas = viewer.canvas;
|
|
79
81
|
const rect = canvas.getBoundingClientRect();
|
|
80
82
|
// any row will do - whether the tail collapses into `+N more` depends on the viewer's height
|
|
81
83
|
let tooltip: string[] = [];
|
|
@@ -97,4 +99,75 @@ category('multi curve viewer', () => {
|
|
|
97
99
|
tv.close();
|
|
98
100
|
}
|
|
99
101
|
}, {timeout: 90000});
|
|
102
|
+
|
|
103
|
+
// GROK-20661: a range one cell declares for its own chart was enforced on the whole overlay, cutting the rest
|
|
104
|
+
test('the axes take in every point, whatever range one cell declares for its own chart', async () => {
|
|
105
|
+
const curve = (name: string, value: object) => {
|
|
106
|
+
const col = DG.Column.fromStrings(name, [JSON.stringify(value)]);
|
|
107
|
+
col.semType = FitConstants.FIT_SEM_TYPE;
|
|
108
|
+
return col;
|
|
109
|
+
};
|
|
110
|
+
const df = DG.DataFrame.fromColumns([
|
|
111
|
+
curve('narrow', {chartOptions: {minY: 0, maxY: 10}, series: [{points: [{x: 0.1, y: 1}, {x: 1, y: 5}, {x: 10, y: 9}]}]}),
|
|
112
|
+
curve('tall', {series: [{points: [{x: 0.1, y: 10}, {x: 1, y: 50}, {x: 10, y: 100}]}]}),
|
|
113
|
+
]);
|
|
114
|
+
df.name = 'multiCurveAxes';
|
|
115
|
+
const tv = grok.shell.addTableView(df);
|
|
116
|
+
try {
|
|
117
|
+
df.currentRowIdx = 0;
|
|
118
|
+
const viewer = await addMultiCurveViewer(tv, ['narrow', 'tall']);
|
|
119
|
+
const values = viewer.getWidgetStatus().values!;
|
|
120
|
+
expect(values['curves'], 2);
|
|
121
|
+
expect(values['points outside the axes'], 0, `the axes span ${values['y range']}`);
|
|
122
|
+
} finally {
|
|
123
|
+
tv.close();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
test('the viewer reports the legend it drew, and a render still on its way', async () => {
|
|
128
|
+
const col = DG.Column.fromStrings('curve', [multiSeriesCurveJson(Array.from({length: 40}, (_, i) => -8 + i * 0.1))]);
|
|
129
|
+
col.semType = FitConstants.FIT_SEM_TYPE;
|
|
130
|
+
const df = DG.DataFrame.fromColumns([col]);
|
|
131
|
+
df.name = 'multiCurveStatus';
|
|
132
|
+
const tv = grok.shell.addTableView(df);
|
|
133
|
+
try {
|
|
134
|
+
df.currentRowIdx = 0;
|
|
135
|
+
const viewer = await addMultiCurveViewer(tv, ['curve']);
|
|
136
|
+
let status = viewer.getWidgetStatus();
|
|
137
|
+
expect(status.parts['canvas'] === viewer.canvas, true, 'the canvas is the part the hit areas are on');
|
|
138
|
+
expect(status.values!['curves'], 40);
|
|
139
|
+
expect(status.values!['legend shown'], true);
|
|
140
|
+
expect(viewer.props.get('showLegend') as unknown, true, 'Show Legend should read on while the legend is drawn');
|
|
141
|
+
expect((status.values!['legend rows'] as number) + (status.values!['legend hidden'] as number), 40,
|
|
142
|
+
'the rows drawn and the ones counted should cover every curve');
|
|
143
|
+
const more = status.hitAreas['legend more'];
|
|
144
|
+
expect(more !== undefined, true, 'forty curves do not fit, so the rest is counted');
|
|
145
|
+
|
|
146
|
+
// the area is where the hover answers with the list
|
|
147
|
+
const rect = viewer.canvas.getBoundingClientRect();
|
|
148
|
+
viewer.canvas.dispatchEvent(new MouseEvent('mousemove', {bubbles: true,
|
|
149
|
+
clientX: rect.left + more.x + more.width / 2, clientY: rect.top + more.y + more.height / 2}));
|
|
150
|
+
const listed = document.querySelector('.d4-tooltip')?.querySelectorAll('canvas').length ?? 0;
|
|
151
|
+
ui.tooltip.hide();
|
|
152
|
+
expect(listed > 1, true, `hovering "legend more" should list the curves, it listed ${listed}`);
|
|
153
|
+
|
|
154
|
+
viewer.props.set('showLegend', false as unknown as object);
|
|
155
|
+
status = viewer.getWidgetStatus();
|
|
156
|
+
expect(status.values!['legend shown'], false, 'Show Legend off should leave the curves unnamed');
|
|
157
|
+
expect(Object.keys(status.hitAreas).some((name) => name.includes('legend')), false,
|
|
158
|
+
'and no legend row to point at');
|
|
159
|
+
|
|
160
|
+
let pendingOnChange = false;
|
|
161
|
+
const sub = df.onSelectionChanged.subscribe(() => pendingOnChange = viewer.isRenderPending);
|
|
162
|
+
try {
|
|
163
|
+
await testEvent(viewer.onRendered, () => expect(viewer.isRenderPending, false, 'a render landed'),
|
|
164
|
+
() => df.selection.set(0, true), 5000);
|
|
165
|
+
} finally {
|
|
166
|
+
sub.unsubscribe();
|
|
167
|
+
}
|
|
168
|
+
expect(pendingOnChange, true, 'a selection change should say a render is on its way');
|
|
169
|
+
} finally {
|
|
170
|
+
tv.close();
|
|
171
|
+
}
|
|
172
|
+
}, {timeout: 90000});
|
|
100
173
|
});
|
|
@@ -3,7 +3,7 @@ import * as DG from 'datagrok-api/dg';
|
|
|
3
3
|
import * as ui from 'datagrok-api/ui';
|
|
4
4
|
import * as grok from 'datagrok-api/grok';
|
|
5
5
|
|
|
6
|
-
import {category, test, expect, expectArray, expectFloat,
|
|
6
|
+
import {category, test, expect, expectArray, expectFloat, waitUntil} from '@datagrok-libraries/test/src/test';
|
|
7
7
|
import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
|
|
8
8
|
import {IFitChartData} from '@datagrok-libraries/statistics/src/fit/fit-curve';
|
|
9
9
|
import {FitChartCellRenderer} from '../fit/fit-renderer';
|
|
@@ -43,6 +43,20 @@ async function addStatisticColumn(df: DG.DataFrame, params: {[key: string]: stri
|
|
|
43
43
|
.call(false, undefined, {processed: false});
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
/** The values-changed events [action] fired, by the column they name ('' for the whole table). Only an event
|
|
47
|
+
* naming a column starts recalculating the formula columns that read it, so none naming it means no refit. */
|
|
48
|
+
function valuesChangedBy(df: DG.DataFrame, action: () => void): string[] {
|
|
49
|
+
const names: string[] = [];
|
|
50
|
+
const sub = df.onValuesChanged.subscribe((e) => names.push(e?.args?.column?.name ?? ''));
|
|
51
|
+
try {
|
|
52
|
+
action();
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
sub.unsubscribe();
|
|
56
|
+
}
|
|
57
|
+
return names;
|
|
58
|
+
}
|
|
59
|
+
|
|
46
60
|
category('panel and renderer', () => {
|
|
47
61
|
test('every registered aggregation input offers only convertible aggregations', async () => {
|
|
48
62
|
// enumerated from the registry: a hand-written list of the ones we fixed missed a third
|
|
@@ -87,7 +101,7 @@ category('panel and renderer', () => {
|
|
|
87
101
|
col.setTag(FitConstants.TAG_FIT, JSON.stringify({chartOptions: {logX: false}}));
|
|
88
102
|
// pins the platform contract the panel relies on, not the call site in changeCurvesOptions
|
|
89
103
|
col.fireValuesChanged();
|
|
90
|
-
await
|
|
104
|
+
await waitUntil(() => df.col('curve 1 ic50')!.get(0) !== before,
|
|
91
105
|
'statistic column did not recalculate after the column-level option changed', 5000);
|
|
92
106
|
});
|
|
93
107
|
|
|
@@ -103,15 +117,14 @@ category('panel and renderer', () => {
|
|
|
103
117
|
df.name = 'panelNoRecalcOnCosmetic';
|
|
104
118
|
await addStatisticColumn(df, {propName: 'ic50', seriesNumber: 0});
|
|
105
119
|
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
expect(stat.version, before, 'a cosmetic rewrite recalculated the statistic column');
|
|
120
|
+
const changed = valuesChangedBy(df, () => {
|
|
121
|
+
for (let j = 0; j < col.length; j++) {
|
|
122
|
+
const data = JSON.parse(col.get(j));
|
|
123
|
+
delete data.series[0].pointColor;
|
|
124
|
+
col.set(j, JSON.stringify(data), false);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
expect(changed.includes('curve'), false, 'a cosmetic rewrite recalculates the statistic column');
|
|
115
128
|
});
|
|
116
129
|
|
|
117
130
|
test('a column-level option overrides a cell-level one, without recalculating', async () => {
|
|
@@ -126,17 +139,14 @@ category('panel and renderer', () => {
|
|
|
126
139
|
df.name = 'panelColumnOverridesCell';
|
|
127
140
|
await addStatisticColumn(df, {propName: 'ic50', seriesNumber: 0});
|
|
128
141
|
|
|
129
|
-
const stat = df.col('curve 1 ic50')!;
|
|
130
|
-
const version = stat.version;
|
|
131
142
|
const gridCell = DG.Viewer.grid(df).cell('curve', 0);
|
|
132
143
|
const input = {property: {name: 'pointColor'}, value: '#00ff00'} as unknown as DG.InputBase;
|
|
133
144
|
|
|
134
|
-
changeCurvesOptions(gridCell, input, 'seriesOptions', 'Column');
|
|
135
|
-
await delay(500);
|
|
145
|
+
const changed = valuesChangedBy(df, () => changeCurvesOptions(gridCell, input, 'seriesOptions', 'Column'));
|
|
136
146
|
|
|
137
147
|
expect(getOrCreateParsedChartData(df.cell(0, 'curve')).series![0].pointColor === '#ff0000', false,
|
|
138
148
|
'the cell-level value still wins after the column-level change');
|
|
139
|
-
expect(
|
|
149
|
+
expect(changed.includes('curve'), false, 'a cosmetic option change recalculates the statistic column');
|
|
140
150
|
});
|
|
141
151
|
|
|
142
152
|
test('clearing cell overrides marks the table changed without recalculating', async () => {
|
|
@@ -147,24 +157,17 @@ category('panel and renderer', () => {
|
|
|
147
157
|
df.name = 'panelMarksTableChanged';
|
|
148
158
|
await addStatisticColumn(df, {propName: 'ic50', seriesNumber: 0});
|
|
149
159
|
|
|
150
|
-
const stat = df.col('curve 1 ic50')!;
|
|
151
|
-
const version = stat.version;
|
|
152
160
|
const gridCell = DG.Viewer.grid(df).cell('curve', 0);
|
|
153
|
-
|
|
154
|
-
const sub = df.onValuesChanged.subscribe(() => fired++);
|
|
155
|
-
|
|
156
|
-
changeCurvesOptions(gridCell,
|
|
161
|
+
const changed = valuesChangedBy(df, () => changeCurvesOptions(gridCell,
|
|
157
162
|
{property: {name: 'showCurveConfidenceInterval'}, value: false} as unknown as DG.InputBase,
|
|
158
|
-
'seriesOptions', 'Column');
|
|
159
|
-
await delay(500);
|
|
160
|
-
sub.unsubscribe();
|
|
163
|
+
'seriesOptions', 'Column'));
|
|
161
164
|
|
|
162
165
|
// the value the data declares is left alone - it just stops winning
|
|
163
166
|
expect(JSON.parse(col.get(0)).series[0].showCurveConfidenceInterval, true, 'the cell data was mutated');
|
|
164
167
|
expect(getOrCreateParsedChartData(df.cell(0, 'curve')).series![0].showCurveConfidenceInterval, false,
|
|
165
168
|
'the column-level value did not outrank the value declared in the cell');
|
|
166
|
-
expect(
|
|
167
|
-
expect(
|
|
169
|
+
expect(changed.length > 0, true, 'nothing marked the table changed, so the option would not be saved');
|
|
170
|
+
expect(changed.includes('curve'), false, 'a cosmetic option change recalculates the statistic column');
|
|
168
171
|
});
|
|
169
172
|
|
|
170
173
|
test('a column-level change overrides a value set at cell level first', async () => {
|
|
@@ -234,7 +237,6 @@ category('panel and renderer', () => {
|
|
|
234
237
|
const layout = sourceView.saveLayout();
|
|
235
238
|
|
|
236
239
|
freshView.loadLayout(layout);
|
|
237
|
-
await delay(500);
|
|
238
240
|
|
|
239
241
|
expect(getOrCreateParsedChartData(fresh.cell(0, 'curve')).series![0].showCurveConfidenceInterval, false,
|
|
240
242
|
'the column-level option did not survive the layout');
|
|
@@ -345,6 +347,27 @@ category('panel and renderer', () => {
|
|
|
345
347
|
'with one curve the aggregate is that curve, so it should not be drawn');
|
|
346
348
|
// and the mode falls back to per series rather than drawing nothing at all
|
|
347
349
|
expect(drawn.some((t) => t.startsWith('IC50')), true, 'the single curve should still show its own');
|
|
350
|
+
|
|
351
|
+
const offered = (logIC50s: number[]) =>
|
|
352
|
+
chartPropertiesFor(JSON.parse(multiSeriesCurveJson(logIC50s)) as IFitChartData).map((p) => p.name);
|
|
353
|
+
expect(offered([-6.5]).some((name) => name === 'statisticsMode' || name === 'aggrType'), false,
|
|
354
|
+
'the Options pane of a one-curve cell should offer no summary');
|
|
355
|
+
expect(offered([-7, -5]).includes('statisticsMode') && offered([-7, -5]).includes('aggrType'), true,
|
|
356
|
+
'the one of a two-curve cell should');
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
test('a click on a second curve cell right after the first makes that one current', async () => {
|
|
360
|
+
// the first click used to freeze the current object for a second, and the Context Panel kept its panes
|
|
361
|
+
const tv = grok.shell.addTableView(curveTable('panelSecondClick', true));
|
|
362
|
+
try {
|
|
363
|
+
const renderer = new FitChartCellRenderer();
|
|
364
|
+
renderer.onClick(tv.grid.cell('curve', 0), new MouseEvent('click'));
|
|
365
|
+
renderer.onClick(tv.grid.cell('curve', 1), new MouseEvent('click'));
|
|
366
|
+
const current = grok.shell.o;
|
|
367
|
+
expect(current instanceof DG.GridCell && current.gridRow === 1, true, `the second cell should be current, not ${current}`);
|
|
368
|
+
} finally {
|
|
369
|
+
tv.close();
|
|
370
|
+
}
|
|
348
371
|
});
|
|
349
372
|
|
|
350
373
|
test('the panel offers droplines only for a fit that has asymptotes', async () => {
|
|
@@ -404,7 +427,6 @@ category('panel and renderer', () => {
|
|
|
404
427
|
|
|
405
428
|
changeCurvesOptions(gridCell, {property: {name: 'fitFunction'}, value: custom.name} as unknown as DG.InputBase,
|
|
406
429
|
'seriesOptions', 'Cell');
|
|
407
|
-
await delay(300);
|
|
408
430
|
const stored = JSON.parse(df.col('curve')!.get(0)!).series[0].fitFunction;
|
|
409
431
|
expect(typeof stored, 'object', 'the name alone would not resolve in a session that never loaded it');
|
|
410
432
|
expect(stored.name, custom.name);
|
|
@@ -412,7 +434,6 @@ category('panel and renderer', () => {
|
|
|
412
434
|
|
|
413
435
|
changeCurvesOptions(gridCell, {property: {name: 'fitFunction'}, value: 'linear'} as unknown as DG.InputBase,
|
|
414
436
|
'seriesOptions', 'Cell');
|
|
415
|
-
await delay(300);
|
|
416
437
|
expect(JSON.parse(df.col('curve')!.get(0)!).series[0].fitFunction, 'linear',
|
|
417
438
|
'a built-in one is always there, so it stays a name');
|
|
418
439
|
} finally {
|
|
@@ -489,6 +510,30 @@ category('panel and renderer', () => {
|
|
|
489
510
|
expect(root instanceof HTMLElement, true, 'the property panel failed to render');
|
|
490
511
|
});
|
|
491
512
|
|
|
513
|
+
test('a level survives the panel being rebuilt for the same cell', async () => {
|
|
514
|
+
const df = curveTable('levelRebuilt', true);
|
|
515
|
+
const grid = DG.Viewer.grid(df);
|
|
516
|
+
const handler = new FitGridCellHandler();
|
|
517
|
+
const levelOf = (row: number) => handler.levelInput(grid.cell('curve', row));
|
|
518
|
+
|
|
519
|
+
expect(levelOf(0).value, 'Column');
|
|
520
|
+
levelOf(0).stringValue = 'Cell';
|
|
521
|
+
// each read builds the input anew, as the Context Panel does once the current cell settles
|
|
522
|
+
await waitUntil(() => levelOf(0).value === 'Cell', 'a rebuilt panel fell back to the default level');
|
|
523
|
+
|
|
524
|
+
changeCurvesOptions(grid.cell('curve', 0), {property: {name: 'title'}, value: 'Only this one'} as unknown as DG.InputBase,
|
|
525
|
+
'chartOptions', levelOf(0).value);
|
|
526
|
+
expect(getOrCreateParsedChartData(grid.cell('curve', 0).cell).chartOptions?.title, 'Only this one');
|
|
527
|
+
expect(getOrCreateParsedChartData(grid.cell('curve', 1).cell).chartOptions?.title === 'Only this one', false,
|
|
528
|
+
'a Cell level option reached another cell');
|
|
529
|
+
|
|
530
|
+
const sameName = DG.Viewer.grid(curveTable('levelRebuilt', true));
|
|
531
|
+
expect(handler.levelInput(sameName.cell('curve', 0)).value, 'Column', 'a table of the same name starts from the default');
|
|
532
|
+
|
|
533
|
+
levelOf(0).stringValue = 'Cell';
|
|
534
|
+
expect(levelOf(1).value, 'Column', 'another cell starts from the default');
|
|
535
|
+
});
|
|
536
|
+
|
|
492
537
|
test('statistic names stored under a legacy name map onto the current ones', async () => {
|
|
493
538
|
const chartData = JSON.parse(JSON.stringify({
|
|
494
539
|
chartOptions: {logX: true},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {after, category, expect, settled, test, waitUntil} from '@datagrok-libraries/test/src/test';
|
|
5
5
|
import {FitConstants} from '@datagrok-libraries/statistics/src/fit/const';
|
|
6
6
|
import {createDefaultChartData} from '@datagrok-libraries/statistics/src/fit/fit-data';
|
|
7
7
|
import {changeCurvesOptions} from '../fit/fit-options';
|
|
@@ -19,6 +19,9 @@ async function createTableView(tableName: string): Promise<DG.TableView> {
|
|
|
19
19
|
return grok.shell.addTableView(df);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
/** The projects the tests saved, deleted after the category; a project takes its table and layout with it. */
|
|
23
|
+
const savedProjects: DG.Project[] = [];
|
|
24
|
+
|
|
22
25
|
async function saveAndOpenProject(tv: DG.TableView, dataSync?: boolean): Promise<void> {
|
|
23
26
|
const project = DG.Project.create();
|
|
24
27
|
project.name = 'Curves test project';
|
|
@@ -37,19 +40,18 @@ async function saveAndOpenProject(tv: DG.TableView, dataSync?: boolean): Promise
|
|
|
37
40
|
await grok.dapi.tables.uploadDataFrame(tv.dataFrame);
|
|
38
41
|
await grok.dapi.tables.save(tableInfo);
|
|
39
42
|
await grok.dapi.views.save(layoutInfo);
|
|
40
|
-
await grok.dapi.projects.save(project);
|
|
43
|
+
savedProjects.push(await grok.dapi.projects.save(project));
|
|
41
44
|
const projId = project.id;
|
|
42
45
|
// the fit cell renderer keeps painting while the view tears down, and closeAll() surfaces that as
|
|
43
46
|
// an unhandled exception - let the grid settle first
|
|
44
|
-
await
|
|
47
|
+
await settled(tv.grid);
|
|
45
48
|
grok.shell.closeAll();
|
|
46
|
-
await delay(500);
|
|
47
49
|
const p = await grok.dapi.projects.find(projId);
|
|
48
50
|
await p.open();
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
async function dataFrameContainsColumn(colName: string): Promise<void> {
|
|
52
|
-
await
|
|
54
|
+
await waitUntil(() => grok.shell.tv?.dataFrame?.col(colName) != null,
|
|
53
55
|
`${colName} is missing from the reopened project`, 30000);
|
|
54
56
|
}
|
|
55
57
|
|
|
@@ -70,14 +72,11 @@ async function runSaveAndOpenProjectTest(dataSync?: boolean): Promise<void> {
|
|
|
70
72
|
tv = grok.shell.tv;
|
|
71
73
|
await grok.data.detectSemanticTypes(tv.dataFrame);
|
|
72
74
|
} else { tv = await createTableView(DEMO_FILE); }
|
|
73
|
-
await delay(100);
|
|
74
75
|
turnOffConfidenceIntervals(tv);
|
|
75
|
-
await delay(10);
|
|
76
76
|
await saveAndOpenProject(tv, dataSync);
|
|
77
|
-
await delay(10);
|
|
78
77
|
await dataFrameContainsColumn(CURVE_COLUMN);
|
|
79
78
|
// the tags are restored after the table, so wait for the option rather than for the column
|
|
80
|
-
await
|
|
79
|
+
await waitUntil(() => getColumnChartOptions(grok.shell.tv.dataFrame.col(CURVE_COLUMN)!)
|
|
81
80
|
.seriesOptions?.showCurveConfidenceInterval === false,
|
|
82
81
|
'the column tag did not come back with the project', 30000);
|
|
83
82
|
|
|
@@ -87,9 +86,13 @@ async function runSaveAndOpenProjectTest(dataSync?: boolean): Promise<void> {
|
|
|
87
86
|
}
|
|
88
87
|
|
|
89
88
|
category('projects', () => {
|
|
89
|
+
after(async () => {
|
|
90
|
+
for (const p of savedProjects)
|
|
91
|
+
await grok.dapi.projects.delete(p);
|
|
92
|
+
});
|
|
93
|
+
|
|
90
94
|
test('column-level option survives a project', async () => {
|
|
91
95
|
await runSaveAndOpenProjectTest();
|
|
92
|
-
await delay(100);
|
|
93
96
|
}, {timeout: 120000});
|
|
94
97
|
|
|
95
98
|
test('painting a table leaves its dataframe tags alone, so its layout saves', async () => {
|
|
@@ -104,7 +107,7 @@ category('projects', () => {
|
|
|
104
107
|
try {
|
|
105
108
|
for (const col of df.columns.bySemTypeAll(FitConstants.FIT_SEM_TYPE))
|
|
106
109
|
getOrCreateParsedChartData(df.cell(0, col.name), false);
|
|
107
|
-
await
|
|
110
|
+
await settled(tv.grid);
|
|
108
111
|
expect(df.getTag(FitConstants.TAG_FIT) == null, true, 'reading the options tagged the dataframe');
|
|
109
112
|
layout = await grok.dapi.layouts.save(tv.saveLayout());
|
|
110
113
|
} finally {
|
|
@@ -114,10 +117,25 @@ category('projects', () => {
|
|
|
114
117
|
}
|
|
115
118
|
}, {timeout: 60000});
|
|
116
119
|
|
|
120
|
+
test('curve columns are curves again in a reopened project', async () => {
|
|
121
|
+
// GROK-14876
|
|
122
|
+
const tv = await createTableView(DEMO_FILE);
|
|
123
|
+
const curveColumns = tv.dataFrame.columns.bySemTypeAll(FitConstants.FIT_SEM_TYPE).map((c) => c.name);
|
|
124
|
+
expect(curveColumns.length, 5, `the demo has five curve columns, found ${curveColumns}`);
|
|
125
|
+
await saveAndOpenProject(tv);
|
|
126
|
+
try {
|
|
127
|
+
await waitUntil(() => curveColumns.every((name) =>
|
|
128
|
+
grok.shell.tv?.dataFrame?.col(name)?.semType === FitConstants.FIT_SEM_TYPE),
|
|
129
|
+
`the reopened project lost a curve column: ${curveColumns}`, 30000);
|
|
130
|
+
} finally {
|
|
131
|
+
await settled(grok.shell.tv.grid);
|
|
132
|
+
grok.shell.closeAll();
|
|
133
|
+
}
|
|
134
|
+
}, {timeout: 120000});
|
|
135
|
+
|
|
117
136
|
test('column-level option survives a datasync project', async () => {
|
|
118
137
|
// the table is rebuilt from its creation script, so the cells come back declaring the interval
|
|
119
138
|
// and only the tag the layout carries can turn it off
|
|
120
139
|
await runSaveAndOpenProjectTest(true);
|
|
121
|
-
await delay(100);
|
|
122
140
|
}, {timeout: 120000});
|
|
123
141
|
});
|