pik-copan / pyunicorn

Unified Complex Network and Recurrence Analysis Toolbox
http://pik-potsdam.de/~donges/pyunicorn/
Other
195 stars 86 forks source link

CrossRecurrencePlot buffer dtype mismatch #126

Closed frankieliu closed 4 years ago

frankieliu commented 5 years ago

I am calling CrossRecurrencePlot with metric='euclidean' or metric='manhattan', I am trying to trace the error, it shows a type mismatch in pyunicorn/timeseries/_ext/numerics.pyx

Could someone point me out if the most likely change needs to be done in cross_recurrence? But looking at the signature of manhattan/euclidean matrix fast shows returning a float*

Traceback (most recent call last): File "rp.py", line 29, in threshold=0.1) File "/home/adam/anaconda3/lib/python3.7/site-packages/pyunicorn/timeseries/cross_recurrence_plot.py", line 147, in init CrossRecurrencePlot.set_fixed_threshold(self, threshold) File "/home/adam/anaconda3/lib/python3.7/site-packages/pyunicorn/timeseries/cross_recurrence_plot.py", line 287, in set_fixed_threshold self.metric) File "/home/adam/anaconda3/lib/python3.7/site-packages/pyunicorn/timeseries/cross_recurrence_plot.py", line 198, in distance_matrix y_embedded.astype('float32')) File "/home/adam/anaconda3/lib/python3.7/site-packages/pyunicorn/timeseries/cross_recurrence_plot.py", line 249, in euclidean_distance_matrix y_embedded.copy(order='c')) File "pyunicorn/timeseries/_ext/numerics.pyx", line 83, in pyunicorn.timeseries._ext.numerics._euclidean_distance_matrix_crp ValueError: Buffer dtype mismatch, expected 'double' but got 'float'

jkroenke commented 5 years ago

The error occurs because the corresponding cython functions expect the embedding arrays to be of type double. It can be avoided by replacing 'float32' with 'double' in cross_recurrence_plot.py lines 194, 195, 197 and 198.