From 68953ed938235ddb3d7400c7b7717b822c2c7391 Mon Sep 17 00:00:00 2001 From: jreback Date: Sun, 19 May 2013 13:18:54 -0400 Subject: [PATCH] TST: fixup 32-bit failing tests PTF --- pandas/core/format.py | 4 +--- pandas/core/internals.py | 13 ++++++++----- pandas/tests/test_frame.py | 5 +++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pandas/core/format.py b/pandas/core/format.py index cd4364edc6662..3d38caa84492f 100644 --- a/pandas/core/format.py +++ b/pandas/core/format.py @@ -778,8 +778,6 @@ def __init__(self, obj, path_or_buf, sep=",", na_rep='', float_format=None, tupleize_cols=True): self.engine = engine # remove for 0.12 - - obj._consolidate_inplace() self.obj = obj self.path_or_buf = path_or_buf @@ -835,7 +833,7 @@ def __init__(self, obj, path_or_buf, sep=",", na_rep='', float_format=None, self.blocks = self.obj._data.blocks ncols = sum(len(b.items) for b in self.blocks) self.data =[None] * ncols - self.column_map = self.obj._data.get_items_map() + self.column_map = self.obj._data.get_items_map(use_cached=False) if chunksize is None: chunksize = (100000/ (len(self.cols) or 1)) or 1 diff --git a/pandas/core/internals.py b/pandas/core/internals.py index 849776940512e..ca04bd3fe26e0 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -1130,17 +1130,20 @@ def maybe_create_block(block): # when we recreate the block manager if needed return getattr(self,'_ref_locs',None) - def get_items_map(self): + def get_items_map(self, use_cached=True): """ return an inverted ref_loc map for an item index block -> item (in that block) location -> column location + + use_cached : boolean, use the cached items map, or recreate """ # cache check - im = getattr(self,'_items_map',None) - if im is not None: - return im - + if use_cached: + im = getattr(self,'_items_map',None) + if im is not None: + return im + im = dict() rl = self._set_ref_locs() diff --git a/pandas/tests/test_frame.py b/pandas/tests/test_frame.py index 413c39a330ad2..50bddb6ecd85c 100644 --- a/pandas/tests/test_frame.py +++ b/pandas/tests/test_frame.py @@ -4942,7 +4942,7 @@ def test_to_csv_no_index(self): df.to_csv(path, index=False) result = read_csv(path) assert_frame_equal(df,result) - df['c3'] = [7,8,9] + df['c3'] = Series([7,8,9],dtype='int64') df.to_csv(path, index=False) result = read_csv(path) assert_frame_equal(df,result) @@ -5000,7 +5000,8 @@ def _make_frame(names=None): columns=MultiIndex.from_tuples([('bah', 'foo'), ('bah', 'bar'), ('ban', 'baz')], - names=names)) + names=names), + dtype='int64') # column & index are multi-index df = mkdf(5,3,r_idx_nlevels=2,c_idx_nlevels=4)