-
Notifications
You must be signed in to change notification settings - Fork 463
/
marks_test.py
50 lines (38 loc) · 1.55 KB
/
marks_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import bqplot
import numpy as np
import pytest
def test_scatter(figure):
x = np.arange(10, dtype=np.float64)
y = (x**2).astype(np.int32)
scatter = bqplot.Scatter(x=x, y=y)
assert scatter.x.dtype == np.float64
assert scatter.y.dtype == np.int32
assert scatter.x.shape == (10,)
assert scatter.y.shape == (10,)
def test_lines(scales):
# Create a Line chart with data of multiple shapes should work with binary serialization
lines = bqplot.Lines(x=np.array([[0, 1], [0, 1, 2]], dtype=object), y=np.array([[0, 1], [1, 0, -1]], dtype=object), scales=scales)
lines = bqplot.Lines(x=[[0, 1], [0, 1]], y=[[0, 1], [1, 0]], scales=scales)
state = lines.get_state()
lines2 = bqplot.Lines(scales=scales)
lines2.set_state(state)
assert lines.x[0][0] == 0
assert lines.x[0][1] == 1
assert lines.x[1][1] == 1
def test_lines_ordinal(scale_ordinal, scale_y):
scales = {'x': scale_ordinal, 'y': scale_y}
lines = bqplot.Lines(x=list('ABC'), y=[1, 2, 3], scales=scales)
def test_bars(scales):
# Create a Bar chart with data of multiple shapes should work with binary serialization
y = np.array([[0, 1], [1, 0, -1]], dtype=object)
bars = bqplot.Bars(x=[0, 1], y=y, scales=scales)
bars = bqplot.Bars(x=[0, 1], y=[[1, 2], [3, 4]], scales=scales)
state = bars.get_state()
bars2 = bqplot.Bars(scales=scales)
bars2.set_state(state)
assert bars.x[0] == 0
assert bars.x[1] == 1
assert bars.y[0][0] == 1
assert bars.y[0][1] == 2
assert bars.y[1][0] == 3
assert bars.y[1][1] == 4