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