**OS**: Win64

**PsychoPy version**: v2023.2.2

**Standard Standalone? (y/n)**: yes

**What are you trying to achieve?:** I believe I am getting closer to my goal. see my previous post

**edited to remove an issue I’ve sorted (see reply below)**

I used the np.random.choice on my numpy array equation for calculating the levels to give to the participant (see below). It then crashed when I ran and gave me the type error (see below). I am wondering if anyone knows a way to choose at random 9 items within a ‘block’ created by this equation?

*Begin Experiment*

t = pandas.read_excel(‘Passages.xlsx’)

olevels = t[‘Olevel’].tolist()

all_ps = t[‘Passages’].tolist()

p1 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev)[0]))(all_ps)

p2 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev+1)[0]))(all_ps)

p3 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev+2)[0]))(all_ps)

p4 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev+3)[0]))(all_ps)

p5 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev+4)[0]))(all_ps)

p6 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev+5)[0]))(all_ps)

Next Routine - Begin Routine

if EffortLevel == 1:

pim = p1[0]

elif EffortLevel == 2:

pim = p2[0]

elif EffortLevel == 3:

pim = p3[0]

elif EffortLevel == 4:

pim = p3[0]

elif EffortLevel == 5:

pim = p5[0]

elif EffortLevel == 6:

pim = p6[0]

chooseBlocks.xlsx (12.3 KB)

Effort.psyexp (226.6 KB)

Passages.xlsx (17.0 KB)

**What did you try to make it work?:** I tried installing a specific version of numpy via install numpy (1.23.2), I tried using pipe – version or numpy – version. I tried deleting my pre-existing numpy package and replacing it with the 23 version (Psychopy didn’t even open when I did that). I have tried the np.random and other codes. I have tried changing my lope and Excel spreadsheets. I am running out of ideas and seriously need some guidance (even if it is just a link!). I have tried most of the solutions on here for randomization, but sadly, they haven’t worked for my specific project.

**What specifically went wrong when you tried that?:**

Include pasted full error message if possible.

File “C:\Users\hanna\OneDrive\Documents\University\PhD\Studies\Paradigm\PsychPi\Effort_lastrun.py”, line 4150, in

run(

File “C:\Users\hanna\OneDrive\Documents\University\PhD\Studies\Paradigm\PsychPi\Effort_lastrun.py”, line 456, in run

p1 = itemgetter(np.random.choice(*np.where(np.array(olevels) == base_lev)[0]))(all_ps)

File “mtrand.pyx”, line 825, in numpy.random.mtrand.RandomState.choice

TypeError: choice() takes at most 4 positional arguments (9 given)

2783.8571 WARNING Exception caught: C++ assertion “m_buffer && m_buffer->IsOk()” failed at …..\src\common\dcbufcmn.cpp(134) in wxBufferedDC::UnMask(): invalid backing store

################ Experiment ended with exit code 1 [pid:22036] #################

(btw, I inherited this and have tried to change it to our new goal, I am a PhD student, and any help is much appreciated).