@datagrok/compute 0.4.0 → 0.4.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datagrok/compute",
3
3
  "friendlyName": "Compute",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "",
6
6
  "dependencies": {
7
7
  "cash-dom": "latest",
@@ -20,8 +20,10 @@
20
20
  "@types/wu": "latest",
21
21
  "@typescript-eslint/eslint-plugin": "^5.1.0",
22
22
  "@typescript-eslint/parser": "^5.1.0",
23
+ "css-loader": "^6.5.1",
23
24
  "eslint": "^8.0.1",
24
25
  "eslint-config-google": "^0.14.0",
26
+ "style-loader": "^3.3.1",
25
27
  "webpack": "latest",
26
28
  "webpack-cli": "latest"
27
29
  },
package/scripts/vMaxJS.js CHANGED
@@ -1,18 +1,17 @@
1
1
  //name: Vmax
2
2
  //description: Predict the minimum filter size required for the separation of effluent from bioreactors, given the constraints of batch size and total batch time based on a training dataset of time vs filtrate volume for a given filter type, filter area and pressure
3
3
  //language: javascript
4
- //tags: model
5
- //input: dataframe inputTable {editor: Compute:manualOutlierSelectionDialog; editor-button: Outliers...}
4
+ //tags: model, filtration
5
+ //input: dataframe inputTable {viewer: OutliersSelectionViewer() | Scatter Plot(color: "isOutlier", lassoTool: "true", legendVisibility: "Never", filterByZoom: "false") | Grid()}
6
+ //input: dataframe inputParametersForReporting {viewer: Grid()}
6
7
  //input: double testArea = 3.5 {caption: Test Filter Area; units: cm²} [Test Filter area]
7
8
  //input: double vbatch = 25 {caption: Desired Volume of Batch; units: L} [Desired Volume of Batch]
8
9
  //input: double tbatch = 0.5 {caption: Desired process time; units: hr} [Desired process time]
9
10
  //input: double sf = 1.5 {caption: Safety Factor} [Safety Factor]
10
- //input: int orderOfPolynomialRegression = 2 {caption: Order Of Polynomial Regression} [Order Of Polynomial Regression]
11
- //meta.showInputs: true
12
11
  //help-url: https://github.com/datagrok-ai/public/blob/master/packages/Compute/src/help.md
13
- //output: dataframe regressionTable {viewer: Scatter Plot(x: "time (min)", y: "filtrate volume (mL)", filter: "!${isOutlier}", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, showRegressionLine: "true"); category: OUTPUT}
14
- //output: dataframe absoluteFluxDecay {viewer: Scatter Plot(x: "V/A (L/m2)", y: "J (LMH)"); category: OUTPUT}
15
- //output: dataframe normalizedFluxDecay {viewer: Scatter Plot(x: "V/A (L/m2)", y: "J/Jo"); category: OUTPUT}
12
+ //output: dataframe regressionTable {viewer: Scatter Plot(filter: "!${isOutlier}", showFilteredOutPoints: "true", filteredOutRowsColor: 4293991195, showRegressionLine: "true"); category: OUTPUT}
13
+ //output: dataframe absoluteFluxDecay {viewer: Scatter Plot(); category: OUTPUT}
14
+ //output: dataframe normalizedFluxDecay {viewer: Scatter Plot(); category: OUTPUT}
16
15
  //output: dataframe experimentalResults {category: OUTPUT}
17
16
  //output: dataframe experimentalResultsSummary {category: OUTPUT}
18
17
  //output: dataframe recommendations {category: OUTPUT}
@@ -22,42 +21,49 @@
22
21
 
23
22
  volume = vbatch;
24
23
  function gaussianElimination(input, orderOfPolynomialRegression) {
25
- const n = input.length - 1, coefficients = [orderOfPolynomialRegression];
24
+ const n = input.length - 1; const coefficients = [orderOfPolynomialRegression];
26
25
  for (let i = 0; i < n; i++) {
27
26
  let maxrow = i;
28
- for (let j = i + 1; j < n; j++)
29
- if (Math.abs(input[i][j]) > Math.abs(input[i][maxrow]))
27
+ for (let j = i + 1; j < n; j++) {
28
+ if (Math.abs(input[i][j]) > Math.abs(input[i][maxrow])) {
30
29
  maxrow = j;
30
+ }
31
+ }
31
32
  for (let k = i; k < n + 1; k++) {
32
33
  const tmp = input[k][i];
33
34
  input[k][i] = input[k][maxrow];
34
35
  input[k][maxrow] = tmp;
35
36
  }
36
- for (let j = i + 1; j < n; j++)
37
- for (let k = n; k >= i; k--)
37
+ for (let j = i + 1; j < n; j++) {
38
+ for (let k = n; k >= i; k--) {
38
39
  input[k][j] -= (input[k][i] * input[i][j]) / input[i][i];
40
+ }
41
+ }
39
42
  }
40
43
  for (let j = n - 1; j >= 0; j--) {
41
44
  let total = 0;
42
- for (let k = j + 1; k < n; k++)
45
+ for (let k = j + 1; k < n; k++) {
43
46
  total += input[k][j] * coefficients[k];
47
+ }
44
48
  coefficients[j] = (input[n][j] - total) / input[j][j];
45
49
  }
46
50
  return coefficients;
47
51
  }
48
52
 
49
53
  function polynomialRegressionCoefficients(xCol, yCol, orderOfPolynomialRegression) {
50
- const lhs = [], rhs = [], len = xCol.length, k = orderOfPolynomialRegression + 1;
51
- let a = 0, b = 0;
54
+ const lhs = []; const rhs = []; const len = xCol.length; const k = orderOfPolynomialRegression + 1;
55
+ let a = 0; let b = 0;
52
56
  for (let i = 0; i < k; i++) {
53
- for (let l = 0; l < len; l++)
57
+ for (let l = 0; l < len; l++) {
54
58
  a += (xCol.get(l) ** i) * yCol.get(l);
59
+ }
55
60
  lhs.push(a);
56
61
  a = 0;
57
62
  const c = [];
58
63
  for (let j = 0; j < k; j++) {
59
- for (let l = 0; l < len; l++)
64
+ for (let l = 0; l < len; l++) {
60
65
  b += xCol.get(l) ** (i + j);
66
+ }
61
67
  c.push(b);
62
68
  b = 0;
63
69
  }
@@ -67,42 +73,43 @@ function polynomialRegressionCoefficients(xCol, yCol, orderOfPolynomialRegressio
67
73
  return gaussianElimination(rhs, k);
68
74
  }
69
75
 
76
+ const orderOfPolynomialRegression = 2;
70
77
  const area = 0.00035;
71
- const isOutlierCol = inputTable.col("isOutlier");
72
- let timeMin = [];
73
- let vol = [];
78
+ const isOutlierCol = inputTable.col('isOutlier');
79
+ const timeMin = [];
80
+ const vol = [];
74
81
  for (let i = 0; i < isOutlierCol.length; i++) {
75
82
  if (isOutlierCol.get(i) == false) {
76
- timeMin.push(inputTable.col("time (min)").get(i));
77
- vol.push(inputTable.col("filtrate volume (mL)").get(i));
83
+ timeMin.push(inputTable.col('time (min)').get(i));
84
+ vol.push(inputTable.col('filtrate volume (mL)').get(i));
78
85
  }
79
86
  }
80
87
  dfWithoutOutliers = DG.DataFrame.fromColumns([
81
- DG.Column.fromList('double', "time (min)", timeMin),
82
- DG.Column.fromList('double', "filtrate volume (mL)", vol)
88
+ DG.Column.fromList('double', 'time (min)', timeMin),
89
+ DG.Column.fromList('double', 'filtrate volume (mL)', vol),
83
90
  ]);
84
- const timeInMinutes = dfWithoutOutliers.col("time (min)");
85
- const volumeInMilliliters = dfWithoutOutliers.col("filtrate volume (mL)");
91
+ const timeInMinutes = dfWithoutOutliers.col('time (min)');
92
+ const volumeInMilliliters = dfWithoutOutliers.col('filtrate volume (mL)');
86
93
  dfWithoutOutliers.columns.addNewFloat('time (hr)').init((i) => timeInMinutes.get(i) / 60);
87
- const timeInHours = dfWithoutOutliers.col("time (hr)");
94
+ const timeInHours = dfWithoutOutliers.col('time (hr)');
88
95
 
89
96
  dfWithoutOutliers.columns.addNewFloat('V (L/m2)').init((i) => 10 * volumeInMilliliters.get(i) / testArea);
90
97
  const newVolume = dfWithoutOutliers.col('V (L/m2)');
91
98
 
92
- dfWithoutOutliers.columns.addNewFloat("t/V (hr/(L/m2))").init((i) => 100 * timeInHours.get(i) / newVolume.get(i));
99
+ dfWithoutOutliers.columns.addNewFloat('t/V (hr/(L/m2))').init((i) => 100 * timeInHours.get(i) / newVolume.get(i));
93
100
 
94
- dfWithoutOutliers.columns.addNewFloat("Time (s)").init((i) => 60 * timeInMinutes.get(i));
95
- dfWithoutOutliers.columns.addNewFloat("V (L)").init((i) => volumeInMilliliters.get(i) / 1000);
101
+ dfWithoutOutliers.columns.addNewFloat('Time (s)').init((i) => 60 * timeInMinutes.get(i));
102
+ dfWithoutOutliers.columns.addNewFloat('V (L)').init((i) => volumeInMilliliters.get(i) / 1000);
96
103
  const volumeInLiters = dfWithoutOutliers.col('V (L)');
97
104
  const timeInSeconds = dfWithoutOutliers.col('Time (s)');
98
105
  dfWithoutOutliers.columns.addNewFloat('V/A (L/m2)').init((i) => volumeInLiters.get(i) / area);
99
106
  const va = dfWithoutOutliers.col('V/A (L/m2)');
100
- let ca = [];
101
- let cb = [];
107
+ const ca = [];
108
+ const cb = [];
102
109
  for (let i = 1; i < va.length - 3; i++) {
103
- let xCol = DG.Column.fromList('double', 'name', timeInSeconds.toList().slice(i, i + 3));
104
- let yCol = DG.Column.fromList('double', 'name', va.toList().slice(i, i + 3));
105
- let coefficients = polynomialRegressionCoefficients(xCol, yCol, orderOfPolynomialRegression);
110
+ const xCol = DG.Column.fromList('double', 'name', timeInSeconds.toList().slice(i, i + 3));
111
+ const yCol = DG.Column.fromList('double', 'name', va.toList().slice(i, i + 3));
112
+ const coefficients = polynomialRegressionCoefficients(xCol, yCol, orderOfPolynomialRegression);
106
113
  ca.push(coefficients[orderOfPolynomialRegression]);
107
114
  cb.push(coefficients[orderOfPolynomialRegression - 1]);
108
115
  }
@@ -122,9 +129,10 @@ const trialThroughput = va.max;
122
129
  const flux = 9372.11;
123
130
  const ff0 = flux / j.get(1);
124
131
  experimentalResults = DG.DataFrame.fromColumns([
125
- DG.Column.fromList('string', 'Parameter', ['Trial Throughput', 'Flux', 'Flux/Flux0']),
126
- DG.Column.fromList('double', 'Value', [trialThroughput, flux, ff0]),
127
- DG.Column.fromList('string', 'Unit', ["L/m²", "LMH", "LMH"])
132
+ DG.Column.fromList('string', 'Run', ['1']),
133
+ DG.Column.fromList('double', 'Trial Throughput (L/m²)', [trialThroughput]),
134
+ DG.Column.fromList('double', 'Flux (LMH)', [flux]),
135
+ DG.Column.fromList('double', 'Flux/Flux0 (LMH)', [ff0]),
128
136
  ]);
129
137
  const meanFlux = j.stats.avg;
130
138
  const vmax = 0.28;//Math.round(1 / coefficients[1]);
@@ -132,34 +140,52 @@ const instantaneousFlux = j.get(j.length - 1);
132
140
  const initialFlux = j.get(1);
133
141
  const fluxDecay = (1 - instantaneousFlux / initialFlux) * 100;
134
142
  experimentalResultsSummary = DG.DataFrame.fromColumns([
135
- DG.Column.fromList('string', 'Parameter', ['Trial Throughput', 'Flux', 'Flux/Flux0', 'Mean Flux', 'Vmax', 'Flux Decay']),
136
- DG.Column.fromList('double', 'Value', [trialThroughput, flux, ff0, meanFlux, vmax, fluxDecay]),
137
- DG.Column.fromList('string', 'Unit', ["L/m²", "LMH", "LMH", "LMH", "L/m²", '%'])
143
+ DG.Column.fromList('string', 'Run', ['1']),
144
+ DG.Column.fromList('string', 'Filter', [inputParametersForReporting.get(0, 1)]),
145
+ DG.Column.fromList('double', 'Trial Throughput (L/m²)', [trialThroughput]),
146
+ DG.Column.fromList('double', 'Flux0 (LMH)', [j.get(1)]),
147
+ // DG.Column.fromList('double', 'Flux/Flux0 (LMH)', [ff0]),
148
+ DG.Column.fromList('double', 'Mean Flux (LMH)', [meanFlux]),
149
+ DG.Column.fromList('double', 'Vmax (L/m²)', [vmax]),
150
+ DG.Column.fromList('double', 'Flux Decay (%)', [fluxDecay]),
138
151
  ]);
139
152
  const q0 = Math.round(1 / coefficients[0]);
140
153
  const amin = (vbatch / vmax) + (vbatch / tbatch / q0);
141
154
  const installedArea = sf * amin;
142
155
  const processLoading = volumeInLiters.get(volumeInLiters.length - 1) / installedArea;
143
156
  recommendations = DG.DataFrame.fromColumns([
144
- DG.Column.fromList('string', 'Parameter', ['Volume', 'Time', 'Amin', 'Safety Factor', 'Installed Area', 'Process Loading']),
145
- DG.Column.fromList('double', 'Value', [vbatch, tbatch, amin, sf, installedArea, processLoading]),
146
- DG.Column.fromList('string', 'Unit', ["L", "h", "m²", "", '', 'L/m²'])
157
+ DG.Column.fromList('double', 'Volume (L)', [vbatch]),
158
+ DG.Column.fromList('double', 'Time (h)', [tbatch]),
159
+ DG.Column.fromList('double', 'Amin (m²)', [amin]),
160
+ DG.Column.fromList('double', 'Safety Factor', [sf]),
161
+ DG.Column.fromList('double', 'Installed Area', [installedArea]),
162
+ DG.Column.fromList('double', 'Process Loading (L/m²)', [processLoading]),
163
+ DG.Column.fromList('string', 'Filter', [inputParametersForReporting.get(1, 0)]),
164
+ DG.Column.fromList('string', 'Installed Device', [inputParametersForReporting.get(1, 10)]),
147
165
  ]);
148
166
 
149
167
  const v90 = vmax * 0.68;
150
168
  const initialFlowArea = coefficients[0];
151
169
  trialData = DG.DataFrame.fromColumns([
152
- DG.Column.fromList('string', 'Parameter', ['Test Filter Area', 'Initial Flow Area', 'Vmax', 'V90']),
153
- DG.Column.fromList('double', 'Value', [testArea, initialFlowArea, vmax, v90]),
154
- DG.Column.fromList('string', 'Unit', ["m²", "L/h", "m²", "m²"])
170
+ DG.Column.fromList('double', 'Test Filter Area (m²)', [testArea]),
171
+ DG.Column.fromList('double', 'Initial Flow Area (L/h)', [initialFlowArea]),
172
+ DG.Column.fromList('double', 'Vmax (m²)', [vmax]),
173
+ DG.Column.fromList('double', 'V90 (m²)', [v90]),
155
174
  ]);
156
175
 
157
176
  filter = DG.DataFrame.fromColumns([
158
- DG.Column.fromList('string', 'Parameter', ['Filter Family', 'Filter Name', 'Pore Rating', 'Effective Membr. Area', 'Membr material', 'Catalog']),
159
- DG.Column.fromList('string', 'Value', ['', '', '', '', '', ''])
177
+ DG.Column.fromList('string', 'Filter Family', [inputParametersForReporting.columns.names()[1]]),
178
+ DG.Column.fromList('string', 'Filter Name', [inputParametersForReporting.get(1, 0)]),
179
+ DG.Column.fromList('string', 'Pore Rating', [inputParametersForReporting.get(1, 1)]),
180
+ DG.Column.fromList('string', 'Effective Membr. Area', [inputParametersForReporting.get(1, 2)]),
181
+ DG.Column.fromList('string', 'Membr material', [inputParametersForReporting.get(1, 3)]),
182
+ DG.Column.fromList('string', 'Catalog', [inputParametersForReporting.get(1, 4)]),
160
183
  ]);
161
184
 
162
185
  sampleCharacteristics = DG.DataFrame.fromColumns([
163
- DG.Column.fromList('string', 'Parameter', ['Date', 'Prior step', 'Prot conc', 'Density', 'Turbidity']),
164
- DG.Column.fromList('string', 'Value', ['', '', '', '', ''])
165
- ]);
186
+ DG.Column.fromList('string', 'Date', [inputParametersForReporting.get(1, 5)]),
187
+ DG.Column.fromList('string', 'Prior step', [inputParametersForReporting.get(1, 6)]),
188
+ DG.Column.fromList('string', 'Prot conc', [inputParametersForReporting.get(1, 7)]),
189
+ DG.Column.fromList('string', 'Density', [inputParametersForReporting.get(1, 8)]),
190
+ DG.Column.fromList('string', 'Turbidity', [inputParametersForReporting.get(1, 9)]),
191
+ ]);
@@ -84,7 +84,7 @@ export async function exportFuncCall(call: DG.FuncCall) {
84
84
  } else {
85
85
  const plot = titleDiv.nextSibling;
86
86
  // if plot does not exist or it is only grid, skip it
87
- if (!plot || (plot.firstChild as HTMLElement).getAttribute('name') === 'viewer-Grid') continue;
87
+ if (!plot || (plot.firstChild?.firstChild?.firstChild as HTMLElement).getAttribute('name') === 'viewer-Grid') continue;
88
88
 
89
89
  if (plot) {
90
90
  const canvas = await DG.HtmlUtils.renderToCanvas(plot as HTMLElement);
@@ -146,7 +146,7 @@ export async function exportFuncCall(call: DG.FuncCall) {
146
146
  } else {
147
147
  const plot = titleDiv.nextSibling;
148
148
  // if plot does not exist or it is only grid, skip it
149
- if (!plot || (plot.firstChild as HTMLElement).getAttribute('name') === 'viewer-Grid') continue;
149
+ if (!plot || (plot.firstChild?.firstChild?.firstChild as HTMLElement).getAttribute('name') === 'viewer-Grid') continue;
150
150
 
151
151
  if (plot) {
152
152
  const canvas = await DG.HtmlUtils.renderToCanvas(plot as HTMLElement);
@@ -2,6 +2,7 @@ import * as grok from 'datagrok-api/grok';
2
2
  import * as ui from 'datagrok-api/ui';
3
3
  import * as DG from 'datagrok-api/dg';
4
4
  import CodeMirror from 'codemirror';
5
+ import 'codemirror/lib/codemirror.css';
5
6
  import {_package} from '../package';
6
7
 
7
8
  const enum FUNC_PROPS_FIELDS {
@@ -95,6 +96,75 @@ const functionParamsLabels = (key: FUNC_PARAM_FIELDS) => {
95
96
  }
96
97
  };
97
98
 
99
+ enum COMMON_TAG_NAME {
100
+ VALIDATORS = 'validators',
101
+ CAPTION = 'caption',
102
+ POSTFIX = 'postfix',
103
+ UNITS = 'units'
104
+ }
105
+
106
+ enum OPTIONAL_TAG_NAME {
107
+ COLUMNS = 'columns',
108
+ CATEGORICAL = 'categorical',
109
+ TYPE = 'type',
110
+ FORMAT = 'format',
111
+ ALLOW_NULLS = 'allowNulls',
112
+ ACTION = 'action',
113
+ CHOICES = 'choices',
114
+ SUGGESTIONS = 'suggestions',
115
+ SEM_TYPE = 'semType'
116
+ }
117
+
118
+ type DF_TAG_NAME = COMMON_TAG_NAME | OPTIONAL_TAG_NAME.COLUMNS | OPTIONAL_TAG_NAME.CATEGORICAL;
119
+ type COLUMN_TAG_NAME = COMMON_TAG_NAME |
120
+ OPTIONAL_TAG_NAME.TYPE | OPTIONAL_TAG_NAME.FORMAT |
121
+ OPTIONAL_TAG_NAME.ALLOW_NULLS | OPTIONAL_TAG_NAME.ACTION | OPTIONAL_TAG_NAME.SEM_TYPE
122
+
123
+ type STRING_TAG_NAME = COMMON_TAG_NAME |
124
+ OPTIONAL_TAG_NAME.CHOICES | OPTIONAL_TAG_NAME.SUGGESTIONS
125
+
126
+ const DF_TAG_NAMES = [...Object.values(COMMON_TAG_NAME), OPTIONAL_TAG_NAME.COLUMNS, OPTIONAL_TAG_NAME.CATEGORICAL];
127
+ const COLUMN_TAG_NAMES = [...Object.values(COMMON_TAG_NAME), OPTIONAL_TAG_NAME.TYPE, OPTIONAL_TAG_NAME.FORMAT,
128
+ OPTIONAL_TAG_NAME.ALLOW_NULLS, OPTIONAL_TAG_NAME.ACTION, OPTIONAL_TAG_NAME.SEM_TYPE];
129
+ const STRING_TAG_NAMES = [...Object.values(COMMON_TAG_NAME), OPTIONAL_TAG_NAME.CHOICES, OPTIONAL_TAG_NAME.SUGGESTIONS];
130
+
131
+ type FuncParamBase = {
132
+ direction: DIRECTION,
133
+ name?: string,
134
+ defaultValue?: string,
135
+ description?: string
136
+ }
137
+
138
+ type FuncParam =
139
+ FuncParamBase & {
140
+ type: DG.TYPE.BOOL | DG.TYPE.DATE_TIME | DG.TYPE.FLOAT | DG.TYPE.GRAPHICS | DG.TYPE.INT
141
+ options?: {tag: COMMON_TAG_NAME, value: string}[]
142
+ } | FuncParamBase & {
143
+ type: DG.TYPE.DATA_FRAME,
144
+ options?: {tag: DF_TAG_NAME, value: string}[]
145
+ } | FuncParamBase & {
146
+ type: DG.TYPE.COLUMN_LIST | DG.TYPE.COLUMN,
147
+ options?: {tag: COLUMN_TAG_NAME, value: string}[]
148
+ } | FuncParamBase & {
149
+ type: DG.TYPE.STRING
150
+ options?: {tag: STRING_TAG_NAME, value: string}[]
151
+ }
152
+
153
+ const generateParamLine = (param: DG.Property, direction: string) => {
154
+ const optionTags = `{${
155
+ COLUMN_TAG_NAMES
156
+ .map((tag) => {
157
+ console.log(param.name, tag, param.options(), (param.options() as any)[tag]);
158
+ return {tag: tag, val: (param.options() as any)[tag]};
159
+ })
160
+ .filter((value) => !!value.val)
161
+ .map(({tag, val}) => `${tag}:${val}`)
162
+ .join('; ')
163
+ }}`;
164
+ const result =`#${direction}: ${param.propertyType} ${param.name || ''} ${param.defaultValue ? `= ${param.defaultValue}` : ''} ${optionTags} ${param.description ? ` [${param.description}]` : ''}\n`;
165
+ return result;
166
+ };
167
+
98
168
  export function _functionEditor(functionCode: string) {
99
169
  const inputScript = DG.Script.create(functionCode);
100
170
 
@@ -276,15 +346,10 @@ export function _functionEditor(functionCode: string) {
276
346
  return ui.div(result);
277
347
  });
278
348
 
279
- acc.addPane('Connections', ()=> {
349
+ acc.addPane('Tags', ()=> {
280
350
  return ui.div();
281
351
  });
282
352
 
283
- acc.addPane('Viewers', ()=> {
284
- return ui.div();
285
- });
286
-
287
-
288
353
  grok.shell.o = ui.divV([ui.h1(`Param: ${paramName}`), acc.root]);
289
354
  };
290
355
 
@@ -351,9 +416,9 @@ export function _functionEditor(functionCode: string) {
351
416
  );
352
417
 
353
418
  const area = ui.textInput('', '');
354
- const myCM = CodeMirror.fromTextArea((area.input as HTMLTextAreaElement), {});
419
+ const myCM = CodeMirror.fromTextArea((area.input as HTMLTextAreaElement));
355
420
 
356
- const previewDiv = ui.divV([ui.h1('Code preview'), area]);
421
+ const previewDiv = ui.panel([ui.divV([ui.h1('Code preview'), area])]);
357
422
  previewDiv.style.flexGrow = '1';
358
423
 
359
424
  propsForm = functionPropsForm();
@@ -429,10 +494,10 @@ export function _functionEditor(functionCode: string) {
429
494
  if (propValue) result += `#${functionPropsCode(propField as keyof FuncPropsState)}: ${propValue}\n`;
430
495
  });
431
496
  functionInputParamsCopy.map((param) => {
432
- result += `#input: ${param.propertyType} ${param.name}\n`;
497
+ result += generateParamLine(param, DIRECTION.INPUT);
433
498
  });
434
499
  functionOutputParamsCopy.map((param) => {
435
- result += `#output: ${param.propertyType} ${param.name}\n`;
500
+ result += generateParamLine(param, DIRECTION.OUTPUT);
436
501
  });
437
502
  myCM.setValue(result);
438
503
  };
@@ -33,7 +33,8 @@ export class OutliersSelectionViewer extends DG.JsViewer {
33
33
  const OUTLIER_RATIONALE_COL_LABEL = 'Rationale';
34
34
  const OUTLIER_COUNT_COL_LABEL = 'Count';
35
35
  const IS_GROUP_CONFIRMED_LABEL = 'isConfirmed';
36
- const FLUX = 't/V (hr/L)';
36
+ const FLUX = 't/V (hr/(L/m²))';
37
+ const DEFAULT_TEST_AREA = 3.5;
37
38
 
38
39
  if (!inputData.columns.byName(IS_OUTLIER_COL_LABEL)) {
39
40
  inputData.columns
@@ -46,7 +47,7 @@ export class OutliersSelectionViewer extends DG.JsViewer {
46
47
  }
47
48
 
48
49
  if (!inputData.columns.byName(FLUX)) {
49
- (inputData.columns as DG.ColumnList).addNew(FLUX, 'double').init((index) => (inputData.cell(index, 'filtrate volume (mL)').value/1000.0) / (inputData.cell(index, 'time (min)').value/60.0));
50
+ (inputData.columns as DG.ColumnList).addNew(FLUX, 'double').init((index) => (inputData.cell(index, 'time (min)').value/60.0) / ((inputData.cell(index, 'filtrate volume (mL)').value/1000.0) / (DEFAULT_TEST_AREA / 10000.0)));
50
51
  }
51
52
 
52
53
  const initialData = inputData.clone();
@@ -240,20 +241,22 @@ export class OutliersSelectionViewer extends DG.JsViewer {
240
241
  updateGroupsTable();
241
242
  resetSelectedBtn.classList.add('disabled');
242
243
 
243
- this.root.replaceWith(ui.panel([
244
+ const info = ui.info(
245
+ ui.div([
246
+ ui.p('Hold the “SHIFT” key and start to draw a freehand selection on the plot area'),
247
+ ], {style: {'white-space': 'pre-wrap'}}),
248
+ );
249
+ info.style.marginBottom = '0px';
250
+
251
+ this.root.replaceWith(
244
252
  ui.divV([
245
- ui.info(
246
- ui.div([
247
- ui.p('Hold the “SHIFT” key and start to draw a freehand selection on the plot area'),
248
- ], {style: {'white-space': 'pre-wrap'}}),
249
- ),
253
+ info,
250
254
  ui.divV([
251
255
  ui.divH([
252
256
  resetSelectedBtn, resetAllBtn, autoOutlierGroupBtn,
253
- ], {style: {'text-align': 'center'}}),
257
+ ], {style: {'text-align': 'center', 'justify-content': 'center'}}),
254
258
  groupsListGrid.root,
255
259
  ], {style: {'height': '75%'}}),
256
- ], {style: {'height': '100%', 'min-width': '230px'}}),
257
- ], {style: {'height': '100%'}}));
260
+ ], {style: {'height': '100%', 'min-width': '230px'}}));
258
261
  }
259
262
  }
@@ -13,7 +13,8 @@ export async function selectOutliersManually(inputData: DG.DataFrame) {
13
13
  const OUTLIER_RATIONALE_COL_LABEL = 'Rationale';
14
14
  const OUTLIER_COUNT_COL_LABEL = 'Count';
15
15
  const IS_GROUP_CONFIRMED_LABEL = 'isConfirmed';
16
- const FLUX = 't/V (hr/L)';
16
+ const FLUX = 't/V (hr/(L/m²))';
17
+ const DEFAULT_TEST_AREA = 3.5;
17
18
 
18
19
  if (!inputData.columns.byName(IS_OUTLIER_COL_LABEL)) {
19
20
  inputData.columns
@@ -26,7 +27,7 @@ export async function selectOutliersManually(inputData: DG.DataFrame) {
26
27
  }
27
28
 
28
29
  if (!inputData.columns.byName(FLUX)) {
29
- (inputData.columns as DG.ColumnList).addNew(FLUX, 'double').init((index) => (inputData.cell(index, 'filtrate volume (mL)').value/1000.0) / (inputData.cell(index, 'time (min)').value/60.0));
30
+ (inputData.columns as DG.ColumnList).addNew(FLUX, 'double').init((index) => (inputData.cell(index, 'time (min)').value/60.0) / ((inputData.cell(index, 'filtrate volume (mL)').value/1000.0) / (DEFAULT_TEST_AREA / 10000.0)));
30
31
  }
31
32
 
32
33
  const initialData = inputData.clone();
package/src/package.ts CHANGED
@@ -71,13 +71,17 @@ export function functionEditor() {
71
71
  #language: python
72
72
  #sample: chem/smiles_coordinates.csv
73
73
  #tags: demo, chem, rdkit
74
- #input: dataframe data [Input data table]
75
- #input: column smiles {type:categorical, semType: Molecule} [Molecules, in SMILES format]
76
- #input: int components = 2 [Number of components]
77
- #input: int minClusterSize = 3 [Minimum cluster size]
78
- #output: graphics spanningTree
79
- #output: graphics linkageTree
80
- #output: graphics chemSpace
74
+ #input: dataframe t1 {columns:numerical} [first input data table]
75
+ #input: dataframe t2 {columns:numerical} [second input data table]
76
+ #input: column x {type:numerical; table:t1} [x axis column name]
77
+ #input: column y {type:numerical} [y axis column name]
78
+ #input: column date {type:datetime; format:mm/dd/yyyy} [date column name]
79
+ #input: column_list numdata {type:numerical; table:t1} [numerical columns names]
80
+ #input: int numcomp = 2 {range:2-7} [number of components]
81
+ #input: bool center = true [number of components]
82
+ #input: string type = high {choices: ["high", "low"]} [type of filter]
83
+ #output: dataframe result {action:join(t1)} [pca components]
84
+ #output: graphics scatter [scatter plot]
81
85
 
82
86
  import numba
83
87
  import hdbscan
package/webpack.config.js CHANGED
@@ -11,6 +11,10 @@ module.exports = {
11
11
  module: {
12
12
  rules: [
13
13
  {test: /\.tsx?$/, loader: 'ts-loader'},
14
+ {
15
+ test: /\.css$/,
16
+ use: ['style-loader', 'css-loader'],
17
+ },
14
18
  ],
15
19
  },
16
20
  devtool: 'inline-source-map',
@@ -23,7 +27,7 @@ module.exports = {
23
27
  'rxjs/operators': 'rxjs.operators',
24
28
  'cash-dom': '$',
25
29
  'dayjs': 'dayjs',
26
- 'wu': 'wu'
30
+ 'wu': 'wu',
27
31
  },
28
32
  output: {
29
33
  filename: '[name].js',