示例#1
0
def testListAggregatePullNoFRET():
    pull_list = experiment.List(pulls).not_has('fret')
    aggregated = datatypes.TrapData.aggregate(pull_list.get('trap'))
    assert type(aggregated) == datatypes.TrapData
    rows, cols = aggregated.shape
    total_rows = sum(p.shape[0] for p in pull_list.get('trap'))
    assert total_rows == rows
示例#2
0
 def test_collapse_two_exp_with_filename(self):
     filename = 'test'
     test_list = experiment.List(map(experiment.Pulling, self.to_collapse))
     for p in test_list:
         p.metadata['filename'] = filename
     collapsed = test_list.collapse()
     self.assertEqual(collapsed.filename, filename + '_collapsed')
示例#3
0
 def test_collapse_on_two_exp_with_trap_data(self):
     test_list = experiment.List(map(experiment.Pulling, self.to_collapse))
     collapsed = test_list.collapse()
     print collapsed.trap
     correct = datatypes.TrapData.aggregate(self.to_collapse)
     print correct
     self.assertItemsEqual(collapsed.trap.data.flat, correct.data.flat)
     self.assertEqual(collapsed.filename, 'collapsed')
示例#4
0
def testListCall():
    pull_list = experiment.List(pulls)

    def testFunc():
        return True

    for p in pull_list:
        p.testFunc = testFunc
    assert pull_list.call('testFunc') == [True] * len(pull_list)
示例#5
0
def byMolecule(directory='./',
               exp_type=experiment.Pulling,
               fromMatch=('', ),
               **metadata):
    """Return a generator (iterator) which yields experiment.List for all molecules in given directory."""
    assert issubclass(exp_type, experiment.Base)
    assert isinstance(fromMatch, (tuple, list))
    assert isinstance(directory, str)
    with ChangeDirectory(directory):
        flist = filter(exp_type.filenameMatchesType,
                       experiment.filelist(*fromMatch))
    filelist = groupby(flist, lambda f: fileIO.parseFilename(f)[:4])
    for mol, group in filelist:
        with ChangeDirectory(directory):
            dirname = path.basename(directory)
            date_ = dir_to_date(dirname)
            metadata.setdefault('date', date_)
            yield experiment.List(
                map(lambda f: exp_type.fromFile(f, **metadata), group))
示例#6
0
def testListGet():
    pull_list = experiment.List(pulls)
    info = pull_list.get('filename')
    assert set(info) == set(LOADED_FILES)
示例#7
0
def testListAggregatePull():
    pull_list = experiment.List(pulls)
    aggregated = datatypes.TrapData.aggregate(pull_list.get('trap'))
    rows, cols = aggregated.shape
    total_rows = sum(p.shape[0] for p in pull_list.get('trap'))
    assert total_rows == rows
示例#8
0
def testList():
    pulls = [Mock(autospec=experiment.Pulling)] * 3
    pull_list = experiment.List(pulls)
    assert pull_list == pulls
示例#9
0
def groupMolecules(exps):
    group_iter = groupby(exps, lambda p: p.info[:4])
    for info, group in group_iter:
        yield experiment.List(group)