-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interpolate with t=Infinity returns NaN instead of Infinity #91
Comments
Related to #73 |
Two possible implementations as discussed on https://d3js.zulipchat.com/#narrow/stream/273725-D3/topic/d3-scale
and
|
It’s doing exactly what it’s documented to do, so I’m not sure I consider this a bug. 0 * Infinity is NaN. Why is it useful to support Infinity? |
I found the case while wanting to transform a domain extent (that accepts -Infinity and Infinity as valid) to a range extent, something like: [-Infinity, Infinity].map(d3.scaleLinear()) and I expected having [-Infinity, Infinity] as the output, but got It's not difficult to test for this case in my application, but I was wondering if it was the "normal" behavior. If it is, OK for me to close the issue. |
For the record, another possible implementation by Jacob Rus: lerp = (a, b, t) => {
var y = a * (1 - t) + b * t;
return (y === y) ? y : (b - a) * t
} |
This scale is a way of defining a certain linear function f. In the event that the slope is not 0, f(∞) should theoretically be ±∞, not undefined. (Whether it is important or useful to support this edge case is debatable.) |
returns
NaN
, while I would expect it to returnInfinity
.Note that replacing
d3-interpolate/src/number.js
Line 3 in e8cddfd
with
would generate a new
NaN
issue that is not a problem with the current version:The text was updated successfully, but these errors were encountered: