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
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"
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)
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)
def toStr(pkt): src, dest, typ, data = pkt data = np.tostring(data) return (src, dest, typ, data)
def pack_mat(v, dims): return np.tostring(v)
def pack_vec(v): return np.tostring(v)
def toString( array ): from numpy import tostring array.shape = -1, return tostring( array )
def read_pol(snap, pol): bram_data = snap.sbrams[pol].read_raw() return numpy.array(numpy.tostring(bram_data, dtype=">Q"), dtype="uint64")
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)
def tostring(self, axis=None): return np.tostring(self)