Skip to content

Commit 0cafc81

Browse files
dbrattliclaude
andcommitted
fix(math): fix build error, add missing tests, fix CHANGELOG order
Replace IEnumerable<T> with seq<T> in fsum/prod to fix build (missing import). Add tests for nan, prod, perm, dist, hyperbolic functions, and special functions. Move Unreleased section above rc.3 in CHANGELOG. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8ef0d3d commit 0cafc81

3 files changed

Lines changed: 66 additions & 8 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ name: Fable.Python
77

88
All notable changes to this project will be documented in this file.
99

10-
## 5.0.0-rc.3 - 2026-04-16
11-
12-
### 🐞 Bug Fixes
13-
14-
* Bump Fable.Core to 5.0.0-rc.2 and ShipIt to 2.0.2 (#243) ([cb06fd6](https://github.com/fable-compiler/Fable.Python/commit/cb06fd6fc338fde73e8eb3c3720ed20bfdd17287))
15-
1610
## Unreleased
1711

1812
### 🐞 Bug Fixes
@@ -25,6 +19,12 @@ All notable changes to this project will be documented in this file.
2519
* Add missing `math` module functions: `sqrt`, `degrees`, `radians`, `trunc`, `hypot`, `fsum`, `isqrt`, `prod`, `perm`, `acosh`, `asinh`, `atanh`, `cosh`, `sinh`, `tanh`, `erf`, `erfc`, `gamma`, `lgamma`
2620
* Fix `math.dist` signature to accept float arrays (for multi-dimensional distance)
2721

22+
## 5.0.0-rc.3 - 2026-04-16
23+
24+
### 🐞 Bug Fixes
25+
26+
* Bump Fable.Core to 5.0.0-rc.2 and ShipIt to 2.0.2 (#243) ([cb06fd6](https://github.com/fable-compiler/Fable.Python/commit/cb06fd6fc338fde73e8eb3c3720ed20bfdd17287))
27+
2828
<strong><small>[View changes on Github](https://github.com/fable-compiler/Fable.Python/compare/8223cc8eb8b2dcaa02c1a19566c5ed5d73242b11..66e56764fefe824e1b2a28635245820c2dc92a34)</small></strong>
2929

3030
## 5.0.0-rc.2 - 2026-03-09

‎src/stdlib/Math.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type IExports =
6262
abstract fmod: x: int -> y: int -> int
6363
/// Return an accurate floating-point sum of values in the iterable
6464
/// See https://docs.python.org/3/library/math.html#math.fsum
65-
abstract fsum: iterable: IEnumerable<float> -> float
65+
abstract fsum: iterable: float seq -> float
6666
/// Return the greatest common divisor of the integers
6767
/// See https://docs.python.org/3/library/math.html#math.gcd
6868
abstract gcd: [<ParamArray>] ints: int[] -> int
@@ -80,7 +80,7 @@ type IExports =
8080
abstract perm: n: int * k: int -> int
8181
/// Return the product of all elements in the iterable
8282
/// See https://docs.python.org/3/library/math.html#math.prod
83-
abstract prod: iterable: IEnumerable<'T> -> 'T
83+
abstract prod: iterable: 'T seq -> 'T
8484
/// Truncate x to an integer (towards zero)
8585
/// See https://docs.python.org/3/library/math.html#math.trunc
8686
abstract trunc: x: float -> int

‎test/TestMath.fs‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,3 +166,61 @@ let ``test isqrt works`` () =
166166
[<Fact>]
167167
let ``test fsum works`` () =
168168
math.fsum [ 1.0; 2.0; 3.0 ] |> equal 6.0
169+
170+
[<Fact>]
171+
let ``test nan constant works`` () =
172+
math.isnan math.nan |> equal true
173+
174+
[<Fact>]
175+
let ``test prod works`` () =
176+
math.prod [ 1; 2; 3; 4 ] |> equal 24
177+
178+
[<Fact>]
179+
let ``test perm works`` () =
180+
math.perm 5 |> equal 120
181+
math.perm (5, 2) |> equal 20
182+
183+
[<Fact>]
184+
let ``test dist works`` () =
185+
math.dist [| 0.0; 0.0 |] [| 3.0; 4.0 |] |> equal 5.0
186+
187+
[<Fact>]
188+
let ``test cosh works`` () =
189+
math.cosh 0.0 |> equal 1.0
190+
191+
[<Fact>]
192+
let ``test sinh works`` () =
193+
math.sinh 0.0 |> equal 0.0
194+
195+
[<Fact>]
196+
let ``test tanh works`` () =
197+
math.tanh 0.0 |> equal 0.0
198+
199+
[<Fact>]
200+
let ``test acosh works`` () =
201+
math.acosh 1.0 |> equal 0.0
202+
203+
[<Fact>]
204+
let ``test asinh works`` () =
205+
math.asinh 0.0 |> equal 0.0
206+
207+
[<Fact>]
208+
let ``test atanh works`` () =
209+
math.atanh 0.0 |> equal 0.0
210+
211+
[<Fact>]
212+
let ``test erf works`` () =
213+
math.erf 0.0 |> equal 0.0
214+
215+
[<Fact>]
216+
let ``test erfc works`` () =
217+
math.erfc 0.0 |> equal 1.0
218+
219+
[<Fact>]
220+
let ``test gamma works`` () =
221+
math.gamma 1.0 |> equal 1.0
222+
math.gamma 5.0 |> equal 24.0
223+
224+
[<Fact>]
225+
let ``test lgamma works`` () =
226+
math.lgamma 1.0 |> equal 0.0

0 commit comments

Comments
 (0)