MCPcopy Index your code
hub / github.com/RustPython/RustPython / sqrt

Function sqrt

crates/stdlib/src/math.rs:174–183  ·  view source on GitHub ↗
(x: ArgIntoFloat, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

172
173 #[pyfunction]
174 fn sqrt(x: ArgIntoFloat, vm: &VirtualMachine) -> PyResult<f64> {
175 let val = x.into_float();
176 pymath::math::sqrt(val).map_err(|err| match err {
177 pymath::Error::EDOM => vm.new_value_error(format!(
178 "expected a nonnegative input, got {}",
179 super::float_repr(val)
180 )),
181 _ => pymath_exception(err, vm),
182 })
183 }
184
185 // Trigonometric functions:
186 #[pyfunction]

Callers 8

statistics.pyFile · 0.90
normal_kernelFunction · 0.90
triangular_kernelFunction · 0.90
pdfMethod · 0.90
overlapMethod · 0.90
_sqrtprodFunction · 0.90
_normal_dist_inv_cdfFunction · 0.90
testDistMethod · 0.50

Calls 2

pymath_exceptionFunction · 0.85
into_floatMethod · 0.80

Tested by 1

testDistMethod · 0.40