def test_memmap_text(): folder = tempfile.gettempdir() filename = os.path.join(folder, 'memmap') x = np.random.randint(size=(MemMappedText.BUFFER_SIZE + 1000, 10), low=0, high=100) save_text(filename, x) m = MemMappedText(filename, np.int32) l = m.next() i = 0 while l is not None: assert np.array_equal(l, x[i, :]) i += 1 l = m.next()
def setup(): # Create mock directory if needed. dir = TEST_FOLDER # Create mock data. waveforms = create_waveforms(nspikes, nsamples, nchannels) features = create_features(nspikes, nchannels, fetdim, duration, freq) clusters = create_clusters(nspikes, nclusters) cluster_colors = create_cluster_colors(nclusters) cluster_groups = create_cluster_groups(nclusters) cluster_info = pd.DataFrame( {'color': cluster_colors, 'group': cluster_groups}, dtype=np.int32, index=np.unique(clusters)) group_colors = create_group_colors(ngroups) group_names = create_group_names(ngroups) group_info = pd.DataFrame( {'color': group_colors, 'name': group_names}, index=np.arange(ngroups)) masks = create_masks(nspikes, nchannels, fetdim) xml = create_xml(nchannels, nsamples, fetdim) probe = create_probe(nchannels) # Create mock files. save_binary(os.path.join(dir, 'test.spk.1'), waveforms) save_text(os.path.join(dir, 'test.fet.1'), features, header=nchannels * fetdim + 1) save_text(os.path.join(dir, 'test.aclu.1'), clusters, header=nclusters) save_text(os.path.join(dir, 'test.clu.1'), clusters, header=nclusters) save_text(os.path.join(dir, 'test.fmask.1'), masks, header=nclusters, fmt='%.6f') save_text(os.path.join(dir, 'test.xml'), xml) save_text(os.path.join(dir, 'test.probe'), probe)