guidepost 0.2.15__tar.gz → 0.2.16__tar.gz
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.
- {guidepost-0.2.15/guidepost.egg-info → guidepost-0.2.16}/PKG-INFO +1 -1
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost/guidepost.js +58 -75
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost/guidepost.py +4 -0
- guidepost-0.2.16/guidepost/version.py +2 -0
- {guidepost-0.2.15 → guidepost-0.2.16/guidepost.egg-info}/PKG-INFO +1 -1
- guidepost-0.2.15/guidepost/version.py +0 -2
- {guidepost-0.2.15 → guidepost-0.2.16}/LICENSE +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/MANIFEST.in +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/README.md +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost/__init__.py +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost.egg-info/SOURCES.txt +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost.egg-info/dependency_links.txt +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost.egg-info/requires.txt +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/guidepost.egg-info/top_level.txt +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/pyproject.toml +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/setup.cfg +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/setup.py +0 -0
- {guidepost-0.2.15 → guidepost-0.2.16}/tutorials/__init__.py +0 -0
|
@@ -236,7 +236,7 @@ class JSModel{
|
|
|
236
236
|
* @param {string} col - The column to get summary statistics for.
|
|
237
237
|
* @returns {Object} - The summary statistics for the column.
|
|
238
238
|
*/
|
|
239
|
-
get_summary_stats(data, col){
|
|
239
|
+
get_summary_stats(data, col, index){
|
|
240
240
|
let sum_stats = {};
|
|
241
241
|
|
|
242
242
|
if(data.length > 0){
|
|
@@ -271,6 +271,7 @@ class JSModel{
|
|
|
271
271
|
sum_stats.var = sum_stats.variance;
|
|
272
272
|
sum_stats.average = sum_stats.avg;
|
|
273
273
|
sum_stats.mean = sum_stats.avg;
|
|
274
|
+
sum_stats.count = data.length;
|
|
274
275
|
}
|
|
275
276
|
else{
|
|
276
277
|
sum_stats.sum = 0;
|
|
@@ -283,8 +284,12 @@ class JSModel{
|
|
|
283
284
|
sum_stats.std = 0;
|
|
284
285
|
sum_stats.median = 0;
|
|
285
286
|
sum_stats.med = 0;
|
|
287
|
+
sum_stats.count = 0;
|
|
286
288
|
}
|
|
287
289
|
|
|
290
|
+
|
|
291
|
+
sum_stats.index = index;
|
|
292
|
+
|
|
288
293
|
|
|
289
294
|
return sum_stats;
|
|
290
295
|
}
|
|
@@ -371,6 +376,29 @@ class JSModel{
|
|
|
371
376
|
return Math.log10(max) - Math.log10(min) > order;
|
|
372
377
|
}
|
|
373
378
|
|
|
379
|
+
|
|
380
|
+
//box bins for a column
|
|
381
|
+
binValues(values, thresholds, accessor) {
|
|
382
|
+
const bins = [];
|
|
383
|
+
// Create an empty bin for each interval between consecutive thresholds
|
|
384
|
+
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
385
|
+
bins.push([]);
|
|
386
|
+
}
|
|
387
|
+
// Place each value in the appropriate bin
|
|
388
|
+
values.forEach(d => {
|
|
389
|
+
const val = accessor(d);
|
|
390
|
+
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
391
|
+
// For the last bin, include values equal to the upper bound
|
|
392
|
+
if (val >= thresholds[i] && (i === thresholds.length - 2 || val < thresholds[i + 1])) {
|
|
393
|
+
bins[i].push(d);
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
});
|
|
398
|
+
return bins;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
|
|
374
402
|
/**
|
|
375
403
|
* Calculates metrics for the rectangles of the summary view for a specified facet. Bins come into this function already oragnized
|
|
376
404
|
* into columns delinated by the x_axis_thresholds. It's a user specified datetime variable.
|
|
@@ -385,8 +413,9 @@ class JSModel{
|
|
|
385
413
|
// console.log("CALC BOX METRICS: ", fac, current_bins, x_axis_thresholds, y_axis_thresholds);
|
|
386
414
|
|
|
387
415
|
// Iterate over the columns that divide the data along the x axis
|
|
416
|
+
|
|
417
|
+
let col_indx = 0;
|
|
388
418
|
for(let bin in current_bins){
|
|
389
|
-
|
|
390
419
|
let filtered_bin;
|
|
391
420
|
|
|
392
421
|
//Do not filter if no filter is specified currently
|
|
@@ -401,34 +430,13 @@ class JSModel{
|
|
|
401
430
|
}
|
|
402
431
|
}
|
|
403
432
|
|
|
404
|
-
|
|
405
|
-
|
|
433
|
+
// Get summary statistics for the entire column of data before it is split into rows
|
|
434
|
+
let temp_box_stats = this.get_summary_stats(filtered_bin, this.vars.y, col_indx);
|
|
406
435
|
temp_box_stats.threshold = x_axis_thresholds[bin];
|
|
407
436
|
|
|
408
437
|
temp_box_stats.bins = [];
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
function binValues(values, thresholds, accessor) {
|
|
412
|
-
const bins = [];
|
|
413
|
-
// Create an empty bin for each interval between consecutive thresholds
|
|
414
|
-
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
415
|
-
bins.push([]);
|
|
416
|
-
}
|
|
417
|
-
// Place each value in the appropriate bin
|
|
418
|
-
values.forEach(d => {
|
|
419
|
-
const val = accessor(d);
|
|
420
|
-
for (let i = 0; i < thresholds.length - 1; i++) {
|
|
421
|
-
// For the last bin, include values equal to the upper bound
|
|
422
|
-
if (val >= thresholds[i] && (i === thresholds.length - 2 || val < thresholds[i + 1])) {
|
|
423
|
-
bins[i].push(d);
|
|
424
|
-
break;
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
return bins;
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
const customBins = binValues(filtered_bin, y_axis_thresholds, d => d[this.vars.y]);
|
|
438
|
+
|
|
439
|
+
const customBins = this.binValues(filtered_bin, y_axis_thresholds, d => d[this.vars.y]);
|
|
432
440
|
|
|
433
441
|
// Process each bin's summary statistics and update color scale range
|
|
434
442
|
temp_box_stats.bins = customBins.map((bin, index) => {
|
|
@@ -436,51 +444,17 @@ class JSModel{
|
|
|
436
444
|
stats.values = bin;
|
|
437
445
|
stats.std_ratio = stats.std / this.faceted_sum_stats[fac].color.std;
|
|
438
446
|
stats.threshold = y_axis_thresholds[index];
|
|
439
|
-
this.color_scale_range[0] = Math.min(this.color_scale_range[0], stats[this.vars.color_agg]);
|
|
447
|
+
this.color_scale_range[0] = Math.min(this.color_scale_range[0], stats[this.vars.color_agg] ? stats[this.vars.color_agg] : this.color_scale_range[0]);
|
|
440
448
|
this.color_scale_range[1] = Math.max(this.color_scale_range[1], stats[this.vars.color_agg]);
|
|
441
449
|
return stats;
|
|
442
450
|
});
|
|
443
451
|
|
|
444
452
|
|
|
445
|
-
// let row_bins = d3.bin()
|
|
446
|
-
// .value(d => d[this.vars.y])
|
|
447
|
-
// .domain([sum_stats.y.min, sum_stats.y.max]).thresholds(y_axis_thresholds)(filtered_bin);
|
|
448
|
-
|
|
449
|
-
// // console.log("ROW BINS BEFORE CLAMP: ", row_bins.length, y_axis_thresholds.length);
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
// //clamps down last bin(s) if more are produced than desired
|
|
453
|
-
// // idk why but d3 produces too many bins sometimes
|
|
454
|
-
// if(row_bins.length > y_axis_thresholds.length-1){
|
|
455
|
-
// let diff = (y_axis_thresholds.length-1)-row_bins.length;
|
|
456
|
-
// let head = row_bins.slice(0, diff);
|
|
457
|
-
|
|
458
|
-
// for(let i = row_bins.length-1; i > y_axis_thresholds.length-2; i--){
|
|
459
|
-
// head[head.length-1] = head[head.length-1].concat(row_bins[i]);
|
|
460
|
-
// }
|
|
461
|
-
// row_bins = head;
|
|
462
|
-
// }
|
|
463
|
-
|
|
464
|
-
// // console.log("ROW BINS AFTER CLAMP: ", row_bins.length, y_axis_thresholds.length);
|
|
465
|
-
|
|
466
|
-
// //load individual boxes of values with summary statistics describing them
|
|
467
|
-
// for(let index in row_bins){
|
|
468
|
-
// let row = row_bins[index];
|
|
469
|
-
// let sum_stats = this.get_summary_stats(row, this.vars.color);
|
|
470
|
-
// sum_stats.values = row;
|
|
471
|
-
// sum_stats['std_ratio'] = sum_stats.std/this.faceted_sum_stats[fac].color.std;
|
|
472
|
-
// sum_stats.threshold = y_axis_thresholds[index];
|
|
473
|
-
// temp_box_stats.bins.push(sum_stats);
|
|
474
|
-
// this.color_scale_range[0] = Math.min(this.color_scale_range[0], sum_stats[this.vars.color_agg]);
|
|
475
|
-
// this.color_scale_range[1] = Math.max(this.color_scale_range[1], sum_stats[this.vars.color_agg]);
|
|
476
|
-
// }
|
|
477
|
-
|
|
478
453
|
temp_box_stats.column_values = filtered_bin;
|
|
479
454
|
this.faceted_bins[fac].column[bin] = temp_box_stats;
|
|
455
|
+
col_indx += 1;
|
|
480
456
|
}
|
|
481
457
|
|
|
482
|
-
// console.log("THE BINS END OF CALC BOX METRICS: ", this.faceted_bins[fac].column);
|
|
483
|
-
|
|
484
458
|
}
|
|
485
459
|
|
|
486
460
|
/**
|
|
@@ -548,7 +522,8 @@ class JSModel{
|
|
|
548
522
|
this.faceted_bins[fac] = {}
|
|
549
523
|
|
|
550
524
|
|
|
551
|
-
|
|
525
|
+
|
|
526
|
+
// console.log("SUM STATS: ", fac, sum_stats, "blahaj");
|
|
552
527
|
|
|
553
528
|
//conditional x axis thresholds based on time or numbers
|
|
554
529
|
// important for calculating the scales which layout the columns
|
|
@@ -587,11 +562,9 @@ class JSModel{
|
|
|
587
562
|
if(this.is_more_than_n_orders_of_magnitude(sum_stats.y.min, sum_stats.y.max, 3)){
|
|
588
563
|
this.scale_types[fac].y.log = true;
|
|
589
564
|
this.y_axis_thresholds[fac] = this.logScale(this.log_values_floor, sum_stats.y.max, num_rows);
|
|
590
|
-
console.log("Y AXIS THRESHOLDS LOG: ", fac, this.y_axis_thresholds[fac].length);
|
|
591
565
|
} else {
|
|
592
566
|
this.scale_types[fac].y.linear = true;
|
|
593
567
|
this.y_axis_thresholds[fac] = this.linearScale(sum_stats.y.min, sum_stats.y.max, num_rows);
|
|
594
|
-
console.log("Y AXIS THRESHOLDS LINEAR: ", fac, this.y_axis_thresholds[fac].length);
|
|
595
568
|
}
|
|
596
569
|
|
|
597
570
|
sum_stats.col_counts = {
|
|
@@ -603,11 +576,9 @@ class JSModel{
|
|
|
603
576
|
sum_stats.col_counts.max = Math.max(sum_stats.col_counts.max, bin.length);
|
|
604
577
|
sum_stats.col_counts.min = Math.min(sum_stats.col_counts.min, bin.length);
|
|
605
578
|
}
|
|
606
|
-
|
|
607
579
|
|
|
608
580
|
this.global_sum_stats.num_cols = Math.max(this.faceted_bins[fac].column.length, this.global_sum_stats.num_cols);
|
|
609
581
|
|
|
610
|
-
// temporary as Y AXIS IS FIXED LOG
|
|
611
582
|
this.calculate_box_metrics(fac, this.x_axis_thresholds[fac], this.y_axis_thresholds[fac]);
|
|
612
583
|
this.calc_row_major_counts(fac);
|
|
613
584
|
|
|
@@ -1025,9 +996,14 @@ class Heatmap{
|
|
|
1025
996
|
.attr('height', this.height);
|
|
1026
997
|
|
|
1027
998
|
|
|
999
|
+
let axis_left = d3.axisLeft().scale(this.scale_y_inverse);
|
|
1000
|
+
if(this.model.scale_types[this.facet].y.linear){
|
|
1001
|
+
axis_left.tickFormat(d3.format(".2s"));
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1028
1004
|
view.append('g')
|
|
1029
1005
|
.attr('class', 'left-axis')
|
|
1030
|
-
.call(
|
|
1006
|
+
.call(axis_left)
|
|
1031
1007
|
.attr('transform', `translate(${OVERVIEW_LAYOUT.inner_padding},${0})`);
|
|
1032
1008
|
|
|
1033
1009
|
view.append('g')
|
|
@@ -1464,7 +1440,11 @@ class Histogram{
|
|
|
1464
1440
|
.attr('width', this.width - 2*HISTOGRAM_LAYOUT.inner_padding)
|
|
1465
1441
|
.attr('height', this.height - HISTOGRAM_LAYOUT.inner_padding)
|
|
1466
1442
|
.attr('fill', 'rgba(240,240,240)')
|
|
1467
|
-
.attr('transform', `translate(${HISTOGRAM_LAYOUT.inner_padding},${0})`)
|
|
1443
|
+
.attr('transform', `translate(${HISTOGRAM_LAYOUT.inner_padding},${0})`);
|
|
1444
|
+
|
|
1445
|
+
|
|
1446
|
+
h_hist.append("g")
|
|
1447
|
+
.attr('class', 'bars');
|
|
1468
1448
|
|
|
1469
1449
|
h_hist.append('g')
|
|
1470
1450
|
.attr('class', 'left-axis')
|
|
@@ -1487,8 +1467,6 @@ class Histogram{
|
|
|
1487
1467
|
.attr('transform', `translate(${this.width/2},${this.height})`);
|
|
1488
1468
|
|
|
1489
1469
|
|
|
1490
|
-
h_hist.append("g")
|
|
1491
|
-
.attr('class', 'bars');
|
|
1492
1470
|
|
|
1493
1471
|
this.view = h_hist;
|
|
1494
1472
|
|
|
@@ -1645,6 +1623,8 @@ class Histogram{
|
|
|
1645
1623
|
render(){
|
|
1646
1624
|
const self = this;
|
|
1647
1625
|
let bar_width = 0;
|
|
1626
|
+
let axis_height = 1;
|
|
1627
|
+
|
|
1648
1628
|
if(SHARED_X_SCALE){
|
|
1649
1629
|
bar_width = Math.min(MIN_BAR_WIDTH, (draw_width / self.model.global_sum_stats.num_cols))
|
|
1650
1630
|
}
|
|
@@ -1658,7 +1638,7 @@ class Histogram{
|
|
|
1658
1638
|
if(self.model.row_major_counts[self.facet].length > 2){
|
|
1659
1639
|
if(this.orientation == 'bottom'){
|
|
1660
1640
|
bar_layer.selectAll('.column')
|
|
1661
|
-
.data(self.model.faceted_bins[self.facet].column, function(){return
|
|
1641
|
+
.data(self.model.faceted_bins[self.facet].column, function(d){console.log("INDEX", d.index); return d.index} )
|
|
1662
1642
|
.join(
|
|
1663
1643
|
function(enter){
|
|
1664
1644
|
let col = enter.append('g')
|
|
@@ -1675,12 +1655,14 @@ class Histogram{
|
|
|
1675
1655
|
.attr('height', (d)=>{return self.scale_y(d.column_values.length)})
|
|
1676
1656
|
.attr('width', bar_width)
|
|
1677
1657
|
.attr('fill', TAN)
|
|
1678
|
-
.attr(`transform`, (d)=>{return `translate(${0}, ${(HISTOGRAM_LAYOUT.height- self.scale_y(d.column_values.length))-2*HISTOGRAM_LAYOUT.inner_padding})`});
|
|
1658
|
+
.attr(`transform`, (d)=>{return `translate(${0}, ${(HISTOGRAM_LAYOUT.height- self.scale_y(d.column_values.length))-2*HISTOGRAM_LAYOUT.inner_padding - axis_height})`});
|
|
1679
1659
|
},
|
|
1680
1660
|
function(update){
|
|
1681
|
-
update.
|
|
1661
|
+
update.select('.bar')
|
|
1682
1662
|
.transition()
|
|
1663
|
+
.duration(500)
|
|
1683
1664
|
.attr('height', (d,i)=>{return self.scale_y(self.model.faceted_bins[self.facet].column[i].column_values.length)})
|
|
1665
|
+
.attr(`transform`, (d, i)=>{return `translate(${0}, ${(HISTOGRAM_LAYOUT.height- self.scale_y(self.model.faceted_bins[self.facet].column[i].column_values.length))-2*HISTOGRAM_LAYOUT.inner_padding - axis_height})`});
|
|
1684
1666
|
}
|
|
1685
1667
|
);
|
|
1686
1668
|
}
|
|
@@ -1969,6 +1951,7 @@ class Legend {
|
|
|
1969
1951
|
if(color_scale.domain().length > 2){
|
|
1970
1952
|
this.ticks_scale = d3.scaleDiverging().domain(color_scale.domain().reverse()).range([0, this.bar_height/2, this.bar_height]);
|
|
1971
1953
|
} else{
|
|
1954
|
+
console.log("DOMAIN at LEGEND CREATE", color_scale.domain());
|
|
1972
1955
|
if(color_scale.domain()[1] > 2){
|
|
1973
1956
|
this.ticks_scale = d3.scaleSymlog().domain([color_scale.domain()[0]+1, color_scale.domain()[1]].reverse()).range([0, this.bar_height]);
|
|
1974
1957
|
}
|
|
@@ -5,6 +5,7 @@ import numpy as np
|
|
|
5
5
|
import warnings
|
|
6
6
|
import json
|
|
7
7
|
import os
|
|
8
|
+
import sys
|
|
8
9
|
|
|
9
10
|
class Guidepost(anywidget.AnyWidget):
|
|
10
11
|
_esm = os.path.join(os.path.dirname(__file__), "guidepost.js")
|
|
@@ -24,6 +25,9 @@ class Guidepost(anywidget.AnyWidget):
|
|
|
24
25
|
in_cpy.insert(0, 'gp_idx', range(0, len(in_cpy)))
|
|
25
26
|
self.cached_records_df = in_cpy
|
|
26
27
|
|
|
28
|
+
if sys.version_info.major < 3 or sys.version_info.minor < 12:
|
|
29
|
+
raise EnvironmentError("Python 3.12 or greater is required to run this library.")
|
|
30
|
+
|
|
27
31
|
_warn_skips = (os.path.dirname('.'),)
|
|
28
32
|
original_cols = in_cpy.columns
|
|
29
33
|
o_df = in_cpy.dropna(axis=1, how='all')
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|