i have these:
a=sc.array([0,1])
b=sc.array([1,0])
c=sc.array([0,-1])
d=sc.array([-1,0])
orientation_list=(sc.array([a,b,c,d])).tolist()
#---------------------------------------------------------------------
#i am trying sth like this
tab=sc.random.random_integers(orientation_list)
I want the ‘tab’ to retrieve randomly one of the above arrays.For example ‘tab=[0,1]’
Is there a way?
Your code creates a bunch of NumPy arrays, then a list of these NumPy arrays, then transforms this list itself into a NumPy array and finally transforms everything back to a list. The code above skips all those (rather pointless) conversions and uses Python’s built-in
randommodule instead of NumPy’snumpy.random.