While working on something else, I realized that linspace is not handling requests for returning the sampling spacing consistently:
>>> np.linspace(0, 1, 3, retstep=True) (array([ 0. , 0.5, 1. ]), 0.5) >>> np.linspace(0, 1, 1, retstep=True) array([ 0.]) >>> np.linspace(0, 1, 0, retstep=True) array([], dtype=float64) Basically, retstep is ignored if the number of samples is 0 or 1. One could argue that it makes sense, because those sequences do not have a spacing defined. But at the very least it should be documented as doing so, and the following inconsistency removed: >>> np.linspace(0, 1, 1, endpoint=True, retstep=True) array([ 0.]) >>> np.linspace(0, 1, 1, endpoint=False, retstep=True) (array([ 0.]), 1.0) I am personally inclined to think that if a step is requested, then a step should be returned, and if it cannot be calculated in a reasonable manner, then a placeholder such as None, nan, 0 or stop - start should be returned. What does the collective wisdom think is the best approach for this? Jaime -- (\__/) ( O.o) ( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
_______________________________________________ NumPy-Discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
