MCPcopy
hub / github.com/pandas-dev/pandas / assert_sp_array_equal

Function assert_sp_array_equal

pandas/_testing/asserters.py:1406–1436  ·  view source on GitHub ↗

Check that the left and right SparseArray are equal. Parameters ---------- left : SparseArray right : SparseArray

(left, right)

Source from the content-addressed store, hash-verified

1404
1405
1406def assert_sp_array_equal(left, right) -> None:
1407 """
1408 Check that the left and right SparseArray are equal.
1409
1410 Parameters
1411 ----------
1412 left : SparseArray
1413 right : SparseArray
1414 """
1415 _check_isinstance(left, right, pd.arrays.SparseArray)
1416
1417 assert_numpy_array_equal(left.sp_values, right.sp_values)
1418
1419 # SparseIndex comparison
1420 assert isinstance(left.sp_index, SparseIndex)
1421 assert isinstance(right.sp_index, SparseIndex)
1422
1423 left_index = left.sp_index
1424 right_index = right.sp_index
1425
1426 if not left_index.equals(right_index):
1427 raise_assert_detail(
1428 "SparseArray.index", "index are not equal", left_index, right_index
1429 )
1430 else:
1431 # Just ensure a
1432 pass
1433
1434 assert_attr_equal("fill_value", left, right)
1435 assert_attr_equal("dtype", left, right)
1436 assert_numpy_array_equal(left.to_dense(), right.to_dense())
1437
1438
1439def assert_contains_all(iterable, dic) -> None:

Callers

nothing calls this directly

Calls 6

_check_isinstanceFunction · 0.85
assert_numpy_array_equalFunction · 0.85
raise_assert_detailFunction · 0.85
assert_attr_equalFunction · 0.85
equalsMethod · 0.45
to_denseMethod · 0.45

Tested by

no test coverage detected