streadway/quantile — pull request #2 by matttproud (2014-04-16 10:07:04+00:00)
Title: Formally handle errors when querying empty streams.

I like this library a lot for its simplicity and ease of understanding,
but I do have a use case where I would like to query an estimator for
a rank without having to know a priori whether it has observed any
samples. Adding in handling for this a priori do-I-have-samples-and
-avoid-querying-to-prevent-a-panic is dirty at best, so I would like
a way to be lazy about it and check for error value.

I am complately open to your wisdom and reflections on this:

- Representing a response from a query on an empty stream with NaN
seems fine but also borders on violating the reduction of sentinel
values to represent state principle and idioms.

Pros: Concise. No impact to current API users.
Cons: Unidiomatic for purists. NaN may not be good representer of
illegal state. NaN check requires importing math module.

- Remodeling Estimator.Get to have a function return signature of a
double is possible. (Approach taken in this commit.)

Pros: Idiomatic for purists. Minimizes panics in library code.
Cons: Breaks API compatibility for legacy users. More verbose.
Compromise: Users who care about state legality may use
Estimator.MustGet which has a return signature of a
single and panics if an error is detected.

Regardless of which approach we take, I think minimizing
unanticipated panics in library code makes everyone happy! :-)