Ejemplo n.º 1
0
    def addMC(MC):
        '''
		INPUT:
			MC :: NPArray<NPArray<Float>>
		'''
        theStr = np.tostring(MC)
        if theStr in self.MCdict:
            self.MCdict[theStr] += 1
        else:
            self.MCdict[theStr] = 1
Ejemplo n.º 2
0
    def delMC_all(MC):
        '''
		INPUT:
			MC :: NPArray<NPArray<Float>>
		'''
        theStr = np.tostring(MC)
        if theStr in self.MCdict:
            del self.MCdict[theStr]
        else:
            print "\nError! ~~ delMC_once() ~~ Your input MC is not in the class dictionary!\n"
Ejemplo n.º 3
0
def np2image(np, path):
    "Save an image array to a file."
    if len(np.shape) > 2:
        if np.shape[2] == 3:
            mode = 'RGB'
        elif np.shape[2] == 2:
            mode = 'LA'
    else:
        mode = 'L'
    im = Image.frombytes(mode, (np.shape[1], np.shape[0]), np.tostring())
    im.save(path)
Ejemplo n.º 4
0
def np2image(np, path):
    "Save an image array to a file."
    if len(np.shape) > 2:
        if np.shape[2] == 3:
            mode = 'RGB'
        elif np.shape[2] == 2:
            mode = 'LA'
    else:
        mode = 'L'
    im = Image.fromstring(
        mode, (np.shape[1], np.shape[0]), np.tostring())
    im.save(path)
Ejemplo n.º 5
0
 def toStr(pkt):
     src, dest, typ, data = pkt
     data = np.tostring(data)
     return (src, dest, typ, data)
Ejemplo n.º 6
0
def pack_mat(v, dims):
    return np.tostring(v)
Ejemplo n.º 7
0
def pack_vec(v):
    return np.tostring(v)
Ejemplo n.º 8
0
 def toStr(pkt):
     src, dest, typ, data = pkt
     data = np.tostring(data)
     return (src, dest, typ, data)
Ejemplo n.º 9
0
def toString( array ):
    from numpy import tostring
    array.shape = -1,
    return tostring( array )
Ejemplo n.º 10
0
def pack_mat(v, dims):
    return np.tostring(v)
Ejemplo n.º 11
0
def pack_vec(v):
    return np.tostring(v)
Ejemplo n.º 12
0
def read_pol(snap, pol):
    bram_data = snap.sbrams[pol].read_raw()
    return numpy.array(numpy.tostring(bram_data, dtype=">Q"), dtype="uint64")
Ejemplo n.º 13
0
def np2image(np, path):
    "Save an image array to a file."
    im = Image.fromstring(
        'RGB', (np.shape[1], np.shape[0]), np.tostring())
    im.save(path)
Ejemplo n.º 14
0
 def tostring(self, axis=None):
     return np.tostring(self)