From 91bb969ed10e90c3169a841db80f3ae6444430b4 Mon Sep 17 00:00:00 2001 From: Daren Liang Date: Tue, 5 Nov 2019 20:45:05 -0500 Subject: [PATCH] stats: use c style for loop --- vlib/math/stats/stats.v | 4 +--- vlib/math/stats/stats_test.v | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/vlib/math/stats/stats.v b/vlib/math/stats/stats.v index 538366c548..bde6853e49 100644 --- a/vlib/math/stats/stats.v +++ b/vlib/math/stats/stats.v @@ -118,13 +118,11 @@ pub fn mode(arr []f64) f64 { for v in arr { freqs< freqs[max] { max = i } - i++ } return arr[max] } diff --git a/vlib/math/stats/stats_test.v b/vlib/math/stats/stats_test.v index 6379fe0693..6c39561033 100644 --- a/vlib/math/stats/stats_test.v +++ b/vlib/math/stats/stats_test.v @@ -35,7 +35,6 @@ fn test_geometric_mean() { assert o.str().eq('5.159932') data = [f64(-3.0),f64(67.31),f64(4.4),f64(1.89)] o = stats.geometric_mean(data) - println(o) // Some issue with precision comparison in f64 using == operator hence serializing to string assert o.str().eq('nan') || o.str().eq('-nan') || o.str().eq('-1.#IND00') || o == f64(0) || o.str().eq('-nan(ind)') // Because in math it yields a complex number data = [f64(12.0),f64(7.88),f64(76.122),f64(54.83)]