holoviz / holoviz/datashader

ufunc 'over' not supported for the input types

Open
#519 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
3.6k
Forks
376
Avg merge
4h 32m
Merged PRs (30d)
1

Description

I am trying to generate "10-million-point datashaded plots: interactive" from https://anaconda.org/jbednar/nyc_taxi/notebook.

I am seeing this error:

`TypeError: ufunc 'over' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''`

Here is my code:

```
import datashader as ds
from datashader.bokeh_ext import InteractiveImage
from functools import partial
from datashader.utils import export_image
from datashader.colors import colormap_select, Greys9, Hot, viridis, inferno
from IPython.core.display import HTML, display
from datashader import transfer_functions as tf
from pyproj import Proj, transform
from bokeh.io import output_notebook, show
from bokeh.plotting import figure
from bokeh.io import output_file, show
from bokeh.models import (
GMapPlot, GMapOptions, ColumnDataSource, Circle, DataRange1d, PanTool, WheelZoomTool, BoxSelectTool
)
import pandas as pd
output_notebook()

plot_width = int(750)
plot_height = int(plot_width//1.2)
NYC = x_range, y_range = ((-8242000,-8210000), (4965000,4990000))

%time df = pd.read_csv('/Users/amitrathi/Documents/places_2k_transformed.csv',usecols= ['x', 'y', 'count'])

background = "black"
export = partial(export_image, export_path="export", background=background)
cm = partial(colormap_select, reverse=(background=="black"))

def base_plot(tools='pan,wheel_zoom,reset',plot_width=plot_width, plot_height=plot_height, **plot_args):
p = figure(tools=tools, plot_width=plot_width, plot_height=plot_height,
x_range=x_range, y_range=y_range, outline_line_color=None,
min_border=0, min_border_left=0, min_border_right=0,
min_border_top=0, min_border_bottom=0, **plot_args)

p.axis.visible = False
p.xgrid.grid_line_color = None
p.ygrid.grid_line_color = None
return p

def create_image(x_range, y_range, w=plot_width, h=plot_height):
cvs = ds.Canvas(plot_width=w, plot_height=h, x_range=x_range, y_range=y_range)
agg = cvs.points(df, 'x', 'y', ds.count('count'))
img = tf.shade(agg, cmap=Hot, how='eq_hist')
return tf.dynspread(img, threshold=0.5, max_px=4)

p = base_plot(background_fill_color=background)
show(p)
im = create_image(*NYC)
print im.data

print type(im)
print im

export(im,"NYCT_hot")
InteractiveImage(p, create_image)
```

Here is a full stack trace:

```
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
in ()
56 print im
57
---> 58 export(im,"NYCT_hot")
59 InteractiveImage(p, create_image)
60

/Users/amitrathi/miniconda2/lib/python2.7/site-packages/datashader/utils.pyc in export_image(img, filename, fmt, _return, export_path, background)
131
132 if background:
--> 133 img=set_background(img,background)
134
135 img.to_pil().save(os.path.join(export_path,filename+fmt))

/Users/amitrathi/miniconda2/lib/python2.7/site-packages/datashader/transfer_functions.pyc in set_background(img, color)
361 return img
362 background = np.uint8(rgb(color) + (255,)).view('uint32')[0]
--> 363 data = over(img.data, background)
364 return Image(data, coords=img.coords, dims=img.dims)
365

TypeError: ufunc 'over' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.