diff --git a/pandas/tests/arrays/test_integer.py b/pandas/tests/arrays/test_integer.py index b88ba1cf01426..759dacd7f221e 100644 --- a/pandas/tests/arrays/test_integer.py +++ b/pandas/tests/arrays/test_integer.py @@ -159,7 +159,7 @@ def _check_op(self, s, op_name, other, exc=None): # integer result type else: - rs = pd.Series(s.values._data) + rs = pd.Series(s.values._data, name=s.name) expected = op(rs, other) self._check_op_integer(result, expected, mask, s, op_name, other) diff --git a/pandas/tests/indexes/interval/test_interval.py b/pandas/tests/indexes/interval/test_interval.py index 19e42b4621b3a..a22210268e5aa 100644 --- a/pandas/tests/indexes/interval/test_interval.py +++ b/pandas/tests/indexes/interval/test_interval.py @@ -566,12 +566,12 @@ def test_get_loc_datetimelike_overlapping(self, arrays): value = index[0].mid + Timedelta('12 hours') result = np.sort(index.get_loc(value)) expected = np.array([0, 1], dtype='intp') - assert tm.assert_numpy_array_equal(result, expected) + tm.assert_numpy_array_equal(result, expected) interval = Interval(index[0].left, index[1].right) result = np.sort(index.get_loc(interval)) expected = np.array([0, 1, 2], dtype='intp') - assert tm.assert_numpy_array_equal(result, expected) + tm.assert_numpy_array_equal(result, expected) # To be removed, replaced by test_interval_new.py (see #16316, #16386) def test_get_indexer(self): diff --git a/pandas/tests/io/parser/test_textreader.py b/pandas/tests/io/parser/test_textreader.py index eb3789bb72910..2177d6bb93108 100644 --- a/pandas/tests/io/parser/test_textreader.py +++ b/pandas/tests/io/parser/test_textreader.py @@ -345,5 +345,5 @@ def test_empty_csv_input(self): def assert_array_dicts_equal(left, right): for k, v in left.items(): - assert tm.assert_numpy_array_equal(np.asarray(v), - np.asarray(right[k])) + tm.assert_numpy_array_equal(np.asarray(v), + np.asarray(right[k])) diff --git a/pandas/tests/reductions/test_reductions.py b/pandas/tests/reductions/test_reductions.py index 76ac5353c5916..c91233e9317b7 100644 --- a/pandas/tests/reductions/test_reductions.py +++ b/pandas/tests/reductions/test_reductions.py @@ -147,7 +147,7 @@ def test_same_tz_min_max_axis_1(self, op, expected_col): columns=['a']) df['b'] = df.a.subtract(pd.Timedelta(seconds=3600)) result = getattr(df, op)(axis=1) - expected = df[expected_col] + expected = df[expected_col].rename(None) tm.assert_series_equal(result, expected) diff --git a/pandas/tests/series/test_constructors.py b/pandas/tests/series/test_constructors.py index 5376cb3696012..fd90a87c553c4 100644 --- a/pandas/tests/series/test_constructors.py +++ b/pandas/tests/series/test_constructors.py @@ -1058,7 +1058,7 @@ def test_fromDict(self): data = {'a': 0, 'b': 1, 'c': 2, 'd': 3} series = Series(data) - assert tm.is_sorted(series.index) + tm.assert_is_sorted(series.index) data = {'a': 0, 'b': '1', 'c': '2', 'd': datetime.now()} series = Series(data) diff --git a/pandas/tests/tools/test_numeric.py b/pandas/tests/tools/test_numeric.py index ee2c2c0c3cdfa..5d3903cb93bd5 100644 --- a/pandas/tests/tools/test_numeric.py +++ b/pandas/tests/tools/test_numeric.py @@ -240,7 +240,7 @@ def test_really_large_scalar(large_val, signed, transform, errors): else: expected = float(val) if (errors == "coerce" and val_is_string) else val - assert tm.assert_almost_equal(to_numeric(val, **kwargs), expected) + tm.assert_almost_equal(to_numeric(val, **kwargs), expected) def test_really_large_in_arr(large_val, signed, transform, diff --git a/pandas/util/testing.py b/pandas/util/testing.py index 70c06efa30fee..5ef68dcefdf8b 100644 --- a/pandas/util/testing.py +++ b/pandas/util/testing.py @@ -281,25 +281,25 @@ def assert_almost_equal(left, right, check_dtype="equiv", """ if isinstance(left, pd.Index): - return assert_index_equal(left, right, - check_exact=False, - exact=check_dtype, - check_less_precise=check_less_precise, - **kwargs) + assert_index_equal(left, right, + check_exact=False, + exact=check_dtype, + check_less_precise=check_less_precise, + **kwargs) elif isinstance(left, pd.Series): - return assert_series_equal(left, right, - check_exact=False, - check_dtype=check_dtype, - check_less_precise=check_less_precise, - **kwargs) + assert_series_equal(left, right, + check_exact=False, + check_dtype=check_dtype, + check_less_precise=check_less_precise, + **kwargs) elif isinstance(left, pd.DataFrame): - return assert_frame_equal(left, right, - check_exact=False, - check_dtype=check_dtype, - check_less_precise=check_less_precise, - **kwargs) + assert_frame_equal(left, right, + check_exact=False, + check_dtype=check_dtype, + check_less_precise=check_less_precise, + **kwargs) else: # Other sequences. @@ -317,7 +317,7 @@ def assert_almost_equal(left, right, check_dtype="equiv", else: obj = "Input" assert_class_equal(left, right, obj=obj) - return _testing.assert_almost_equal( + _testing.assert_almost_equal( left, right, check_dtype=check_dtype, check_less_precise=check_less_precise, @@ -355,7 +355,7 @@ def _check_isinstance(left, right, cls): def assert_dict_equal(left, right, compare_keys=True): _check_isinstance(left, right, dict) - return _testing.assert_dict_equal(left, right, compare_keys=compare_keys) + _testing.assert_dict_equal(left, right, compare_keys=compare_keys) def randbool(size=(), p=0.5): @@ -717,11 +717,12 @@ def isiterable(obj): return hasattr(obj, '__iter__') -def is_sorted(seq): +def assert_is_sorted(seq): + """Assert that the sequence is sorted.""" if isinstance(seq, (Index, Series)): seq = seq.values # sorting does not change precisions - return assert_numpy_array_equal(seq, np.sort(np.array(seq))) + assert_numpy_array_equal(seq, np.sort(np.array(seq))) def assert_categorical_equal(left, right, check_dtype=True, @@ -911,8 +912,6 @@ def _raise(left, right, err_msg): if isinstance(left, np.ndarray) and isinstance(right, np.ndarray): assert_attr_equal('dtype', left, right, obj=obj) - return True - def assert_extension_array_equal(left, right, check_dtype=True, check_less_precise=False, @@ -1073,12 +1072,10 @@ def assert_series_equal(left, right, check_dtype=True, # .values is an ndarray, but ._values is the ExtensionArray. # TODO: Use .array assert is_extension_array_dtype(right.dtype) - return assert_extension_array_equal(left._values, right._values) - + assert_extension_array_equal(left._values, right._values) elif (is_extension_array_dtype(left) and not is_categorical_dtype(left) and is_extension_array_dtype(right) and not is_categorical_dtype(right)): - return assert_extension_array_equal(left.array, right.array) - + assert_extension_array_equal(left.array, right.array) else: _testing.assert_almost_equal(left.get_values(), right.get_values(), check_less_precise=check_less_precise,