Skip to content

Commit 4db1ef8

Browse files
authored
Merge branch 'dev' into Pytest-Setup
2 parents f8cef69 + c6c04e1 commit 4db1ef8

33 files changed

Lines changed: 948 additions & 382 deletions

.agents/context/backend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
## Coding Rules
1515

1616
- Follow PEP 8, format with `black py` (v23.1.0), 80-char lines
17-
- Python >= 3.8 compatibility
17+
- Python >= 3.12 compatibility
1818
- Use `@pytorch_wrap` on all `Visdom` methods
1919
- Use `warn_once()` for deprecation warnings
2020

.github/actions/prepare/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
python-version:
1313
description: 'Python version to use'
1414
required: false
15-
default: '3.10'
15+
default: '3.12'
1616

1717
runs:
1818
using: "composite"

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ jobs:
5252
steps:
5353
- name: Deploy to GitHub Pages
5454
id: deployment
55-
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e
55+
uses: actions/deploy-pages@cd2ce8fcbc39b97be8ca5fce6e763baed58fa128

.github/workflows/process-changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ jobs:
154154
needs: install-and-build
155155
strategy:
156156
matrix:
157-
python: ['3.10', '3.11', '3.12']
157+
python: ['3.12', '3.13']
158158
steps:
159159
- name: "Checkout Repository"
160160
uses: actions/checkout@v7.0.0

AGENTS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# AGENTS instructions
55

66
Visdom: Python client + Tornado server + React frontend for live data visualization.
7-
Version `0.2.4` · Python >= 3.8 · Apache 2.0
7+
Version `0.2.4` · Python >= 3.12 · Apache 2.0
88

99
## Setup
1010

README.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,7 @@ The following API is currently supported:
287287
- [`vis.line`](#visline) : line plots
288288
- [`vis.stem`](#visstem) : stem plots
289289
- [`vis.heatmap`](#visheatmap) : heatmap plots
290+
- [`vis.confusion_matrix`](#visconfusion_matrix) : confusion matrix plots
290291
- [`vis.bar`](#visbar) : bar graphs
291292
- [`vis.histogram`](#vishistogram) : histograms
292293
- [`vis.histogram2d`](#vishistogram2d) : 2D histograms (density maps)
@@ -297,6 +298,7 @@ The following API is currently supported:
297298
- [`vis.contour`](#viscontour) : contour plots
298299
- [`vis.quiver`](#visquiver) : quiver plots
299300
- [`vis.mesh`](#vismesh) : mesh plots
301+
- [`vis.sankey`](#vissankey) : sankey (flow) diagrams
300302
- [`vis.dual_axis_lines`](#visdual_axis_lines) : double y axis line plots
301303
- [`vis.graph`](#visgraph) : network graphs
302304

@@ -578,6 +580,32 @@ The following `opts` are supported:
578580
- `opts.layoutopts` : `dict` of any additional options that the graph backend accepts for a layout. For example `layoutopts = {'plotly': {'legend': {'x':0, 'y':0}}}`.
579581
- `opts.nancolor` : color for plotting `NaN`s. If this is `None`, `NaN`s will be plotted as transparent. (`string`; default = `None`)
580582

583+
#### vis.confusion_matrix
584+
This function draws a confusion matrix for classification evaluation.
585+
586+
It accepts either:
587+
- raw label vectors via `y_true` and `y_pred`, or
588+
- a precomputed confusion matrix via `cm`.
589+
590+
Optional normalization can be applied with the `normalize` parameter:
591+
- `'true'`: normalize by row (actual class)
592+
- `'pred'`: normalize by column (predicted class)
593+
- `'all'`: normalize by total count
594+
595+
An existing confusion matrix window can be modified with the `update` parameter:
596+
- `'replace'`: redraw the whole matrix in the window given by `win`
597+
- `'remove'`: delete the window given by `win`
598+
599+
The following `opts` are supported:
600+
601+
- `opts.title` : plot title (`string`; default = `Confusion Matrix`)
602+
- `opts.xlabel` : x-axis label (`string`; default = `Predicted`)
603+
- `opts.ylabel` : y-axis label (`string`; default = `Actual`)
604+
- `opts.colormap` : Plotly colorscale (`string`; default = `Blues`)
605+
- `opts.showCounts` : show raw counts in cells (`bool`; default = `True`)
606+
- `opts.showPercent` : show percentages in cells (`bool`; default = `True` when normalized, `False` otherwise)
607+
- `opts.layoutopts` : `dict` of any additional options that the graph backend accepts for a layout.
608+
581609
#### vis.bar
582610
This function draws a regular, stacked, or grouped bar plot. It takes as
583611
input an `N` or `NxM` tensor `X` that specifies the height of each of the
@@ -696,6 +724,27 @@ The following `opts` are supported:
696724
- `opts.opacity`: opacity of polygons (`number` between 0 and 1)
697725
- `opts.layoutopts` : `dict` of any additional options that the graph backend accepts for a layout. For example `layoutopts = {'plotly': {'legend': {'x':0, 'y':0}}}`.
698726

727+
#### vis.sankey
728+
This function draws a Sankey (flow) diagram. Flows are defined by three
729+
equal-length arrays:
730+
731+
- `source`: source node index of each link (`N` array of ints)
732+
- `target`: target node index of each link (`N` array of ints)
733+
- `value` : magnitude of each link (`N` array of non-negative numbers)
734+
735+
`labels` is an optional list of node names. If omitted, nodes are referenced
736+
by their index alone.
737+
738+
The following `opts` are supported:
739+
740+
- `opts.labels` : list of node labels (alternative to the `labels` arg)
741+
- `opts.pad` : node padding in px (`number`; default = 15)
742+
- `opts.thickness` : node thickness in px (`number`; default = 20)
743+
- `opts.orientation`: `'h'` (default) or `'v'`
744+
- `opts.nodecolor` : node color(s) (`string` or list of strings)
745+
- `opts.linkcolor` : link color(s) (`string` or list of strings)
746+
- `opts.layoutopts` : `dict` of any additional options that the graph backend accepts for a layout.
747+
699748
#### vis.dual_axis_lines
700749
This function will create a line plot using plotly with different Y-Axis.
701750

cypress/integration/pane.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@ const basic_examples = [
1414
['Violin Plot', 'plot_violin_basic'],
1515
// ["Mesh Plot", "plot_special_mesh"], // disabled due to webgl
1616
['Graph Plot', 'plot_special_graph'],
17+
['Sankey Plot', 'plot_special_sankey'],
1718
['Matplotlib Plot', 'misc_plot_matplot'],
1819
['Latex Plot', 'misc_plot_latex'],
1920
['Video Pane', 'misc_video_tensor'],
2021
// ["Audio Pane", "misc_audio_basic"], // bug: disabled due to inconsistent resize
2122
['Properties Pane', 'properties_basic'],
2223
['HTML Table', 'html_table'],
24+
['Confusion Matrix', 'plot_confusion_matrix_basic'],
2325
];
2426

2527
basic_examples.forEach((setting) => {

cypress/integration/screenshots.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const maxDiffPixels = {
2020
misc_video_tensor: 5000,
2121
misc_video_download: 5000,
2222
misc_audio_basic: 5000,
23+
misc_plot_latex: 3000,
2324
};
2425

2526
const compare_thresholds = {
@@ -40,7 +41,7 @@ const compare_thresholds = {
4041
plot_bar_stacked: 200,
4142
plot_bar_nonstacked: 200,
4243
plot_special_boxplot: 200,
43-
misc_plot_latex: 50,
44+
misc_plot_latex: 3000,
4445
misc_plot_latex_update: 200,
4546
};
4647

cypress/support/commands.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,17 @@ Cypress.Commands.add('waitForPlotRender', () => {
112112

113113
Cypress.Commands.add('waitForMathJax', () => {
114114
cy.wait(2000);
115+
cy.window().then((win) => {
116+
return new Cypress.Promise((resolve) => {
117+
if (win.MathJax && win.MathJax.Hub) {
118+
win.MathJax.Hub.Queue(() => resolve());
119+
} else {
120+
resolve();
121+
}
122+
});
123+
});
124+
cy.document().then((doc) => {
125+
return cy.wrap(doc.fonts.ready, { timeout: 10000 });
126+
});
127+
cy.wait(2000);
115128
});

example/components/plot_bar.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ def plot_bar_histogram(viz, env, args):
4242
# 2D histogram (density)
4343
def plot_bar_histogram2d(viz, env, args):
4444
title = args[0] if len(args) > 0 else None
45-
hist2d_x = np.concatenate([np.random.randn(10000) - 1.5, np.random.randn(10000) + 1.5])
46-
hist2d_y = np.concatenate([np.random.randn(10000) - 1.5, np.random.randn(10000) + 1.5])
45+
hist2d_x = np.concatenate(
46+
[np.random.randn(10000) - 1.5, np.random.randn(10000) + 1.5]
47+
)
48+
hist2d_y = np.concatenate(
49+
[np.random.randn(10000) - 1.5, np.random.randn(10000) + 1.5]
50+
)
4751
viz.histogram2d(
4852
X=hist2d_x,
4953
Y=hist2d_y,

0 commit comments

Comments
 (0)