From 4a96a8d755c753bbb2fe1b7071faec8ec46c8e3a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 16 Apr 2026 11:24:13 +0000 Subject: [PATCH 1/2] fix(math): correct type signatures for copysign, fmod and curried bindings - math.copysign: fix y parameter type from int to float (Python always takes two floats) - math.fmod: fix parameter and return types from int to float (computes floating-point remainder, not integer modulo) - math.comb, math.pow, math.atan2, math.dist: convert curried parameter syntax to tupled for consistency with all other multi-parameter bindings in the codebase Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- CHANGELOG.md | 10 +++------- src/stdlib/Math.fs | 12 ++++++------ 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 715bd5b..a442df5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,13 +11,9 @@ All notable changes to this project will be documented in this file. ### 🐞 Bug Fixes -* Fix `math.factorial` binding: changed signature from `float -> float` to `int -> int` to match Python 3.12+ where float arguments raise `TypeError`. Fixes test to use integer literals. - -### ✨ Enhancements - -* Add missing `math` module constants: `pi`, `e`, `tau`, `inf`, `nan` -* Add missing `math` module functions: `sqrt`, `degrees`, `radians`, `trunc`, `hypot`, `fsum`, `isqrt`, `prod`, `perm`, `acosh`, `asinh`, `atanh`, `cosh`, `sinh`, `tanh`, `erf`, `erfc`, `gamma`, `lgamma` -* Fix `math.dist` signature to accept float arrays (for multi-dimensional distance) +* Fix `math.copysign` binding: `y` parameter was incorrectly typed as `int`, now correctly `float` — `copysign(x, y)` always takes two floats +* Fix `math.fmod` binding: parameters were incorrectly typed as `int * int -> int`, now correctly `float * float -> float` — `fmod` computes floating-point remainder +* Fix `math.comb`, `math.pow`, `math.atan2`, `math.dist` bindings: converted curried parameter syntax to tupled for consistency with all other multi-parameter bindings in the codebase ## 5.0.0-rc.3 - 2026-04-16 diff --git a/src/stdlib/Math.fs b/src/stdlib/Math.fs index 857d783..897d8cd 100644 --- a/src/stdlib/Math.fs +++ b/src/stdlib/Math.fs @@ -40,10 +40,10 @@ type IExports = abstract ceil: x: float -> int /// Return the number of ways to choose k items from n items (n choose k) /// See https://docs.python.org/3/library/math.html#math.comb - abstract comb: n: int -> k: int -> int + abstract comb: n: int * k: int -> int /// Return a float with the magnitude of x and the sign of y /// See https://docs.python.org/3/library/math.html#math.copysign - abstract copysign: x: float -> y: int -> float + abstract copysign: x: float * y: float -> float /// Return the absolute value of x /// See https://docs.python.org/3/library/math.html#math.fabs abstract fabs: x: float -> float @@ -59,7 +59,7 @@ type IExports = abstract floor: x: float -> int /// Return the floating-point remainder of x / y /// See https://docs.python.org/3/library/math.html#math.fmod - abstract fmod: x: int -> y: int -> int + abstract fmod: x: float * y: float -> float /// Return an accurate floating-point sum of values in the iterable /// See https://docs.python.org/3/library/math.html#math.fsum abstract fsum: iterable: float seq -> float @@ -132,7 +132,7 @@ type IExports = abstract log10: x: float -> float /// Return x raised to the power y /// See https://docs.python.org/3/library/math.html#math.pow - abstract pow: x: float -> y: float -> float + abstract pow: x: float * y: float -> float /// Return the square root of x /// See https://docs.python.org/3/library/math.html#math.sqrt abstract sqrt: x: float -> float @@ -152,7 +152,7 @@ type IExports = abstract atan: x: float -> float /// Return the arc tangent of y/x in radians /// See https://docs.python.org/3/library/math.html#math.atan2 - abstract atan2: y: float -> x: float -> float + abstract atan2: y: float * x: float -> float /// Return the cosine of x radians /// See https://docs.python.org/3/library/math.html#math.cos abstract cos: x: float -> float @@ -218,7 +218,7 @@ type IExports = /// Return the Euclidean distance between two points p and q /// See https://docs.python.org/3/library/math.html#math.dist - abstract dist: p: float[] -> q: float[] -> float + abstract dist: p: float[] * q: float[] -> float /// Mathematical functions [] From 13a6e6d1fd2cb0812d356cd8a2592d44a314a830 Mon Sep 17 00:00:00 2001 From: Dag Brattli Date: Thu, 16 Apr 2026 17:18:19 +0200 Subject: [PATCH 2/2] fix: update tests for tupled params, restore CHANGELOG entries Update tests for comb, copysign, fmod, pow, atan2, dist to use tupled calling convention matching the corrected type signatures. Restore PR #251 entries that were dropped from the Unreleased CHANGELOG section. Co-Authored-By: Claude Opus 4.6 (1M context) --- CHANGELOG.md | 13 ++++++++++--- test/TestMath.fs | 20 ++++++++++---------- 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a442df5..749c832 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,9 +11,16 @@ All notable changes to this project will be documented in this file. ### 🐞 Bug Fixes -* Fix `math.copysign` binding: `y` parameter was incorrectly typed as `int`, now correctly `float` — `copysign(x, y)` always takes two floats -* Fix `math.fmod` binding: parameters were incorrectly typed as `int * int -> int`, now correctly `float * float -> float` — `fmod` computes floating-point remainder -* Fix `math.comb`, `math.pow`, `math.atan2`, `math.dist` bindings: converted curried parameter syntax to tupled for consistency with all other multi-parameter bindings in the codebase +* Fix `math.factorial` binding: changed signature from `float -> float` to `int -> int` to match Python 3.12+ where float arguments raise `TypeError`. Fixes test to use integer literals. +* Fix `math.copysign` binding: `y` parameter was incorrectly typed as `int`, now correctly `float` +* Fix `math.fmod` binding: parameters were incorrectly typed as `int -> int -> int`, now correctly `float * float -> float` +* Fix `math.comb`, `math.pow`, `math.atan2`, `math.dist` bindings: converted curried parameter syntax to tupled for consistency + +### ✨ Enhancements + +* Add missing `math` module constants: `pi`, `e`, `tau`, `inf`, `nan` +* Add missing `math` module functions: `sqrt`, `degrees`, `radians`, `trunc`, `hypot`, `fsum`, `isqrt`, `prod`, `perm`, `acosh`, `asinh`, `atanh`, `cosh`, `sinh`, `tanh`, `erf`, `erfc`, `gamma`, `lgamma` +* Fix `math.dist` signature to accept float arrays (for multi-dimensional distance) ## 5.0.0-rc.3 - 2026-04-16 diff --git a/test/TestMath.fs b/test/TestMath.fs index a8b3ae5..ea0fb96 100644 --- a/test/TestMath.fs +++ b/test/TestMath.fs @@ -17,13 +17,13 @@ let ``test floor works`` () = [] let ``test comb works`` () = - math.comb 5 2 |> equal 10 - math.comb 10 3 |> equal 120 + math.comb (5, 2) |> equal 10 + math.comb (10, 3) |> equal 120 [] let ``test copysign works`` () = - math.copysign 1.0 -1 |> equal -1.0 - math.copysign -1.0 1 |> equal 1.0 + math.copysign (1.0, -1.0) |> equal -1.0 + math.copysign (-1.0, 1.0) |> equal 1.0 [] let ``test fabs works`` () = @@ -37,8 +37,8 @@ let ``test factorial works`` () = [] let ``test fmod works`` () = - math.fmod 10 3 |> equal 1 - math.fmod 7 2 |> equal 1 + math.fmod (10.0, 3.0) |> equal 1.0 + math.fmod (7.0, 2.0) |> equal 1.0 [] let ``test gcd works`` () = @@ -89,8 +89,8 @@ let ``test log10 works`` () = [] let ``test pow works`` () = - math.pow 2.0 3.0 |> equal 8.0 - math.pow 10.0 2.0 |> equal 100.0 + math.pow (2.0, 3.0) |> equal 8.0 + math.pow (10.0, 2.0) |> equal 100.0 [] let ``test sin works`` () = @@ -118,7 +118,7 @@ let ``test atan works`` () = [] let ``test atan2 works`` () = - math.atan2 0.0 1.0 |> equal 0.0 + math.atan2 (0.0, 1.0) |> equal 0.0 [] let ``test pi constant works`` () = @@ -182,7 +182,7 @@ let ``test perm works`` () = [] let ``test dist works`` () = - math.dist [| 0.0; 0.0 |] [| 3.0; 4.0 |] |> equal 5.0 + math.dist ([| 0.0; 0.0 |], [| 3.0; 4.0 |]) |> equal 5.0 [] let ``test cosh works`` () =