Skip to content

Commit 39ce222

Browse files
committed
undo numpy 2 changes?
1 parent 5d0f9a8 commit 39ce222

File tree

3 files changed

+7
-30
lines changed

3 files changed

+7
-30
lines changed

pandas/tests/dtypes/test_inference.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
missing as libmissing,
3535
ops as libops,
3636
)
37-
from pandas.compat.numpy import np_version_gt2
3837

3938
from pandas.core.dtypes import inference
4039
from pandas.core.dtypes.cast import find_result_type
@@ -1989,7 +1988,7 @@ def test_ensure_int32():
19891988
# find a smaller floating dtype
19901989
(300.0, np.uint16), # for integer floats, we convert them to ints
19911990
(300.1, np.float64),
1992-
(np.int16(300), np.int16 if np_version_gt2 else np.uint16),
1991+
(np.int16(300), np.uint16),
19931992
],
19941993
)
19951994
def test_find_result_type_uint_int(right, result):

pandas/tests/indexing/test_coercion.py

-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
IS64,
1414
is_platform_windows,
1515
)
16-
from pandas.compat.numpy import np_version_gt2
1716

1817
import pandas as pd
1918
import pandas._testing as tm
@@ -230,11 +229,6 @@ def test_insert_float_index(
230229
dtype = float_numpy_dtype
231230
obj = pd.Index([1.0, 2.0, 3.0, 4.0], dtype=dtype)
232231
coerced_dtype = coerced_dtype if coerced_dtype is not None else dtype
233-
234-
if np_version_gt2 and dtype == "float32" and coerced_val == 1.1:
235-
# Hack, in the 2nd test case, since 1.1 can be losslessly cast to float32
236-
# the expected dtype will be float32 if the original dtype was float32
237-
coerced_dtype = np.float32
238232
exp = pd.Index([1.0, coerced_val, 2.0, 3.0, 4.0], dtype=coerced_dtype)
239233
self._assert_insert_conversion(obj, insert, exp, coerced_dtype)
240234

pandas/tests/series/test_constructors.py

+6-22
Original file line numberDiff line numberDiff line change
@@ -770,12 +770,8 @@ def test_constructor_cast(self):
770770

771771
def test_constructor_signed_int_overflow_raises(self):
772772
# GH#41734 disallow silent overflow, enforced in 2.0
773-
if np_version_gt2:
774-
msg = "The elements provided in the data cannot all be casted to the dtype"
775-
err = OverflowError
776-
else:
777-
msg = "Values are too large to be losslessly converted"
778-
err = ValueError
773+
msg = "Values are too large to be losslessly converted"
774+
err = ValueError
779775
with pytest.raises(err, match=msg):
780776
Series([1, 200, 923442], dtype="int8")
781777

@@ -803,13 +799,7 @@ def test_constructor_numpy_uints(self, values):
803799

804800
def test_constructor_unsigned_dtype_overflow(self, any_unsigned_int_numpy_dtype):
805801
# see gh-15832
806-
if np_version_gt2:
807-
msg = (
808-
f"The elements provided in the data cannot "
809-
f"all be casted to the dtype {any_unsigned_int_numpy_dtype}"
810-
)
811-
else:
812-
msg = "Trying to coerce negative values to unsigned integers"
802+
msg = "Trying to coerce negative values to unsigned integers"
813803
with pytest.raises(OverflowError, match=msg):
814804
Series([-1], dtype=any_unsigned_int_numpy_dtype)
815805

@@ -1939,15 +1929,9 @@ def test_constructor_int64_dtype(self, any_int_dtype):
19391929

19401930
def test_constructor_raise_on_lossy_conversion_of_strings(self):
19411931
# GH#44923
1942-
if not np_version_gt2:
1943-
raises = pytest.raises(
1944-
ValueError, match="string values cannot be losslessly cast to int8"
1945-
)
1946-
else:
1947-
raises = pytest.raises(
1948-
OverflowError, match="The elements provided in the data"
1949-
)
1950-
with raises:
1932+
with pytest.raises(
1933+
ValueError, match="string values cannot be losslessly cast to int8"
1934+
):
19511935
Series(["128"], dtype="int8")
19521936

19531937
def test_constructor_dtype_timedelta_alternative_construct(self):

0 commit comments

Comments
 (0)