Skip to content

Commit

Permalink
Merge pull request #330 from jbcrail/extend_line_segfault
Browse files Browse the repository at this point in the history
Adjust line to account for exclusive upper bounds
  • Loading branch information
jbednar committed Apr 28, 2017
2 parents a81c401 + 37a0a8e commit f158168
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
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

0 comments on commit f158168

Please sign in to comment.