Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pandas/tests/arrays/test_integer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/indexes/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/parser/test_textreader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]))
2 changes: 1 addition & 1 deletion pandas/tests/reductions/test_reductions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/series/test_constructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pandas/tests/tools/test_numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
47 changes: 22 additions & 25 deletions pandas/util/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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,
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down