Package lib :: Module compat
[hide private]
[frames] | no frames]

Module compat

source code

Temporary module for allowing relax to support both Python 2 and 3.

Classes [hide private]
  Bzip2Fixed
Incredibly nasty hack for bzip2 files support in Python 3.0, 3.1 and 3.2.
  GzipFixed
Incredibly nasty hack for gzipped files support in Python 3.0, 3.1 and 3.2.
  TaskQueue
Python 2.4 and earlier Queuing class replacement.
Functions [hide private]
file object
bz2_open(file, mode='r')
Abstract the numerous ways BZ2 files are handled in Python.
source code
file object
gz_open(file, mode='r')
Abstract the numerous ways gzipped files are handled in Python.
source code
unknown
from_iterable(items)
Implementation of the itertools.chain.from_iterable() function for all Python versions.
source code
unknown
from_iterable_pre_2_6(items)
Replacement itertools.chain.from_iterable() function for Python < 2.6.
source code
 
norm(x, ord=None, axis=None)
Replacement numpy.linalg.norm() function to handle the axis argument for old numpy.
source code
unicode
u(text)
Create a unicode string for Python 2.
source code
Variables [hide private]
  bz2_module = True
  bz2_module_message = message.args [0]
  gzip_module = True
  message = sys.exc_info() [1]
  gzip_module_message = message.args [0]
  io_module = False
  IOBase = None
hash(x)
  SYSTEM = 'Linux'
  PY_VERSION = 2
  numpy_norm_axis = True
  __package__ = 'lib'

Imports: bz2, BZ2File, gzip, io, itertools, os, platform, sys, threading, builtins, queue, Queue3, Queue2, StringIO, TextTestResult, pickle, numpy, Queue, unicode_escape_decode, unicode


Function Details [hide private]

bz2_open(file, mode='r')

source code 

Abstract the numerous ways BZ2 files are handled in Python.

Parameters:
  • file (str) - The file path to open.
  • mode (str) - The mode to open the file with. Only the values of 'r' and 'w' for reading and writing respectively are supported.
Returns: file object
The bzip2 file object.

gz_open(file, mode='r')

source code 

Abstract the numerous ways gzipped files are handled in Python.

Parameters:
  • file (str) - The file path to open.
  • mode (str) - The mode to open the file with. Only the values of 'r' and 'w' for reading and writing respectively are supported.
Returns: file object
The gzipped file object.

from_iterable(items)

source code 

Implementation of the itertools.chain.from_iterable() function for all Python versions.

Parameters:
  • items (list) - The normal argument for itertools.chain.from_iterable().
Returns: unknown
The items of the list.

from_iterable_pre_2_6(items)

source code 

Replacement itertools.chain.from_iterable() function for Python < 2.6.

Parameters:
  • items (list) - The normal argument for itertools.chain.from_iterable().
Returns: unknown
The elements

norm(x, ord=None, axis=None)

source code 

Replacement numpy.linalg.norm() function to handle the axis argument for old numpy.

Parameters:
  • x (array_like) - Input array. If `axis` is None, `x` must be 1-D or 2-D.
  • ord ({non-zero int, inf, -inf, 'fro'}, optional) - Order of the norm (see table under ``Notes``). inf means numpy's `inf` object.
  • axis ({int, 2-tuple of ints, None}, optional) - If `axis` is an integer, it specifies the axis of `x` along which to compute the vector norms. If `axis` is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed. If `axis` is None then either a vector norm (when `x` is 1-D) or a matrix norm (when `x` is 2-D) is returned.

u(text)

source code 

Create a unicode string for Python 2.

Parameters:
  • text (str) - The text to convert.
Returns: unicode
The text converted to unicode.