def __init__( self, genprog, num_edits): DD.__init__( self ) self.genprog = genprog self.assume_axioms_hold = False self.num_edits = num_edits if options.disable_cache: self.cache_outcomes = 0
def __init__(self, debuggee, args_1, args_2, version): DD.__init__(self) self.debugcase1 = args_1 self.debugcase2 = args_2 self.gdb = StateGDB(debuggee) self.gdb2 = StateGDB(debuggee) self.conn = sqlite3.connect("abc/"+version+".db") print "abc/"+version+".db" self.count_all = self.conn.execute("select count(*) from testcase").fetchall()[0][0] self.count_fail = self.conn.execute("select count(*) from testcase where pass=0").fetchall()[0][0] cur = self.conn.execute("select para, pass from testcase where name='%s'"%args_1).fetchall() assert cur[0][1] == 1 self.args_1 = cur[0][0] self.gdb2.question("set args " + self.args_1) cur = self.conn.execute("select para, pass from testcase where name='%s'"%args_2).fetchall() assert cur[0][1] == 0 self.args_2 = cur[0][0] cur = self.conn.execute("select lineNumber from breakpoint").fetchall() self.syncpoints = [] for cur2 in cur: self.syncpoints.append(cur2[0]) self.gdb.break_at(cur2[0]) self.gdb2.break_at(cur2[0]) print self.syncpoints self.check = check.CheckResult(RightVersion, self.syncpoints)
def __init__( self, genprog, builder, deltas ): DD.__init__( self ) self.builder = builder self.genprog = genprog infomsg( "INFO: computing optimized energy usage" ) self.optimized = self.get_fitness( deltas ) self.mean = numpy.mean( self.optimized )
def __init__( self, genprog, builder, deltas ): DD.__init__( self ) self.builder = builder self.genprog = genprog if options.disable_cache: self.cache_outcomes = 0 self.duration = 0 infomsg( "INFO: computing optimized energy usage" ) self.optimized = np.array( self.get_fitness( deltas ) ) self.mean = np.mean( self.optimized, axis = 0 ) assert np.all( self.mean > 0 ), "'optimized' variant has 0 fitness!"
def wiener_filtering(clean_signal, filename, audio_sr): """ Performs Wiener Filtering on a file located at filepath :param clean_signal: 1D numpy array containing the signal of a clean audio file :param filename: string of the audio file name """ if len(clean_signal) > MAX_SIGNAL_LENGTH: clean_signal = clean_signal[:MAX_SIGNAL_LENGTH] write_name = filename.split(".")[0] if '+' not in filename: noisy_signal = generate_noise(clean_signal, sr=audio_sr) new_path = "audio/test_audio_noisy/" + write_name + "_noisy.wav" wavwrite(new_path, noisy_signal, audio_sr) else: noisy_signal = clean_signal.copy() stft_noisy, DD_gains, noise_est = DD(noisy_signal) TSNR_sig, TSNR_gains = TSNR(stft_noisy, DD_gains, noise_est) signal_est = HRNR(stft_noisy, TSNR_sig, TSNR_gains, noise_est) signal_est = highpass(signal_est, audio_sr) new_path = "audio/test_audio_results/" + write_name + "_reduced.wav" wavwrite(new_path, signal_est, audio_sr) if '+' not in filename: print("Noisy Segmented SNR: " + snr(noisy_signal, clean_signal)) print("Denoisned Segmented SNR: " + snr(signal_est, noisy_signal))
def __init__(self, path): self.CD = CD(path) self.DD = DD(path) self.DO = DO(path) self.GD = GD(path) self.GO = GO(path) self.ID = ID(path) self.OO = OO(path)
def noise_filter(signal, sample_rate): stft_noisy, DD_gains, noise_est = DD(signal) TSNR_sig, TSNR_gains = TSNR(stft_noisy, DD_gains, noise_est) new_signal = HRNR(stft_noisy, TSNR_sig, TSNR_gains, noise_est) new_signal = highpass(new_signal, sample_rate) return new_signal
class CodeBook: def __init__(self, path): self.CD = CD(path) self.DD = DD(path) self.DO = DO(path) self.GD = GD(path) self.GO = GO(path) self.ID = ID(path) self.OO = OO(path) def decode(self, code, encoding, year): if encoding == 'CD': return self.CD.decode(code, year) elif encoding == 'DD': return self.DD.decode(code, year) elif encoding == 'DO': return self.DO.decode(code, year) elif encoding == 'GD': return self.GD.decode(code, year) elif encoding == 'GO': return self.GO.decode(code, year) elif encoding == 'ID': return self.ID.decode(code, year) elif encoding == 'OO': return self.OO.decode(code, year) else: print 'Error: encoding do not found' exit(-1) def decode_file(self, filename, encoding, year): data = [] f = open(filename) for line in f.readlines(): code = self.decode(line[:-1], encoding, year) data.append(code) f.close() return data
def _dd( self, c, n ): assert self.test(c) == self.FAIL return DD._dd( self, c, n )