# Path: commpy/utilities.py
# def dec2bitarray(in_number, bit_width):
#     """
#     Converts a positive integer or an array-like of positive integers to NumPy array of the specified size containing
#     bits (0 and 1).
# 
#     Parameters
#     ----------
#     in_number : int or array-like of int
#         Positive integer to be converted to a bit array.
# 
#     bit_width : int
#         Size of the output bit array.
# 
#     Returns
#     -------
#     bitarray : 1D ndarray of numpy.int8
#         Array containing the binary representation of all the input decimal(s).
# 
#     """
# 
#     if isinstance(in_number, (np.integer, int)):
#         return decimal2bitarray(in_number, bit_width).copy()
#     result = np.zeros(bit_width * len(in_number), np.int8)
#     for pox, number in enumerate(in_number):
#         result[pox * bit_width:(pox + 1) * bit_width] = decimal2bitarray(number, bit_width).copy()
#     return result


from numpy import array
from numpy.testing import run_module_suite, assert_array_equal
from commpy.utilities import dec2bitarray
# Authors: CommPy contributors
# License: BSD 3-Clause




def test_dec2bitarray():
    # Assert result
    assert_array_equal(dec2bitarray(17, 8), array((0, 0, 0, 1, 0, 0, 0, 1)))
    assert_array_equal(dec2bitarray((17, 12), 5), array((1, 0, 0, 0, 1, 0, 1, 1, 0, 0)))


if __name__ == "__main__":

# Path: commpy/utilities.py
# def dec2bitarray(in_number, bit_width):
#     """
#     Converts a positive integer or an array-like of positive integers to NumPy array of the specified size containing
#     bits (0 and 1).
# 
#     Parameters
#     ----------
#     in_number : int or array-like of int
#         Positive integer to be converted to a bit array.
# 
#     bit_width : int
#         Size of the output bit array.
# 
#     Returns
#     -------
#     bitarray : 1D ndarray of numpy.int8
#         Array containing the binary representation of all the input decimal(s).
# 
#     """
# 
#     if isinstance(in_number, (np.integer, int)):
#         return decimal2bitarray(in_number, bit_width).copy()
#     result = np.zeros(bit_width * len(in_number), np.int8)
#     for pox, number in enumerate(in_number):
#         result[pox * bit_width:(pox + 1) * bit_width] = decimal2bitarray(number, bit_width).copy()
#     return result


# Path: commpy/tests/test_utilities.py
from numpy import array
from numpy.testing import run_module_suite, assert_array_equal
from commpy.utilities import dec2bitarray

# Authors: CommPy contributors
# License: BSD 3-Clause




def test_dec2bitarray():
    # Assert result
    assert_array_equal(dec2bitarray(17, 8), array((0, 0, 0, 1, 0, 0, 0, 1)))
    assert_array_equal(dec2bitarray((17, 12), 5), array((1, 0, 0, 0, 1, 0, 1, 1, 0, 0)))


if __name__ == "__main__":

    run_module_suite()