Пример #1
0
def test_EncoderBase_flush0():
    '''
  Test EncoderBase.encodeValues() with some data
  '''
    encoder = EncoderBase(bufferSize=10, attDb=5.)
    encoder.bits[:2].fill(1)
    encoder.n_bits = 2
    encoded = encoder.flush()
    assert len(encoded) == 1
    assert encoder.n_bits == 0
    assert (encoder.bits == 0).all()
    assert encoded[0] == 192
Пример #2
0
def test_EncoderBase_encodeValues1():
    '''
  Test EncoderBase.encodeValues() with some data
  '''
    encoder = EncoderBase(bufferSize=10, attDb=5.)
    encoder.bits.fill(1)
    encoder.n_bits = 8
    encoded = encoder.encodeValues()
    assert len(encoded) == 1
    assert encoder.n_bits == 0
    assert (encoder.bits == 0).all()
    assert encoded[0] == 255
Пример #3
0
def test_EncoderBase_ensureExtraCapacity1():
    '''
  Test EncoderBase capacity extension
  '''
    encoder = EncoderBase(bufferSize=10, attDb=5.)
    encoder.n_bits = 5
    encoder.bits[:5].fill(1)
    encoder.ensureExtraCapacity(10)
    assert len(encoder.bits) == 15
    assert encoder.n_bits == 5
    assert (encoder.bits[:5] == 1).all()
    assert (encoder.bits[5:] == 0).all()
Пример #4
0
def test_EncoderBase_flush0():
  '''
  Test EncoderBase.encodeValues() with some data
  '''
  encoder = EncoderBase(bufferSize=10, attDb=5.)
  encoder.bits[:2].fill(1)
  encoder.n_bits = 2
  encoded = encoder.flush()
  assert len(encoded) == 1
  assert encoder.n_bits == 0
  assert (encoder.bits == 0).all()
  assert encoded[0] == 192
Пример #5
0
def test_EncoderBase_encodeValues1():
  '''
  Test EncoderBase.encodeValues() with some data
  '''
  encoder = EncoderBase(bufferSize=10, attDb=5.)
  encoder.bits.fill(1)
  encoder.n_bits = 8
  encoded = encoder.encodeValues()
  assert len(encoded) == 1
  assert encoder.n_bits == 0
  assert (encoder.bits == 0).all()
  assert encoded[0] == 255
Пример #6
0
def test_EncoderBase_ensureExtraCapacity1():
  '''
  Test EncoderBase capacity extension
  '''
  encoder = EncoderBase(bufferSize=10, attDb=5.)
  encoder.n_bits = 5
  encoder.bits[:5].fill(1)
  encoder.ensureExtraCapacity(10)
  assert len(encoder.bits) == 15
  assert encoder.n_bits == 5
  assert (encoder.bits[:5] == 1).all()
  assert (encoder.bits[5:] == 0).all()