Skip to content

Commit 7d6dbc1

Browse files
[pre-commit.ci] auto fixes from pre-commit hooks
1 parent 23c32d6 commit 7d6dbc1

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

doc/source/api/diffpy.utils.parsers.rst

-1
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ diffpy.utils.parsers.serialization module
3434
:members:
3535
:undoc-members:
3636
:show-inheritance:
37-

doc/source/api/diffpy.utils.rst

-1
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,3 @@ diffpy.utils.resampler module
6767
:members:
6868
:undoc-members:
6969
:show-inheritance:
70-

doc/source/api/diffpy.utils.wx.rst

-1
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,3 @@ diffpy.utils.wx.gridutils module
1818
:members:
1919
:undoc-members:
2020
:show-inheritance:
21-

src/diffpy/utils/validators.py

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
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.
43
54
Parameters
65
----------
@@ -31,15 +30,15 @@ def is_number(string):
3130
3231
>>> is_number("NaN")
3332
True
34-
33+
3534
>>> is_number("Infinity")
3635
True
37-
36+
3837
>>> is_number("Inf")
3938
True
4039
"""
4140
try:
4241
float(string)
4342
return True
4443
except ValueError:
45-
return False
44+
return False

tests/test_validators.py

+24-19
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,27 @@
1-
from diffpy.utils.validators import is_number
21
import pytest
32

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+
)
2126
def test_is_number(input, expected):
22-
assert is_number(input) == expected
27+
assert is_number(input) == expected

0 commit comments

Comments
 (0)