Minor updates to variance (#2458)

This commit is contained in:
Chris Gillespie 2020-08-30 13:50:36 -07:00 committed by GitHub
parent d6b6b1df38
commit 965e07d8cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -81,30 +81,32 @@ impl WholeStreamCommand for SubCommand {
entries: column_totals,
})
.into_untagged_value())
};
}?;
match res {
Ok(v) => {
if v.value.is_table() {
Ok(OutputStream::from(
v.table_entries()
.map(|v| ReturnSuccess::value(v.clone()))
.collect::<Vec<_>>(),
))
} else {
Ok(OutputStream::one(ReturnSuccess::value(v)))
}
}
Err(e) => Err(e),
if res.value.is_table() {
Ok(OutputStream::from(
res.table_entries()
.map(|v| ReturnSuccess::value(v.clone()))
.collect::<Vec<_>>(),
))
} else {
Ok(OutputStream::one(ReturnSuccess::value(res)))
}
}
fn examples(&self) -> Vec<Example> {
vec![Example {
description: "Get the variance of a list of numbers",
example: "echo [1 2 3 4 5] | math variance",
result: Some(vec![UntaggedValue::decimal(2).into()]),
}]
vec![
Example {
description: "Get the variance of a list of numbers",
example: "echo [1 2 3 4 5] | math variance",
result: Some(vec![UntaggedValue::decimal(2).into()]),
},
Example {
description: "Get the sample variance of a list of numbers",
example: "echo [1 2 3 4 5] | math variance -s",
result: Some(vec![UntaggedValue::decimal(2.5).into()]),
},
]
}
}