| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 23c32d6 commit 7d6dbc1
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -34,4 +34,3 @@ diffpy.utils.parsers.serialization module | |||
| 34 | 34 | :members: | |
| 35 | 35 | :undoc-members: | |
| 36 | 36 | :show-inheritance: | |
| 37 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -67,4 +67,3 @@ diffpy.utils.resampler module | |||
| 67 | 67 | :members: | |
| 68 | 68 | :undoc-members: | |
| 69 | 69 | :show-inheritance: | |
| 70 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -18,4 +18,3 @@ diffpy.utils.wx.gridutils module | |||
| 18 | 18 | :members: | |
| 19 | 19 | :undoc-members: | |
| 20 | 20 | :show-inheritance: | |
| 21 | - | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | def is_number(string): | |
| 2 | - """ | ||
| 3 | - Check if the provided string can be converted to a float. | ||
| 2 | + """Check if the provided string can be converted to a float. | ||
| 4 | 3 | ||
| 5 | 4 | Parameters | |
| 6 | 5 | ---------- | |
@@ -31,15 +30,15 @@ def is_number(string): | |||
| 31 | 30 | ||
| 32 | 31 | >>> is_number("NaN") | |
| 33 | 32 | True | |
| 34 | - | ||
| 33 | + | ||
| 35 | 34 | >>> is_number("Infinity") | |
| 36 | 35 | True | |
| 37 | - | ||
| 36 | + | ||
| 38 | 37 | >>> is_number("Inf") | |
| 39 | 38 | True | |
| 40 | 39 | """ | |
| 41 | 40 | try: | |
| 42 | 41 | float(string) | |
| 43 | 42 | return True | |
| 44 | 43 | except ValueError: | |
| 45 | - return False | ||
| 44 | + return False | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,22 +1,27 @@ | |||
| 1 | - from diffpy.utils.validators import is_number | ||
| 2 | 1 | import pytest | |
| 3 | 2 | ||
| 4 | - @pytest.mark.parametrize("input,expected", [ | ||
| 5 | - ("3.14", True), # Standard float | ||
| 6 | - ("2", True), # Integer | ||
| 7 | - ("-100", True), # Negative integer | ||
| 8 | - ("-3.14", True), # Negative float | ||
| 9 | - ("0", True), # Zero | ||
| 10 | - ("4.5e-1", True), # Scientific notation | ||
| 11 | - ("abc", False), # Non-numeric string | ||
| 12 | - ("", False), # Empty string | ||
| 13 | - ("3.14.15", False), # Multiple dots | ||
| 14 | - ("2+3", False), # Arithmetic expression | ||
| 15 | - ("NaN", True), # Not a Number (special float value) | ||
| 16 | - ("Infinity", True), # Positive infinity | ||
| 17 | - ("-Infinity", True), # Negative infinity | ||
| 18 | - ("Inf", True), # Positive infinity | ||
| 19 | - ("-Inf", True), # Negative infinity | ||
| 20 | - ]) | ||
| 3 | + from diffpy.utils.validators import is_number | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + @pytest.mark.parametrize( | ||
| 7 | + "input,expected", | ||
| 8 | + [ | ||
| 9 | + ("3.14", True), # Standard float | ||
| 10 | + ("2", True), # Integer | ||
| 11 | + ("-100", True), # Negative integer | ||
| 12 | + ("-3.14", True), # Negative float | ||
| 13 | + ("0", True), # Zero | ||
| 14 | + ("4.5e-1", True), # Scientific notation | ||
| 15 | + ("abc", False), # Non-numeric string | ||
| 16 | + ("", False), # Empty string | ||
| 17 | + ("3.14.15", False), # Multiple dots | ||
| 18 | + ("2+3", False), # Arithmetic expression | ||
| 19 | + ("NaN", True), # Not a Number (special float value) | ||
| 20 | + ("Infinity", True), # Positive infinity | ||
| 21 | + ("-Infinity", True), # Negative infinity | ||
| 22 | + ("Inf", True), # Positive infinity | ||
| 23 | + ("-Inf", True), # Negative infinity | ||
| 24 | + ], | ||
| 25 | + ) | ||
| 21 | 26 | def test_is_number(input, expected): | |
| 22 | - assert is_number(input) == expected | ||
| 27 | + assert is_number(input) == expected | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments