From dd7ee1808a9c7a22c9e9480897effb02129491a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Wed, 12 Aug 2020 08:46:09 -0500 Subject: [PATCH] histogram: rename 'count' column to 'ocurrences' --- crates/nu-cli/src/commands/histogram.rs | 8 ++++---- crates/nu-cli/tests/commands/histogram.rs | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/nu-cli/src/commands/histogram.rs b/crates/nu-cli/src/commands/histogram.rs index 231529d582..ad9f325b3e 100644 --- a/crates/nu-cli/src/commands/histogram.rs +++ b/crates/nu-cli/src/commands/histogram.rs @@ -127,13 +127,13 @@ pub async fn histogram( .table_entries() .map(move |value| { let values = value.table_entries().cloned().collect::>(); - let count = values.len(); + let ocurrences = values.len(); - (count, values[count - 1].clone()) + (ocurrences, values[ocurrences - 1].clone()) }) .collect::>() .into_iter() - .map(move |(count, value)| { + .map(move |(ocurrences, value)| { let mut fact = TaggedDictBuilder::new(&name); let column_value = labels .get(idx) @@ -147,7 +147,7 @@ pub async fn histogram( .clone(); fact.insert_value(&column.item, column_value); - fact.insert_untagged("count", UntaggedValue::int(count)); + fact.insert_untagged("ocurrences", UntaggedValue::int(ocurrences)); let percentage = format!( "{}%", diff --git a/crates/nu-cli/tests/commands/histogram.rs b/crates/nu-cli/tests/commands/histogram.rs index 34c41d3693..dcddfa93d1 100644 --- a/crates/nu-cli/tests/commands/histogram.rs +++ b/crates/nu-cli/tests/commands/histogram.rs @@ -54,7 +54,7 @@ fn summarizes_by_values() { | get rusty_at | histogram | where value == "Estados Unidos" - | get count + | get ocurrences | echo $it "# )); @@ -93,20 +93,20 @@ fn help() { } #[test] -fn count() { +fn ocurrences() { let actual = nu!( cwd: ".", pipeline( r#" echo "[{"bit":1},{"bit":0},{"bit":0},{"bit":0},{"bit":0},{"bit":0},{"bit":0},{"bit":1}]" | from json | histogram bit - | sort-by count + | sort-by ocurrences | reject frequency | to json "# )); - let bit_json = r#"[{"bit":"1","count":2,"percentage":"33.33%"},{"bit":"0","count":6,"percentage":"100.00%"}]"#; + let bit_json = r#"[{"bit":"1","ocurrences":2,"percentage":"33.33%"},{"bit":"0","ocurrences":6,"percentage":"100.00%"}]"#; assert_eq!(actual.out, bit_json); }