scikit-learn/scikit-learn — pull request #1458 by seberg (2012-12-10 15:23:55+00:00)
Title: FIX: Do not rely on strides for contiguous arrays

When an array is contiguous in memory but has `shape[dim] == 1`, then
its `strides[dim]` is not really used, so it can be considered arbitrary
even if the array is contiguous. This is generally true for 0-sized arrays.

If there is no chance of 0-sized (or 1-sized and 1-dimensioal) arrays, then
this code is perfectly correct in current numpy. But its a dangerous
design choice and it would be nice to be able to change numpy at some point.

----

This fixes gh-1406 (without a numpy change, which I am sure will come soon, but there is no reason to change it here anyway). Using `.itemsize` is much clearer anyway, so the only reason to not do it is to do some premature optimization because Cython doesn't compile it away.

(Recreated the c files with cython 0.17.1)

Btw. all over this file `` casts seem to be used for memory pointers. Is this really correct? Since it should be `npy_intp` from a numpy perspective.