@@ -2037,58 +2037,59 @@ def test_diff_invalid_type_handling(self):
2037
2037
"""Test that diff function properly handles invalid input types"""
2038
2038
# Test for the bug fix where non-numeric types would raise AttributeError
2039
2039
# instead of ValueError
2040
-
2040
+
2041
2041
# Create a simple array for testing
2042
2042
arr = np .array ([1 , 2 , 3 , 4 , 5 ])
2043
-
2043
+
2044
2044
# Test cases that should raise ValueError (not AttributeError)
2045
2045
invalid_inputs = [
2046
2046
"hello" , # string
2047
- None , # None
2048
- [1 , 2 ], # list
2047
+ None , # None
2048
+ [1 , 2 ], # list
2049
2049
{"key" : "value" }, # dict
2050
- object (), # generic object
2050
+ object (), # generic object
2051
2051
]
2052
-
2052
+
2053
2053
for invalid_input in invalid_inputs :
2054
2054
with pytest .raises (ValueError , match = "periods must be an integer" ):
2055
2055
algos .diff (arr , invalid_input )
2056
-
2056
+
2057
2057
def test_diff_valid_float_handling (self ):
2058
2058
"""Test that diff function properly handles valid float inputs"""
2059
-
2059
+
2060
2060
# Create a simple array for testing
2061
2061
arr = np .array ([1 , 2 , 3 , 4 , 5 ])
2062
-
2062
+
2063
2063
# Test cases that should work (float values that are integers)
2064
2064
valid_inputs = [
2065
- 1.0 , # float that is an integer
2066
- 2.0 , # another float that is an integer
2065
+ 1.0 , # float that is an integer
2066
+ 2.0 , # another float that is an integer
2067
2067
- 1.0 , # negative float that is an integer
2068
2068
]
2069
-
2069
+
2070
2070
for valid_input in valid_inputs :
2071
2071
# Should not raise an exception
2072
2072
result = algos .diff (arr , valid_input )
2073
2073
assert result .shape == arr .shape
2074
-
2074
+
2075
2075
def test_diff_invalid_float_handling (self ):
2076
2076
"""Test that diff function properly handles invalid float inputs"""
2077
-
2077
+
2078
2078
# Create a simple array for testing
2079
2079
arr = np .array ([1 , 2 , 3 , 4 , 5 ])
2080
-
2080
+
2081
2081
# Test cases that should raise ValueError (float values that are not integers)
2082
2082
invalid_float_inputs = [
2083
- 1.5 , # float that is not an integer
2084
- 2.7 , # another float that is not an integer
2083
+ 1.5 , # float that is not an integer
2084
+ 2.7 , # another float that is not an integer
2085
2085
- 1.3 , # negative float that is not an integer
2086
2086
]
2087
-
2087
+
2088
2088
for invalid_input in invalid_float_inputs :
2089
2089
with pytest .raises (ValueError , match = "periods must be an integer" ):
2090
2090
algos .diff (arr , invalid_input )
2091
2091
2092
+
2092
2093
@pytest .mark .parametrize ("op" , [np .array , pd .array ])
2093
2094
def test_union_with_duplicates (op ):
2094
2095
# GH#36289
0 commit comments