def test__filterdata_multi_nores(self): block = simple_block() targ = [] data = block.children_recur name1 = block.segments[0].analogsignals[0].name, res0 = filterdata(data, [{"thing": "a good thing"}, {}]) res1 = filterdata(data, {}, thing="a good thing") res2 = filterdata(data, [{}], thing="a good thing") res3 = filterdata(data, name=name1, targdict={"thing": "a good thing"}) res4 = filterdata(data, {'name': name1}, thing="a good thing") res5 = filterdata(data, targdict={'name': name1}, thing="a good thing") res12 = filterdata(data, {'name': name1}, thing="a good thing") res13 = filterdata(data, targdict={'name': name1}, thing="a good thing") res14 = filterdata(data, name=name1, targdict={"thing": "a good thing"}) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ) assert_same_sub_schema(res3, targ) assert_same_sub_schema(res4, targ) assert_same_sub_schema(res5, targ) assert_same_sub_schema(res12, targ) assert_same_sub_schema(res13, targ) assert_same_sub_schema(res14, targ)
def test__filter_single_attribute_container_norecur(self): block = simple_block() targ = [block.segments[1]] res0 = block.filter(name=targ[0].name, container=True, recursive=False) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ)
def test__filter_single_annotation_container_norecur(self): block = simple_block() targ = [block.segments[1]] res0 = block.filter(thing="amajig", container=True, recursive=False) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ)
def test__filter_single_attribute_nodata_norecur(self): block = simple_block() targ = [] res0 = block.filter(name=block.segments[0].analogsignals[0], data=False, recursive=False) assert_same_sub_schema(res0, targ)
def test__filter_single_annotation_obj_multi(self): segment = simple_block().segments[0] targ = [segment.analogsignals[0], segment.spiketrains[1]] res0 = segment.filter(thing="wotsit", objects=["Event", SpikeTrain, "AnalogSignal"]) assert_same_sub_schema(res0, targ)
def test__filter_single_annotation_container(self): segment = simple_block().segments[1] targ = [] res0 = segment.filter(thing="amajig", container=True, data=False) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ)
def test__filter_single_attribute_container(self): segment = simple_block().segments[1] targ = [segment.analogsignals[0], segment.irregularlysampledsignals[0]] res0 = segment.filter(name=targ[0].name, container=True) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ)
def test__filter_single_attribute_nodata_container_norecur_nores(self): block = simple_block() targ = [] res0 = block.filter(name="puffin", data=False, container=True, recursive=False) assert_same_sub_schema(res0, targ)
def test__filter_single_attribute_nodata_container(self): segment = simple_block().segments[1] targ = [] res0 = segment.filter(name=segment.analogsignals[0].name, container=True, data=False) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ)
def test__filter_attribute_single_nores(self): segment = simple_block().segments[1] name = "potato" res0 = segment.filter(name=name) res1 = segment.filter({'name': name}) res2 = segment.filter(targdict={'name': name}) self.assertEqual(len(res0), 0) self.assertEqual(len(res1), 0) self.assertEqual(len(res2), 0)
def test__filter_attribute_single_nores(self): block = simple_block() name = "potato" res0 = block.filter(name=name) res1 = block.filter({'name': name}) res2 = block.filter(targdict={'name': name}) self.assertEqual(len(res0), 0) self.assertEqual(len(res1), 0) self.assertEqual(len(res2), 0)
def test__filter_single_annotation_obj_none(self): segment = simple_block().segments[0] targ = [] res0 = segment.filter(j=1, objects=Epoch) res1 = segment.filter(j=1, objects='Epoch') res2 = segment.filter(j=1, objects=[]) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ)
def test__filter_single_annotation_container(self): block = simple_block() targ = [ block.segments[1].analogsignals[0], block.segments[1].irregularlysampledsignals[0], block.segments[1] ] res0 = block.filter(thing="amajig", container=True) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ)
def test__filter_attribute_single(self): segment = simple_block().segments[1] targ = [segment.analogsignals[0], segment.irregularlysampledsignals[0]] name = targ[0].name res0 = segment.filter(name=name) res1 = segment.filter({'name': name}) res2 = segment.filter(targdict={'name': name}) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ)
def test__filter_single_annotation_obj_single(self): block = simple_block() targ = [block.segments[0].analogsignals[1]] res0 = block.filter(thing="frooble", objects='AnalogSignal') res1 = block.filter(thing="frooble", objects=AnalogSignal) res2 = block.filter(thing="frooble", objects=['AnalogSignal']) res3 = block.filter(thing="frooble", objects=[AnalogSignal]) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ) assert_same_sub_schema(res3, targ)
def test__filter_multi_nores(self): block = simple_block() targ = [] filter = {"name": "carrot", "thing": "another thing"} res0 = block.filter(**filter) res1 = block.filter(filter) res2 = block.filter(targdict=filter) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ)
def test__filter_multi_partres(self): segment = simple_block().segments[1] targ = [segment.analogsignals[0], segment.irregularlysampledsignals[0]] filter = {"name": targ[0].name, "thing": "another thing"} res0 = segment.filter(**filter) res1 = segment.filter(filter) res2 = segment.filter(targdict=filter) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ)
def test__filter_single_annotation_nores(self): block = simple_block() res0 = block.filter(j=5) res1 = block.filter({'j': 5}) res2 = block.filter(targdict={'j': 5}) res3 = block.filter([{'j': 5}]) res4 = block.filter(targdict=[{'j': 5}]) self.assertEqual(len(res0), 0) self.assertEqual(len(res1), 0) self.assertEqual(len(res2), 0) self.assertEqual(len(res3), 0) self.assertEqual(len(res4), 0)
def test__filter_annotation_single(self): segment = simple_block().segments[0] targ = [segment.analogsignals[0], segment.spiketrains[1]] res0 = segment.filter(thing="wotsit") res1 = segment.filter({'thing': "wotsit"}) res2 = segment.filter(targdict={'thing': "wotsit"}) res3 = segment.filter([{'thing': "wotsit"}]) res4 = segment.filter(targdict=[{'thing': "wotsit"}]) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ) assert_same_sub_schema(res3, targ) assert_same_sub_schema(res4, targ)
def test__filter_single_annotation_nores(self): segment = simple_block().segments[0] targ = [] res0 = segment.filter(j=5) res1 = segment.filter({'j': 5}) res2 = segment.filter(targdict={'j': 5}) res3 = segment.filter([{'j': 5}]) res4 = segment.filter(targdict=[{'j': 5}]) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ) assert_same_sub_schema(res3, targ) assert_same_sub_schema(res4, targ)
def test__filter_multi(self): block = simple_block() targ = [ block.segments[1].analogsignals[0], block.segments[1].irregularlysampledsignals[0] ] filter = {"name": targ[0].name, "thing": targ[0].annotations["thing"]} res0 = block.filter(**filter) res1 = block.filter(filter) res2 = block.filter(targdict=filter) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ)
def test__filterdata_multi(self): block = simple_block() targ = [ block.segments[1].analogsignals[0], block.segments[1].irregularlysampledsignals[0], block.segments[1] ] data = block.children_recur filter = {"name": targ[0].name, "thing": targ[0].annotations["thing"]} res0 = filterdata(data, **filter) res1 = filterdata(data, filter) res2 = filterdata(data, targdict=filter) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ)
def test__filter_annotation_single(self): block = simple_block() targ = [ block.segments[0].analogsignals[0], block.segments[0].spiketrains[1], block.segments[1].events[0] ] res0 = block.filter(thing="wotsit") res1 = block.filter({'thing': "wotsit"}) res2 = block.filter(targdict={'thing': "wotsit"}) res3 = block.filter([{'thing': "wotsit"}]) res4 = block.filter(targdict=[{'thing': "wotsit"}]) self.assertEqual(res0, targ) assert_same_sub_schema(res0, targ) assert_same_sub_schema(res1, targ) assert_same_sub_schema(res2, targ) assert_same_sub_schema(res3, targ) assert_same_sub_schema(res4, targ)
def test__filter_no_annotation_but_object(self): block = simple_block() targ = [] for seg in block.segments: targ.extend(seg.events) res = block.filter(objects=Event) assert_same_sub_schema(res, targ) targ = [] for seg in block.segments: targ.extend(seg.analogsignals) res = block.filter(objects=AnalogSignal) assert_same_sub_schema(res, targ) targ = [] for seg in block.segments: targ.extend(seg.analogsignals) targ.extend(seg.events) res = block.filter(objects=[AnalogSignal, Event]) assert_same_sub_schema(res, targ)
def test__filter_single_annotation_nodata(self): segment = simple_block().segments[0] targ = [] res0 = segment.filter(thing="frooble", data=False) assert_same_sub_schema(res0, targ)
def test__filter_single_attribute_nodata(self): segment = simple_block().segments[0] targ = [] res0 = segment.filter(name=segment.analogsignals[0], data=False) assert_same_sub_schema(res0, targ)
def test__filter_single_annotation_nodata_norecur(self): block = simple_block() targ = [] res0 = block.filter(thing="frooble", data=False, recursive=False) assert_same_sub_schema(res0, targ)
def test__filter_single_attribute_container_data(self): block = simple_block() targ = [block.segments[1]] res0 = block.filter(name=targ[0].name, container=True) assert_same_sub_schema(res0, targ)