8000 accelerate plotly JSON encoder for numpy arrays without nans by emmanuelle · Pull Request #2880 · plotly/plotly.py · GitHub
[go: up one dir, main page]

Skip to content

accelerate plotly JSON encoder for numpy arrays without nans #2880

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Nov 17, 2020
Prev Previous commit
Next Next commit
black
  • Loading branch information
emmanuelle committed Nov 15, 2020
commit 224082ec8f5d7176a83fbe7b414a0470cd8e1b30
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def test_fast_track_finite_arrays(self):
# without inf or nan is faster (because we can avoid decoding
# and reencoding).
z = np.random.randn(100, 100)
x = np.arange(100.)
x = np.arange(100.0)
fig_1 = go.Figure(go.Heatmap(z=z, x=x))
t1 = time()
json_str_1 = _json.dumps(fig_1, cls=PlotlyJSONEncoder)
Expand All @@ -40,18 +40,18 @@ def test_fast_track_finite_arrays(self):
t3 = time()
json_str_2 = _json.dumps(fig_2, cls=PlotlyJSONEncoder)
t4 = time()
assert(t2 - t1 < t4 - t3)
assert 'null' in json_str_2
assert 'NaN' not in json_str_2
assert 'Infinity' not in json_str_2
x = np.arange(100.)
assert t2 - t1 < t4 - t3
assert "null" in json_str_2
assert "NaN" not in json_str_2
assert "Infinity" not in json_str_2
x = np.arange(100.0)
fig_3 = go.Figure(go.Heatmap(z=z, x=x))
fig_3.update_layout(title_text='Infinity')
fig_3.update_layout(title_text="Infinity")
t5 = time()
json_str_3 = _json.dumps(fig_3, cls=PlotlyJSONEncoder)
t6 = time()
assert(t2 - t1 < t6 - t5)
assert 'Infinity' in json_str_3
assert t2 - t1 < t6 - t5
assert "Infinity" in json_str_3


class TestGetByPath(TestCase):
Expand Down
0