Skip to main content

TSorted lets you sort your data topologically, such as for dependency resolution or task management.

Project description

TSorted

Test status Code coverage PyPI releases Supported Python versions Recent downloads

TSorted lets you sort your data topologically, such as for dependency resolution or task management.

Usage

Before sorting your data, transform it into a Directed Acyclic Graph (DAG). Graph dictionary keys are the (hashable) starting vertices, and their values are sets of destination vertices, defining unidirectional edges.

A standard topological sort:

from tsorted import tsorted
graph = {
    1: {2, 3},
    2: {4},
    4: {3},
}
tsorted(graph)
# >>> OrderedSet([1, 2, 4, 3])

A grouped topological sort:

from tsorted import tsorted_grouped
graph = {
    1: {2, 3},
    2: {4},
    3: {4},
}
tsorted_grouped(graph)
# >>> OrderedSet([frozenset({1}), frozenset({2, 3}), frozenset({4})])

Development

First, fork and clone the repository, and navigate to its root directory.

Requirements

  • Bash (you're all good if which bash outputs a path in your terminal)

Installation

If you have tox installed on your machine, tox --develop will create the necessary virtual environments and install all development dependencies.

Alternatively, in any existing Python environment, run ./bin/build-dev.

Testing

In any existing Python environment, run ./bin/test.

Fixing problems automatically

In any existing Python environment, run ./bin/fix.

Contributions 🥳

TSorted is Free and Open Source Software. As such you are welcome to report bugs or submit improvements.

Copyright & license

TSorted is copyright Bart Feenstra and contributors, and released under the MIT License. In short, that means you are free to use TSorted, but if you distribute TSorted yourself, you must do so under the exact same license and provide that license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tsorted-0.1.0.tar.gz (4.6 kB view hashes)

Uploaded Source

Built Distribution

tsorted-0.1.0-py2.py3-none-any.whl (6.6 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page