
from __future__ import absolute_import

from os.path import dirname, join
import logging
import warnings


import numpy as np
import pandas as pd

from blaze import resource
log = logging.getLogger(__name__)

qty=10000
gauss = {'oneA': np.random.randn(qty),
         'oneB': np.random.randn(qty),
         'cats': np.random.randint(0,5,size=qty),
         'hundredA': np.random.randn(qty)*100,
         'hundredB': np.random.randn(qty)*100}
gauss = pd.DataFrame(gauss)

uniform = {'oneA': np.random.rand(qty),
           'oneB': np.random.rand(qty),
           'hundredA': np.random.rand(qty)*100,
           'hundredB': np.random.rand(qty)*100}
uniform = pd.DataFrame(uniform)
bivariate = {'A1': np.hstack([np.random.randn(qty/2), np.random.randn(qty/2)+1]),
             'A2': np.hstack([np.random.randn(qty/2), np.random.randn(qty/2)+2]),
             'A3': np.hstack([np.random.randn(qty/2), np.random.randn(qty/2)+3]),
             'A4': np.hstack([np.random.randn(qty/2), np.random.randn(qty/2)+4]),
             'A5': np.hstack([np.random.randn(qty/2), np.random.randn(qty/2)+5]),
             'B': np.random.randn(qty),
             'C': np.hstack([np.zeros(qty/2), np.ones(qty/2)])}
bivariate = pd.DataFrame(bivariate)
import bokeh.server.tests
path = join(dirname(bokeh.server.tests.__file__), 'data', 'AAPL.hdf5')

try:
    aapl = resource("hdfstore://%s::__data__" % path)
except Exception as e:
    aapl = None
    log.error(e)
    warnings.warn(
        "Error loading hdfstore for AAPL. Your version of Blaze is too old, or incompatible"
    )

path = join(dirname(bokeh.server.tests.__file__), 'data', 'array.hdf5')
try:
    arr = resource(path + "::" + "array")
except Exception as e:
    arr = None
    log.error(e)
    warnings.warn(
        "Error loading hdfstore for array. Your version of Blaze is too old, or incompatible"
    )

path = join(dirname(bokeh.server.tests.__file__), 'data', 'CensusTracts.hdf5')

try:
    census = resource("hdfstore://%s::__data__" % path)
except Exception as e:
    census = None
    log.error(e)
    warnings.warn(
        "Error loading hdfstore for CensusTracts. Your version of Blaze is too old, or incompatible"
    )



data = dict(uniform=uniform,
            gauss=gauss,
            bivariate=bivariate,
)
if aapl:
    data['aapl'] = aapl
if census:
    data['census'] = census
if arr:
    data['array'] = arr

@@ -1,13 +1,12 @@
-%0A
 from __futur
@@ -33,16 +33,47 @@
 import%0A%0A
+import logging%0Aimport warnings%0A
 from os.
@@ -102,40 +102,8 @@
 oin%0A
-import logging%0Aimport warnings%0A%0A
 %0Aimp
@@ -138,17 +138,16 @@
 s as pd%0A
-%0A
 from bla
@@ -165,16 +165,44 @@
 esource%0A
+%0Aimport bokeh.server.tests%0A%0A
 log = lo
@@ -238,16 +238,17 @@
 y=10000%0A
+%0A
 gauss = 
@@ -698,16 +698,17 @@
 niform)%0A
+%0A
 bivariat
@@ -1253,33 +1253,172 @@
 te)%0A
-import bokeh.server.tests
+%0AMESSAGE = %22%22%22%0A%0AError loading hdfstore for %25s.%0AYour version of Blaze is too old, or incompatible%0Aor you have missing dependencies such as h5py and/or pytables.%0A%22%22%22%0A
 %0Apat
@@ -1477,33 +1477,32 @@
 ', 'AAPL.hdf5')%0A
-%0A
 try:%0A    aapl = 
@@ -1622,106 +1622,24 @@
 arn(
-%0A        %22Error loading hdfstore for AAPL. Your version of Blaze is too old, or incompatible%22%0A    
+MESSAGE %25 %22AAPL%22
 )%0A%0Ap
@@ -1833,107 +1833,25 @@
 arn(
-%0A        %22Error loading hdfstore for array. Your version of Blaze is too old, or incompatible%22%0A    
+MESSAGE %25 %22array%22
 )%0A%0Ap
@@ -1928,17 +1928,16 @@
 .hdf5')%0A
-%0A
 try:%0A   
@@ -2069,117 +2069,33 @@
 arn(
-%0A        %22Error loading hdfstore for CensusTracts. Your version of Blaze is too old, or incompatible%22%0A    )%0A%0A
+MESSAGE %25 %22CensusTracts%22)
 %0A%0Ada
@@ -2181,11 +2181,10 @@
 iate
-,%0A
 )
+%0A
 %0Aif 

Add info in the warn message about some missing dependecies. Also some changes to make is more readable.