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

Method test_delete

pandas/tests/internals/test_internals.py:284–324  ·  view source on GitHub ↗
(self, fblock)

Source from the content-addressed store, hash-verified

282 assert_block_equal(fblock, cop)
283
284 def test_delete(self, fblock):
285 newb = fblock.copy(deep=True)
286 locs = newb.mgr_locs
287 nb = newb.delete(0)[0]
288 assert newb.mgr_locs is locs
289
290 assert nb is not newb
291
292 tm.assert_numpy_array_equal(
293 nb.mgr_locs.as_array, np.array([2, 4], dtype=np.intp)
294 )
295 assert not (newb.values[0] == 1).all()
296 assert (nb.values[0] == 1).all()
297
298 newb = fblock.copy(deep=True)
299 locs = newb.mgr_locs
300 nb = newb.delete(1)
301 assert len(nb) == 2
302 assert newb.mgr_locs is locs
303
304 tm.assert_numpy_array_equal(
305 nb[0].mgr_locs.as_array, np.array([0], dtype=np.intp)
306 )
307 tm.assert_numpy_array_equal(
308 nb[1].mgr_locs.as_array, np.array([4], dtype=np.intp)
309 )
310 assert not (newb.values[1] == 2).all()
311 assert (nb[1].values[0] == 2).all()
312
313 newb = fblock.copy(deep=True)
314 nb = newb.delete(2)
315 assert len(nb) == 1
316 tm.assert_numpy_array_equal(
317 nb[0].mgr_locs.as_array, np.array([0, 2], dtype=np.intp)
318 )
319 assert (nb[0].values[1] == 1).all()
320
321 newb = fblock.copy(deep=True)
322
323 with pytest.raises(IndexError, match=None):
324 newb.delete(3)
325
326 def test_delete_datetimelike(self):
327 # dont use np.delete on values, as that will coerce from DTA/TDA to ndarray

Callers

nothing calls this directly

Calls 5

copyMethod · 0.45
deleteMethod · 0.45
arrayMethod · 0.45
allMethod · 0.45
raisesMethod · 0.45

Tested by

no test coverage detected