Fix bug identified in #1817, comment 17340049

Here's the bug report:

https://github.com/scikit-learn/scikit-learn/issues/1817#issuecomment-17340048