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

Class MEGICodec



Codec --+
        |
       MEGICodec


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

  for each integer:
  d-leading zeros     = each zero means one add one to the bit width
  ?-bits for integer  = width of integer equal to sum of leading 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.
 
hash2idx(self, h)
 
idx2hash(self, i)
 
encodeL(self, data, logM=None, 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=MEGICodec()
>>> set(S.keys())==G.decode(G(S))
1
Otherwise, a dictionary is returned.
>>> G=MEGICodec(counts=True)
>>> G.decode(G(S))==S
1
Overrides: Codec.__init__

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

 
Overrides: Codec.encodeL

decodeI(self, iter)

 
Overrides: Codec.decodeI