votes up 1

events cannot have dimensions more than 1

Package:
scipy
github stars 8546
Exception Class:
ValueError

Raise code

''' 
        when we vary the "probing" frequency while keeping the spike times
        fixed.  Biol Cybern. 2013 Aug;107(4):491-94.
        :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)

Ways to fix

votes up 2 votes down

Shape of events shouldn't be >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-2-baa79e52ad7b> in <module>()  5 targ_strength = 1.  6 targ_phase = .1 ----> 7 strength, phase = vectorstrength(events, period) 
/usr/local/lib/python3.7/dist-packages/scipy/signal/signaltools.py in vectorstrength(events, period)  3185 period = np.asarray(period)  3186 if events.ndim > 1: -> 3187 raise ValueError('events cannot have dimensions more than 1')  3188 if period.ndim > 1:  3189 raise ValueError('period cannot have dimensions more than 1') 
ValueError: events cannot have dimensions more than 1

Fixed:

  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 answer
kellemnegasi 18.4k

Add a possible fix

Please authorize to post fix