def setUp(self): self.project_name = 'testing' self.project = cw.create_project(self.project_name) self.fake_trace = cw.Trace(np.array([i for i in range(35)]), 'asdf', 'sdaf', 'sdf') self.project.traces.seg_ind_max = 4 self.trace_num = 13 for i in range(self.trace_num-1): self.project.traces.append(self.fake_trace) self.fake_trace_2 = cw.Trace(np.array([i for i in range(35)]), 'asdf', 'sdaf', 'hello') self.project.traces.append(self.fake_trace_2)
def setUp(self): self.project = cw.create_project('test_seg', overwrite=True) for i in range(0, 10000): arr = bytearray(b'CWUNIQUESTRING1') tr = cw.Trace(np.array([0]), arr, arr, arr) self.project.traces.append(tr) arr = bytearray(b'CWUNIQUESTRING2') tr = cw.Trace(np.array([0]), arr, arr, arr) self.project.traces.append(tr) self.project.save() self.project.close()
def create_random_traces(num, wave_length): traces = [] for i in range(num): wave = np.random.rand(wave_length) textin = [random.randrange(256) for i in range(16)] textout = [random.randrange(256) for i in range(16)] key = [random.randrange(256) for i in range(16)] traces.append(cw.Trace(wave, textin, textout, key)) return traces
def test_create_and_save_project(self): self.project = cw.create_project(self.project_name) self.assertTrue(os.path.isdir(self.project_name + '_data')) trace = cw.Trace(np.array([i for i in range(100)]), 'text in', 'text out', 'key') for i in range(500): self.project.traces.append(trace) self.project.save() self.assertTrue(os.path.exists(ensure_cwp_extension(self.project_name))) # calling it again should not cause issues. self.project.save()
def convert_shard_to_cw(info): # avoid trashing the HD by desync multi process time.sleep(randint(0, 100) / 1000) cw_traces = [] shard = np.load(info['fname']) # CW traces cts = np.transpose(shard['cts']) pts = np.transpose(shard['pts']) keys = np.transpose(shard['keys']) for idx in range(info['num_traces_by_shard']): wave = np.squeeze(shard['traces'][idx]) wave = wave[:info['trace_len']] t = cw.Trace(wave, pts[idx], cts[idx], keys[idx]) cw_traces.append(t) return cw_traces