thanks, I was able to create a shorter version which throws the same error:
import numpy as np
import numba
import math
# Data
rec_type = np.dtype([
(('Start time', 'time'), '<i8'),
(('Baseline', 'baseline'), '<i2'),
(('Waveform data', 'data'), '<i2', (2,))
])
rr_old_sample = np.array(
[
( 0, 0, [13812, 13813,]),
( 0, 0, [13621, 13622, ]),
( 0, 0, [13608, 13609, ]),
], dtype=rec_type
)
@numba.njit
def foo(rr_old_sample):
return rr_old_sample['data']
foo(rr_old_sample)
This is a case of missing functionality. The nested array case is not working when trying to perform a “static getitem”. If you want, you can open a request here: Issues · numba/numba · GitHub
Please attach the short example above to explain what is missing.
In the meantime, since you probably cannot wait for this to be fixed, I suggest a workaround like the following below. If you extract the waveform data into its own array, you should be to write something like np.median(waveform_data[rr_old['channel'] == ch][rr_start:records_required])
. It’s not as nice as what you have, but it’s not a big change and it should work.
import numpy as np
import numba
import math
# Data
rec_type = np.dtype([
(('Start time', 'time'), '<i8'),
(('Baseline', 'baseline'), '<i2'),
(('Waveform data', 'data'), '<i2', (2,))
])
rr_old_sample = np.array(
[
( 0, 0, [13812, 13813,]),
( 0, 0, [13621, 13622, ]),
( 0, 0, [13608, 13609, ]),
], dtype=rec_type
)
rr_old_sample_short = rr_old_sample[['time', 'baseline']]
waveform_data = rr_old_sample['data']
@numba.njit
def foo(rr_old_sample_short, waveform_data):
return waveform_data
foo(rr_old_sample, waveform_data)
cheers,
Luk