Skip to content

Commit 6df1219

Browse files
samuelsinayokojreback
authored andcommitted
Remove return values for asserts (#25462)
1 parent 87df599 commit 6df1219

File tree

7 files changed

+30
-33
lines changed

7 files changed

+30
-33
lines changed

pandas/tests/arrays/test_integer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def _check_op(self, s, op_name, other, exc=None):
159159

160160
# integer result type
161161
else:
162-
rs = pd.Series(s.values._data)
162+
rs = pd.Series(s.values._data, name=s.name)
163163
expected = op(rs, other)
164164
self._check_op_integer(result, expected, mask, s, op_name, other)
165165

pandas/tests/indexes/interval/test_interval.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -566,12 +566,12 @@ def test_get_loc_datetimelike_overlapping(self, arrays):
566566
value = index[0].mid + Timedelta('12 hours')
567567
result = np.sort(index.get_loc(value))
568568
expected = np.array([0, 1], dtype='intp')
569-
assert tm.assert_numpy_array_equal(result, expected)
569+
tm.assert_numpy_array_equal(result, expected)
570570

571571
interval = Interval(index[0].left, index[1].right)
572572
result = np.sort(index.get_loc(interval))
573573
expected = np.array([0, 1, 2], dtype='intp')
574-
assert tm.assert_numpy_array_equal(result, expected)
574+
tm.assert_numpy_array_equal(result, expected)
575575

576576
# To be removed, replaced by test_interval_new.py (see #16316, #16386)
577577
def test_get_indexer(self):

pandas/tests/io/parser/test_textreader.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -345,5 +345,5 @@ def test_empty_csv_input(self):
345345

346346
def assert_array_dicts_equal(left, right):
347347
for k, v in left.items():
348-
assert tm.assert_numpy_array_equal(np.asarray(v),
349-
np.asarray(right[k]))
348+
tm.assert_numpy_array_equal(np.asarray(v),
349+
np.asarray(right[k]))

pandas/tests/reductions/test_reductions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ def test_same_tz_min_max_axis_1(self, op, expected_col):
147147
columns=['a'])
148148
df['b'] = df.a.subtract(pd.Timedelta(seconds=3600))
149149
result = getattr(df, op)(axis=1)
150-
expected = df[expected_col]
150+
expected = df[expected_col].rename(None)
151151
tm.assert_series_equal(result, expected)
152152

153153

pandas/tests/series/test_constructors.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ def test_fromDict(self):
10581058
data = {'a': 0, 'b': 1, 'c': 2, 'd': 3}
10591059

10601060
series = Series(data)
1061-
assert tm.is_sorted(series.index)
1061+
tm.assert_is_sorted(series.index)
10621062

10631063
data = {'a': 0, 'b': '1', 'c': '2', 'd': datetime.now()}
10641064
series = Series(data)

pandas/tests/tools/test_numeric.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def test_really_large_scalar(large_val, signed, transform, errors):
240240
else:
241241
expected = float(val) if (errors == "coerce" and
242242
val_is_string) else val
243-
assert tm.assert_almost_equal(to_numeric(val, **kwargs), expected)
243+
tm.assert_almost_equal(to_numeric(val, **kwargs), expected)
244244

245245

246246
def test_really_large_in_arr(large_val, signed, transform,

pandas/util/testing.py

+22-25
Original file line numberDiff line numberDiff line change
@@ -281,25 +281,25 @@ def assert_almost_equal(left, right, check_dtype="equiv",
281281
"""
282282

283283
if isinstance(left, pd.Index):
284-
return assert_index_equal(left, right,
285-
check_exact=False,
286-
exact=check_dtype,
287-
check_less_precise=check_less_precise,
288-
**kwargs)
284+
assert_index_equal(left, right,
285+
check_exact=False,
286+
exact=check_dtype,
287+
check_less_precise=check_less_precise,
288+
**kwargs)
289289

290290
elif isinstance(left, pd.Series):
291-
return assert_series_equal(left, right,
292-
check_exact=False,
293-
check_dtype=check_dtype,
294-
check_less_precise=check_less_precise,
295-
**kwargs)
291+
assert_series_equal(left, right,
292+
check_exact=False,
293+
check_dtype=check_dtype,
294+
check_less_precise=check_less_precise,
295+
**kwargs)
296296

297297
elif isinstance(left, pd.DataFrame):
298-
return assert_frame_equal(left, right,
299-
check_exact=False,
300-
check_dtype=check_dtype,
301-
check_less_precise=check_less_precise,
302-
**kwargs)
298+
assert_frame_equal(left, right,
299+
check_exact=False,
300+
check_dtype=check_dtype,
301+
check_less_precise=check_less_precise,
302+
**kwargs)
303303

304304
else:
305305
# Other sequences.
@@ -317,7 +317,7 @@ def assert_almost_equal(left, right, check_dtype="equiv",
317317
else:
318318
obj = "Input"
319319
assert_class_equal(left, right, obj=obj)
320-
return _testing.assert_almost_equal(
320+
_testing.assert_almost_equal(
321321
left, right,
322322
check_dtype=check_dtype,
323323
check_less_precise=check_less_precise,
@@ -355,7 +355,7 @@ def _check_isinstance(left, right, cls):
355355
def assert_dict_equal(left, right, compare_keys=True):
356356

357357
_check_isinstance(left, right, dict)
358-
return _testing.assert_dict_equal(left, right, compare_keys=compare_keys)
358+
_testing.assert_dict_equal(left, right, compare_keys=compare_keys)
359359

360360

361361
def randbool(size=(), p=0.5):
@@ -717,11 +717,12 @@ def isiterable(obj):
717717
return hasattr(obj, '__iter__')
718718

719719

720-
def is_sorted(seq):
720+
def assert_is_sorted(seq):
721+
"""Assert that the sequence is sorted."""
721722
if isinstance(seq, (Index, Series)):
722723
seq = seq.values
723724
# sorting does not change precisions
724-
return assert_numpy_array_equal(seq, np.sort(np.array(seq)))
725+
assert_numpy_array_equal(seq, np.sort(np.array(seq)))
725726

726727

727728
def assert_categorical_equal(left, right, check_dtype=True,
@@ -911,8 +912,6 @@ def _raise(left, right, err_msg):
911912
if isinstance(left, np.ndarray) and isinstance(right, np.ndarray):
912913
assert_attr_equal('dtype', left, right, obj=obj)
913914

914-
return True
915-
916915

917916
def assert_extension_array_equal(left, right, check_dtype=True,
918917
check_less_precise=False,
@@ -1073,12 +1072,10 @@ def assert_series_equal(left, right, check_dtype=True,
10731072
# .values is an ndarray, but ._values is the ExtensionArray.
10741073
# TODO: Use .array
10751074
assert is_extension_array_dtype(right.dtype)
1076-
return assert_extension_array_equal(left._values, right._values)
1077-
1075+
assert_extension_array_equal(left._values, right._values)
10781076
elif (is_extension_array_dtype(left) and not is_categorical_dtype(left) and
10791077
is_extension_array_dtype(right) and not is_categorical_dtype(right)):
1080-
return assert_extension_array_equal(left.array, right.array)
1081-
1078+
assert_extension_array_equal(left.array, right.array)
10821079
else:
10831080
_testing.assert_almost_equal(left.get_values(), right.get_values(),
10841081
check_less_precise=check_less_precise,

0 commit comments

Comments
 (0)