Holoviews Rasterize int64 to int32 Error

Hi,
I am using python 32 bit version and I have a plot in which i am using rasterization,
Since i am using python 32 bit, i am getting Error of not casting my int64 data tp int32.
Data input my plot is accepting only while generating plot and using rasterization I am getting error.
I will really appreciate if you let me know how to solve this errror.

Error message is below:-

 File "D:\\Python38x86\\lib\\site-packages\\holoviews\\util\\_init_.py", line 1018, in dynamic_operation\r, referer: IP_address
     key, obj = resolve(key, kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\util\\_init_.py", line 1007, in resolve\r, referer: IP_address
     return key, map_obj[key]\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\spaces.py", line 1331, in _getitem_\r, referer: IP_address
     val = self._execute_callback(*tuple_key)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\spaces.py", line 1100, in _execute_callback\r, referer: IP_address
     retval = self.callback(*args, **kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\spaces.py", line 714, in _call_\r, referer: IP_address
     ret = self.callable(*args, **kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\util\\_init_.py", line 1019, in dynamic_operation\r, referer: IP_address
     return apply(obj, *key, **kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\util\\_init_.py", line 1011, in apply\r, referer: IP_address
     processed = self._process(element, key, kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\util\\_init_.py", line 993, in _process\r, referer: IP_address
     return self.p.operation.process_element(element, key, **kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\operation.py", line 181, in process_element\r, referer: IP_address
     return self._apply(element, key)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\operation.py", line 137, in _apply\r, referer: IP_address
     ret = self._process(element, key)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\operation\\datashader.py", line 1423, in _process\r, referer: IP_address
     element = element.map(op, predicate)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\data\\_init_.py", line 216, in pipelined_fn\r, referer: IP_address
     result = method_fn(*args, **kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\data\\_init_.py", line 1183, in map\r, referer: IP_address
     return super(Dataset, self).map(*args, **kwargs)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\dimension.py", line 705, in map\r, referer: IP_address
     return map_fn(self) if applies else self\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\operation.py", line 201, in _call_\r, referer: IP_address
     return self._apply(element)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\core\\operation.py", line 137, in _apply\r, referer: IP_address
     ret = self._process(element, key)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\operation\\datashader.py", line 1015, in _process\r, referer: IP_address
     precomputed = self._precompute(element, agg)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\holoviews\\operation\\datashader.py", line 961, in _precompute\r, referer: IP_address
     return {'mesh': mesh(verts, simplices), 'simplices': simplices,\r, referer: IP_address
   File "D:\\Apache2_Projects\\plot\\site-packages\\datashader\\utils.py", line 595, in mesh\r, referer: IP_address
     return _pd_mesh(vertices, simplices)\r, referer: IP_address
   File "D:\\Apache2_Projects\\plot\\site-packages\\datashader\\utils.py", line 541, in _pd_mesh\r, referer: IP_address
     vals = np.take(vertices.values, vertex_idxs, axis=0)\r, referer: IP_address
   File "<_array_function_ internals>", line 5, in take\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\numpy\\core\\fromnumeric.py", line 191, in take\r, referer: IP_address
     return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\numpy\\core\\fromnumeric.py", line 67, in _wrapfunc\r, referer: IP_address
     return _wrapit(obj, method, *args, **kwds)\r, referer: IP_address
   File "D:\\Python38x86\\lib\\site-packages\\numpy\\core\\fromnumeric.py", line 44, in _wrapit\r, referer: IP_address
     result = getattr(asarray(obj), method)(*args, **kwds)\r, referer: IP_address
 TypeError: Cannot cast array data from dtype('int64') to dtype('int32') according to the rule 'safe'\r, referer: IP_address

Main Error :-
**result = getattr(asarray(obj), method)(*args, kwds)\r,referer: IP_address
TypeError: Cannot cast array data from dtype(‘int64’) to dtype(‘int32’) according to the rule ‘safe’\r,referer: IP_address

My code snippet :-

         pts = np.stack((Longitude, Latitude, HS)).T
    verts = pd.DataFrame(np.stack((Longitude, Latitude, HS)).T, columns=['Longitude', 'Latitude', 'HS'])

    # openStreet Background.
    tri_sub = tri_new.apply(lambda x: x - 1)
    ggpoints = gv.Points(verts, vdims=['HS'])
    ggsubraster = rasterize(gv.TriMesh((tri_sub, gv.Points(verts))))

    tri = gv.TriMesh((tri_sub, gv.Points(verts)))

    return tri
allplot = {(k.strftime("%Y-%m-%d %H:%M:%S"), r): plotthis(k, r) for k in
           perdelta(strt, strt + timedelta(days=2), timedelta(hours=3)) for r in
           ['O', 'A', 'Wt', 'T']}

 hmap1 = hv.HoloMap(allplot, kdims=['Select Date and Time :', 'Select Indian States'])
 finalplot = pn.Column(pn.Row(dd),
                          tiles * rasterize(hmap1).options(**opts) * logo1.opts(hooks=[absolute_position],
                                                                                apply_ranges=False))

Hi @sameerCoder,

I would try your code with Python 3.7.(latest) I don’t know if rasterize uses datashader behind the scenes but I used to get a very similar cast error when using shading functions it was related to Python 3.8 not being fully supported as far as I could tell from the datashader website.

If it’s down to the code snippet afraid I can’t help any further there.

Thanks, Carl.

HI Carl,
Thanks for reply,
so you mean to say if i downgrade the python from 3.8 to 3.7 of my python 32bit then problem will be solved ?

Yes but can’t say with any certainty but I got this part of the error " Cannot cast array data from dtype(‘int64’) to dtype(‘int32’)" the rest is not the same by any means so may be a long shot with the downgrade but when I got it, downgraded and the issue I had cleared up.