import dask.array as da
import numpy as np
import pandas as pd
size = 10000
x_vals = da.linspace(0, 1, 1000)
test = da.random.uniform(low=0, high=1, size=(size,4,1000), chunks=(size / 10, 1, 1000))
def simple_convolve(x, y):
temp_lst = []
for i in range(x.shape[0]):
a = da.fft.rfft(x[i])
b = da.fft.rfft(y[i])
conv_res = da.fft.irfft(a * b, n = size)
temp_lst.append(conv_res)
res = da.stack(temp_lst, axis=0)
return res
res = da.map_blocks(simple_convolve, test[:,0], test[:,1], dtype='float32')
da.argmax(res, axis=1).compute()
The last line gives error:
TypeError: '>=' not supported between instances of 'str' and 'int'
Since the error is saying I’m comparing a string and an integer, I checked that res has no nulls and no infinity values:
da.isnan(res).sum().compute().compute()
0
(~da.isfinite(res)).sum().compute().compute()
0
Also checked mins and maxes of all timestamps and nothing strange there
min_ = da.min(res, axis=1).compute().compute()
pd.Series(min_).describe()
max_ = da.max(res, axis=1).compute().compute()
pd.Series(max_).describe()
Converting res to numpy array and then running np argmax works fine.
np.argmax(res.compute().compute(), axis=1)
Possibly a bug?