def _is_fromfile_compatible(stream):
 if (sys.version_info[0] < 3):
  return True
 bad_cls = []
 try:
  import gzip
  bad_cls.append(gzip.GzipFile)
 except ImportError:
  pass
 try:
  import bz2
  bad_cls.append(bz2.BZ2File)
 except ImportError:
  pass
 bad_cls = tuple(bad_cls)
 return (not isinstance(stream, bad_cls))

def _is_fromfile_compatible ( stream ) : if ( sys . version_info [ 0 ] < 3 ) : return True bad_cls = [ ] try : import gzip bad_cls . append ( gzip . GzipFile ) except ImportError : pass try : import bz2 bad_cls . append ( bz2 . BZ2File ) except ImportError : pass bad_cls = tuple ( bad_cls ) return ( not isinstance ( stream , bad_cls ) )
check whether stream is compatible with numpy .