Skip to content

Commit

Permalink
Add tests for lines/points along the outside edge of canvas
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmmease committed Jan 6, 2019
1 parent 9db0ce6 commit c3264e1
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions datashader/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,46 @@ def test_line():
assert_eq(agg, out)


def test_points_on_edge():
df = pd.DataFrame(dict(x=[0, 0.5, 1.1, 1.5, 2.2, 3, 3, 0],
y=[0, 0, 0, 0, 0, 0, 3, 3]))

canvas = ds.Canvas(plot_width=3, plot_height=3,
x_range=(0, 3), y_range=(0, 3))

agg = canvas.points(df, 'x', 'y', agg=ds.count())

sol = np.array([[2, 2, 2],
[0, 0, 0],
[1, 0, 1]], dtype='int32')
out = xr.DataArray(sol,
coords=[('x', [0.5, 1.5, 2.5]),
('y', [0.5, 1.5, 2.5])],
dims=['y', 'x'])

assert_eq(agg, out)


def test_lines_on_edge():
df = pd.DataFrame(dict(x=[0, 3, 3, 0],
y=[0, 0, 3, 3]))

canvas = ds.Canvas(plot_width=3, plot_height=3,
x_range=(0, 3), y_range=(0, 3))

agg = canvas.line(df, 'x', 'y', agg=ds.count())

sol = np.array([[1, 1, 1],
[0, 0, 1],
[1, 1, 1]], dtype='int32')
out = xr.DataArray(sol,
coords=[('x', [0.5, 1.5, 2.5]),
('y', [0.5, 1.5, 2.5])],
dims=['y', 'x'])

assert_eq(agg, out)


def test_log_axis_line():
axis = ds.core.LogAxis()
logcoords = axis.compute_index(axis.compute_scale_and_translate((1, 10), 2), 2)
Expand Down

0 comments on commit c3264e1

Please sign in to comment.