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

Support antialiasing in pipeline API #1213

Merged
merged 1 commit into from
May 15, 2023
Merged

Support antialiasing in pipeline API #1213

merged 1 commit into from
May 15, 2023

Conversation

ianthomas23
Copy link
Member

Fixes #1204.

In the pipeline API we weren't passing through the antialias flag. With this fix, the OP's example works fine for all values of line_width:

import datashader as ds
import pandas as pd

df = pd.DataFrame(dict(x=[0,1],y=[0,1]))

glyph = ds.glyphs.LineAxis0('x','y')
glyph.set_line_width(1)
pipeline = ds.Pipeline(df, glyph)

image = pipeline(x_range=(0,1), y_range=(0,1), width=400, height=400)

@@ -431,7 +431,6 @@ def line(self, source, x=None, y=None, agg=None, axis=0, geometry=None,
line_width = 0

glyph.set_line_width(line_width)
glyph.antialiased = (line_width > 0)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now handled in line.py.

@@ -61,6 +61,8 @@ class _AntiAliasedLine(object):

def set_line_width(self, line_width):
self._line_width = line_width
if hasattr(self, "antialiased"):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't excellent, but is the simplest solution available given that the Glyph class has the antialiased attribute and this _AntiAliasedLine class is a mixin for line glyphs only. In fact the antialiased flag is always available here given how we are using it, so this hasattr isn't really needed but it is good practice to check before setting it.

In the long run, when we add antialiasing to other glyphs such as points it would be better to remove the _AntialisedLine class and move the line_width to the Glyph base class. But it will need a more generic name than line_width (antialiased_spread?) which is TBD.

@ianthomas23 ianthomas23 added this to the v0.14.5 milestone May 11, 2023
@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Merging #1213 (6fd8d37) into main (31b3182) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1213      +/-   ##
==========================================
+ Coverage   84.63%   84.65%   +0.02%     
==========================================
  Files          35       35              
  Lines        8354     8355       +1     
==========================================
+ Hits         7070     7073       +3     
+ Misses       1284     1282       -2     
Impacted Files Coverage Δ
datashader/core.py 88.23% <ø> (-0.03%) ⬇️
datashader/glyphs/line.py 93.05% <100.00%> (+0.20%) ⬆️
datashader/pipeline.py 100.00% <100.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ianthomas23 ianthomas23 merged commit 8092f4d into holoviz:main May 15, 2023
@ianthomas23 ianthomas23 deleted the 1204_pipeline_antialias branch May 15, 2023 07:39
Copy link
Member

@jbednar jbednar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Too many positional arguments" in pipeline when line_width>0
2 participants