Metadata-Version: 2.1
Name: PyDigital
Version: 1.1.0
Summary: A python package intended for visualizing digital data line coding, generating parity bits and detecting errors in parity encoded binary data
Author-email: Sanjay S <sanjusuresh2001@gmail.com>, Prathish K V <prathishvijayakumar@gmail.com>
Project-URL: Repository, https://github.com/RapidCompiler/pydigital
Project-URL: Bug Tracker, https://github.com/RapidCompiler/pydigital/issues
Project-URL: Documentation, http://pydigital-docs.readthedocs.io/
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE

# PyDigital

[![PyPI version](https://badge.fury.io/py/)](https://badge.fury.io/py/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/Django.svg)](https://pypi.org/project//)
[![PyPI - Status](https://img.shields.io/pypi/status/Django.svg)](https://pypi.org/project//)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://.mit-license.org/)

This python package __PyDigital__ provides visual representations of digital data line coding 📈 as well as generation of parity bits 🔢 and error detection for binary data.

The package can be used to prototype and visualize digital data transmission using the various line coding plots and the parity encoding and decoding functionalities.

If you like the package, feel free to 🌟 the repo and contribute to it! Also find us on Twitter [@PyDigital](https://twitter.com/).

## Installation

Install using `pip` with the command

```sh
$ pip install pydigital
```

## Usage
### Line Coding

```python
from pydigital import LineCoding

lc = LineCoding()

# Plots differential manchester line coding for the binary string
lc.diffmanchester('10010110')
```

> ❗ All line coding methods accept parameters in the form of strings, and arrays/tuples of integers/strings.

Different line coding techniques are available, all of which are listed below. 

| Method | Return Type |
| :---   | :---        |
|`unipolar_nrz (binary_string_literal)` | Plots input binary data in Unipolar NRZ |
|`unipolar_rz (binary_string_literal)` | Plots input binary data in Unipolar RZ |
|`polar_nrz (binary_string_literal)` | Plots input binary data in Polar NRZ |
|`polar_nrzl (binary_string_literal)` | Plots input binary data in Polar NRZL |
|`polar_nrzi (binary_string_literal)` | Plots input binary data in Polar NRZI |
|`polar_rz (binary_string_literal)` | Plots input binary data in Polar RZ |
|`bipolar_nrz (binary_string_literal)` | Plots input binary data in Bipolar NRZ |
|`bipolar_rz (binary_string_literal)` | Plots input binary data in Bipolar RZ |
|`pseudoternary (binary_string_literal)` | Plots input binary data in Pseudoternary |
|`manchester_ieee (binary_string_literal)` | Plots input binary data in IEEE Manchester |
|`manchester_gethomas (binary_string_literal)` | Plots input binary data in G.E.Thomas Manchester |
|`diffmanchester (binary_string_literal)` | Plots input binary data in Differential Manchester |


### Parity Encoding and Decoding

```python
from pydigital import ParityEncDec

pr = ParityEncDec()

vrc = pr.encode_vrc(['10110', '10100'])
print("VRC :", vrc[0])
print("DATA TRANSMITTED :", vrc[1])
# VRC : 10
# DATA TRANSMITTED : 101101 101000
        
vrc = pr.decode_vrc('101101 101000', 5, 2, 2)
print(vrc)
# THE DATA TRANSMITTED IS CORRECT
```
> ❗ Binary data are passed as string literals. Spaces are optional.

Encoding and decoding methods for four different types of parity techniques are given below.

|Method | Return Type|
| :---  | :---|
|`encode_lrc ([binary_string_literals])`| Array [LRC Bits, LRC Encoded Data]|
|`encode_vrc ([binary_string_literals])`| Array [VRC Bits, VRC Encoded Data]|
|`encode_crc (binary_string_literal, crc_key_string_literal)`| Array [CRC Bits, CRC Encoded Data]|
|`encode_checksum ([binary_string_literals])`| Array [Checksum Bits, Checksum Encoded Data]|
|`decode_lrc (binary_string_literal, bits_per_data_string, number_of_data_strings, return_type)`| Boolean, Decoded Data, or Text |
|`decode_vrc (binary_string_literal, bits_per_data_string, number_of_data_strings, return_type)`| Boolean, Decoded Data, or Text |
|`decode_crc (binary_string_literal, crc_key_string_literal, return_type)`| Boolean, Decoded Data, or Text |
|`decode_checksum (binary_string_literal, bits_per_data_string, number_of_data_strings, return_type)`| Boolean, Decoded Data, or Text |

## Development

To contribute to the package, first clone the repository and `cd` into it.
```sh
$ git clone https://github.com/RapidCompiler/pydigital.git
$ cd pydigital
```

Make changes inside the `pydigital` folder located in the `src` directory. You can then test this functionality either by creating a test file and importing the methods into it or by installing the package on your computer.

Create a virtual environment and activate it before you install the package locally.

```sh
$ python -m virtualenv env
$ env\Scripts\activate
$ pip install .
```
Run the `pip install .` command in the main project directory.

This project does not have a `setup.py` file and hence cannot be installed in the editable mode.
## Issues

You can report bugs and suggest improvements on this repository's [issue tracker](https://github.com/rapidcompiler/pydigital/issues)

## License
Designed and published with ♥ by Prathish K V ([@prathishkv](https://github.com/prathishkv)) and Sanjay S ([@rapidcompiler](https://github.com/rapidcompiler)) under MIT License[]()
