[Numpy-discussion] arange and floating point arguments

Charles R Harris charlesr.harris@gmail....
Fri Sep 14 17:29:22 CDT 2007

On 9/14/07, Robert Kern <robert.kern@gmail.com> wrote:
> Charles R Harris wrote:
> > In the case of arange it should be possible to determine when the result
> > is potentially ambiguous and issue a warning. For instance, if the
> > argument of the ceil function is close to its rounded value.
> What's "close"? The appropriate tolerance depends on the operations that
> would
> cause error. For literal inputs, where the only source of error is
> representation error, 1 eps would suffice, but then so would linspace().
> For
> results of other computations, you might need more than 1 eps. But if
> you're
> doing computations, then it oughtn't to matter whether you get the
> endpoint or
> not (since you don't know what the values are anyway).

I would make 'close' very rough, maybe a relative 100*eps. The point would
be to warn of *potential* problems and suggest linspace or some other
approach, not to warn on only real problems. My guess is that most uses of
arange are either well defined or such that a less ambiguous approach should
be used. In a way, the warning would be a guess at programmer intent and a
gentler solution than making arange integer only.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20070914/40a2c5cd/attachment.html 

More information about the Numpy-discussion mailing list