From 7b68810856d2ddbcbb867d86271445241cdd8247 Mon Sep 17 00:00:00 2001 From: Ian Thomas Date: Thu, 27 Jul 2023 10:20:39 +0100 Subject: [PATCH] Better function naming --- datashader/antialias.py | 5 - datashader/compiler.py | 38 ++++--- datashader/data_libraries/dask.py | 14 +-- datashader/data_libraries/dask_xarray.py | 21 ++-- datashader/data_libraries/pandas.py | 7 +- datashader/glyphs/area.py | 24 ++--- datashader/glyphs/line.py | 98 +++++++++---------- datashader/glyphs/points.py | 4 +- datashader/glyphs/polygon.py | 2 +- datashader/glyphs/quadmesh.py | 6 +- datashader/glyphs/trimesh.py | 2 +- datashader/reductions.py | 2 - .../tests/benchmarks/test_extend_line.py | 2 +- datashader/tests/test_glyphs.py | 2 +- 14 files changed, 112 insertions(+), 115 deletions(-) diff --git a/datashader/antialias.py b/datashader/antialias.py index bef9c7b3d..18594c977 100644 --- a/datashader/antialias.py +++ b/datashader/antialias.py @@ -2,11 +2,6 @@ from enum import Enum from typing import NamedTuple, TYPE_CHECKING -from datashader.utils import ( - nanfirst_in_place, nanlast_in_place, nanmax_in_place, - nanmin_in_place, nansum_in_place, ngjit, parallel_fill) -from numba import literal_unroll - # Enum used to specify how the second stage aggregation is performed # for 2-stage antialiased lines. diff --git a/datashader/compiler.py b/datashader/compiler.py index a9167a599..8b46f3657 100644 --- a/datashader/compiler.py +++ b/datashader/compiler.py @@ -79,7 +79,13 @@ def compile_components(agg, schema, glyph, *, antialias=False, cuda=False, parti ``antialias_stage_2`` If using antialiased lines this is a tuple of the ``AntialiasCombination`` values corresponding to the aggs. If not using antialiased lines then - this is False. + this is ``False``. + + ``antialias_stage_2_funcs`` + If using antialiased lines which require a second stage combine, this + is a tuple of the three combine functions which are the accumulate, + clear and copy_back functions. If not using antialiased lines then this + is ``None``. ``column_names`` Names of DataFrame columns or DataArray variables that are used by the @@ -103,11 +109,11 @@ def compile_components(agg, schema, glyph, *, antialias=False, cuda=False, parti else: array_module = np antialias_stage_2 = antialias_stage_2(array_module) - aa_3_funcs = make_aa(antialias_stage_2) + antialias_stage_2_funcs = make_antialias_stage_2_functions(antialias_stage_2) else: self_intersect = False antialias_stage_2 = False - aa_3_funcs = None #None, None, None + antialias_stage_2_funcs = None # List of tuples of # (append, base, input columns, temps, combine temps, uses cuda mutex, is_categorical) @@ -131,11 +137,15 @@ def compile_components(agg, schema, glyph, *, antialias=False, cuda=False, parti column_names = [c.column for c in cols if c.column != SpecialColumn.RowIndex] - return create, info, append, combine, finalize, antialias_stage_2, aa_3_funcs, column_names + return create, info, append, combine, finalize, antialias_stage_2, antialias_stage_2_funcs, column_names -def _get_combine_func(combination: AntialiasCombination, zero: float, n_reduction: bool, categorical: bool): - if not n_reduction and not categorical: +def _get_antialias_stage_2_combine_func(combination: AntialiasCombination, zero: float, + n_reduction: bool, categorical: bool): + if not n_reduction: + # The aggs to combine here are either 3D (ny, nx, ncat) if categorical is True or + # 2D (ny, nx) if categorical is False. The same combination functions can be for both + # as all elements are independent. if combination == AntialiasCombination.MAX: return nanmax_in_place elif combination == AntialiasCombination.MIN: @@ -147,26 +157,14 @@ def _get_combine_func(combination: AntialiasCombination, zero: float, n_reductio else: return nansum_in_place - if not n_reduction and categorical: - if combination == AntialiasCombination.MAX: - raise NotImplementedError - elif combination == AntialiasCombination.MIN: - raise NotImplementedError - elif combination == AntialiasCombination.FIRST: - raise NotImplementedError - elif combination == AntialiasCombination.LAST: - raise NotImplementedError - else: - return nansum_in_place - raise NotImplementedError -def make_aa(antialias_stage_2): +def make_antialias_stage_2_functions(antialias_stage_2): aa_combinations, aa_zeroes, aa_n_reductions, aa_categorical = antialias_stage_2 # Accumulate functions. - funcs = [_get_combine_func(comb, zero, n_red, cat) for comb, zero, n_red, cat + funcs = [_get_antialias_stage_2_combine_func(comb, zero, n_red, cat) for comb, zero, n_red, cat in zip(aa_combinations, aa_zeroes, aa_n_reductions, aa_categorical)] namespace = {} diff --git a/datashader/data_libraries/dask.py b/datashader/data_libraries/dask.py index dd721caf6..fd526b8d4 100644 --- a/datashader/data_libraries/dask.py +++ b/datashader/data_libraries/dask.py @@ -71,11 +71,12 @@ def default(glyph, df, schema, canvas, summary, *, antialias=False, cuda=False): # Compile functions partitioned = isinstance(df, dd.DataFrame) and df.npartitions > 1 - create, info, append, combine, finalize, antialias_stage_2, aa_3_funcs, column_names = compile_components( - summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=partitioned) + create, info, append, combine, finalize, antialias_stage_2, antialias_stage_2_funcs, column_names = \ + compile_components(summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=partitioned) x_mapper = canvas.x_axis.mapper y_mapper = canvas.y_axis.mapper - extend = glyph._build_extend(x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs) + extend = glyph._build_extend( + x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs) x_range = bounds[:2] y_range = bounds[2:] @@ -209,11 +210,12 @@ def line(glyph, df, schema, canvas, summary, *, antialias=False, cuda=False): # Compile functions partitioned = isinstance(df, dd.DataFrame) and df.npartitions > 1 - create, info, append, combine, finalize, antialias_stage_2, aa_3_funcs, _ = compile_components( - summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=partitioned) + create, info, append, combine, finalize, antialias_stage_2, antialias_stage_2_funcs, _ = \ + compile_components(summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=partitioned) x_mapper = canvas.x_axis.mapper y_mapper = canvas.y_axis.mapper - extend = glyph._build_extend(x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs) + extend = glyph._build_extend( + x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs) x_range = bounds[:2] y_range = bounds[2:] diff --git a/datashader/data_libraries/dask_xarray.py b/datashader/data_libraries/dask_xarray.py index ad59bbacb..0062a3f61 100644 --- a/datashader/data_libraries/dask_xarray.py +++ b/datashader/data_libraries/dask_xarray.py @@ -58,11 +58,12 @@ def dask_rectilinear(glyph, xr_ds, schema, canvas, summary, *, antialias=False, shape, bounds, st, axis = shape_bounds_st_and_axis(xr_ds, canvas, glyph) # Compile functions - create, info, append, combine, finalize, antialias_stage_2, aa_3_funcs, _ = compile_components( - summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=True) + create, info, append, combine, finalize, antialias_stage_2, antialias_stage_2_funcs, _ = \ + compile_components(summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=True) x_mapper = canvas.x_axis.mapper y_mapper = canvas.y_axis.mapper - extend = glyph._build_extend(x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs) + extend = glyph._build_extend( + x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs) x_range = bounds[:2] y_range = bounds[2:] @@ -140,11 +141,12 @@ def dask_raster(glyph, xr_ds, schema, canvas, summary, *, antialias=False, cuda= shape, bounds, st, axis = shape_bounds_st_and_axis(xr_ds, canvas, glyph) # Compile functions - create, info, append, combine, finalize, antialias_stage_2, aa_3_funcs, _ = compile_components( - summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=True) + create, info, append, combine, finalize, antialias_stage_2, antialias_stage_2_funcs, _ = \ + compile_components(summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=True) x_mapper = canvas.x_axis.mapper y_mapper = canvas.y_axis.mapper - extend = glyph._build_extend(x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs) + extend = glyph._build_extend( + x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs) x_range = bounds[:2] y_range = bounds[2:] @@ -234,11 +236,12 @@ def dask_curvilinear(glyph, xr_ds, schema, canvas, summary, *, antialias=False, shape, bounds, st, axis = shape_bounds_st_and_axis(xr_ds, canvas, glyph) # Compile functions - create, info, append, combine, finalize, antialias_stage_2, aa_3_funcs, _ = compile_components( - summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=True) + create, info, append, combine, finalize, antialias_stage_2, antialias_stage_2_funcs, _ = \ + compile_components(summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=True) x_mapper = canvas.x_axis.mapper y_mapper = canvas.y_axis.mapper - extend = glyph._build_extend(x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs) + extend = glyph._build_extend( + x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs) x_range = bounds[:2] y_range = bounds[2:] diff --git a/datashader/data_libraries/pandas.py b/datashader/data_libraries/pandas.py index 37c0bd87f..8abb50793 100644 --- a/datashader/data_libraries/pandas.py +++ b/datashader/data_libraries/pandas.py @@ -23,11 +23,12 @@ def pandas_pipeline(df, schema, canvas, glyph, summary, *, antialias=False): @glyph_dispatch.register(_GeometryLike) @glyph_dispatch.register(_AreaToLineLike) def default(glyph, source, schema, canvas, summary, *, antialias=False, cuda=False): - create, info, append, _, finalize, antialias_stage_2, aa_3_funcs, _ = compile_components( - summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=False) + create, info, append, _, finalize, antialias_stage_2, antialias_stage_2_funcs, _ = \ + compile_components(summary, schema, glyph, antialias=antialias, cuda=cuda, partitioned=False) x_mapper = canvas.x_axis.mapper y_mapper = canvas.y_axis.mapper - extend = glyph._build_extend(x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs) + extend = glyph._build_extend( + x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs) x_range = canvas.x_range or glyph.compute_x_bounds(source) y_range = canvas.y_range or glyph.compute_y_bounds(source) diff --git a/datashader/glyphs/area.py b/datashader/glyphs/area.py index b9448d858..37e094a02 100644 --- a/datashader/glyphs/area.py +++ b/datashader/glyphs/area.py @@ -98,7 +98,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -182,7 +182,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -274,7 +274,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -365,7 +365,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -472,7 +472,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -580,7 +580,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -649,7 +649,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -728,7 +728,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -797,7 +797,7 @@ def compute_bounds_dask(self, ddf): self.compute_y_bounds()) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -865,7 +865,7 @@ def compute_bounds_dask(self, ddf): self.compute_y_bounds()) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -950,7 +950,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( @@ -1030,7 +1030,7 @@ def compute_bounds_dask(self, ddf): self.maybe_expand_bounds(y_extents)) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_trapezoid_y = _build_draw_trapezoid_y( diff --git a/datashader/glyphs/line.py b/datashader/glyphs/line.py index b53303c07..77d40111c 100644 --- a/datashader/glyphs/line.py +++ b/datashader/glyphs/line.py @@ -33,9 +33,9 @@ def set_line_width(self, line_width): if hasattr(self, "antialiased"): self.antialiased = (line_width > 0) - def _build_extend(self, x_mapper, y_mapper, info, append, antialias_stage_2, aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, antialias_stage_2, antialias_stage_2_funcs): return self._internal_build_extend( - x_mapper, y_mapper, info, append, self._line_width, antialias_stage_2, aa_3_funcs) + x_mapper, y_mapper, info, append, self._line_width, antialias_stage_2, antialias_stage_2_funcs) class LineAxis0(_PointLike, _AntiAliasedLine): @@ -48,19 +48,19 @@ class LineAxis0(_PointLike, _AntiAliasedLine): """ @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): antialias = line_width > 0 expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) extend_cpu, extend_cuda = _build_extend_line_axis0( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) x_name = self.x y_name = self.y @@ -143,19 +143,19 @@ def compute_bounds_dask(self, ddf): @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): antialias = line_width > 0 expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) extend_cpu, extend_cuda = _build_extend_line_axis0_multi( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) x_names = self.x @@ -261,19 +261,19 @@ def compute_bounds_dask(self, ddf): @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): antialias = line_width > 0 expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) extend_cpu, extend_cuda = _build_extend_line_axis1_none_constant( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) x_names = self.x y_names = self.y @@ -338,19 +338,19 @@ def compute_bounds_dask(self, ddf): @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): antialias = line_width > 0 expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) extend_cpu, extend_cuda = _build_extend_line_axis1_x_constant( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) x_values = self.x @@ -416,19 +416,19 @@ def compute_bounds_dask(self, ddf): @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): antialias = line_width > 0 expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) extend_cpu, extend_cuda = _build_extend_line_axis1_y_constant( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) x_names = self.x @@ -496,19 +496,19 @@ def compute_bounds_dask(self, ddf): @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): antialias = line_width > 0 expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) extend_cpu = _build_extend_line_axis1_ragged( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) x_name = self.x y_name = self.y @@ -542,7 +542,7 @@ def geom_dtypes(self): @memoize def _internal_build_extend( - self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, aa_3_funcs): + self, x_mapper, y_mapper, info, append, line_width, antialias_stage_2, antialias_stage_2_funcs): from spatialpandas.geometry import ( PolygonArray, MultiPolygonArray, RingArray ) @@ -552,12 +552,12 @@ def _internal_build_extend( x_mapper, y_mapper, antialias) overwrite, use_2_stage_agg = two_stage_agg(antialias_stage_2) if not use_2_stage_agg: - aa_3_funcs = None + antialias_stage_2_funcs = None draw_segment = _build_draw_segment( append, map_onto_pixel, expand_aggs_and_cols, line_width, overwrite ) perform_extend_cpu = _build_extend_line_axis1_geometry( - draw_segment, expand_aggs_and_cols, aa_3_funcs, + draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs, ) geometry_name = self.geometry @@ -995,8 +995,8 @@ def draw_segment( return draw_segment -def _build_extend_line_axis0(draw_segment, expand_aggs_and_cols, aa_3_funcs): - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis0(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + use_2_stage_agg = antialias_stage_2_funcs is not None @ngjit @expand_aggs_and_cols @@ -1048,10 +1048,10 @@ def extend_cuda(sx, tx, sy, ty, xmin, xmax, ymin, ymax, return extend_cpu, extend_cuda -def _build_extend_line_axis0_multi(draw_segment, expand_aggs_and_cols, aa_3_funcs): - if aa_3_funcs is not None: - aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = aa_3_funcs - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis0_multi(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + if antialias_stage_2_funcs is not None: + aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = antialias_stage_2_funcs + use_2_stage_agg = antialias_stage_2_funcs is not None @ngjit @expand_aggs_and_cols @@ -1140,10 +1140,10 @@ def extend_cuda(sx, tx, sy, ty, xmin, xmax, ymin, ymax, xs, ys, return extend_cpu, extend_cuda -def _build_extend_line_axis1_none_constant(draw_segment, expand_aggs_and_cols, aa_3_funcs): - if aa_3_funcs is not None: - aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = aa_3_funcs - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis1_none_constant(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + if antialias_stage_2_funcs is not None: + aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = antialias_stage_2_funcs + use_2_stage_agg = antialias_stage_2_funcs is not None @ngjit @expand_aggs_and_cols @@ -1233,10 +1233,10 @@ def extend_cuda(sx, tx, sy, ty, xmin, xmax, ymin, ymax, xs, ys, antialias_stage_ return extend_cpu, extend_cuda -def _build_extend_line_axis1_x_constant(draw_segment, expand_aggs_and_cols, aa_3_funcs): - if aa_3_funcs is not None: - aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = aa_3_funcs - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis1_x_constant(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + if antialias_stage_2_funcs is not None: + aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = antialias_stage_2_funcs + use_2_stage_agg = antialias_stage_2_funcs is not None @ngjit @expand_aggs_and_cols @@ -1327,10 +1327,10 @@ def extend_cuda(sx, tx, sy, ty, xmin, xmax, ymin, ymax, xs, ys, antialias_stage_ return extend_cpu, extend_cuda -def _build_extend_line_axis1_y_constant(draw_segment, expand_aggs_and_cols, aa_3_funcs): - if aa_3_funcs is not None: - aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = aa_3_funcs - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis1_y_constant(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + if antialias_stage_2_funcs is not None: + aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = antialias_stage_2_funcs + use_2_stage_agg = antialias_stage_2_funcs is not None @ngjit @expand_aggs_and_cols @@ -1423,10 +1423,10 @@ def extend_cuda(sx, tx, sy, ty, xmin, xmax, ymin, ymax, xs, ys, antialias_stage_ return extend_cpu, extend_cuda -def _build_extend_line_axis1_ragged(draw_segment, expand_aggs_and_cols, aa_3_funcs): - if aa_3_funcs is not None: - aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = aa_3_funcs - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis1_ragged(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + if antialias_stage_2_funcs is not None: + aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = antialias_stage_2_funcs + use_2_stage_agg = antialias_stage_2_funcs is not None def extend_cpu( sx, tx, sy, ty, xmin, xmax, ymin, ymax, xs, ys, antialias_stage_2, *aggs_and_cols @@ -1587,10 +1587,10 @@ def extend_cpu_numba_antialias_2agg( return extend_cpu -def _build_extend_line_axis1_geometry(draw_segment, expand_aggs_and_cols, aa_3_funcs): - if aa_3_funcs is not None: - aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = aa_3_funcs - use_2_stage_agg = aa_3_funcs is not None +def _build_extend_line_axis1_geometry(draw_segment, expand_aggs_and_cols, antialias_stage_2_funcs): + if antialias_stage_2_funcs is not None: + aa_stage_2_accumulate, aa_stage_2_clear, aa_stage_2_copy_back = antialias_stage_2_funcs + use_2_stage_agg = antialias_stage_2_funcs is not None def extend_cpu( sx, tx, sy, ty, xmin, xmax, ymin, ymax, diff --git a/datashader/glyphs/points.py b/datashader/glyphs/points.py index 80a7c6f94..ef69d5ee7 100644 --- a/datashader/glyphs/points.py +++ b/datashader/glyphs/points.py @@ -158,7 +158,7 @@ class Point(_PointLike): Column names for the x and y coordinates of each point. """ @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): x_name = self.x y_name = self.y @@ -228,7 +228,7 @@ def geom_dtypes(self): return PointDtype, MultiPointDtype @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): geometry_name = self.geometry @ngjit diff --git a/datashader/glyphs/polygon.py b/datashader/glyphs/polygon.py index 883f2ff37..a9d1c7089 100644 --- a/datashader/glyphs/polygon.py +++ b/datashader/glyphs/polygon.py @@ -20,7 +20,7 @@ def geom_dtypes(self): return PolygonDtype, MultiPolygonDtype @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): expand_aggs_and_cols = self.expand_aggs_and_cols(append) map_onto_pixel = _build_map_onto_pixel_for_line(x_mapper, y_mapper) draw_polygon = _build_draw_polygon( diff --git a/datashader/glyphs/quadmesh.py b/datashader/glyphs/quadmesh.py index dc67c8632..601df858d 100644 --- a/datashader/glyphs/quadmesh.py +++ b/datashader/glyphs/quadmesh.py @@ -105,7 +105,7 @@ def infer_interval_breaks(self, centers): return infer_interval_breaks(centers) @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): x_name = self.x y_name = self.y name = self.name @@ -257,7 +257,7 @@ def is_upsample(self, source, x, y, name, x_range, y_range, out_w, out_h): return upsample_width, upsample_height @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): x_name = self.x y_name = self.y name = self.name @@ -431,7 +431,7 @@ def infer_interval_breaks(self, centers): return breaks @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): x_name = self.x y_name = self.y name = self.name diff --git a/datashader/glyphs/trimesh.py b/datashader/glyphs/trimesh.py index 0b492a5e5..0ede9959d 100644 --- a/datashader/glyphs/trimesh.py +++ b/datashader/glyphs/trimesh.py @@ -62,7 +62,7 @@ class Triangles(_PolygonLike): Column names of x, y, and (optional) z coordinates of each vertex. """ @memoize - def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _aa_3_funcs): + def _build_extend(self, x_mapper, y_mapper, info, append, _antialias_stage_2, _antialias_stage_2_funcs): draw_triangle, draw_triangle_interp = _build_draw_triangle(append) map_onto_pixel = _build_map_onto_pixel_for_triangle(x_mapper, y_mapper) extend_triangles = _build_extend_triangles(draw_triangle, draw_triangle_interp, map_onto_pixel) diff --git a/datashader/reductions.py b/datashader/reductions.py index 684d0ecd4..cbb9c0529 100644 --- a/datashader/reductions.py +++ b/datashader/reductions.py @@ -711,8 +711,6 @@ def _antialias_requires_2_stages(self): def _antialias_stage_2(self, self_intersect, array_module) -> tuple[AntialiasStage2]: ret = self.reduction._antialias_stage_2(self_intersect, array_module) - if len(ret) != 1: - raise NotImplementedError return (AntialiasStage2(combination=ret[0].combination, zero=ret[0].zero, n_reduction=ret[0].n_reduction, diff --git a/datashader/tests/benchmarks/test_extend_line.py b/datashader/tests/benchmarks/test_extend_line.py index c2423d54f..0df6cf7b4 100644 --- a/datashader/tests/benchmarks/test_extend_line.py +++ b/datashader/tests/benchmarks/test_extend_line.py @@ -19,7 +19,7 @@ def append(i, x, y, agg): expand_aggs_and_cols = Glyph._expand_aggs_and_cols(append, 1, False) draw_line = _build_draw_segment(append, map_onto_pixel, expand_aggs_and_cols, 0, False) - return _build_extend_line_axis0(draw_line, expand_aggs_and_cols, False, None)[0] + return _build_extend_line_axis0(draw_line, expand_aggs_and_cols, None)[0] @pytest.mark.parametrize('high', [0, 10**5]) diff --git a/datashader/tests/test_glyphs.py b/datashader/tests/test_glyphs.py index 948e10bcb..f8748d4dc 100644 --- a/datashader/tests/test_glyphs.py +++ b/datashader/tests/test_glyphs.py @@ -55,7 +55,7 @@ def new_agg(): expand_aggs_and_cols = Glyph._expand_aggs_and_cols(append, 1, False) _draw_segment = _build_draw_segment(append, map_onto_pixel_for_line, expand_aggs_and_cols, 0, False) -extend_line, _ = _build_extend_line_axis0(_draw_segment, expand_aggs_and_cols, False, None) +extend_line, _ = _build_extend_line_axis0(_draw_segment, expand_aggs_and_cols, None) # Triangles rasterization draw_triangle, draw_triangle_interp = _build_draw_triangle(tri_append)