Hacker News new | ask | show | jobs
by tlocke 5042 days ago
I had a look though this and was confused by this line:

ratings[ratings<1.0] = 1.0

in

https://github.com/alexbw/Netflix-Prize/blob/master/src/pred...

Is it specific to NumPy? Or perhaps a Python trick I haven't seen before?

2 comments

Yep. The indexing and slicing are quite powerful. For those familiar with MATLAB, this is a fantastic resource: http://www.scipy.org/NumPy_for_Matlab_Users
Got it, thanks for the info and pointers everyone.
I believe that's an example of 'logical indexing', which is a useful feature in many vector-oriented languages / packages:

http://blogs.mathworks.com/steve/2008/01/28/logical-indexing...