Package CHEM :: Package datatype :: Module compress :: Class MEGRCodec
[hide private]
[frames] | no frames]

Class MEGRCodec



Codec --+
        |
       MEGRCodec


MEG vector encoding zero runs.

FORMAT:
  C_Alpha code        = len(Ns)
  1-bit flag          = counts? (T/F)=(1/0)
  C_Alpha code        = sum(counts) (optional)

  for each integer:
  0unary encoded scal increase  = each zero means one add one to the bit width
  ?-bits for integer            = width of integer equal to sum of unary zeros seen so far + 1
  C_Alpha code                   = counts(optiona)



Instance Methods [hide private]
 
__init__(self, counts=False)
if counts=False, then only the keys are stored, and returned as a set.
 
encodeL(self, data, counts=None, info={})
 
decodeI(self, iter)
 
iter_decode(self, iter)

Inherited from Codec: __call__, decode, finger

Method Details [hide private]

__init__(self, counts=False)
(Constructor)

 
>>> S=RandomDict(200,N=600)
>>> Ss=[RandomDict(200,N=600) for x in xrange(100)]
if counts=False, then only the keys are stored, and returned as a set.
>>> G=MEGRCodec()
>>> set(S.keys())==G.decode(G(S))
1
Otherwise, a dictionary is returned.
>>> G=MEGRCodec(counts=True)
>>> G.decode(G(S))==S
1
Overrides: Codec.__init__

encodeL(self, data, counts=None, info={})

 
Overrides: Codec.encodeL

decodeI(self, iter)

 
Overrides: Codec.decodeI