 1

length must be greater than or equal to 0

Package:
scipy 8546
Exception Class:
ValueError

Raise code

taps = np.array(taps)  # needed for Cython and Pythran
n_max = (2**nbits) - 1
if length is None:
length = n_max
else:
length = int(length)
if length < 0:
raise ValueError('length must be greater than or equal to 0')
# We use int8 instead of bool here because NumPy arrays of bools
# don't seem to work nicely with Cython
if state is None:
state = np.ones(nbits, dtype=np.int8, order='c')
else:
# makes a copy if need be, ensuring it's 0's and 1's
state = np.array(state, dtype=bool, order='c').astype(np.int8)
😲 Agile task management is now easier than calling a taxi. #Tracklify

Ways to fix 1 length shouldn't be negative.

Code to reproduce the exception:

from scipy.signal import max_len_seq
max_len_seq(4,length=-5)

---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-32-97a41916ddea> in <module>()  1 from scipy.signal import max_len_seq ----> 2 max_len_seq(4,length=-5)
/usr/local/lib/python3.7/dist-packages/scipy/signal/_max_len_seq.py in max_len_seq(nbits, state, length, taps)  120 length = int(length)  121 if length < 0: --> 122 raise ValueError('length must be greater than or equal to 0')  123 # We use int8 instead of bool here because numpy arrays of bools  124 # don't seem to work nicely with Cython
ValueError: length must be greater than or equal to 0

Fixed version of the code:

from scipy.signal import max_len_seq
max_len_seq(4,length=5)

array([1, 1, 1, 1, 0], dtype=int8)