コード例 #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