1

# period cannot have dimensions more than 1

Package:
scipy
8546
Exception Class:
ValueError

## Raise code

``````'''
:doi:`10.1007/s00422-013-0560-8`.
'''
events = np.asarray(events)
period = np.asarray(period)
if events.ndim > 1:
raise ValueError('events cannot have dimensions more than 1')
if period.ndim > 1:
raise ValueError('period cannot have dimensions more than 1')

# we need to know later if period was originally a scalar
scalarperiod = not period.ndim

events = np.atleast_2d(events)
period = np.atleast_2d(period)
if (period <= 0).any():``````
😲 Agile task management is now easier than calling a taxi. #Tracklify

## Ways to fix

2

period should be either scalar or 1D.

Code to reproduce the exception:

```from scipy.signal import vectorstrength
import numpy as np
events = np.array([.5])
period = [[5.]]
targ_strength = 1.
targ_phase = .1
strength, phase = vectorstrength(events, period)
```

```---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-77-289c700c4bb9> in <module>()  4 targ_strength = 1.  5 targ_phase = .1 ----> 6 strength, phase = vectorstrength(events, period)
/usr/local/lib/python3.7/dist-packages/scipy/signal/signaltools.py in vectorstrength(events, period)  3380 raise ValueError('events cannot have dimensions more than 1')  3381 if period.ndim > 1: -> 3382 raise ValueError('period cannot have dimensions more than 1')  3383   3384 # we need to know later if period was originally a scalar
ValueError: period cannot have dimensions more than 1
```

Fixed version of the above code:

```from scipy.signal import vectorstrength
import numpy as np
events = np.array([.5])
period = 5.
targ_strength = 1.
targ_phase = .1
strength, phase = vectorstrength(events, period)
```
Nov 24, 2021
kellemnegasi 18.4k