<div dir="ltr"><div class=""><div class="">Hi,<br><br></div><div class="">it popped again on the Theano mailing list that this don't work:<br><br></div><div class="">np.arange(10) <= a_theano_vector.<br><br></div><div class="">

The reason is that __array_priority__ isn't respected for that class of operation.<br></div><br></div><div class="">This page explain the problem and give a work around:<br></div><div class=""><div class=""><br><a href="http://stackoverflow.com/questions/14619449/how-can-i-override-comparisons-between-numpys-ndarray-and-my-type">http://stackoverflow.com/questions/14619449/how-can-i-override-comparisons-between-numpys-ndarray-and-my-type</a><br>

<br></div><div class="">The work around is to make a python function that will decide witch version of the comparator to call and do the call. Then we tell NumPy to use that function instead of its current function with: np.set_numeric_ops(...)<br>

<br>But<span name="John Salvatier" class=""> if we do that, when we import theano, we will slow down all normal numpy comparison for the user, as when <= is execute, first there will be numpy c code executed, that will call the python function to decide witch version to do, then if it is 2 numpy ndarray, it will call again numpy c code.<br>

<br></span></div><div class=""><span name="John Salvatier" class="">That isn't a good solution. We could do the same override in C, but then theano work the same when there isn't a c++ compiler. That isn't nice.<br>

<br></span></div><div class=""><span name="John Salvatier" class="">What do you think of changing them to check for __array_priority__ before doing the comparison?<br><br></span></div><div class=""><span name="John Salvatier" class="">Frédéric<br>

</span></div></div></div>