Package: metatable
Extensible table data structure that supports the introduction of user-defined workflow combinators and the use of these combinators in concise workflow descriptions.Installation and UsageThis library is available as apackage on PyPI:python -m pip install metatableThe library can be imported in the usual ways:import metatable
from metatable import *ExamplesThis library makes it possible to work with tabular data that is represented as a list of lists (i.e., each row is a list of column values and a table is a list of rows):>>> from metatable import *
>>> t = metatable([['a', 0], ['b', 1], ['c', 2]])
>>> list(iter(t))
[['a', 0], ['b', 1], ['c', 2]]All rows in ametatableinstance can be updated in-place using a symbolic representation (implemented using thesymbolismlibrary) of the transformation that must be applied to each row. For example, the transformation{1: column(0)}indicates that the value in the column having index1(i.e., the right-hand column) should be replaced with the value in the column having index0(i.e., the left-hand column):>>> t.update({1: column(0)})
[['a', 'a'], ['b', 'b'], ['c', 'c']]It is also possible to perform an update that removes rows based on a condition. The condition in the example below is the symbolic expressioncolumn(1) > symbol(0)(constructed using thesymbolismlibrary):>>> from symbolism import symbol
>>> t = metatable([['a', 0], ['b', 1], ['c', 2]])
>>> t.update_filter({0: column(1)}, column(1) > symbol(0))
[[1, 1], [2, 2]]There is also support for working with a tabular data set in which there is a header row containing column names:>>> t = metatable([['char', 'num'], ['a', 0], ['b', 1]], header=True)
>>> t.update({1: column(0)})
[['char', 'num'], ['a', 'a'], ['b', 'b']]DevelopmentAll installation and development dependencies are fully specified inpyproject.toml. Theproject.optional-dependenciesobject is used tospecify optional requirementsfor various development tasks. This makes it possible to specify additional options (such asdocs,lint, and so on) when performing installation usingpip:python -m pip install .[docs,lint]DocumentationThe documentation can be generated automatically from the source files usingSphinx:python -m pip install .[docs]
cd docs
sphinx-apidoc -f -E --templatedir=_templates -o _source .. && make htmlTesting and ConventionsAll unit tests are executed and their coverage is measured when usingpytest(see thepyproject.tomlfile for configuration details):python -m pip install .[test]
python -m pytestAlternatively, all unit tests are included in the module itself and can be executed usingdoctest:python src/metatable/metatable.py -vStyle conventions are enforced usingPylint:python -m pip install .[lint]
python -m pylint src/metatableContributionsIn order to contribute to the source code, open an issue or submit a pull request on theGitHub pagefor this library.VersioningThe version number format for this library and the changes to the library associated with version number increments conform withSemantic Versioning 2.0.0.PublishingThis library can be published as apackage on PyPIby a package maintainer. First, install the dependencies required for packaging and publishing:python -m pip install .[publish]Ensure that the correct version number appears inpyproject.toml, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has anautomation rulethat activates and sets as the default all tagged versions. Create and push a tag for this version (replacing?.?.?with the version number):git tag ?.?.?
git push origin ?.?.?Remove any old build/distribution files. Then, package the source into a distribution archive:rm -rf build dist src/*.egg-info
python -m build --sdist --wheel .Finally, upload the package distribution archive toPyPI:python -m twine upload dist/*