Skip to main content

Consensus mechanism for Truthcoin

Project description

https://travis-ci.org/tensorjack/pyconsensus.svg?branch=master https://coveralls.io/repos/tensorjack/pyconsensus/badge.png

pyconsensus is a Python implementation of the Truthcoin consensus mechanism, originally invented by Paul Sztorc: https://github.com/psztorc/Truthcoin.

Installation

The easiest way to install pyconsensus is using pip:

$ pip install pyconsensus

To upgrade your pyconsensus installation, use:

$ pip install --upgrade --no-deps pyconsensus

Usage

To use pyconsensus, import the Oracle class:

from pyconsensus import Oracle

# Example vote matrix:
#   - each row represents a voter
#   - each column represents a decision in a prediction market
my_votes = [[1, 1, 0, 0],
            [1, 0, 0, 0],
            [1, 1, 0, 0],
            [1, 1, 1, 0],
            [0, 0, 1, 1],
            [0, 0, 1, 1]]
my_decision_bounds = [
    {"scaled": True, "min": 0.1, "max": 0.5},
    {"scaled": True, "min": 0.2, "max": 0.7},
    {"scaled": False, "min": 0, "max": 1},
    {"scaled": False, "min": 0, "max": 1},
]

oracle = Oracle(votes=my_votes, decision_bounds=my_decision_bounds)
oracle.consensus()

Tests

Unit tests are in the test/ directory.

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

pyconsensus-0.1.5.tar.gz (21.5 kB view details)

Uploaded Source

File details

Details for the file pyconsensus-0.1.5.tar.gz.

File metadata

  • Download URL: pyconsensus-0.1.5.tar.gz
  • Upload date:
  • Size: 21.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyconsensus-0.1.5.tar.gz
Algorithm Hash digest
SHA256 7bbd704c87d76279735e34b130959c05952d01ced9fbdf6994284f16415cdfc6
MD5 1bc1e1a77c04f942cfde6904a04abce5
BLAKE2b-256 f946bfc95ae0e1f270aefd63e44a16aafa5ebce1346f9e15c89b16922a74b975

See more details on using hashes here.

Supported by

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