Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
array operation with numpy ndarray

Below array operation with numpy ndarray are not allowed in Quantopian IDE

import numpy as np
np.array([1,2,3]) > 2
np.array([x > 2 for x in np.array([1,2,3])])
np.array([x > 2 for x in list(np.array([1,2,3]))])

any reason why? and what are the alternatives?

2 responses

Hello Yoyo,

What's not working for you? The attached backtest runs.

Grant

import numpy as np

def initialize(context):  
    context.spy = sid(8554)  
def handle_data(context, data):  
    print np.array([1,2,3]) > 2  
    print np.array([x > 2 for x in np.array([1,2,3])])  
    print np.array([x > 2 for x in list(np.array([1,2,3]))])  

I just ran my code again, and it is working also! Have absolutely no clue why it didn't work 6 hours ago.
Thanks Grant for testing this out.