Top-level variables and functions

Global variables

tables.__version__ = '3.10.1'

str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str

Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.

tables.hdf5_version = '1.10.7'

The underlying HDF5 library version number.

Added in version 3.0.

Global functions

tables.copy_file(srcfilename: str, dstfilename: str, overwrite: bool = False, **kwargs) None[source]

An easy way of copying one PyTables file to another.

This function allows you to copy an existing PyTables file named srcfilename to another file called dstfilename. The source file must exist and be readable. The destination file can be overwritten in place if existing by asserting the overwrite argument.

This function is a shorthand for the File.copy_file() method, which acts on an already opened file. kwargs takes keyword arguments used to customize the copying process. See the documentation of File.copy_file() for a description of those arguments.

tables.is_hdf5_file(filename)

Determine whether a file is in the HDF5 format.

When successful, it returns a true value if the file is an HDF5 file, false otherwise. If there were problems identifying the file, an HDF5ExtError is raised.

tables.is_pytables_file(filename)

Determine whether a file is in the PyTables format.

When successful, it returns the format version string if the file is a PyTables file, None otherwise. If there were problems identifying the file, an HDF5ExtError is raised.

tables.open_file(filename: str, mode: Literal['r', 'w', 'a', 'r+'] = 'r', title: str = '', root_uep: str = '/', filters: Filters | None = None, **kwargs) File[source]

Open a PyTables (or generic HDF5) file and return a File object.

Parameters:
  • filename (str) – The name of the file (supports environment variable expansion). It is suggested that file names have any of the .h5, .hdf or .hdf5 extensions, although this is not mandatory.

  • mode (str) –

    The mode to open the file. It can be one of the following:

    • ’r’: Read-only; no data can be modified.

    • ’w’: Write; a new file is created (an existing file with the same name would be deleted).

    • ’a’: Append; an existing file is opened for reading and writing, and if the file does not exist it is created.

    • ’r+’: It is similar to ‘a’, but the file must already exist.

  • title (str) – If the file is to be created, a TITLE string attribute will be set on the root group with the given value. Otherwise, the title will be read from disk, and this will not have any effect.

  • root_uep (str) –

    The root User Entry Point. This is a group in the HDF5 hierarchy which will be taken as the starting point to create the object tree. It can be whatever existing group in the file, named by its HDF5 path. If it does not exist, an HDF5ExtError is issued. Use this if you do not want to build the entire object tree, but rather only a subtree of it.

    Changed in version 3.0: The rootUEP parameter has been renamed into root_uep.

  • filters (Filters) – An instance of the Filters (see The Filters class) class that provides information about the desired I/O filters applicable to the leaves that hang directly from the root group, unless other filter properties are specified for these leaves. Besides, if you do not specify filter properties for child groups, they will inherit these ones, which will in turn propagate to child nodes.

Notes

In addition, it recognizes the (lowercase) names of parameters present in tables/parameters.py as additional keyword arguments. See PyTables parameter files for a detailed info on the supported parameters.

Note

If you need to deal with a large number of nodes in an efficient way, please see Getting the most from the node LRU cache for more info and advices about the integrated node cache engine.

tables.set_blosc_max_threads(nthreads)

Set the maximum number of threads that Blosc can use.

This actually overrides the tables.parameters.MAX_BLOSC_THREADS setting in tables.parameters, so the new value will be effective until this function is called again or a new file with a different tables.parameters.MAX_BLOSC_THREADS value is specified.

Returns the previous setting for maximum threads.

tables.set_blosc2_max_threads(nthreads)

Set the maximum number of threads that Blosc2 can use.

This actually overrides the tables.parameters.MAX_BLOSC_THREADS setting in tables.parameters, so the new value will be effective until this function is called again or a new file with a different tables.parameters.MAX_BLOSC_THREADS value is specified.

Returns the previous setting for maximum threads.

tables.print_versions()[source]

Print all the versions of software that PyTables relies on.

tables.restrict_flavors(keep: Sequence[Literal['numpy', 'python']] = ('python',)) None[source]

Disable all flavors except those in keep.

Providing an empty keep sequence implies disabling all flavors (but the internal one). If the sequence is not specified, only optional flavors are disabled.

Important

Once you disable a flavor, it can not be enabled again.

tables.split_type(type: str) tuple[str, int | None][source]

Split a PyTables type into a PyTables kind and an item size.

Returns a tuple of (kind, itemsize). If no item size is present in the type (in the form of a precision), the returned item size is None:

>>> split_type('int32')
('int', 4)
>>> split_type('string')
('string', None)
>>> split_type('int20')
Traceback (most recent call last):
...
ValueError: precision must be a multiple of 8: 20
>>> split_type('foo bar')
Traceback (most recent call last):
...
ValueError: malformed type: 'foo bar'
tables.test(verbose=False, heavy=False)[source]

Run all the tests in the test suite.

If verbose is set, the test suite will emit messages with full verbosity (not recommended unless you are looking into a certain problem).

If heavy is set, the test suite will be run in heavy mode (you should be careful with this because it can take a lot of time and resources from your computer).

Return 0 (os.EX_OK) if all tests pass, 1 in case of failure

tables.which_lib_version(name)

Get version information about a C library.

If the library indicated by name is available, this function returns a 3-tuple containing the major library version as an integer, its full version as a string, and the version date as a string. If the library is not available, None is returned.

The currently supported library names are hdf5, zlib, lzo, bzip2, and blosc. If another name is given, a ValueError is raised.

tables.silence_hdf5_messages(silence=True)

Silence (or re-enable) messages from the HDF5 C library.

The silence parameter can be used control the behaviour and reset the standard HDF5 logging.

Added in version 2.4.