ERROR [data.subject.Subject.DistractorTaskHigh220726_v7] Couldnt trim data given to graduation objects to current set of sessions, using subject.py:781
full data history. got exception
only size-1 arrays can be converted to Python scalars
╭──────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────╮
│ │
│ /home/mouse/dev/autopilot/autopilot/data/subject.py:778 in _trim_trial_to_session │
│ │
│ 775 │ │ │ │ │ │ # fine, use the whole thing │
│ 776 │ │ │ │ │ │ pass │
│ 777 │ │ │ │ │ else: │
│ ❱ 778 │ │ │ │ │ │ slice_start = int(discontinuities[-1]+1) │
│ 779 │ │ │ │
│ 780 │ │ │ except Exception as e: │
│ 781 │ │ │ │ self.logger.exception( │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: only size-1 arrays can be converted to Python scalars
From quickly perusing the code, I am pretty sure this is the classic gotcha with np.where, in which its result always needs to be indexed with [0]. (np.where should be rewritten to do this automatically when the input data is 1d in my opinion)
for example:
In [3]: np.where(np.array([1,2,3]) == 2)
Out[3]: (array([1]),)
In [4]: np.where(np.array([1,2,3]) == 2)[0]
Out[4]: array([1])
I get this error:
From quickly perusing the code, I am pretty sure this is the classic gotcha with
np.where
, in which its result always needs to be indexed with [0]. (np.where
should be rewritten to do this automatically when the input data is 1d in my opinion)for example:
fix (?) is here: https://github.com/Rodgers-PAC-Lab/autopilot/commit/3caefcc68b2fa718daf727c5cb329af3ec8d6a40