Specification and model for describing and comparing things.
Project description
Compspec Python
A compspec (Composition spec) is a specification and model for comparing things. This means that we take an abstract and simple approach to model complex systems as graphs (nodes and relaionshps) and then can compare between graphs or extract corpora (groups of facts) to use later. Compspec python, the implementation here, is intended to provide a basic Python for using compspec for your own needs.
- The Spec: read about the background, concepts, and design of the specification.
under development
Usage
The core client here is intended to be used as an API, meaning you can derive facts and relations and then run a model. It is intended for higher level libraries to use this module for custom command line parsing of specific domain-oriented entities.
Install
You can install locally
$ git clone git@github.com:compspec/compspec.git
$ cd compspec
$ pip install -e .
or from pypi:
$ pip install compspec
Examples
For full examples, try running the scripts under examples after you install compspec. More complex examples (with DWARF, etc) are coming soon.
- Creating a basic graph: (a composition)
- Calculating a Diff: (a difference between two compositions)
- Combining Graphs
- Calculating a DWARF diff: a set of more real world examples
$ python examples/basic-graph/run.py
$ python examples/basic-diff/run.py
$ python examples/combine-graphs/run.py
Additional Functionality
Given that you have a graph:
A = Graph()
for node_id, name, value in [
["id0", "func", "goodbye_world"],
["id1", "func", "hello_world"],
["id3", "parameter", "name"],
["id4", "default", "Squidward"],
]:
A.new_node(name, value, node_id)
for fromid, relation, toid in [
["id1", "has", "id3"],
["id3", "has", "id4"],
["id3", "has", "id5"],
["id1", "has", "id6"],
["id6", "has", "id7"],
]:
A.new_relation(fromid, toid, relation)
You can convert it to a dictionary:
obj = A.to_dict()
And given that loaded (e.g., from json), we can then populate a new graph!
g = Graph.from_dict(obj)
These are very simple operations to define graphs, and primarily the work is done manually to create the nodes, relations, and identifiers. It is expected that specific domains that intend to create graphs will load in some object (e.g., a binary file) and do this creation on behalf of the user.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file compspec-0.0.1.tar.gz
.
File metadata
- Download URL: compspec-0.0.1.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.8.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8b9e08ed1e1bbb212c107eb109ed8a50d6c2147b1610507f23ff7142ca6b25a |
|
MD5 | 65f295b04646368bdc36cc3e78b048d5 |
|
BLAKE2b-256 | 0fadcda4d4ab490743c29209068083f904cd7531918d85fdaf9bd1e683960977 |