Skip to content
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

Adjust line to account for exclusive upper bounds #330

Merged
merged 1 commit into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions datashader/glyphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ def extend_line(vt, bounds, xs, ys, plot_start, *aggs_and_cols):
"""Aggregate along a line formed by ``xs`` and ``ys``"""
sx, tx, sy, ty = vt
xmin, xmax, ymin, ymax = bounds
# Adjustments for exclusive upper bounds for x and y
xmax -= 1
ymax -= 1
nrows = xs.shape[0]
i = 0
while i < nrows - 1:
Expand Down
2 changes: 1 addition & 1 deletion datashader/tests/test_dask.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_line():
[0, 1, 0, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0],
[3, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1],
[0, 2, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 0]], dtype='i4')
out = xr.DataArray(sol, coords=[np.arange(-3., 4.), np.arange(-3., 4.)],
Expand Down
10 changes: 5 additions & 5 deletions datashader/tests/test_glyphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def test_extend_lines():
[0, 0, 0, 0, 0],
[0, 1, 1, 1, 0],
[0, 1, 0, 1, 0],
[0, 1, 0, 1, 0]])
[0, 0, 0, 0, 0]])
agg = new_agg()
extend_line(vt, bounds, xs, ys, False, agg)
np.testing.assert_equal(agg, out)
Expand All @@ -141,10 +141,10 @@ def test_extend_lines():
xs = np.array([2, 1, 0, -1, -4, -1, -100, -1, 2])
ys = np.array([-1, -2, -3, -4, -1, 2, 100, 2, -1])
out = np.array([[0, 1, 0, 1, 0],
[1, 0, 0, 0, 1],
[1, 0, 0, 0, 0],
[0, 0, 0, 0, 0],
[1, 0, 0, 0, 1],
[0, 1, 0, 1, 0]])
[1, 0, 0, 0, 0],
[0, 0, 0, 0, 0]])
agg = new_agg()
extend_line(vt, bounds, xs, ys, True, agg)
np.testing.assert_equal(agg, out)
Expand All @@ -163,5 +163,5 @@ def test_extend_lines_nan():
ys = np.array([-3, -2, np.nan, 0, 1])
agg = new_agg()
extend_line(vt, bounds, xs, ys, True, agg)
out = np.diag([1, 1, 0, 1, 1])
out = np.diag([1, 1, 0, 1, 0])
np.testing.assert_equal(agg, out)
2 changes: 1 addition & 1 deletion datashader/tests/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_line():
[0, 1, 0, 0, 0, 1, 0],
[1, 0, 0, 0, 0, 0, 1],
[0, 0, 0, 0, 0, 0, 0],
[3, 0, 0, 0, 0, 0, 1],
[1, 0, 0, 0, 0, 0, 1],
[0, 2, 0, 0, 0, 1, 0],
[0, 0, 1, 0, 1, 0, 0]], dtype='i4')
out = xr.DataArray(sol, coords=[np.arange(-3., 4.), np.arange(-3., 4.)],
Expand Down