fslaborg / FSharp.Stats

statistical testing, linear algebra, machine learning, fitting and signal processing in F#
https://fslab.org/FSharp.Stats/
Other
205 stars 54 forks source link

[Feature Request] Rename round operator #332

Open kevmal opened 1 month ago

kevmal commented 1 month ago

FSharp.Stats.Ops.round shadows the existing round operator upon opening FSharp.Stats. Causes issues particularly with FSI when FSharp.Stats is opened, reevaluated code that relied on the F# round op then fails.

I propose round gets renamed, perhaps to roundTo so:

open FSharp.Stats
let a = 5.321
round a // F# op -> 5.0
roundTo 1 a //F# stats op -> 5.3
smoothdeveloper commented 1 month ago

As a workaround, open FSharp.Core before using round a seems to be ok.

I was thinking of open type, but it occurs that it will still call FSharp.Core round

type Rounder =
  static member round v = round v
  static member round(upTo: int, v) = round v

open type Rounder

round(1, 4.44)

error FS0001: Expecting a type supporting the operator 'Round' but given a tuple type

roundTo seems intuitive with the suggested parameter order, maybe we'd want to already come up with open type because there are many ways to round things (up, down, closest to mid point, maybe others).

Maybe interesting to get @pblasucci & @baronfel opinions in terms of API.

related: #333