ZeroDivisionError with line antialiasing
See original GitHub issueHello,
I’ve been playing with the new line antialiasing feature, and it’s throwing a ZeroDivisionError on my dataset, with a less than helpful stacktrace (included below).
I managed to identify the division by zero as happening here (grad = dy/dx
in _xiaolinwu
). I assume this means that I have repeated points in my dataset (not sure how), but the error is not very helpful.
Adding an early return to that function when dx == 0
appears to fix the error, although it is taking substantially longer to run with antialiasing enabled so I can’t tell if it’s actually providing a sensible result.
Versions
Python 3.8 datashader 0.12.0 numba 0.51.2 numpy 1.20.1 (+ a whole load of other stuff in my environment which I am sure is irrelevant)
Stack trace
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/core.py in line(self, source, x, y, agg, axis, geometry, antialias) 403 format(agg)) 404 warnings.warn(message) –> 405 return bypixel(source, self, glyph, agg) 406 407 def area(self, source, x, y, agg=None, axis=0, y_stack=None):
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/core.py in bypixel(source, canvas, glyph, agg) 1200 with np.warnings.catch_warnings(): 1201 np.warnings.filterwarnings(‘ignore’, r’All-NaN (slice|axis) encountered’) -> 1202 return bypixel.pipeline(source, schema, canvas, glyph, agg) 1203 1204
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/utils.py in call(self, head, *rest, **kwargs) 107 typ = type(head) 108 if typ in lk: –> 109 return lk[typ](head, *rest, **kwargs) 110 for cls in getmro(typ)[1:]: 111 if cls in lk:
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/data_libraries/pandas.py in pandas_pipeline(df, schema, canvas, glyph, summary) 15 @bypixel.pipeline.register(pd.DataFrame) 16 def pandas_pipeline(df, schema, canvas, glyph, summary): —> 17 return glyph_dispatch(glyph, df, schema, canvas, summary) 18 19
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/utils.py in call(self, head, *rest, **kwargs) 110 for cls in getmro(typ)[1:]: 111 if cls in lk: –> 112 return lk[cls](head, *rest, **kwargs) 113 raise TypeError(“No dispatch for {0} type”.format(typ)) 114
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/data_libraries/pandas.py in default(glyph, source, schema, canvas, summary, cuda) 43 44 bases = create((height, width)) —> 45 extend(bases, source, x_st + y_st, x_range + y_range) 46 47 return finalize(bases,
~/.cache/pypoetry/virtualenvs/datashader-env-0ZOB1KZS-py3.8/lib/python3.8/site-packages/datashader/glyphs/line.py in extend(aggs, df, vt, bounds, plot_start) 69 70 # line may be clipped, then mapped to pixels —> 71 do_extend( 72 sx, tx, sy, ty, xmin, xmax, ymin, ymax, 73 xs, ys, plot_start, *aggs_and_cols
ZeroDivisionError: division by zero
</details>
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (8 by maintainers)
Top GitHub Comments
@bbudescu Thanks for checking. We will release version 0.14.2 soon as this quite a serious bug.
I still get
ZeroDivisionError
s when trying to turn on antialising in 0.14.1