Commit bbf0dd98 authored by Nathan/Eilisha Shiraini's avatar Nathan/Eilisha Shiraini
Browse files

Docs of the Builder module

parent 75259556
......@@ -17,9 +17,47 @@ from . import sizes
from . import positions
class AztecBuilder(object):
"""
Aztec Code builder class
This class is tasked with organizing all the building algorithm,
from the building blocks defined in all the other packages.
"""
@staticmethod
def prepareData(data, forceLayers = None, forceCompact = None):
"""
Turns raw input data into the actual data that will be put in the code
This method takes the input data as a Python string or bytes string
and turns it into the list of bits that corresponds to the actual data
that needs to be layed out on the code grid.
Parameters
----------
data
The data to encode, as a Unicode string (that will be encoded to UTF-8),
a :py:class:`bytes` string or :py:class:`bytearray`,
or an object that will be turned into a string via the :py:func:`str` function.
forceLayers: :py:class:`int` or :py:const:`None`
Set to an integer to force a given number of layers on the code
forceCompact: :py:class:`bool` or :py:const:`None`
Set to a boolean to for the use of a compact (:py:const:`True`)
or full (:py:const:`False`) Aztec code
Returns
-------
:py:class:`list` of :py:class:`bool`
The full list of bits that needs to be arranged on the code matrix
:py:class:`int`
The number of layers that must be used when arranging the data
:py:class:`bool`
:py:const:`True` if the compact arrangement must be used, :py:const:`False` otherwise
:py:class:`tuple` of :py:class:`int`
A 2-tuple of integers, the fisrt elements is the number of data words,
the second is the number of error-correction code words.
"""
encoded = encoder.Encoder().encode(data, asBits = True)
if isinstance(forceLayers, int):
wordsize = sizes.WORD_SIZE_FOR_LAYERS[forceLayers]
......@@ -59,6 +97,40 @@ class AztecBuilder(object):
@staticmethod
def prepareDataMatrix(data, layers, compact, wordcount):
"""
Arranges the data on the code matrix
This method generates a 2 dimensional Numpy boolean array the contains the data,
arranged according to the final Aztec code.
This method does not gnerate the mode message and reference grid however.
Parameters
----------
data: :py:class:`list` of :py:class:`bool`
The data prepared to be arranged on the code grid,
that is after stuffing, padding and error-correction
layers: :py:class:`int`
The number of layers that must be used when arranging the data
compact: :py:class:`bool`
:py:const:`True` if the compact arrangement must be used, :py:const:`False` otherwise
wordcount: :py:class:`tuple` of :py:class:`int`
A 2-tuple of integers, the fisrt elements is the number of data words,
the second is the number of error-correction code words (passed through)
Returns
-------
:py:class:`numpy.ndarray`
The full list of bits that needs to be arranged on the code matrix
:py:class:`int`
The number of layers that must be used when arranging the data
:py:class:`bool`
:py:const:`True` if the compact arrangement must be used, :py:const:`False` otherwise
:py:class:`tuple` of :py:class:`int`
A 2-tuple of integers, the fisrt elements is the number of data words,
the second is the number of error-correction code words
(passed through from the wordcount parameter)
"""
size = positions.matrixSize(layers, compact)
result = np.zeros((size, size), dtype=np.bool8)
if compact:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment