From 0036036c8045d059ba61bf1a64627d6f40edbca7 Mon Sep 17 00:00:00 2001 From: jreback Date: Tue, 6 Aug 2013 21:02:28 -0400 Subject: [PATCH] TST: reverse hdf_fix --- pandas/io/pytables.py | 5 +++-- pandas/io/tests/test_pytables.py | 16 +++------------- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 9034007be2f6e..4295139965f81 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -332,11 +332,12 @@ def __len__(self): def __unicode__(self): output = '%s\nFile path: %s\n' % (type(self), pprint_thing(self._path)) if self.is_open: - if len(list(self.keys())): + lkeys = list(self.keys()) + if len(lkeys): keys = [] values = [] - for k in self.keys(): + for k in lkeys: try: s = self.get_storer(k) if s is not None: diff --git a/pandas/io/tests/test_pytables.py b/pandas/io/tests/test_pytables.py index 4ccbbb7e18cb2..43b77ec7bdd82 100644 --- a/pandas/io/tests/test_pytables.py +++ b/pandas/io/tests/test_pytables.py @@ -11,7 +11,7 @@ import pandas from pandas import (Series, DataFrame, Panel, MultiIndex, bdate_range, - date_range, Index, DatetimeIndex) + date_range, Index, DatetimeIndex, isnull) from pandas.io.pytables import (HDFStore, get_store, Term, read_hdf, IncompatibilityWarning, PerformanceWarning, AttributeConflictWarning, DuplicateWarning, @@ -2404,14 +2404,11 @@ def test_frame_select(self): def test_string_select(self): # GH 2973 - - df = tm.makeTimeDataFrame() - with ensure_clean(self.path) as store: + df = tm.makeTimeDataFrame() # test string ==/!= - df['x'] = 'none' df.ix[2:7,'x'] = '' @@ -2421,25 +2418,18 @@ def test_string_select(self): expected = df[df.x == 'none'] assert_frame_equal(result,expected) - print("bogus test") - print(df) - print(store) result = store.select('df',Term('x!=none')) - print(result) expected = df[df.x != 'none'] - print(expected) assert_frame_equal(result,expected) df2 = df.copy() - df2.x[df2.x==''] = np.nan + df2.loc[df2.x=='','x'] = np.nan - from pandas import isnull store.append('df2',df2,data_columns=['x']) result = store.select('df2',Term('x!=none')) expected = df2[isnull(df2.x)] assert_frame_equal(result,expected) - # int ==/!= df['int'] = 1 df.ix[2:7,'int'] = 2