Python Simple decision table procesor
=====================================
.. image:: https://github.com/matkapi/pysidetap/workflows/ci/badge.svg?branch=main
:target: https://github.com/matkapi/pysidetap/actions?workflow=ci
:alt: CI
.. image:: https://codecov.io/gh/matkapi/pysidetap/branch/main/graph/badge.svg
:target: https://codecov.io/gh/matkapi/pysidetap
:alt: Codecov
.. image:: https://api.codeclimate.com/v1/badges/d96cc9a1841a819cd4f5/maintainability
:target: https://codeclimate.com/github/matkapi/pysidetap/maintainability
:alt: Maintainability
.. image:: https://img.shields.io/codeclimate/tech-debt/matkapi/pysidetap
:target: https://codeclimate.com/github/matkapi/pysidetap
:alt: Code Climate technical debt
.. image:: https://img.shields.io/readthedocs/pysidetap/latest?label=Read%20the%20Docs
:target: https://pysidetap.readthedocs.io/en/latest/index.html
:alt: Read the Docs
.. image:: https://badge.fury.io/py/pysidetap.svg
:target: https://badge.fury.io/py/pysidetap
:alt: PyPi
Install
-------
pysidetap is available on PyPI `pypi-pysidetap`_ and you can install it using pip:
```sh
pip install pysidetap
```
Summary
-------
Simple Decision Table Processor
https://en.wikipedia.org/wiki/Decision_table
This function find and return field 'return' from Decision Table,
when all operands in row by 'fields' are True.
Example:
--------
This example show use case off Traffic lights decisions.
https://en.wikipedia.org/wiki/Traffic_light#Meanings_of_signals
Decision Table:
+-------+----------+---------+--------+
| red | yellow | green | return |
+=======+==========+=========+========+
| ==on | ==off | ==off | stop |
+-------+----------+---------+--------+
| ==on | ==on | ==off | ready |
+-------+----------+---------+--------+
| ==off | ==off | ==on | go |
+-------+----------+---------+--------+
| ==off | ==on | ==off | break |
+-------+----------+---------+--------+
| ==off | ==off | ==off | off |
+-------+----------+---------+--------+
.. code-block:: python
from pysidetap.processor import DTProcessor
DTableTL = [
{
'fields': {
'red': {'op':'==', 'value':'on'},
'yellow': {'op':'==', 'value':'off'},
'green': {'op':'==', 'value':'off'},
},
# Traffic may not proceed beyond the stop line or
# otherwise enter the intersection
'return': {'stop'}
},
{
'fields': {
'red': {'op':'==', 'value':'on'},
'yellow': {'op':'==', 'value':'on'},
'green': {'op':'==', 'value':'off'},
},
# The signal is about to change, but the red light rules do apply
'return': {'ready'}
},
{
'fields': {
'red': {'op':'==', 'value':'off'},
'yellow': {'op':'==', 'value':'off'},
'green': {'op':'==', 'value':'on'},
},
# Traffic may not pass the stop line or enter the intersection
# unless it cannot safely stop when the light shows
'return': {'go'}
},
{
'fields': {
'red': {'op':'==', 'value':'off'},
'yellow': {'op':'==', 'value':'on'},
'green': {'op':'==', 'value':'off'},
},
# Traffic may proceed unless it would not clear the intersection
# before the next change of phase
'return': {'break'}
},
{
'fields': {
'red': {'op':'==', 'value':'off'},
'yellow': {'op':'==', 'value':'off'},
'green': {'op':'==', 'value':'off'},
},
# Traffic lights is off
'return': {'off'}
},
]
p = DTProcessor(DTableTL)
for red in ['on','off']:
for yellow in ['on','off']:
for green in ['on','off']:
result = p.process({'red':red, 'yellow':yellow, 'green':green})
print(f'red: {red}, yellow: {yellow}, green: {green}, result:{result}')
Issues and Discussions
----------------------
As usual for any GitHub-based project, raise an `issue`_ if you find any bug or
want to suggest an improvement, or open a `discussion`_ if you want to discuss
or chat :wink:
Version
-------
v0.0.8
.. _GitHub Actions: https://github.com/features/actions
.. _PyPI: https://pypi.org
.. _discussion: https://github.com/matkapi/pysidetap/discussions
.. _documentation: https://pysidetap.readthedocs.io/
.. _even for scientific software: https://github.com/MolSSI/cookiecutter-cms
.. _hypothesis: https://hypothesis.readthedocs.io/en/latest/
.. _ionel: https://github.com/ionelmc
.. _issue: https://github.com/matkapi/pysidetap/issues
.. _latest branch: https://github.com/matkapi/pysidetap/tree/latest
.. _master branch: https://github.com/matkapi/pysidetap/tree/master
.. _pdb-tools: https://github.com/haddocking/pdb-tools/blob/2a070bbacee9d6608b44bb6d2f749beefd6a7690/.github/workflows/bump-version-on-push.yml
.. _project's documentation: https://pysidetap.readthedocs.io/en/latest/index.html
.. _pytest: https://docs.pytest.org/en/stable/
.. _python-nameless: https://github.com/ionelmc/python-nameless
.. _structlog: https://github.com/hynek/structlog
.. _test.pypi.org: https://test.pypi.org
.. _tox-gh-actions: https://github.com/ymyzk/tox-gh-actions
.. _tox: https://tox.readthedocs.io/en/latest/
.. _ReadTheDocs: https://readthedocs.org/
.. _pypi-pysidetap: https://pypi.org/project/pysidetap/
Changelog
=========
v0.0.8 (2023-12-22)
------------------------------------------------------------
v0.0.7 (2023-12-22)
------------------------------------------------------------
v0.0.6 (2023-12-22)
------------------------------------------------------------
v0.0.5 (2023-12-22)
------------------------------------------------------------
v0.0.4 (2023-01-08)
------------------------------------------------------------
* documentation update
* added traffic lights example
v0.0.3 (2023-01-05)
------------------------------------------------------------
* documentation update
v0.0.2 (2023-01-05)
------------------------------------------------------------
* First release on PyPI.
v0.1.0 (2023-01-05)
-------------------
Raw data
{
"_id": null,
"home_page": "https://github.com/matkapi/pysidetap",
"name": "pysidetap",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7, <4",
"maintainer_email": "",
"keywords": "decision-table",
"author": "Martin Kapinos",
"author_email": "matkapi19@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/61/40/5aec147e357db7c90f56aea3cc657825194605496412855b81e6c1ffcce6/pysidetap-0.0.8.tar.gz",
"platform": null,
"description": "Python Simple decision table procesor\n=====================================\n\n.. image:: https://github.com/matkapi/pysidetap/workflows/ci/badge.svg?branch=main\n :target: https://github.com/matkapi/pysidetap/actions?workflow=ci\n :alt: CI\n\n.. image:: https://codecov.io/gh/matkapi/pysidetap/branch/main/graph/badge.svg\n :target: https://codecov.io/gh/matkapi/pysidetap\n :alt: Codecov\n\n.. image:: https://api.codeclimate.com/v1/badges/d96cc9a1841a819cd4f5/maintainability\n :target: https://codeclimate.com/github/matkapi/pysidetap/maintainability\n :alt: Maintainability\n\n.. image:: https://img.shields.io/codeclimate/tech-debt/matkapi/pysidetap\n :target: https://codeclimate.com/github/matkapi/pysidetap\n :alt: Code Climate technical debt\n\n.. image:: https://img.shields.io/readthedocs/pysidetap/latest?label=Read%20the%20Docs\n :target: https://pysidetap.readthedocs.io/en/latest/index.html\n :alt: Read the Docs\n\n.. image:: https://badge.fury.io/py/pysidetap.svg\n :target: https://badge.fury.io/py/pysidetap\n :alt: PyPi\n\nInstall\n-------\n\npysidetap is available on PyPI `pypi-pysidetap`_ and you can install it using pip:\n\n```sh\npip install pysidetap\n```\n\nSummary\n-------\n\nSimple Decision Table Processor\n\nhttps://en.wikipedia.org/wiki/Decision_table\n\nThis function find and return field 'return' from Decision Table,\n when all operands in row by 'fields' are True.\n\nExample:\n--------\nThis example show use case off Traffic lights decisions.\n\nhttps://en.wikipedia.org/wiki/Traffic_light#Meanings_of_signals\n\nDecision Table:\n\n+-------+----------+---------+--------+\n| red | yellow | green | return |\n+=======+==========+=========+========+\n| ==on | ==off | ==off | stop |\n+-------+----------+---------+--------+\n| ==on | ==on | ==off | ready |\n+-------+----------+---------+--------+\n| ==off | ==off | ==on | go |\n+-------+----------+---------+--------+\n| ==off | ==on | ==off | break |\n+-------+----------+---------+--------+\n| ==off | ==off | ==off | off |\n+-------+----------+---------+--------+\n\n.. code-block:: python\n\n from pysidetap.processor import DTProcessor\n\n DTableTL = [\n {\n 'fields': {\n 'red': {'op':'==', 'value':'on'},\n 'yellow': {'op':'==', 'value':'off'},\n 'green': {'op':'==', 'value':'off'},\n },\n # Traffic may not proceed beyond the stop line or \n # otherwise enter the intersection\n 'return': {'stop'} \n },\n {\n 'fields': {\n 'red': {'op':'==', 'value':'on'},\n 'yellow': {'op':'==', 'value':'on'},\n 'green': {'op':'==', 'value':'off'},\n },\n # The signal is about to change, but the red light rules do apply\n 'return': {'ready'} \n },\n {\n 'fields': {\n 'red': {'op':'==', 'value':'off'},\n 'yellow': {'op':'==', 'value':'off'},\n 'green': {'op':'==', 'value':'on'},\n },\n # Traffic may not pass the stop line or enter the intersection \n # unless it cannot safely stop when the light shows\n 'return': {'go'} \n },\n {\n 'fields': {\n 'red': {'op':'==', 'value':'off'},\n 'yellow': {'op':'==', 'value':'on'},\n 'green': {'op':'==', 'value':'off'},\n },\n # Traffic may proceed unless it would not clear the intersection\n # before the next change of phase\n 'return': {'break'}\n },\n {\n 'fields': {\n 'red': {'op':'==', 'value':'off'},\n 'yellow': {'op':'==', 'value':'off'},\n 'green': {'op':'==', 'value':'off'},\n },\n # Traffic lights is off\n 'return': {'off'} \n },\n ]\n\n p = DTProcessor(DTableTL)\n for red in ['on','off']:\n for yellow in ['on','off']:\n for green in ['on','off']:\n result = p.process({'red':red, 'yellow':yellow, 'green':green})\n print(f'red: {red}, yellow: {yellow}, green: {green}, result:{result}')\n\n\nIssues and Discussions\n----------------------\n\nAs usual for any GitHub-based project, raise an `issue`_ if you find any bug or\nwant to suggest an improvement, or open a `discussion`_ if you want to discuss\nor chat :wink:\n\nVersion\n-------\n\nv0.0.8\n\n.. _GitHub Actions: https://github.com/features/actions\n.. _PyPI: https://pypi.org\n.. _discussion: https://github.com/matkapi/pysidetap/discussions\n.. _documentation: https://pysidetap.readthedocs.io/\n.. _even for scientific software: https://github.com/MolSSI/cookiecutter-cms\n.. _hypothesis: https://hypothesis.readthedocs.io/en/latest/\n.. _ionel: https://github.com/ionelmc\n.. _issue: https://github.com/matkapi/pysidetap/issues\n.. _latest branch: https://github.com/matkapi/pysidetap/tree/latest\n.. _master branch: https://github.com/matkapi/pysidetap/tree/master\n.. _pdb-tools: https://github.com/haddocking/pdb-tools/blob/2a070bbacee9d6608b44bb6d2f749beefd6a7690/.github/workflows/bump-version-on-push.yml\n.. _project's documentation: https://pysidetap.readthedocs.io/en/latest/index.html\n.. _pytest: https://docs.pytest.org/en/stable/\n.. _python-nameless: https://github.com/ionelmc/python-nameless\n.. _structlog: https://github.com/hynek/structlog\n.. _test.pypi.org: https://test.pypi.org\n.. _tox-gh-actions: https://github.com/ymyzk/tox-gh-actions\n.. _tox: https://tox.readthedocs.io/en/latest/\n.. _ReadTheDocs: https://readthedocs.org/\n.. _pypi-pysidetap: https://pypi.org/project/pysidetap/\n\n\nChangelog\n=========\n\nv0.0.8 (2023-12-22)\n------------------------------------------------------------\n\nv0.0.7 (2023-12-22)\n------------------------------------------------------------\n\nv0.0.6 (2023-12-22)\n------------------------------------------------------------\n\nv0.0.5 (2023-12-22)\n------------------------------------------------------------\n\nv0.0.4 (2023-01-08)\n------------------------------------------------------------\n\n* documentation update\n* added traffic lights example\n\nv0.0.3 (2023-01-05)\n------------------------------------------------------------\n\n* documentation update\n\nv0.0.2 (2023-01-05)\n------------------------------------------------------------\n\n* First release on PyPI.\n\nv0.1.0 (2023-01-05)\n-------------------\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "A skeleton template for Python projects.",
"version": "0.0.8",
"project_urls": {
"Changelog": "https://github.com/matkapi/pysidetap/blob/master/CHANGELOG.rst",
"Discussion Forum": "https://github.com/matkapi/pysidetap/discussions",
"Documentation": "https://pysidetap.readthedocs.io/en/latest/",
"Homepage": "https://github.com/matkapi/pysidetap",
"Issue Tracker": "https://github.com/matkapi/pysidetap/issues",
"webpage": "https://github.com/matkapi/pysidetap"
},
"split_keywords": [
"decision-table"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3e814434d3cb7e52c9232caa283a8424a9732254ae599336a6a68a5e9e3b144d",
"md5": "5cc766c99cfa98555839210823c496fb",
"sha256": "d2cca82a1e13e292e7f3b96394fde7d379f70321e0f6c7f2756c51174942e1bd"
},
"downloads": -1,
"filename": "pysidetap-0.0.8-py3-none-any.whl",
"has_sig": false,
"md5_digest": "5cc766c99cfa98555839210823c496fb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7, <4",
"size": 6350,
"upload_time": "2023-12-22T17:45:58",
"upload_time_iso_8601": "2023-12-22T17:45:58.858438Z",
"url": "https://files.pythonhosted.org/packages/3e/81/4434d3cb7e52c9232caa283a8424a9732254ae599336a6a68a5e9e3b144d/pysidetap-0.0.8-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "61405aec147e357db7c90f56aea3cc657825194605496412855b81e6c1ffcce6",
"md5": "c47958621805c6c2e8c645005acfbe5e",
"sha256": "7cb503bee9ebf7148d0f64fe842035a83661e09adf5e54aa46d4bab43c38befa"
},
"downloads": -1,
"filename": "pysidetap-0.0.8.tar.gz",
"has_sig": false,
"md5_digest": "c47958621805c6c2e8c645005acfbe5e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7, <4",
"size": 22380,
"upload_time": "2023-12-22T17:46:00",
"upload_time_iso_8601": "2023-12-22T17:46:00.766044Z",
"url": "https://files.pythonhosted.org/packages/61/40/5aec147e357db7c90f56aea3cc657825194605496412855b81e6c1ffcce6/pysidetap-0.0.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-22 17:46:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "matkapi",
"github_project": "pysidetap",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"requirements": [],
"tox": true,
"lcname": "pysidetap"
}