hiplot-mm 0.0.1__py3-none-any.whl → 0.0.3rc0__py3-none-any.whl

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 (58) hide show
  1. hiplot/ipython.py +38 -6
  2. hiplot/pkginfo.py +18 -2
  3. hiplot/server.py +8 -2
  4. hiplot/static/built/hiplot.bundle.js +1 -1
  5. hiplot/static/built/streamlit_component/hiplot_streamlit.bundle.js +1 -1
  6. hiplot/streamlit_helpers.py +11 -2
  7. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/METADATA +51 -27
  8. hiplot_mm-0.0.3rc0.dist-info/RECORD +33 -0
  9. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/WHEEL +1 -1
  10. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/entry_points.txt +0 -1
  11. hiplot/static/built/component.d.ts +0 -109
  12. hiplot/static/built/component.js +0 -528
  13. hiplot/static/built/contextmenu.d.ts +0 -26
  14. hiplot/static/built/contextmenu.js +0 -90
  15. hiplot/static/built/controls.d.ts +0 -52
  16. hiplot/static/built/controls.js +0 -163
  17. hiplot/static/built/filters.d.ts +0 -21
  18. hiplot/static/built/filters.js +0 -96
  19. hiplot/static/built/header.d.ts +0 -39
  20. hiplot/static/built/header.js +0 -176
  21. hiplot/static/built/hiplot-mm-0.0.0.tar.gz +0 -0
  22. hiplot/static/built/hiplot.bundle.js.LICENSE.txt +0 -88
  23. hiplot/static/built/hiplot.bundle.js.map +0 -1
  24. hiplot/static/built/hiplot.d.ts +0 -8
  25. hiplot/static/built/hiplot.js +0 -14
  26. hiplot/static/built/hiplot.lib.js +0 -57712
  27. hiplot/static/built/hiplot.lib.js.map +0 -1
  28. hiplot/static/built/hiplot.licenses.txt +0 -682
  29. hiplot/static/built/hiplot_mm-0.0.0-py3-none-any.whl +0 -0
  30. hiplot/static/built/hiplot_streamlit.bundle.js +0 -3
  31. hiplot/static/built/hiplot_streamlit.bundle.js.LICENSE.txt +0 -97
  32. hiplot/static/built/hiplot_streamlit.bundle.js.map +0 -1
  33. hiplot/static/built/hiplot_streamlit.d.ts +0 -1
  34. hiplot/static/built/hiplot_streamlit.js +0 -85
  35. hiplot/static/built/hiplot_streamlit.licenses.txt +0 -689
  36. hiplot/static/built/hiplot_test.bundle.js +0 -3
  37. hiplot/static/built/hiplot_test.bundle.js.LICENSE.txt +0 -88
  38. hiplot/static/built/hiplot_test.bundle.js.map +0 -1
  39. hiplot/static/built/hiplot_test.d.ts +0 -46
  40. hiplot/static/built/hiplot_test.js +0 -238
  41. hiplot/static/built/hiplot_test.licenses.txt +0 -682
  42. hiplot/static/built/hiplot_web.d.ts +0 -3
  43. hiplot/static/built/hiplot_web.js +0 -54
  44. hiplot/static/built/infertypes.d.ts +0 -38
  45. hiplot/static/built/infertypes.js +0 -316
  46. hiplot/static/built/plotxy.d.ts +0 -62
  47. hiplot/static/built/plotxy.js +0 -602
  48. hiplot/static/built/plugin.d.ts +0 -38
  49. hiplot/static/built/plugin.js +0 -8
  50. hiplot/static/built/rowsdisplaytable.d.ts +0 -35
  51. hiplot/static/built/rowsdisplaytable.js +0 -284
  52. hiplot/static/built/streamlit_component/hiplot.bundle.js +0 -3
  53. hiplot/static/built/types.d.ts +0 -64
  54. hiplot/static/built/types.js +0 -55
  55. hiplot_mm-0.0.1.dist-info/RECORD +0 -77
  56. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info/licenses}/LICENSE +0 -0
  57. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info/licenses}/NOTICE +0 -0
  58. {hiplot_mm-0.0.1.dist-info → hiplot_mm-0.0.3rc0.dist-info}/top_level.txt +0 -0
@@ -1,54 +0,0 @@
1
- /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- var __assign = (this && this.__assign) || function () {
8
- __assign = Object.assign || function(t) {
9
- for (var s, i = 1, n = arguments.length; i < n; i++) {
10
- s = arguments[i];
11
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
12
- t[p] = s[p];
13
- }
14
- return t;
15
- };
16
- return __assign.apply(this, arguments);
17
- };
18
- import ReactDOM from "react-dom";
19
- import { HiPlot, defaultPlugins } from "./component";
20
- import React from "react";
21
- import { PersistentStateInURL } from "./lib/savedstate";
22
- import { WebserverDataProvider } from "./dataproviders/webserver";
23
- import { StaticDataProvider } from "./dataproviders/static";
24
- import { UploadDataProvider } from "./dataproviders/upload";
25
- export function build_props(extra) {
26
- var props = {
27
- experiment: null,
28
- persistentState: new PersistentStateInURL("hip"),
29
- plugins: defaultPlugins,
30
- comm: null,
31
- asserts: false,
32
- dataProvider: WebserverDataProvider,
33
- dark: false,
34
- onChange: null
35
- };
36
- if (extra !== undefined) {
37
- Object.assign(props, extra);
38
- }
39
- if (extra.dataProviderName !== undefined) {
40
- props.dataProvider = {
41
- 'webserver': WebserverDataProvider,
42
- 'upload': UploadDataProvider,
43
- 'none': StaticDataProvider
44
- }[extra.dataProviderName];
45
- }
46
- if (extra.persistentStateUrlPrefix !== undefined) {
47
- props.persistentState = new PersistentStateInURL(extra.persistentStateUrlPrefix);
48
- }
49
- return props;
50
- }
51
- export function render(element, extra) {
52
- return ReactDOM.render(React.createElement(React.StrictMode, null,
53
- React.createElement(HiPlot, __assign({}, build_props(extra)))), element);
54
- }
@@ -1,38 +0,0 @@
1
- import { PersistentState } from "./lib/savedstate";
2
- import { Datapoint, ParamType, HiPlotValueDef } from "./types";
3
- export interface ParamDef extends HiPlotValueDef {
4
- name: string;
5
- optional: boolean;
6
- numeric: boolean;
7
- distinct_values: Array<any>;
8
- type_options: Array<ParamType>;
9
- ticks_format?: string;
10
- __val2color?: {
11
- [k: string]: any;
12
- };
13
- __colorscale?: any;
14
- __colormap?: any;
15
- }
16
- export declare function create_d3_scale_without_outliers(pd: ParamDef): any;
17
- export declare function create_d3_scale(pd: ParamDef): any;
18
- export interface ScaleDomainRange {
19
- type: ParamType;
20
- brush_extents_normalized: [number, number];
21
- values?: Array<any>;
22
- range?: [number, number];
23
- include_infnans?: boolean;
24
- }
25
- export declare function scale_pixels_range(scale: any, extents: [number, number]): ScaleDomainRange;
26
- export declare function colorScheme(pd: ParamDef, value: any, alpha: number, defaultColorMap: string): string;
27
- export interface ParamDefMap {
28
- [key: string]: ParamDef;
29
- }
30
- /**
31
- * Ideally we want to infer:
32
- * - If a variable is categorical
33
- * - If a variable is numeric
34
- * - If a variable is log-scaled
35
- */
36
- export declare function infertypes(url_states: PersistentState, table: Array<Datapoint>, hints: {
37
- [key: string]: HiPlotValueDef;
38
- }): ParamDefMap;
@@ -1,316 +0,0 @@
1
- /*
2
- * Copyright (c) Facebook, Inc. and its affiliates.
3
- *
4
- * This source code is licensed under the MIT license found in the
5
- * LICENSE file in the root directory of this source tree.
6
- */
7
- import $ from "jquery";
8
- import * as d3 from "d3";
9
- import * as color from "color";
10
- import { categoricalColorScheme } from "./lib/categoricalcolors";
11
- import { d3_scale_percentile, d3_scale_timestamp, scale_add_outliers, is_special_numeric, d3_scale_categorical, get_numeric_values_sorted } from "./lib/d3_scales";
12
- import { ParamType } from "./types";
13
- function get_min_max_for_numeric_scale(pd) {
14
- var min = pd.force_value_min;
15
- var max = pd.force_value_max;
16
- pd.distinct_values.forEach(function (value) {
17
- var parsed = parseFloat(value);
18
- if (is_special_numeric(parsed)) {
19
- return;
20
- }
21
- if (min === null || parsed < min) {
22
- min = parsed;
23
- }
24
- if (max === null || parsed > max) {
25
- max = parsed;
26
- }
27
- });
28
- return [min, max];
29
- }
30
- function has_inf_or_nans(pd) {
31
- for (var i = 0; i < pd.distinct_values.length; ++i) {
32
- var parsed = parseFloat(pd.distinct_values[i]);
33
- if (is_special_numeric(parsed)) {
34
- return true;
35
- }
36
- }
37
- return false;
38
- }
39
- export function create_d3_scale_without_outliers(pd) {
40
- var dv = pd.distinct_values;
41
- if (pd.type == ParamType.CATEGORICAL) {
42
- return d3_scale_categorical(dv);
43
- }
44
- else {
45
- if (pd.type == ParamType.NUMERICPERCENTILE) {
46
- return d3_scale_percentile(dv);
47
- }
48
- var _a = get_min_max_for_numeric_scale(pd), min = _a[0], max = _a[1];
49
- console.assert(!isNaN(min));
50
- console.assert(!isNaN(max));
51
- console.assert(min <= max);
52
- if (pd.type == ParamType.TIMESTAMP) {
53
- return d3_scale_timestamp().domain([min, max]);
54
- }
55
- if (pd.type == ParamType.NUMERICLOG) {
56
- console.assert(min > 0, "Min value for \"" + pd.name + "\" is negative (" + min + "), can't use log-scale");
57
- return d3.scaleLog().domain([min, max]);
58
- }
59
- console.assert(pd.type == ParamType.NUMERIC, "Unknown variable type " + pd.type);
60
- return d3.scaleLinear().domain([min, max]);
61
- }
62
- }
63
- export function create_d3_scale(pd) {
64
- var scale = create_d3_scale_without_outliers(pd);
65
- if (has_inf_or_nans(pd) && [ParamType.NUMERIC, ParamType.NUMERICLOG, ParamType.NUMERICPERCENTILE].indexOf(pd.type) >= 0) {
66
- scale = scale_add_outliers(scale);
67
- }
68
- scale.hip_type = pd.type;
69
- scale.hip_num_values = pd.distinct_values.length;
70
- return scale;
71
- }
72
- ;
73
- export function scale_pixels_range(scale, extents) {
74
- /**
75
- * Converts scale range in pixels back to domain (aka inverts the scale)
76
- */
77
- console.assert(scale, "No scale provided to `scale_pixels_range`");
78
- console.assert(extents, "No extents provided to `scale_pixels_range`", extents);
79
- var scaleToNorm = d3.scaleLinear().domain(scale.range()).range([0, 1]);
80
- var normalized = [scaleToNorm(extents[0]), scaleToNorm(extents[1])];
81
- switch (scale.hip_type) {
82
- case ParamType.CATEGORICAL:
83
- var domain = scale.domain();
84
- var firstIdx = Math.ceil(Math.min(normalized[0], normalized[1]) * (domain.length - 1));
85
- var lastIdx = Math.floor(Math.max(normalized[0], normalized[1]) * (domain.length - 1) + 1);
86
- return {
87
- "type": scale.hip_type,
88
- "brush_extents_normalized": normalized,
89
- "values": domain.slice(firstIdx, lastIdx)
90
- };
91
- case ParamType.NUMERIC:
92
- case ParamType.NUMERICLOG:
93
- case ParamType.NUMERICPERCENTILE:
94
- case ParamType.TIMESTAMP:
95
- var pxlRange = scale.range();
96
- // Small hack to make sure we can always select the extrema
97
- // (considering loss of precision in computations, especially for logscale)
98
- for (var i = 0; i < 2; ++i) {
99
- if (extents[i] == Math.min.apply(Math, pxlRange)) {
100
- --extents[i];
101
- }
102
- if (extents[i] == Math.max.apply(Math, pxlRange)) {
103
- ++extents[i];
104
- }
105
- }
106
- var range = [scale.invert(extents[0]), scale.invert(extents[1])];
107
- return {
108
- "type": scale.hip_type,
109
- "brush_extents_normalized": normalized,
110
- "range": range,
111
- "include_infnans": extents[0] <= scale(Infinity) && scale(Infinity) <= extents[1]
112
- };
113
- }
114
- }
115
- function compute_val2color(pd) {
116
- if (pd.__val2color !== undefined) {
117
- return;
118
- }
119
- pd.__val2color = pd.colors !== null ? pd.colors : {};
120
- for (var i = 0; i < pd.distinct_values.length; ++i) {
121
- if (pd.__val2color[pd.distinct_values[i]]) {
122
- continue;
123
- }
124
- if (pd.distinct_values.length <= 20) {
125
- var scheme = ["#1f77b4", "#ff7f0e", "#d62728", "#9467bd", "#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf", "#1f77b4", "#aec7e8", "#ffbb78", "#ff9896", "#c5b0d5", "#c49c94", "#f7b6d2", "#c7c7c7", "#dbdb8d", "#9edae5", "#2ca02c"];
126
- // @ts-ignore
127
- pd.__val2color[pd.distinct_values[i]] = color(scheme[i]).rgb().string();
128
- continue;
129
- }
130
- pd.__val2color[pd.distinct_values[i]] = categoricalColorScheme(pd.distinct_values[i]);
131
- }
132
- }
133
- ;
134
- function parseColorMap(full_name, description) {
135
- if (!full_name) {
136
- // @ts-ignore
137
- return d3.interpolateTurbo;
138
- }
139
- var parts = full_name.split("#");
140
- var name = parts[0];
141
- var fn = d3[name];
142
- if (!fn) {
143
- throw new Error("Invalid color map " + name + " " + description);
144
- }
145
- // Assume this is a scheme (eg array of colors)
146
- if (!name.startsWith("interpolate")) {
147
- if (typeof fn[0] != "string") {
148
- fn = fn[fn.length - 1];
149
- }
150
- var array_of_colors_1 = fn;
151
- fn = function (colr) {
152
- return array_of_colors_1[Math.max(0, Math.min(array_of_colors_1.length - 1, Math.floor(colr * array_of_colors_1.length)))];
153
- };
154
- }
155
- // Apply modifiers
156
- if (parts.length > 1) {
157
- parts[1].split(",").forEach(function (modifier_name) {
158
- if (modifier_name == "inverse") {
159
- var orig_fn_1 = fn;
160
- fn = function (colr) {
161
- return orig_fn_1(-colr);
162
- };
163
- }
164
- });
165
- }
166
- return fn;
167
- }
168
- function getColorMap(pd, defaultColorMap) {
169
- if (pd.colormap) {
170
- if (pd.__colormap) {
171
- return pd.__colormap;
172
- }
173
- pd.__colormap = parseColorMap(pd.colormap, "for column " + pd.name);
174
- return pd.__colormap;
175
- }
176
- return parseColorMap(defaultColorMap, "(global default color map)");
177
- }
178
- export function colorScheme(pd, value, alpha, defaultColorMap) {
179
- if (pd.type == ParamType.CATEGORICAL) {
180
- compute_val2color(pd);
181
- var c = pd.__val2color[value];
182
- if (c === undefined) {
183
- return "rgb(100,100,100," + alpha + ")";
184
- }
185
- console.assert((c.startsWith('rgb(') || c.startsWith('hsl(')), c);
186
- return c.slice(0, 3) + 'a' + c.slice(3, c.length - 1) + ',' + alpha + ')';
187
- }
188
- else {
189
- if (value === undefined || value === null || is_special_numeric(value)) {
190
- return "rgb(100,100,100," + alpha + ")";
191
- }
192
- if (!pd.__colorscale || pd.__colorscale.__type !== pd.type) {
193
- pd.__colorscale = create_d3_scale_without_outliers(pd);
194
- pd.__colorscale.range([0, 1]);
195
- pd.__colorscale.__type = pd.type;
196
- }
197
- var colr = Math.max(0, Math.min(1, pd.__colorscale(value)));
198
- var interpColFn = getColorMap(pd, defaultColorMap);
199
- try {
200
- var code = interpColFn(colr);
201
- // @ts-ignore
202
- var rgb = color(code).rgb().object();
203
- return "rgba(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + alpha + ")";
204
- }
205
- catch (err) {
206
- throw new Error("Error below happened while computing color using color map \"" + pd.colormap + "\" for column " + pd.name + ": is the colormap valid? (" + err.toString() + ")");
207
- }
208
- }
209
- }
210
- ;
211
- /**
212
- * Ideally we want to infer:
213
- * - If a variable is categorical
214
- * - If a variable is numeric
215
- * - If a variable is log-scaled
216
- */
217
- export function infertypes(url_states, table, hints) {
218
- if (hints === undefined) {
219
- hints = {};
220
- }
221
- function infertype(key, hint) {
222
- var url_state = url_states.children(key);
223
- var optional = false;
224
- var numeric = ["uid", "from_uid"].indexOf(key) == -1;
225
- var can_be_timestamp = numeric;
226
- var setVals = [];
227
- var addValue = function (v) {
228
- if (v === undefined) {
229
- optional = true;
230
- return;
231
- }
232
- var is_special_num = is_special_numeric(v);
233
- setVals.push(v);
234
- // Detect non-numeric column
235
- if ((typeof v != "number" && !is_special_num && isNaN(v)) ||
236
- v === true || v === false) {
237
- numeric = false;
238
- can_be_timestamp = false;
239
- }
240
- if (!Number.isSafeInteger(v) || v < 0) {
241
- can_be_timestamp = false;
242
- }
243
- };
244
- table.forEach(function (row) {
245
- addValue(row[key]);
246
- });
247
- var values = setVals;
248
- var distinct_values = Array.from(new Set(values));
249
- var numericSorted = numeric ? get_numeric_values_sorted(distinct_values) : [];
250
- var forceValueMinNegative = hint !== undefined && hint.force_value_min != null && hint.force_value_min !== undefined && hint.force_value_min <= 0;
251
- var canBeLogScale = (numericSorted[0] > 0 && !forceValueMinNegative);
252
- var spansMultipleOrdersOfMagnitude = false;
253
- if (numericSorted.length > 10 && numericSorted[0] > 0) {
254
- var top5pct = numericSorted[Math.min(numericSorted.length - 1, ~~(19 * numericSorted.length / 20))];
255
- var bot5pct = numericSorted[~~(numericSorted.length / 20)];
256
- spansMultipleOrdersOfMagnitude = (top5pct / bot5pct) > 100;
257
- }
258
- var categorical = !numeric || ((Math.max(values.length, 10) / distinct_values.length) > 10 && distinct_values.length < 6);
259
- var type = ParamType.CATEGORICAL;
260
- if (numeric && !categorical) {
261
- type = ParamType.NUMERIC;
262
- if (spansMultipleOrdersOfMagnitude) {
263
- type = canBeLogScale ? ParamType.NUMERICLOG : ParamType.NUMERICPERCENTILE;
264
- }
265
- }
266
- if (hint !== undefined && hint.type !== null) {
267
- type = hint.type;
268
- }
269
- else {
270
- type = url_state.get('type', type);
271
- }
272
- var info = {
273
- 'name': key,
274
- 'optional': optional,
275
- 'numeric': numeric,
276
- 'distinct_values': distinct_values,
277
- 'type_options': [ParamType.CATEGORICAL],
278
- 'ticks_format': undefined,
279
- 'type': type,
280
- 'colors': hint !== undefined ? hint.colors : null,
281
- 'colormap': hint !== undefined ? hint.colormap : null,
282
- 'force_value_min': hint !== undefined && hint.force_value_min != null ? hint.force_value_min : null,
283
- 'force_value_max': hint !== undefined && hint.force_value_max != null ? hint.force_value_max : null,
284
- 'label_css': hint !== undefined && hint.label_css !== null ? hint.label_css : "",
285
- 'label_html': hint !== undefined && hint.label_html !== null && hint.label_html !== undefined ? hint.label_html : $("<div>").text(key).html()
286
- };
287
- // What other types we can render as?
288
- if (numeric) {
289
- info.type_options.push(ParamType.NUMERIC);
290
- if (canBeLogScale) {
291
- info.type_options.push(ParamType.NUMERICLOG);
292
- }
293
- info.type_options.push(ParamType.NUMERICPERCENTILE);
294
- if (can_be_timestamp) {
295
- info.type_options.push(ParamType.TIMESTAMP);
296
- }
297
- }
298
- if (info.type == ParamType.NUMERICLOG) {
299
- info.ticks_format = d3.format(".1e");
300
- }
301
- return info;
302
- }
303
- // First, get a set of all the types
304
- var allKeys = new Set();
305
- table.forEach(function (row) {
306
- Object.keys(row).forEach(function (k) {
307
- allKeys.add(k);
308
- });
309
- });
310
- var ret = {};
311
- allKeys.forEach(function (key) {
312
- ret[key] = infertype(key, hints[key]);
313
- });
314
- return ret;
315
- }
316
- ;
@@ -1,62 +0,0 @@
1
- import { HiPlotPluginData } from "./plugin";
2
- import React from "react";
3
- import _ from "underscore";
4
- import { ContextMenu } from "./contextmenu";
5
- export interface PlotXYDisplayData {
6
- axis_x: string | null;
7
- axis_y: string | null;
8
- lines_thickness: number;
9
- lines_opacity: number;
10
- dots_thickness: number;
11
- dots_highlighed_thickness: number;
12
- dots_opacity: number;
13
- height?: number;
14
- }
15
- interface PlotXYProps extends HiPlotPluginData, PlotXYDisplayData {
16
- }
17
- interface PlotXYState extends PlotXYDisplayData {
18
- width: number;
19
- initialHeight: number;
20
- height: number;
21
- hover_uid: string | null;
22
- highlightType: string;
23
- }
24
- interface PlotXYInternal {
25
- clear_canvas: () => void;
26
- update_axis: () => void;
27
- recompute_scale: () => void;
28
- draw_selected_rows: () => void;
29
- draw_highlighted: () => void;
30
- on_resize: (() => void) & _.Cancelable;
31
- }
32
- export declare class PlotXY extends React.Component<PlotXYProps, PlotXYState> {
33
- plot: PlotXYInternal;
34
- svg: any;
35
- root_ref: React.RefObject<HTMLDivElement>;
36
- container_ref: React.RefObject<HTMLDivElement>;
37
- canvas_lines_ref: React.RefObject<HTMLCanvasElement>;
38
- canvas_highlighted_ref: React.RefObject<HTMLCanvasElement>;
39
- plotXYcontextMenuRef: React.RefObject<ContextMenu>;
40
- constructor(props: PlotXYProps);
41
- static defaultProps: {
42
- axis_x: any;
43
- axis_y: any;
44
- lines_thickness: number;
45
- lines_opacity: any;
46
- dots_highlighed_thickness: number;
47
- dots_thickness: number;
48
- dots_opacity: any;
49
- data: {};
50
- };
51
- componentDidMount(): void;
52
- mountPlotXY(this: PlotXY): PlotXYInternal;
53
- onResize: any;
54
- disable(): void;
55
- render(): any[] | JSX.Element;
56
- componentWillUnmount(): void;
57
- isEnabled(): boolean;
58
- drawSelected: any;
59
- drawSelectedThrottled: any;
60
- componentDidUpdate(prevProps: PlotXYProps, prevState: any): void;
61
- }
62
- export {};