mirror of
https://github.com/gonum/gonum.git
synced 2025-10-20 21:59:25 +08:00
floats: fix Same for NaN/N
This commit is contained in:
@@ -706,7 +706,7 @@ func Same(s, t []float64) bool {
|
||||
}
|
||||
for i, v := range s {
|
||||
w := t[i]
|
||||
if v != w && !math.IsNaN(v) && !math.IsNaN(w) {
|
||||
if v != w && !(math.IsNaN(v) && math.IsNaN(w)) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
@@ -1130,7 +1130,7 @@ func TestSame(t *testing.T) {
|
||||
}
|
||||
s1 = []float64{1, 2, math.NaN(), 4}
|
||||
s2 = []float64{1, math.NaN(), 3, 4}
|
||||
if !Same(s1, s2) {
|
||||
if Same(s1, s2) {
|
||||
t.Errorf("Slices with unmatching NaN values returned as equal")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user