Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dtwPlotTwoWay function leads to a crash #33

Closed
XueYanYu opened this issue Sep 1, 2022 · 3 comments
Closed

dtwPlotTwoWay function leads to a crash #33

XueYanYu opened this issue Sep 1, 2022 · 3 comments

Comments

@XueYanYu
Copy link

XueYanYu commented Sep 1, 2022

  • Python port of R's Comprehensive Dynamic Time Warp algorithm package version: v1.2.0
  • Python version: 3.9
  • Operating System: Win10

Description

Using the dtwPlotTwoWay functions leads to a crash.

Changing both numpy.nan to 0 in line 166 and 167 in dtwPlot.py seems to solve the crash.

What I Did

#Using the dtwPlotTwoWay functions in a py file.
import numpy as np
from dtw import *

seq1 = range(5, 9)
seq2 = range(1, 9)

alignment_1_2 = dtw(seq1, seq2, keep_internals=True, step_pattern = asymmetric, open_end=True, open_begin=True)
alignment_2_1 = dtw(seq2, seq1, keep_internals=True, step_pattern = asymmetric, open_end=True, open_begin=True)

dtwPlotTwoWay(alignment_1_2, xts=seq1, yts=seq2, offset=1, ts_type='l', match_indices=None, match_col='gray', xlab='Index', ylab='Query value')


Traceback (most recent call last):
  File "C:\Users\name\Desktop\P2\DTWtest.py", line 10, in <module>
    dtw(seq1, seq2, keep_internals=True).plot(type="twoway", offset=1)
  File "C:\Users\name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\dtw\dtw.py", line 124, in plot
    return dtwPlot(self, type, **kwargs)
  File "C:\Users\name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\dtw\dtwPlot.py", line 70, in dtwPlot
    return dtwPlotTwoWay(x, **kwargs)
  File "C:\Users\name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\dtw\dtwPlot.py", line 166, in dtwPlotTwoWay
    xts = numpy.pad(xts,(0,maxlen-len(xts)),"constant",constant_values=numpy.nan)
  File "<__array_function__ internals>", line 5, in pad
  File "C:\Users\name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\lib\arraypad.py", line 803, in pad
    _set_pad_area(roi, axis, width_pair, value_pair)
  File "C:\Users\name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\numpy\lib\arraypad.py", line 147, in _set_pad_area
    padded[left_slice] = value_pair[0]
ValueError: cannot convert float NaN to integer
@tonigi
Copy link
Collaborator

tonigi commented Sep 1, 2022 via email

@XueYanYu
Copy link
Author

XueYanYu commented Sep 1, 2022

I have updated the inputs before the traceback.

@tonigi tonigi closed this as completed in 8c79531 Sep 1, 2022
@tonigi
Copy link
Collaborator

tonigi commented Sep 1, 2022

Should be fixed in the next release. Thanks

tonigi added a commit that referenced this issue Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants