question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ZeroDivisionError with line antialiasing

See original GitHub issue

Hello,

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

``` --------------------------------------------------------------------------- ZeroDivisionError Traceback (most recent call last) <ipython-input-12-7513dd3004e4> in <module> 9 outline_img = tf.shade(outline_agg, cmap=['black']) 10 ---> 11 agg = canvas.line(lines, 'x', 'y', ds.max('voltage'), antialias=True) 12 lines_img = tf.dynspread(tf.shade(agg, cmap=colorcet.bgyw), threshold=0.6, max_px=width//150) 13 #agg = canvas.points(substations, 'x', 'y', ds.sum('voltage'))

~/.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:closed
  • Created 3 years ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ianthomas23commented, Jul 18, 2022

@bbudescu Thanks for checking. We will release version 0.14.2 soon as this quite a serious bug.

1reaction
bbudescucommented, Jul 14, 2022

I still get ZeroDivisionErrors when trying to turn on antialising in 0.14.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

ZeroDivisionError division by zero in Python error handling
Let's write the following program, divide.py . ... This small program creates a function that divides a by b to return c ....
Read more >
Pygame draw anti-aliased thick line - python - Stack Overflow
Using the computed coordinates, we draw an unfilled anti-aliased polygon (thanks to @martineau) and then fill it as suggested in the ...
Read more >
Answered: exponent =… | bartleby
Want a code in python The below code won't work as later when I use it create zero division error So laplace smoothing...
Read more >
How can I format a user selection matrix? - Python Help ...
I apologize for being python ignorant – a small push would help. Suppose there's a python video processing function, Super(). configSuper, a string,...
Read more >
oggm.utils._funcs — OGGM 1.5.3 documentation
Parameters ---------- array : ndarray the array to apply the smoothing to ... We construct new points on the line but at constant...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found