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

Function test_head_tail

pandas/tests/copy_view/test_methods.py:723–738  ·  view source on GitHub ↗
(method)

Source from the content-addressed store, hash-verified

721 ],
722)
723def test_head_tail(method):
724 df = DataFrame({"a": [1, 2, 3], "b": [0.1, 0.2, 0.3]})
725 df_orig = df.copy()
726 df2 = method(df)
727 df2._mgr._verify_integrity()
728
729 # We are explicitly deviating for CoW here to make an eager copy (avoids
730 # tracking references for very cheap ops)
731 assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))
732 assert not np.shares_memory(get_array(df2, "b"), get_array(df, "b"))
733
734 # modify df2 to trigger CoW for that block
735 df2.iloc[0, 0] = 0
736 assert not np.shares_memory(get_array(df2, "b"), get_array(df, "b"))
737 assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))
738 tm.assert_frame_equal(df, df_orig)
739
740
741def test_infer_objects(using_infer_string):

Callers

nothing calls this directly

Calls 5

DataFrameClass · 0.90
get_arrayFunction · 0.90
methodFunction · 0.50
copyMethod · 0.45
_verify_integrityMethod · 0.45

Tested by

no test coverage detected