Array types incompatible error in convolve.
See original GitHub issueI am trying to use the convolve
function from the dask_image
library. No matter what combination of inputs I try, I seem to keep running into the same error.
My inputs are dcube
:
<xarray.DataArray 'A' (time: 2, y: 823, x: 1296)>
array([[[330., 226., 709., ..., 135., 82., 76.],
[125., 615., 293., ..., 156., 207., 127.],
[126., 506., 218., ..., 228., 240., 179.],
...,
[ 73., 137., 145., ..., 375., 453., 542.],
[ 86., 78., 148., ..., 321., 227., 619.],
[ 88., 155., 42., ..., 262., 279., 518.]],
[[330., 226., 709., ..., 135., 82., 76.],
[125., 615., 293., ..., 156., 207., 127.],
[126., 506., 218., ..., 228., 240., 179.],
...,
[ 73., 137., 145., ..., 375., 453., 542.],
[ 86., 78., 148., ..., 321., 227., 619.],
[ 88., 155., 42., ..., 262., 279., 518.]]])
Coordinates:
pol <U2 'HH'
* y (y) float64 3.653e+06 3.653e+06 3.653e+06 ... 3.652e+06 3.652e+06
* x (x) float64 1.047e+06 1.047e+06 1.047e+06 ... 1.049e+06 1.049e+06
* time (time) datetime64[ns] 2020-11-24T22:24:50 2020-11-18T01:15:05
Attributes:
orbit: A
transform: (1.1987408006010196, 0.0, 1047472.9120438152, 0.0, -1.198740...
crs: {'proj': 'utm', 'zone': 10, 'datum': 'WGS84', 'units': 'm', ...
and a patch
:
filter_wt = (1 / (N * N)) * np.ones((N, N),dtype='float64')
>> array([[0.11111111, 0.11111111, 0.11111111],
[0.11111111, 0.11111111, 0.11111111],
[0.11111111, 0.11111111, 0.11111111]])
When I try to use the convolve
function as follows:
from dask_image.ndfilters import convolve
convolve(dcube[0], xr.DataArray(filter_wt), mode='constant', cval=0.0).compute()
I end up with this error:
*** ValueError: Array types must be compatible.
Even though, DaskArray with a numpy backend and a numpy array should be compatible. To get around this, I tried initializing both as dask arrays:
(Pdb) convolve(da.from_array(dcube[i]), da.from_array(filter_wt), mode='constant', cval=0.0).compute()
*** ValueError: Array types must be compatible.
(Pdb) type(da.from_array(dcube[0]))
<class 'dask.array.core.Array'>
(Pdb) type(da.from_array(filter_wt))
<class 'dask.array.core.Array'>
Any instructions on why casting both to ask arrays didn’t work would be very helpful!
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Trying to pass an array to a method but throws incompatible ...
1 Answer 1 ... The program shows the message: Incompatible types: int[] cannot be converted to int . This is because the return...
Read more >How to Think in JAX - JAX documentation - Read the Docs
jit does have limitations: in particular, it requires all arrays to have static shapes. That means that some JAX operations are incompatible with...
Read more >Supported NumPy features - Numba
Numba excels at generating code that executes on top of NumPy arrays. ... using these attributes will result in a compile-time ( TypingError...
Read more >convolve_fft — Astropy v5.2
Returns a convolved image with shape = array.shape . Assumes kernel is centered. convolve_fft is very similar to convolve in that it replaces ......
Read more >astropy.convolution.convolve — Astropy v0.4.2
The data type depends on the input array type. If array is a floating point type, then the return array keeps the same...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m going to close this issue now since it seems like the problem has been resolved.
For anyone reading, we’d be very happy to accept a pull request aimed at making the documentation clearer & more helpful for this particular problem. I think that’s a very good idea.
The first argument must be a dask array, yes. Your other array inputs (in this case
patch
) must match the type of array stored in the dask array chunks of your first argument (dcube
).Examples of compatible arrays:
Examples of incompatible arrays:
Yes, this is a good summary.