Skip to content

Instantly share code, notes, and snippets.

@Deleplace
Last active March 12, 2026 08:16
Show Gist options
  • Select an option

  • Save Deleplace/1a45e33b9027d4950fa6cd28341fed27 to your computer and use it in GitHub Desktop.

Select an option

Save Deleplace/1a45e33b9027d4950fa6cd28341fed27 to your computer and use it in GitHub Desktop.
Reproduce OOM in stats.MannWhitneyUTest with NaN
package oom
import (
"math"
"testing"
"github.com/aclements/go-moremath/stats"
)
func TestMannWhitneyUTest_NaN_OOM(t *testing.T) {
x1 := []float64{math.NaN()}
x2 := []float64{1.0}
res, err := stats.MannWhitneyUTest(x1, x2, stats.LocationDiffers)
if err != nil {
t.Fatalf("unexpected error: %v", err)
}
if !math.IsNaN(res.U) {
t.Errorf("want U=NaN, got %v", res.U)
}
if !math.IsNaN(res.P) {
t.Errorf("want P=NaN, got %v", res.P)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment