Update internal use of decimal to float (#10333)

# Description
We made the decision that our floating point type should be referred to
as `float` over `decimal`.
Commands were updated by #9979 and #10320

Now make the internal codebase consistent in referring to this data type
as `float`.

Work for #10332

# User-Facing Changes

`decimal` has been removed as a type name/symbol. 

Instead of 
```nushell
def foo [bar: decimal] decimal -> decimal {}
```
use 
```nushell
def foo [bar: float] float -> float {}
```

Potential effect of `SyntaxShape`'s `Display` implementation now also
referring to `float` instead of `decimal`

# Details
- Rename `SyntaxShape::Decimal` to `Float`
- Update `Display for SyntaxShape` to `float`
- Update error message + fn name in dataframe code
- Fix docs in command examples
- Rename tests that are float specific
- Update doccomment on `SyntaxShape`
- Update comment in script

# Tests + Formatting
Updates the names of some tests
This commit is contained in:
Stefan Holderbach
2023-09-13 23:53:55 +02:00
committed by GitHub
parent 5bd7300cd5
commit bbf0b45c59
15 changed files with 48 additions and 63 deletions

View File

@ -107,7 +107,7 @@ impl Command for SubCommand {
result: None,
},
Example {
description: "convert a decimal to a nushell binary primitive",
description: "convert a float to a nushell binary primitive",
example: "1.234 | into binary",
result: Some(Value::binary(
1.234f64.to_ne_bytes().to_vec(),

View File

@ -95,12 +95,12 @@ impl Command for SubCommand {
result: Some(Value::bool(true, span)),
},
Example {
description: "convert decimal to boolean",
description: "convert float to boolean",
example: "0.3 | into bool",
result: Some(Value::bool(true, span)),
},
Example {
description: "convert decimal string to boolean",
description: "convert float string to boolean",
example: "'0.0' | into bool",
result: Some(Value::bool(false, span)),
},

View File

@ -105,7 +105,7 @@ impl Command for SubCommand {
result: Some(Value::filesize(2, Span::test_data())),
},
Example {
description: "Convert decimal to filesize",
description: "Convert float to filesize",
example: "8.3 | into filesize",
result: Some(Value::filesize(8, Span::test_data())),
},

View File

@ -145,7 +145,7 @@ mod tests {
#[test]
#[allow(clippy::approx_constant)]
fn string_to_decimal() {
fn string_to_float() {
let word = Value::test_string("3.1415");
let expected = Value::test_float(3.1415);
@ -154,7 +154,7 @@ mod tests {
}
#[test]
fn communicates_parsing_error_given_an_invalid_decimallike_string() {
fn communicates_parsing_error_given_an_invalid_floatlike_string() {
let invalid_str = Value::test_string("11.6anra");
let actual = action(

View File

@ -169,7 +169,7 @@ impl Command for SubCommand {
result: Some(Value::test_int(2)),
},
Example {
description: "Convert decimal to integer",
description: "Convert float to integer",
example: "5.9 | into int",
result: Some(Value::test_int(5)),
},

View File

@ -89,22 +89,22 @@ impl Command for SubCommand {
result: Some(Value::test_string("5.000")),
},
Example {
description: "convert decimal to string and round to nearest integer",
description: "convert float to string and round to nearest integer",
example: "1.7 | into string -d 0",
result: Some(Value::test_string("2")),
},
Example {
description: "convert decimal to string",
description: "convert float to string",
example: "1.7 | into string -d 1",
result: Some(Value::test_string("1.7")),
},
Example {
description: "convert decimal to string and limit to 2 decimals",
description: "convert float to string and limit to 2 decimals",
example: "1.734 | into string -d 2",
result: Some(Value::test_string("1.73")),
},
Example {
description: "try to convert decimal to string and provide negative decimal points",
description: "try to convert float to string and provide negative decimal points",
example: "1.734 | into string -d -2",
result: None,
// FIXME
@ -116,7 +116,7 @@ impl Command for SubCommand {
// }),
},
Example {
description: "convert decimal to string",
description: "convert float to string",
example: "4.3 | into string",
result: Some(Value::test_string("4.3")),
},