Skip to content

stumpy.match hangs forever when passing np.inf to max_distance #501

@MC-Dave

Description

@MC-Dave
stumpy version: 1.9.2
python version: 3.9.7
numpy version: 1.21.3
OS: Ubuntu 20.04 x64

stumpy.match never completes if you pass in np.inf to max_distance

Example

import stumpy
import numpy as np

stumpy.match(
    np.array([-11.1, 23.4, 79.5, 1001.0]),
    np.array([584., -11., 23., 79., 1001., 0., -19., 27, 198, 4, 38, 2, 1, -12, .29922, 2, 1, 2, 8, 33, 1]),
    max_distance=100.,
)

No problem, completes in less than a second.

Example, really large number

stumpy.match(
    np.array([-11.1, 23.4, 79.5, 1001.0]),
    np.array([584., -11., 23., 79., 1001., 0., -19., 27, 198, 4, 38, 2, 1, -12, .29922, 2, 1, 2, 8, 33, 1]),
    max_distance=1000000000000000000000000.,
)

Same as above, no issues here.

Example, np.inf

stumpy.match(
    np.array([-11.1, 23.4, 79.5, 1001.0]),
    np.array([584., -11., 23., 79., 1001., 0., -19., 27, 198, 4, 38, 2, 1, -12, .29922, 2, 1, 2, 8, 33, 1]),
    max_distance=np.inf,
)

The above will hang for minutes without completing.

Traceback when sending CTRL+C to interrupt execution

Traceback (most recent call last):
  File "/home/.../anaconda3/envs/.../lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3444, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-22-ebbfaa39c6bc>", line 1, in <module>
    stumpy.match(
  File "/home/.../anaconda3/envs/.../lib/python3.9/site-packages/stumpy/core.py", line 127, in inner_wrapper
    return norm(*args, **kwargs)
  File "/home/.../anaconda3/envs/.../lib/python3.9/site-packages/stumpy/motifs.py", line 359, in match
    candidate_idx = np.argmin(D)
  File "<__array_function__ internals>", line 5, in argmin
  File "/home/.../anaconda3/envs/.../lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 1276, in argmin
    return _wrapfunc(a, 'argmin', axis=axis, out=out)
  File "/home/.../anaconda3/envs/.../lib/python3.9/site-packages/numpy/core/fromnumeric.py", line 57, in _wrapfunc
    return bound(*args, **kwds)
KeyboardInterrupt

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions