Skip to content

Commit 3eb3ee4

Browse files
authored
Merge pull request #4188 from plotly/update-ci-images
Update CI
2 parents 956ab2c + e70bf8f commit 3eb3ee4

File tree

11 files changed

+1234
-998
lines changed

11 files changed

+1234
-998
lines changed

.circleci/config.yml

+144-55
Large diffs are not rendered by default.

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,5 @@ doc/check-or-enforce-order.py
5252
packages/javascript/jupyterlab-plotly/lib/
5353
packages/python/plotly/jupyterlab_plotly/labextension/
5454
packages/python/plotly/jupyterlab_plotly/nbextension/index.js*
55+
56+
test/percy/*.html

doc/python/static-image-export.md

+16-16
Original file line numberDiff line numberDiff line change
@@ -109,42 +109,42 @@ If you are running this notebook live, click to [open the output directory](./im
109109

110110
plotly.py can output figures to several raster image formats including **PNG**, ...
111111

112-
```python
112+
~~~python
113113
fig.write_image("images/fig1.png")
114-
```
114+
~~~
115115

116116
**JPEG**, ...
117117

118-
```python
118+
~~~python
119119
fig.write_image("images/fig1.jpeg")
120-
```
120+
~~~
121121

122122
and **WebP**
123123

124-
```python
124+
~~~python
125125
fig.write_image("images/fig1.webp")
126-
```
126+
~~~
127127

128128
#### Vector Formats: SVG and PDF...
129129

130130

131131
plotly.py can also output figures in several vector formats including **SVG**, ...
132132

133-
```python
133+
~~~python
134134
fig.write_image("images/fig1.svg")
135-
```
135+
~~~
136136

137137
**PDF**, ...
138138

139-
```python
139+
~~~python
140140
fig.write_image("images/fig1.pdf")
141-
```
141+
~~~
142142

143143
and **EPS** (requires the poppler library)
144144

145-
```python
145+
~~~python
146146
fig.write_image("images/fig1.eps")
147-
```
147+
~~~
148148

149149
**Note:** It is important to note that any figures containing WebGL traces (i.e. of type `scattergl`, `heatmapgl`, `contourgl`, `scatter3d`, `surface`, `mesh3d`, `scatterpolargl`, `cone`, `streamtube`, `splom`, or `parcoords`) that are exported in a vector format will include encapsulated rasters, instead of vectors, for some parts of the image.
150150

@@ -199,14 +199,14 @@ Image(img_bytes)
199199
If `kaleido` is installed, it will automatically be used to perform image export. If it is not installed, plotly.py will attempt to use `orca` instead. The `engine` argument to the `to_image` and `write_image` functions can be used to override this default behavior.
200200

201201
Here is an example of specifying that orca should be used:
202-
```python
202+
~~~python
203203
fig.to_image(format="png", engine="orca")
204-
```
204+
~~~
205205

206206
And, here is an example of specifying that Kaleido should be used:
207-
```python
207+
~~~python
208208
fig.to_image(format="png", engine="kaleido")
209-
```
209+
~~~
210210

211211
<!-- #endregion -->
212212

packages/python/plotly/plotly/matplotlylib/mplexporter/renderers/vega_renderer.py

+13-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,18 @@ def open_axes(self, ax, props):
2323
dict(type="y", scale="y", ticks=10),
2424
]
2525
self.scales = [
26-
dict(name="x", domain=props["xlim"], type="linear", range="width",),
27-
dict(name="y", domain=props["ylim"], type="linear", range="height",),
26+
dict(
27+
name="x",
28+
domain=props["xlim"],
29+
type="linear",
30+
range="width",
31+
),
32+
dict(
33+
name="y",
34+
domain=props["ylim"],
35+
type="linear",
36+
range="height",
37+
),
2838
]
2939

3040
def draw_line(self, data, coordinates, style, label, mplobj=None):
@@ -103,7 +113,7 @@ def __init__(self, renderer):
103113

104114
def html(self):
105115
"""Build the HTML representation for IPython."""
106-
id = random.randint(0, 2 ** 16)
116+
id = random.randint(0, 2**16)
107117
html = '<div id="vis%d"></div>' % id
108118
html += "<script>\n"
109119
html += VEGA_TEMPLATE % (json.dumps(self.specification), id)

packages/python/plotly/plotly/matplotlylib/mplexporter/tests/test_basic.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ def test_path():
146146

147147

148148
def test_Figure():
149-
""" if the fig is not associated with a canvas, FakeRenderer shall
150-
not fail. """
149+
"""if the fig is not associated with a canvas, FakeRenderer shall
150+
not fail."""
151151
fig = plt.Figure()
152152
ax = fig.add_subplot(111)
153153
ax.add_patch(plt.Circle((0, 0), 1))

packages/python/plotly/plotly/tests/test_orca/images/linux/fig1.eps

+1,031-919
Large diffs are not rendered by default.

packages/python/plotly/plotly/tests/test_orca/images/linux/latexfig.eps

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%!PS-Adobe-3.0 EPSF-3.0
2-
%Produced by poppler pdftops version: 0.71.0 (http://poppler.freedesktop.org)
2+
%Produced by poppler pdftops version: 22.02.0 (http://poppler.freedesktop.org)
33
%%Creator: Chromium
44
%%LanguageLevel: 2
55
%%DocumentSuppliedResources: (atend)

packages/python/plotly/plotly/tests/test_orca/images/linux/topofig.eps

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
%!PS-Adobe-3.0 EPSF-3.0
2-
%Produced by poppler pdftops version: 0.71.0 (http://poppler.freedesktop.org)
2+
%Produced by poppler pdftops version: 22.02.0 (http://poppler.freedesktop.org)
33
%%Creator: Chromium
44
%%LanguageLevel: 2
55
%%DocumentSuppliedResources: (atend)

packages/python/plotly/recipe/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ requirements:
2121
- python
2222
- pip
2323
- jupyterlab =3
24-
- nodejs
24+
- nodejs =16
2525
- setuptools
2626
run:
2727
- python
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
requests==2.12.4
22
tenacity==6.2.0
33
pytest==3.5.1
4+
packaging

test/percy/snapshots.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
version: 2
2+
static:
3+
options:
4+
waitForTimeout: 6000
5+
execute:
6+
beforeSnapshot: |
7+
const stash = window._canvasStash = [];
8+
Array.from(document.querySelectorAll('canvas')).forEach(c => {
9+
const i = document.createElement('img');
10+
i.src = c.toDataURL();
11+
i.width = c.width;
12+
i.height = c.height;
13+
i.setAttribute('style', c.getAttribute('style'));
14+
i.className = c.className;
15+
i.setAttribute('data-canvasnum', stash.length);
16+
stash.push(c);
17+
c.parentElement.insertBefore(i, c);
18+
c.parentElement.removeChild(c);
19+
});
20+
snapshot:
21+
widths:
22+
- 1280

0 commit comments

Comments
 (0)