Skip to content

param s in prescrump and scrump raises error when set to default and T_B is not None #664

Closed
@NimaSarajpoor

Description

@NimaSarajpoor

So, I have been working on scrump and prescrump, and I think we can get error if s=None (default) and T_B is not None.

Because we do:

# in prescrump

# lines 330-334
if T_B is None:
        T_B = T_A
        excl_zone = int(np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM))
    else:
        excl_zone = None

# lines 342-343
if s is None:  # pragma: no cover
        s = excl_zone

So, when T_B is not None, excl_zone is set to None, which makes s=None if s is not provided by the user.


I also tried an example to make sure of it:

import numpy as np
from stumpy.scrump import prescrump

T_A = np.random.rand(10)
T_B = np.random.rand(10)
m = 3
prescrump(T_A, m, T_B)

And the error:

83 if s is None:  # pragma: no cover
     84     s = excl_zone
---> 86 indices = np.random.permutation(range(0, l, s)).astype(np.int64)
     88 return (T_A, T_B, μ_Q, σ_Q, M_T, Σ_T, indices, s, excl_zone)

TypeError: 'NoneType' object cannot be interpreted as an integer

Solution:
Maybe this suffices:

if s is None:  # pragma: no cover:
         s =  int(np.ceil(m / config.STUMPY_EXCL_ZONE_DENOM))

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