예제 #1
0
def test_BandTwoBitsEncoder_addSamples1():
    '''
  Test dual bit encoder samples adding and conversion
  '''
    encoder = BandTwoBitsEncoder(0)
    samples = numpy.ndarray((1, 2), dtype=numpy.float)
    samples[0][1::2].fill(-1.)
    samples[0][0::2].fill(1.)
    converted = encoder.addSamples(samples)
    assert len(converted) == 0
    assert converted.dtype == numpy.uint8
    assert encoder.n_bits == 4
예제 #2
0
def test_BandTwoBitsEncoder_addSamples1():
  '''
  Test dual bit encoder samples adding and conversion
  '''
  encoder = BandTwoBitsEncoder(0)
  samples = numpy.ndarray((1, 2), dtype=numpy.float)
  samples[0][1::2].fill(-1.)
  samples[0][0::2].fill(1.)
  converted = encoder.addSamples(samples)
  assert len(converted) == 0
  assert converted.dtype == numpy.uint8
  assert encoder.n_bits == 4
예제 #3
0
def test_BandTwoBitsEncoder_addSamples0():
    '''
  Test dual bit encoder samples adding and conversion
  '''
    encoder = BandTwoBitsEncoder(0)
    samples = numpy.ndarray((1, EncoderBase.BLOCK_SIZE + 3), dtype=numpy.float)
    samples[0][1::2].fill(-1.)
    samples[0][0::2].fill(1.)
    converted = encoder.addSamples(samples)
    assert len(converted) == len(samples[0]) / 4
    assert converted.dtype == numpy.uint8
    assert (converted == 0x88).all()
    converted = encoder.flush()
    assert len(converted) == 1
    assert converted.dtype == numpy.uint8
    assert converted[0] == 0x88
예제 #4
0
def test_BandTwoBitsEncoder_addSamples0():
  '''
  Test dual bit encoder samples adding and conversion
  '''
  encoder = BandTwoBitsEncoder(0)
  samples = numpy.ndarray((1, EncoderBase.BLOCK_SIZE + 3), dtype=numpy.float)
  samples[0][1::2].fill(-1.)
  samples[0][0::2].fill(1.)
  converted = encoder.addSamples(samples)
  assert len(converted) == len(samples[0]) / 4
  assert converted.dtype == numpy.uint8
  assert (converted == 0x88).all()
  converted = encoder.flush()
  assert len(converted) == 1
  assert converted.dtype == numpy.uint8
  assert converted[0] == 0x88