Skip to content

Commit e4478e5

Browse files
authored
Merge branch 'master' into handle_spacing_with_spec
2 parents d80f975 + 5b65329 commit e4478e5

File tree

15 files changed

+1284
-1003
lines changed

15 files changed

+1284
-1003
lines changed

Diff for: .circleci/config.yml

+157-58
Large diffs are not rendered by default.

Diff for: .gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,6 @@ 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
57+
test/percy/pandas2/*.html

Diff for: CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file.
33
This project adheres to [Semantic Versioning](http://semver.org/).
44

5+
## [UNRELEASED]
6+
7+
### Fixed
8+
- Fixed another compatibility issue with Pandas 2.0, just affecting `px.*(line_close=True)` [[#4190](https://github.com/plotly/plotly.py/pull/4190)]
9+
510
## [5.14.1] - 2023-04-05
611

712
### Fixed

Diff for: 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

Diff for: packages/python/plotly/plotly/express/_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ def make_trace_kwargs(args, trace_spec, trace_data, mapping_labels, sizeref):
268268
fit information to be used for trendlines
269269
"""
270270
if "line_close" in args and args["line_close"]:
271-
trace_data = trace_data.append(trace_data.iloc[0])
271+
trace_data = pd.concat([trace_data, trace_data.iloc[:1]])
272272
trace_patch = trace_spec.trace_patch.copy() or {}
273273
fit_results = None
274274
hover_header = ""

Diff for: 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)

Diff for: 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))

Diff for: packages/python/plotly/plotly/tests/test_orca/images/linux/fig1.eps

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

Diff for: 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)

Diff for: 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)

Diff for: 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

Diff for: packages/python/plotly/test_requirements/requirements_39_pandas_2_optional.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
requests==2.25.1
22
tenacity==6.2.0
3-
pandas==2.0.0
3+
pandas==2.0.1
44
numpy==1.20.3
55
xarray==0.17.0
66
statsmodels

Diff for: test/percy/compare-pandas.py

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import difflib
2+
import json
3+
import os
4+
5+
os.chdir(os.path.dirname(__file__))
6+
7+
8+
def clean_float(numstr):
9+
# round numbers to 3 digits, to remove floating-point differences
10+
return round(float(numstr), 3)
11+
12+
13+
def get_fig(html):
14+
# strip off all the rest of the html and js
15+
fig_str = html[html.index("[{", html.rindex("Plotly.newPlot(")) :]
16+
fig_str = fig_str[: fig_str.index("} ") + 1]
17+
data, layout, config = json.loads(f"[{fig_str}]", parse_float=clean_float)
18+
fig_dict = dict(data=data, layout=layout, config=config)
19+
return json.dumps(fig_dict, indent=2).splitlines(keepends=True)
20+
21+
22+
for filename in os.listdir("pandas2"):
23+
with open(filename, encoding="utf-8") as f1:
24+
with open(os.path.join("pandas2", filename)) as f2:
25+
fig1 = get_fig(f1.read())
26+
fig2 = get_fig(f2.read())
27+
if any(l1 != l2 for l1, l2 in zip(fig1, fig2)):
28+
print("".join(difflib.unified_diff(fig1, fig2)))
29+
raise ValueError(f"Pandas 1/2 difference in {filename}")

Diff for: 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)