Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Tools around the bubble format (see https://github.com/Aluriak/PowerGrASP#bubble-formatted-file)

Project Description
# bubble-tools
python routines related to bubble format, usable in CLI or as a library.

## Installation

pip install bubbletools

See below for usage.


## TODO
- [X] bubble to python
- [ ] python to bubble
- [X] bubble to [gexf](https://gephi.org/gexf/format/)
- [ ] bubble to dot (via [graphviz](http://graphviz.readthedocs.io/en/latest/))
- [X] working implementation
- [ ] unit testing
- [X] test on fully valid bubble
- [ ] test on big graphs, for benchmarking (will probably not scale)
- [ ] dot to python
- [ ] unit testing on bubble describing cliques


## CLI
`bubble-tools` is usable through CLI.

### validation
usage:

python3 bubble-tool.py validate path/to/bubble/file

Try hard to find errors and inconsistancies in the given bubble file

Spot powernode overlapping, inclusions inconsistancies
and empty or singleton powernodes.
Profiling gives general informations about the file data.

### conversion to dot
usage:

python3 bubble-tool.py dot path/to/bubble/file path/to/output/file

Convert given bubble file in dot format.
The optional `--render` flag can be used to show the graph after saving.


## python API
Submodules `validator` and `converter` provides the functionnalities described above for CLI:

from bubbletools import validate, convert

for log in validate(open('path/to/bubble.lp'), profiling=True):
print(log)
convert.to_dot(open('path/to/bubble.lp'), dotfile='path/to/dot.dot')

### python representation of the graph
A lower level interface is the `BubbleTree` object, allowing one to manipulate the graph depicted by bubble data as python object.
See [unit tests](bubbletools/test/test_bbltree.py) for example of `BubbleTree` usage.

from bubbletools import BubbleTree

tree = BubbleTree.from_bubble_file('path/to/bubble.lp')
print(tree.edges, tree.inclusions, tree.roots)

`edges` is a mapping `predecessor -> set of successors`,
`inclusions` is a mapping `(power)node -> set of (power)nodes directly contained`,
and `roots` is a set of (power)nodes that are contained by nothing.

This representation holds all the data necessary for most work on the bubble.
The `BubbleTree.connected_components` function maps a graph with its connected components:

cc, subroots = BubbleTree.connected_components()

Where `cc` and `subroots` are both mappings, respectively linking *the* root of a connected component with all nodes of the connected component,
and *the* root of a connected component with the other roots of the same connected component.
Thus, connected components are identified by one of their roots, which is key is both dictionaries.


### access powernodes and their data
Follow an example of `BubbleTree` usage, retrieving data on powernodes:

tree = BubbleTree.from_bubble_file('bubbles/basic.bbl')
for pnode in tree.powernodes:
data = tree.powernode_data(pnode)
print(
"{} contains nodes {{{}}}, and powernodes {{{}}}."
"".format(pnode, data.contained_nodes, data.contained_pnodes)
)

Release History

Release History

This version
History Node

0.5.3

History Node

0.5.2

History Node

0.5.1

History Node

0.5.0

History Node

0.4.1

History Node

0.4.0

History Node

0.3.1

History Node

0.3.0

History Node

0.2.1

History Node

0.2.0

History Node

0.1.4

History Node

0.1.3

Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
bubbletools-0.5.3.tar.gz (12.3 kB) Copy SHA256 Checksum SHA256 Source Jun 21, 2017

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting