Repository: pandas-dev/pandas

Issue:
fragile test on travis, test_pytables:TestHDFStore.test_append_with_data_columns
Same commit passed/failed:

https://travis-ci.org/y-p/pandas/builds/5559816
https://travis-ci.org/pydata/pandas/builds/5558843



Discussion:
first time I have seen this fail
I will add something

closed by #3120

another one? https://travis-ci.org/pydata/pandas/jobs/5720626

@y-p I saw this...the test looks fine, only thing I can think is that somehow a failure of writing to disk wasn't caught (in that particular moment).....if it comes up again I can revist

fine, travis is not the most stable environment for sure.

I think there's a real issue with that test:
https://travis-ci.org/pydata/pandas/jobs/5940176
https://travis-ci.org/y-p/pandas/jobs/5873084


Resolving patch:
diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py
--- a/pandas/io/pytables.py
+++ b/pandas/io/pytables.py
@@ -453,18 +453,24 @@ def select_as_multiple(self, keys, where=None, selector=None, columns=None, star
         tbls = [ self.get_storer(k) for k in keys ]
 
         # validate rows
-        if tbls[0] is None:
-            raise Exception("no valid tables to select as multiple")
-        nrows = tbls[0].nrows
-        for t in tbls:
-            if t.nrows != nrows:
-                raise ValueError("all tables must have exactly the same nrows!")
+        nrows = None
+        for t, k in zip(tbls, keys):
+            if t is None:
+                raise TypeError("Invalid table [%s]" % k)
             if not t.is_table:
                 raise TypeError("object [%s] is not a table, and cannot be used in all select as multiple" % t.pathname)
 
+            if nrows is None:
+                nrows = t.nrows
+            elif t.nrows != nrows:
+                raise ValueError("all tables must have exactly the same nrows!")
+
         # select coordinates from the selector table
-        c = self.select_as_coordinates(selector, where, start=start, stop=stop)
-        nrows = len(c)
+        try:
+            c = self.select_as_coordinates(selector, where, start=start, stop=stop)
+            nrows = len(c)
+        except (Exception), detail:
+            raise ValueError("invalid selector [%s]" % selector)
 
         def func(_start, _stop):
 


Test patch:
diff --git a/pandas/io/tests/test_pytables.py b/pandas/io/tests/test_pytables.py
--- a/pandas/io/tests/test_pytables.py
+++ b/pandas/io/tests/test_pytables.py
@@ -15,6 +15,8 @@
 from pandas.tests.test_frame import assert_frame_equal
 from pandas import concat, Timestamp
 
+from numpy.testing.decorators import slow
+
 try:
     import tables
 except ImportError:
@@ -2177,6 +2179,12 @@ def test_select_as_multiple(self):
                               None, where=['A>0', 'B>0'], selector='df1')
             self.assertRaises(Exception, store.select_as_multiple,
                               [None], where=['A>0', 'B>0'], selector='df1')
+            self.assertRaises(TypeError, store.select_as_multiple,
+                              ['df1','df3'], where=['A>0', 'B>0'], selector='df1')
+            self.assertRaises(KeyError, store.select_as_multiple,
+                              ['df3'], where=['A>0', 'B>0'], selector='df1')
+            self.assertRaises(ValueError, store.select_as_multiple,
+                              ['df1','df2'], where=['A>0', 'B>0'], selector='df4')
             
             # default select
             result = store.select('df1', ['A>0', 'B>0'])
@@ -2195,12 +2203,19 @@ def test_select_as_multiple(self):
             tm.assert_frame_equal(result, expected)
             
             # multiple (diff selector)
-            result = store.select_as_multiple(['df1', 'df2'], where=[Term(
-                        'index', '>', df2.index[4])], selector='df2')
-            expected = concat([df1, df2], axis=1)
-            expected = expected[5:]
-            tm.assert_frame_equal(result, expected)
-            
+            try:
+                result = store.select_as_multiple(['df1', 'df2'], where=[Term(
+                            'index', '>', df2.index[4])], selector='df2')
+                expected = concat([df1, df2], axis=1)
+                expected = expected[5:]
+                tm.assert_frame_equal(result, expected)
+            except (Exception), detail:
+                print "error in select_as_multiple %s" % str(detail)
+                print "store: ", store
+                print "df1: ", df1
+                print "df2: ", df2
+
+
             # test excpection for diff rows
             store.append('df3', tm.makeTimeDataFrame(nper=50))
             self.assertRaises(ValueError, store.select_as_multiple,