def test_iget(self): cols = Index(list("abc")) values = np.random.rand(3, 3) block = make_block(values=values.copy(), placement=np.arange(3)) mgr = BlockManager(blocks=[block], axes=[cols, np.arange(3)]) tm.assert_almost_equal(mgr.iget(0).internal_values(), values[0]) tm.assert_almost_equal(mgr.iget(1).internal_values(), values[1]) tm.assert_almost_equal(mgr.iget(2).internal_values(), values[2])
def test_iget(self): cols = Index(list("abc")) values = np.random.rand(3, 3) block = new_block( values=values.copy(), placement=np.arange(3, dtype=np.intp), ndim=values.ndim, ) mgr = BlockManager(blocks=(block, ), axes=[cols, Index(np.arange(3))]) tm.assert_almost_equal(mgr.iget(0).internal_values(), values[0]) tm.assert_almost_equal(mgr.iget(1).internal_values(), values[1]) tm.assert_almost_equal(mgr.iget(2).internal_values(), values[2])
def test_duplicate_ref_loc_failure(self): tmp_mgr = create_mgr('a:bool; a: f8') axes, blocks = tmp_mgr.axes, tmp_mgr.blocks blocks[0].mgr_locs = np.array([0]) blocks[1].mgr_locs = np.array([0]) # test trying to create block manager with overlapping ref locs self.assertRaises(AssertionError, BlockManager, blocks, axes) blocks[0].mgr_locs = np.array([0]) blocks[1].mgr_locs = np.array([1]) mgr = BlockManager(blocks, axes) mgr.iget(1)
def test_duplicate_ref_loc_failure(self): tmp_mgr = create_mgr("a:bool; a: f8") axes, blocks = tmp_mgr.axes, tmp_mgr.blocks blocks[0].mgr_locs = np.array([0]) blocks[1].mgr_locs = np.array([0]) # test trying to create block manager with overlapping ref locs msg = "Gaps in blk ref_locs" with pytest.raises(AssertionError, match=msg): BlockManager(blocks, axes) blocks[0].mgr_locs = np.array([0]) blocks[1].mgr_locs = np.array([1]) mgr = BlockManager(blocks, axes) mgr.iget(1)