mirror of
https://github.com/nushell/nushell.git
synced 2025-08-15 00:32:30 +02:00
Fix known externals, fix operator spans (#5140)
This commit is contained in:
@ -67,6 +67,7 @@ pub fn average(values: &[Value], head: &Span) -> Result<Value, ShellError> {
|
||||
val: values.len() as i64,
|
||||
span: *head,
|
||||
},
|
||||
*head,
|
||||
),
|
||||
}
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ pub fn sum(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
| Value::Float { .. }
|
||||
| Value::Filesize { .. }
|
||||
| Value::Duration { .. } => {
|
||||
acc = acc.add(head, value)?;
|
||||
acc = acc.add(head, value, head)?;
|
||||
}
|
||||
other => {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
@ -129,7 +129,7 @@ pub fn product(data: Vec<Value>, head: Span) -> Result<Value, ShellError> {
|
||||
for value in &data {
|
||||
match value {
|
||||
Value::Int { .. } | Value::Float { .. } => {
|
||||
acc = acc.mul(head, value)?;
|
||||
acc = acc.mul(head, value, head)?;
|
||||
}
|
||||
other => {
|
||||
return Err(ShellError::UnsupportedInput(
|
||||
|
@ -78,15 +78,15 @@ fn sum_of_squares(values: &[Value], span: &Span) -> Result<Value, ShellError> {
|
||||
value.span().unwrap_or(*span),
|
||||
))
|
||||
}?;
|
||||
let v_squared = &v.mul(*span, v)?;
|
||||
sum_x2 = sum_x2.add(*span, v_squared)?;
|
||||
sum_x = sum_x.add(*span, v)?;
|
||||
let v_squared = &v.mul(*span, v, *span)?;
|
||||
sum_x2 = sum_x2.add(*span, v_squared, *span)?;
|
||||
sum_x = sum_x.add(*span, v, *span)?;
|
||||
}
|
||||
|
||||
let sum_x_squared = sum_x.mul(*span, &sum_x)?;
|
||||
let sum_x_squared_div_n = sum_x_squared.div(*span, &n)?;
|
||||
let sum_x_squared = sum_x.mul(*span, &sum_x, *span)?;
|
||||
let sum_x_squared_div_n = sum_x_squared.div(*span, &n, *span)?;
|
||||
|
||||
let ss = sum_x2.sub(*span, &sum_x_squared_div_n)?;
|
||||
let ss = sum_x2.sub(*span, &sum_x_squared_div_n, *span)?;
|
||||
|
||||
Ok(ss)
|
||||
}
|
||||
@ -111,7 +111,7 @@ pub fn compute_variance(sample: bool) -> impl Fn(&[Value], &Span) -> Result<Valu
|
||||
val: n as i64,
|
||||
span: *span,
|
||||
};
|
||||
ss.div(*span, &n)
|
||||
ss.div(*span, &n, *span)
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user