def test_TwoBandsBitEncoder_init():
    '''
  Test single bit two band encoder constructor
  '''
    encoder = TwoBandsBitEncoder(0, 1)
    assert encoder.l1Index == 0
    assert encoder.l2Index == 1
    encoder = TwoBandsBitEncoder(1, 0)
    assert encoder.l1Index == 1
    assert encoder.l2Index == 0
def test_TwoBandsBitEncoder_addSamples1():
    '''
  Test single bit encoder samples adding and conversion
  '''
    encoder = TwoBandsBitEncoder(0, 1)
    samples = numpy.ndarray((2, 2), dtype=numpy.float)
    samples[0].fill(-1.)
    samples[1].fill(1.)
    converted = encoder.addSamples(samples)
    assert len(converted) == 0
    assert converted.dtype == numpy.uint8
    assert encoder.n_bits == 4
def test_TwoBandsBitEncoder_addSamples1():
  '''
  Test single bit encoder samples adding and conversion
  '''
  encoder = TwoBandsBitEncoder(0, 1)
  samples = numpy.ndarray((2, 2), dtype=numpy.float)
  samples[0].fill(-1.)
  samples[1].fill(1.)
  converted = encoder.addSamples(samples)
  assert len(converted) == 0
  assert converted.dtype == numpy.uint8
  assert encoder.n_bits == 4
def test_TwoBandsBitEncoder_addSamples0():
    '''
  Test single bit encoder samples adding and conversion
  '''
    encoder = TwoBandsBitEncoder(0, 1)
    samples = numpy.ndarray((2, EncoderBase.BLOCK_SIZE + 2), dtype=numpy.float)
    samples[0].fill(-1.)
    samples[1].fill(1.)
    converted = encoder.addSamples(samples)
    assert len(converted) == len(samples[0]) / 4
    assert converted.dtype == numpy.uint8
    assert (converted == 0xAA).all()
    converted = encoder.flush()
    assert len(converted) == 1
    assert converted.dtype == numpy.uint8
    assert converted[0] == 0xA0
def test_TwoBandsBitEncoder_addSamples0():
  '''
  Test single bit encoder samples adding and conversion
  '''
  encoder = TwoBandsBitEncoder(0, 1)
  samples = numpy.ndarray((2, EncoderBase.BLOCK_SIZE + 2), dtype=numpy.float)
  samples[0].fill(-1.)
  samples[1].fill(1.)
  converted = encoder.addSamples(samples)
  assert len(converted) == len(samples[0]) / 4
  assert converted.dtype == numpy.uint8
  assert (converted == 0xAA).all()
  converted = encoder.flush()
  assert len(converted) == 1
  assert converted.dtype == numpy.uint8
  assert converted[0] == 0xA0