Esempio n. 1
0
def test_FourBandsTwoBitsEncoder_addSamples1():
    '''
  Test single bit encoder samples adding and conversion
  '''
    encoder = FourBandsTwoBitsEncoder(0, 1, 0, 1)
    samples = numpy.ndarray((2, 1), 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 == 8
Esempio n. 2
0
def test_FourBandsTwoBitsEncoder_addSamples1():
  '''
  Test single bit encoder samples adding and conversion
  '''
  encoder = FourBandsTwoBitsEncoder(0, 1, 0, 1)
  samples = numpy.ndarray((2, 1), 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 == 8
Esempio n. 3
0
def test_FourBandsTwoBitsEncoder_init():
    '''
  Test dual bit four band encoder constructor
  '''
    encoder = FourBandsTwoBitsEncoder(0, 1, 2, 3)
    assert encoder.bandIndexes[0] == 0
    assert encoder.bandIndexes[1] == 1
    assert encoder.bandIndexes[2] == 2
    assert encoder.bandIndexes[3] == 3
    encoder = FourBandsTwoBitsEncoder(3, 2, 1, 0)
    assert encoder.bandIndexes[0] == 3
    assert encoder.bandIndexes[1] == 2
    assert encoder.bandIndexes[2] == 1
    assert encoder.bandIndexes[3] == 0
Esempio n. 4
0
def test_FourBandsTwoBitsEncoder_addSamples0():
    '''
  Test dual bit encoder samples adding and conversion
  '''
    encoder = FourBandsTwoBitsEncoder(0, 1, 0, 1)
    samples = numpy.ndarray((2, EncoderBase.BLOCK_SIZE + 1), dtype=numpy.float)
    samples[0].fill(-1.)
    samples[1].fill(1.)
    converted = encoder.addSamples(samples)
    assert len(converted) == len(samples[0])
    assert converted.dtype == numpy.uint8
    assert (converted == 0x22).all()
    converted = encoder.flush()
    assert len(converted) == 0
    assert converted.dtype == numpy.uint8
Esempio n. 5
0
def test_FourBandsTwoBitsEncoder_addSamples0():
  '''
  Test dual bit encoder samples adding and conversion
  '''
  encoder = FourBandsTwoBitsEncoder(0, 1, 0, 1)
  samples = numpy.ndarray((2, EncoderBase.BLOCK_SIZE + 1), dtype=numpy.float)
  samples[0].fill(-1.)
  samples[1].fill(1.)
  converted = encoder.addSamples(samples)
  assert len(converted) == len(samples[0])
  assert converted.dtype == numpy.uint8
  assert (converted == 0x22).all()
  converted = encoder.flush()
  assert len(converted) == 0
  assert converted.dtype == numpy.uint8