Skip to content

A python implementation of the Quine McCluskey algorithm.

License

Notifications You must be signed in to change notification settings

tomas789/quine-mccluskey-tomas789

 
 

Repository files navigation

qm.py

build

A Python implementation of the Quine McCluskey algorithm.

This implementation of the Quine McCluskey algorithm has no inherent limits (other than the calculation time) on the size of the inputs.

Also, in the limited tests of the author of this module, this implementation is considerably faster than other public Python implementations for non-trivial inputs.

Another unique feature of this implementation is the possibility to use the XOR and XNOR operators, in addition to the normal AND operator, to minimise the terms. This slows down the algorithm, but in some cases the result can be much more compact than a sum of product.

Installation

The recommanded way of installing this package is by using pip

python3 -m pip install quine-mccluskey-tomas789

Note that on Windows you might need to use the py command instead.

py -m pip install quine-mccluskey-tomas789

There are some othere means of installing the package which are recommanded only in specific cases.

Development build

python3 -m pip install -e .

Build wheel files locally

Make sure you have the latest version of PyPA's build installed:

python3 -m pip install --upgrade build

Now run this command from the same directory where pyproject.toml is located:

python3 -m build

This command should output a lot of text and once completed should generate two files in the dist directory:

dist/
├── quine_mccluskey_tomas789-1.0-py2.py3-none-any.whl
└── quine_mccluskey_tomas789-1.0.tar.gz

Wheel file can then be distributed via your own means and installed using pip

python3 -m pip install dist/quine_mccluskey_tomas789-1.0-py2.py3-none-any.whl

Running tests

Unit tests

The library comes with a basic set of unit tests. They can be executed using pytest

pytest

Fuzz testing

We also have a fuzz testing. It generates random formulas, simplifies them and checks that the result is correct.

➜  quine-mccluskey-tomas789 git:(main) python fuzz.py   
Checked 24300 formulas and found 0 errors.
Checked 48400 formulas and found 0 errors.
Checked 72300 formulas and found 0 errors.
Checked 96300 formulas and found 0 errors.
Testing formulas ... ⠋ 0:00:44

About

A python implementation of the Quine McCluskey algorithm.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C++ 54.3%
  • Python 44.1%
  • CMake 1.6%