You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When passing an array of ints to stats.rms it returns an error
Reproduction Steps
Start REPL:
import math.stats
>>> x := [1,3,5,7]
>>> stats.rms(x)
Expected Behavior
>>> stats.rms(x)
9.16515138991168
Current Behavior
vlib/math/stats/stats.v:111:15: error: cannot assign to `sum`: expected `int`, not `f64`
109 | mut sum := T(0)
110 | for v in data {
111 | sum += math.pow(v, 2)
| ~~~~~~~~~
112 | }
113 | return math.sqrt(sum / T(data.len))
Possible Solution
pub fn rms[T](data []T) T {
if data.len == 0 {
return T(0)
}
mut sum := T(0)
for v in data {
sum += T(math.pow(v, 2))
}
return T(math.sqrt(sum / T(data.len)))
}
Describe the bug
When passing an array of ints to stats.rms it returns an error
Reproduction Steps
Start REPL:
Expected Behavior
Current Behavior
Possible Solution
Additional Information/Context
No response
V version
V 0.4.9 98f13ef
Environment details (OS name and version, etc.)
V full version: V 0.4.9 3939737.98f13ef
OS: linux, Debian GNU/Linux 11 (bullseye) (WSL 2)
Processor: 8 cpus, 64bit, little endian, Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
getwd: /tmp
vexe: /home/rabt/devel/new_v/v
vexe mtime: 2024-12-23 04:07:42
vroot: OK, value: /home/rabt/devel/new_v
VMODULES: OK, value: /home/rabt/.vmodules
VTMP: OK, value: /tmp/v_1000
Git version: git version 2.30.2
Git vroot status: weekly.2024.50-100-g98f13ef4
.git/config present: true
CC version: cc (Debian 10.2.1-6) 10.2.1 20210110
emcc version: N/A
thirdparty/tcc status: thirdparty-linux-amd64 0134e9b9
Note
You can use the 👍 reaction to increase the issue's priority for developers.
Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.
Huly®: V_0.6-21679
The text was updated successfully, but these errors were encountered: