-
-
Notifications
You must be signed in to change notification settings - Fork 363
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As mentioned in holoviz/holoviews#1909, the ``Canvas.raster()`` API has not been matching the rest of datashader, due to that code originating in an external project (gridtools). These differences made it difficult for external tools like HoloViews to provide a consistent interface for datashading across object types. Fully rewriting this code would be a lot of work, but this PR rewrites the top-level API to be more similar to other Canvas glyph types. The changes should be nearly fully backwards compatible for now, but the previous way of doing it will now be deprecated and removed in a later release. API Changes: - Renamed ``Canvas.raster(downsample_method=X)`` to ``Canvas.raster(agg=X)``: What gridtools calls "downsampling" is precisely the same concept as what datashader calls aggregation everywhere else. "reduction" is perhaps even more accurate, but arguments like that are called ``agg`` elsewhere, so I've adopted that convention here as well. ``downsample_method`` is still accepted as an alias for now, if ``agg`` is not present. - Renamed ``Canvas.raster(upsample_method=X)`` to ``Canvas.raster(interpolate=X)``: "interpolate" seems like a better complement to "agg" than "upsample_method". ``upsample_method`` is still accepted as an alias for now, if ``interpolate`` is not present. - The ``agg`` argument of other calls accepts any object of type ``.reductions.Reduction``, but ``raster(downsample_method=...)`` accepted only string arguments. It now accepts ``Reduction`` objects like ``rd.mean()``, extracting the "column" name, if any, and comparing it to the DataArray's name, if any (signaling an error if a "column" name is specified but doesn't match). Of course, it's not really a "column", but it's the same idea. The column name need not be provided to the agg, but if it is, it must match any name declared for the DataArray. String names are still accepted, for backwards compatibility, but will eventually be removed. - Reduction has been changed to allow instantiation without any argument, for use with unnamed DataArrays. This change may make some messages for user errors more confusing, but additional checks have been added to alleviate that. - Stub reduction functions have been added for three aggregations supported by ``Canvas.raster`` but not previously available ``.reductions``: ``mode``, ``first``, and ``last``. All three are designed for use with categorical data where numerical averaging is not appropriate and an actual existing value must be returned. For now, these work only with raster, but at least ``first`` and ``last`` should be able to be implemented for other glyph types easily. (``mode`` is more complicated because it would require unbounded buffers per pixel to hold all distinct values encountered). - ``Canvas.raster`` now accepts xarray Datasets (collections of aligned DataArrays), with the column argument to each reduction selecting the appropriate DataArray from the Dataset. - Made the interpolation support in ``Canvas.trimesh`` match that of ``Canvas.raster``, using a string argument ``interpolate`` instead of a Boolean ``interp``. The Boolean is still accepted for now, but will be deleted before release once HoloViews and GeoViews master have been updated. - The ``layer`` argument of Canvas.raster was previously confusingly a *1-based* integer index, but it is now an xarray coordinate. Xarray coordinates support 0-based, 1-based, or arbitrary floating-point indexing depending on how the DataArray was declared, and so the behavior should be the same for arrays explicitly declared with 1-based indexing (such as multi-band Landsat images indexed with integers), but in other cases the proper coordinate will now need to be supplied.
- Loading branch information
Showing
7 changed files
with
327 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.