Пример #1
0
    def pprint(self):
        '''
        Prints the data stream to the screen in a human-readable format.
        '''
        time = decode_array(self.dstream1)
        flux = decode_array(self.dstream2)
        fluxerr = decode_array(self.dstream3)

        for d1, d2, d3 in zip(time, flux, fluxerr):
            print '{0: <11.5f} {1: <15.5f} {2: <7.5f}'.format(d1, d2, d3)
Пример #2
0
 def narrow_docids(self, idx):
   m0 = [ decode_array(idx[feat]) for feat in self.feats if idx.has_key(feat) ]
   if not m0:
     return []
   refs = merge(m0)
   locs = [ (refs[i], refs[i+1]) for i in xrange(0, len(refs), 2) ]
   return locs
Пример #3
0
 def convertoldids(self, bits):
     a = decode_array(bits)
     r = array('i')
     for i in xrange(0, len(a), 2):
         if a[i] in self.old2new:
             r.append(self.old2new[a[i]])
             r.append(a[i + 1])
     return r
Пример #4
0
 def convertoldids(self, bits):
   a = decode_array(bits)
   r = array('i')
   for i in xrange(0, len(a), 2):
     if a[i] in self.old2new:
       r.append(self.old2new[a[i]])
       r.append(a[i+1])
   return r
Пример #5
0
 def narrow_docids(self, idx):
     m0 = [
         decode_array(idx[feat]) for feat in self.feats if idx.has_key(feat)
     ]
     if not m0:
         return []
     refs = merge(m0)
     locs = [(refs[i], refs[i + 1]) for i in xrange(0, len(refs), 2)]
     return locs
Пример #6
0
 def narrow_docids(self, idx):
   m0 = [ decode_array(idx[w]) for w in self.r0 if idx.has_key(w) ]
   if self.r0 and not m0:
     return []
   m2 = [ decode_array(idx[w]) for w in self.r2 if idx.has_key(w) ]
   if self.r2 and not m2:
     return []
   if self.r1:
     try:
       refs = intersect( decode_array(idx[w]) for w in self.r1 )
     except KeyError:
       return []
     refs = union(refs, [ m for m in (m0,m2) if m ])
   elif not self.r2:
     refs = merge(m0)
   else:
     refs = union(merge(m0), [m2])
   # Now: refs = [ docid1,sentid1, docid2,sentid2, ... ]
   locs = [ (refs[i], refs[i+1]) for i in xrange(0, len(refs), 2) ]
   return locs
Пример #7
0
 def narrow_docids(self, idx):
     m0 = [decode_array(idx[w]) for w in self.r0 if idx.has_key(w)]
     if self.r0 and not m0:
         return []
     m2 = [decode_array(idx[w]) for w in self.r2 if idx.has_key(w)]
     if self.r2 and not m2:
         return []
     if self.r1:
         try:
             refs = intersect(decode_array(idx[w]) for w in self.r1)
         except KeyError:
             return []
         refs = union(refs, [m for m in (m0, m2) if m])
     elif not self.r2:
         refs = merge(m0)
     else:
         refs = union(merge(m0), [m2])
     # Now: refs = [ docid1,sentid1, docid2,sentid2, ... ]
     locs = [(refs[i], refs[i + 1]) for i in xrange(0, len(refs), 2)]
     return locs