All Projects → welchbj → Tt

welchbj / Tt

Licence: mit
a Pythonic toolkit for working with Boolean expressions

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tt

Metamorph
Morphing mod for Minecraft 1.12.2
Stars: ✭ 52 (-74.76%)
Mutual labels:  transformations
Filestack React
Official React component for Filestack - API and content management system that makes it easy to add powerful file uploading and transformation capabilities to any web or mobile application.
Stars: ✭ 131 (-36.41%)
Mutual labels:  transformations
Transmogrifai
TransmogrifAI (pronounced trăns-mŏgˈrə-fī) is an AutoML library for building modular, reusable, strongly typed machine learning workflows on Apache Spark with minimal hand-tuning
Stars: ✭ 2,084 (+911.65%)
Mutual labels:  transformations
Stetl
Stetl, Streaming ETL, is a lightweight geospatial processing and ETL framework written in Python.
Stars: ✭ 64 (-68.93%)
Mutual labels:  transformations
Hm
Idiomatic Ruby hash transformations
Stars: ✭ 121 (-41.26%)
Mutual labels:  transformations
Bull
BULL - Bean Utils Light Library
Stars: ✭ 150 (-27.18%)
Mutual labels:  transformations
Easyflipviewpager
📖 The library for creating book and card flip animations in ViewPager in Android
Stars: ✭ 698 (+238.83%)
Mutual labels:  transformations
Kazaam
Arbitrary transformations of JSON in Golang
Stars: ✭ 184 (-10.68%)
Mutual labels:  transformations
Easyreact
Are you confused by the functors, applicatives, and monads in RxSwift and ReactiveCocoa? It doesn't matter, the concepts are so complicated that not many developers actually use them in normal projects. Is there an easy-to-use way to use reactive programming? EasyReact is born for this reason.
Stars: ✭ 1,616 (+684.47%)
Mutual labels:  transformations
Elm Geometry
2D/3D geometry package for Elm
Stars: ✭ 162 (-21.36%)
Mutual labels:  transformations
Osom
An Awesome [/osom/] Object Data Modeling (Database Agnostic).
Stars: ✭ 68 (-66.99%)
Mutual labels:  transformations
Serverless Sharp
Serverless image optimizer for S3, Lambda, and Cloudfront
Stars: ✭ 102 (-50.49%)
Mutual labels:  transformations
Tracks
Programming with shapes
Stars: ✭ 151 (-26.7%)
Mutual labels:  transformations
Optimus
🤖 Id obfuscation based on Knuth's multiplicative hashing method for PHP.
Stars: ✭ 1,084 (+426.21%)
Mutual labels:  transformations
Scramjet
Simple yet powerful live data computation framework
Stars: ✭ 171 (-16.99%)
Mutual labels:  transformations
Map Factory
A simple utility to map data from an existing object to a new one.
Stars: ✭ 30 (-85.44%)
Mutual labels:  transformations
Pytransform3d
3D transformations for Python
Stars: ✭ 133 (-35.44%)
Mutual labels:  transformations
Robopy
Robopy is a python port for Robotics Toolbox in Matlab created by Peter Corke
Stars: ✭ 186 (-9.71%)
Mutual labels:  transformations
Transform
A polyglot web converter.
Stars: ✭ 2,842 (+1279.61%)
Mutual labels:  transformations
Remixautoml
R package for automation of machine learning, forecasting, feature engineering, model evaluation, model interpretation, data generation, and recommenders.
Stars: ✭ 159 (-22.82%)
Mutual labels:  transformations

|pypi| |pyversions| |docs| |nixbuild| |winbuild|

Synopsis

tt (t\ ruth t\ able) is a library aiming to provide a Pythonic toolkit for working with Boolean expressions and truth tables. Please see the project site_ for guides and documentation, or check out bool.tools_ for a simple web application powered by this library.

Installation

tt is tested on CPython 3.6, 3.7, and 3.8. You can get the latest release from PyPI with::

pip install ttable

Features

Parse expressions::

>>> from tt import BooleanExpression
>>> b = BooleanExpression('A impl not (B nand C)')
>>> b.tokens
['A', 'impl', 'not', '(', 'B', 'nand', 'C', ')']
>>> print(b.tree)
impl
`----A
`----not
     `----nand
          `----B
          `----C

Evaluate expressions::

>>> b = BooleanExpression('(A /\ B) -> (C \/ D)')
>>> b.evaluate(A=1, B=1, C=0, D=0)
False
>>> b.evaluate(A=1, B=1, C=1, D=0)
True

Interact with expression structure::

>>> b = BooleanExpression('(A and ~B and C) or (~C and D) or E')
>>> b.is_dnf
True
>>> for clause in b.iter_dnf_clauses():
...     print(clause)
...
A and ~B and C
~C and D
E

Apply expression transformations::

>>> from tt import to_primitives, to_cnf
>>> to_primitives('A xor B')
<BooleanExpression "(A and not B) or (not A and B)">
>>> to_cnf('(A nand B) impl (C or D)')
<BooleanExpression "(A or C or D) and (B or C or D)">

Or create your own::

>>> from tt import tt_compose, apply_de_morgans, coalesce_negations, twice
>>> b = BooleanExpression('not (not (A or B))')
>>> f = tt_compose(apply_de_morgans, twice)
>>> f(b)
<BooleanExpression "not not A or not not B">
>>> g = tt_compose(f, coalesce_negations)
>>> g(b)
<BooleanExpression "A or B">

Exhaust SAT solutions::

>>> b = BooleanExpression('~(A or B) xor C')
>>> for sat_solution in b.sat_all():
...     print(sat_solution)
...
A=0, B=1, C=1
A=1, B=0, C=1
A=1, B=1, C=1
A=0, B=0, C=0

Find just a few::

>>> with b.constrain(A=1):
...     for sat_solution in b.sat_all():
...         print(sat_solution)
...
A=1, B=0, C=1
A=1, B=1, C=1

Or just one::

>>> b.sat_one()
<BooleanValues [A=0, B=1, C=1]>

Build truth tables::

>>> from tt import TruthTable
>>> t = TruthTable('A iff B')
>>> print(t)
+---+---+---+
| A | B |   |
+---+---+---+
| 0 | 0 | 1 |
+---+---+---+
| 0 | 1 | 0 |
+---+---+---+
| 1 | 0 | 0 |
+---+---+---+
| 1 | 1 | 1 |
+---+---+---+

And much more_!

License

tt uses the MIT License_.

.. _MIT License: https://opensource.org/licenses/MIT .. _project site: https://tt.brianwel.ch .. _bool.tools: http://www.bool.tools .. _much more: https://tt.brianwel.ch/en/stable/user_guide.html

.. |pypi| image:: https://img.shields.io/pypi/v/ttable.svg?style=flat-square&label=pypi :target: https://pypi.python.org/pypi/ttable :alt: tt's PyPI page

.. |pyversions| image:: https://img.shields.io/pypi/pyversions/ttable.svg?style=flat-square :target: https://pypi.python.org/pypi/ttable :alt: tt runs on Python 3.6, 3.7, and 3.8

.. |docs| image:: https://img.shields.io/badge/docs-latest-c944ff.svg?style=flat-square :target: https://tt.brianwel.ch/en/latest/ :alt: tt documentation site

.. |nixbuild| image:: https://img.shields.io/travis/welchbj/tt/develop.svg?style=flat-square&label=linux%20build :target: https://travis-ci.org/welchbj/tt :alt: Linux build on Travis CI

.. |winbuild| image:: https://img.shields.io/appveyor/ci/welchbj/tt/develop.svg?style=flat-square&label=windows%20build :target: https://ci.appveyor.com/project/welchbj/tt :alt: Windows build on AppVeyor

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].