Skip to content
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

[Feature Request] Median should give a more helpful error for empty non-float sequences #339

Open
nhirschey opened this issue Aug 27, 2024 · 0 comments

Comments

@nhirschey
Copy link
Contributor

Is your feature request related to a problem? Please describe.
The median of an empty float sequence is nan. The median of an empty integer or decimal sequence causes an error with an unhelpful error message.

The error message for an empty non-float sequence should make it clear it's an FSharp.Stats problem to make it easier to debug.

#r "nuget: FSharp.Stats, 0.5.1-preview.2"

open FSharp.Stats

let ys: float [] = [||]
median ys

> val ys: float array = [||]
> val it: float = nan

let xs: decimal [] = [||]
median xs
> System.DivideByZeroException: Attempted to divide by zero.
   at System.Decimal.DecCalc.VarDecDiv(DecCalc& d1, DecCalc& d2)
   at System.Decimal.op_Division(Decimal d1, Decimal d2)

Describe the solution you'd like
An error message such as "FSharp.Stats median is undefined for an empty decimal sequence"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant