lyst / lightfm

A Python implementation of LightFM, a hybrid recommendation algorithm.
Apache License 2.0
4.73k stars 691 forks source link

Predict with ndarrays/int only #533

Closed guidopetri closed 4 years ago

guidopetri commented 4 years ago

Closes #532 .

This is a small PR that just checks if the input to LightFM.predict() is in fact either np.ndarray or int type. It also includes a line in test_predict() to make sure this doesn't break later. The docs weren't changed because they already implied that the only acceptable input was np.ndarray or int.

Let me know if you'd rather not use an AssertionError there. I used it because a couple lines later there's another assert statement, and I figured you'd want some consistency.

guidopetri commented 4 years ago

I think that's the first time the CI has passed first time for me! Yay!

maciejkula commented 4 years ago

Thanks! With hindsight all my uses of asserts would be better as actual exceptions, with informative error messages. Let me know if you want to change this here; otherwise, happy to merge.

guidopetri commented 4 years ago

I'll switch to an exception then. Any specific kind you want here? Maybe TypeError?

maciejkula commented 4 years ago

Thanks!