Exemplo n.º 1
0
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.chx1 = fake_neo(ChannelIndex,
                             seed=self.seed1, n=self.nchildren)
        self.chx2 = fake_neo(ChannelIndex,
                             seed=self.seed2, n=self.nchildren)
        self.targobj = self.chx1

        self.units1 = self.chx1.units
        self.units2 = self.chx2.units
        self.sigarrs1 = self.chx1.analogsignals
        self.sigarrs2 = self.chx2.analogsignals
        self.irrsig1 = self.chx1.irregularlysampledsignals
        self.irrsig2 = self.chx2.irregularlysampledsignals

        self.units1a = clone_object(self.units1)
        self.sigarrs1a = clone_object(self.sigarrs1, n=2)
        self.irrsig1a = clone_object(self.irrsig1, n=2)

        self.trains1 = [[train for train in unit.spiketrains]
                        for unit in self.units1]
        self.trains2 = [[train for train in unit.spiketrains]
                        for unit in self.units2]

        self.trains1 = sum(self.trains1, [])
        self.trains2 = sum(self.trains2, [])
Exemplo n.º 2
0
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.blk1 = fake_neo(Block, seed=self.seed1, n=self.nchildren)
        self.blk2 = fake_neo(Block, seed=self.seed2, n=self.nchildren)
        self.targobj = self.blk1

        self.segs1 = self.blk1.segments
        self.segs2 = self.blk2.segments
        self.chxs1 = self.blk1.channel_indexes
        self.chxs2 = self.blk2.channel_indexes

        self.units1 = [[unit for unit in chx.units] for chx in self.chxs1]
        self.units2 = [[unit for unit in chx.units] for chx in self.chxs2]

        self.units1 = sum(self.units1, [])
        self.units2 = sum(self.units2, [])

        self.sigarrs1 = [[sigarr for sigarr in chx.analogsignals]
                         for chx in self.chxs1]
        self.sigarrs2 = [[sigarr for sigarr in chx.analogsignals]
                         for chx in self.chxs2]

        self.trains1 = [[train for train in unit.spiketrains]
                        for unit in self.units1]
        self.trains2 = [[train for train in unit.spiketrains]
                        for unit in self.units2]

        self.irsigs1 = [[irsig for irsig in chx.irregularlysampledsignals]
                        for chx in self.chxs1]
        self.irsigs2 = [[irsig for irsig in chx.irregularlysampledsignals]
                        for chx in self.chxs2]

        self.epcs1 = [[epc for epc in seg.epochs]
                      for seg in self.segs1]
        self.epcs2 = [[epc for epc in seg.epochs]
                      for seg in self.segs2]
        self.evts1 = [[evt for evt in seg.events]
                      for seg in self.segs1]
        self.evts2 = [[evt for evt in seg.events]
                      for seg in self.segs2]

        self.sigarrs1 = sum(self.sigarrs1, [])
        self.sigarrs2 = sum(self.sigarrs2, [])

        self.trains1 = sum(self.trains1, [])
        self.trains2 = sum(self.trains2, [])
        self.irsigs1 = sum(self.irsigs1, [])
        self.irsigs2 = sum(self.irsigs2, [])

        self.epcs1 = sum(self.epcs1, [])
        self.epcs2 = sum(self.epcs2, [])
        self.evts1 = sum(self.evts1, [])
        self.evts2 = sum(self.evts2, [])
Exemplo n.º 3
0
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.unit1 = fake_neo(Unit, seed=self.seed1, n=self.nchildren)
        self.unit2 = fake_neo(Unit, seed=self.seed2, n=self.nchildren)
        self.targobj = self.unit1

        self.trains1 = self.unit1.spiketrains
        self.trains2 = self.unit2.spiketrains

        self.trains1a = clone_object(self.trains1)
    def subcheck__generate_datasets(self, cls, cascade, seed=None):
        self.annotations['seed'] = seed

        if seed is None:
            res = fake_neo(obj_type=cls, cascade=cascade)
        else:
            res = fake_neo(obj_type=cls, cascade=cascade, seed=seed)

        if not hasattr(cls, 'lower'):
            self.assertTrue(isinstance(res, cls))
        else:
            self.assertEqual(res.__class__.__name__, cls)

        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        resattr = get_fake_values(cls, annotate=False, seed=0)
        if seed is not None:
            for name, value in resattr.items():
                if name in ['channel_names',
                            'channel_indexes',
                            'channel_index']:
                    continue
                try:
                    try:
                        resvalue = getattr(res, name)
                    except AttributeError:
                        if name == 'signal':
                            continue
                        raise
                    try:
                        self.assertEqual(resvalue, value)
                    except ValueError:
                        assert_arrays_equal(resvalue, value)
                except BaseException as exc:
                    exc.args += ('from %s' % name,)
                    raise

        if not getattr(res, '_child_objects', ()):
            pass
        elif not cascade:
            self.assertEqual(res.children, ())
        else:
            self.assertNotEqual(res.children, ())

        if cls in ['RecordingChannelGroup', RecordingChannelGroup]:
            for i, rchan in enumerate(res.recordingchannels):
                self.assertEqual(rchan.name, res.channel_names[i].astype(str))
                self.assertEqual(rchan.index, res.channel_indexes[i])
            for i, unit in enumerate(res.units):
                for sigarr in res.analogsignalarrays:
                    self.assertEqual(unit.channel_indexes[0],
                                     sigarr.channel_index[i])
    def subcheck__generate_datasets(self, cls, cascade, seed=None):
        self.annotations['seed'] = seed

        if seed is None:
            res = fake_neo(obj_type=cls, cascade=cascade)
        else:
            res = fake_neo(obj_type=cls, cascade=cascade, seed=seed)

        if not hasattr(cls, 'lower'):
            self.assertTrue(isinstance(res, cls))
        else:
            self.assertEqual(res.__class__.__name__, cls)

        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        resattr = get_fake_values(cls, annotate=False, seed=0)
        if seed is not None:
            for name, value in resattr.items():
                if name in [
                        'channel_names', 'channel_indexes', 'channel_index',
                        'coordinates'
                ]:
                    continue
                try:
                    try:
                        resvalue = getattr(res, name)
                    except AttributeError:
                        if name == 'signal':
                            continue
                        raise
                    try:
                        self.assertEqual(resvalue, value)
                    except ValueError:
                        assert_arrays_equal(resvalue, value)
                except BaseException as exc:
                    exc.args += ('from %s' % name, )
                    raise

        if not getattr(res, '_child_objects', ()):
            pass
        elif not cascade:
            self.assertEqual(res.children, ())
        else:
            self.assertNotEqual(res.children, ())

        if cls in ['ChannelIndex', ChannelIndex]:
            for i, unit in enumerate(res.units):
                for sigarr in res.analogsignals:
                    self.assertEqual(unit.get_channel_indexes()[0],
                                     sigarr.get_channel_index()[i])
Exemplo n.º 6
0
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.unit1 = fake_neo(Unit, seed=self.seed1, n=self.nchildren)
        self.unit2 = fake_neo(Unit, seed=self.seed2, n=self.nchildren)
        self.targobj = self.unit1

        self.spikes1 = self.unit1.spikes
        self.spikes2 = self.unit2.spikes
        self.trains1 = self.unit1.spiketrains
        self.trains2 = self.unit2.spiketrains

        self.spikes1a = clone_object(self.spikes1)
        self.trains1a = clone_object(self.trains1)
Exemplo n.º 7
0
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.rcg1 = fake_neo(RecordingChannelGroup,
                             seed=self.seed1,
                             n=self.nchildren)
        self.rcg2 = fake_neo(RecordingChannelGroup,
                             seed=self.seed2,
                             n=self.nchildren)
        self.targobj = self.rcg1

        self.rchans1 = self.rcg1.recordingchannels
        self.rchans2 = self.rcg2.recordingchannels
        self.units1 = self.rcg1.units
        self.units2 = self.rcg2.units
        self.sigarrs1 = self.rcg1.analogsignalarrays
        self.sigarrs2 = self.rcg2.analogsignalarrays

        self.rchans1a = clone_object(self.rchans1)
        self.units1a = clone_object(self.units1)
        self.sigarrs1a = clone_object(self.sigarrs1, n=2)

        self.spikes1 = [[spike for spike in unit.spikes]
                        for unit in self.units1]
        self.spikes2 = [[spike for spike in unit.spikes]
                        for unit in self.units2]
        self.trains1 = [[train for train in unit.spiketrains]
                        for unit in self.units1]
        self.trains2 = [[train for train in unit.spiketrains]
                        for unit in self.units2]
        self.sigs1 = [[sig for sig in rchan.analogsignals]
                      for rchan in self.rchans1]
        self.sigs2 = [[sig for sig in rchan.analogsignals]
                      for rchan in self.rchans2]
        self.irsigs1 = [[irsig for irsig in rchan.irregularlysampledsignals]
                        for rchan in self.rchans1]
        self.irsigs2 = [[irsig for irsig in rchan.irregularlysampledsignals]
                        for rchan in self.rchans2]

        self.spikes1 = sum(self.spikes1, [])
        self.spikes2 = sum(self.spikes2, [])
        self.trains1 = sum(self.trains1, [])
        self.trains2 = sum(self.trains2, [])
        self.sigs1 = sum(self.sigs1, [])
        self.sigs2 = sum(self.sigs2, [])
        self.irsigs1 = sum(self.irsigs1, [])
        self.irsigs2 = sum(self.irsigs2, [])
Exemplo n.º 8
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = Segment
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 1)
        self.assertEqual(len(res.irregularlysampledsignals), 1)
        self.assertEqual(len(res.spiketrains), 1)
        self.assertEqual(len(res.events), 1)
        self.assertEqual(len(res.epochs), 1)
        for child in res.children:
            del child.annotations['i']
            del child.annotations['j']

        self.assertEqual(res.analogsignals[0].annotations,
                         self.annotations)
        self.assertEqual(res.irregularlysampledsignals[0].annotations,
                         self.annotations)
        self.assertEqual(res.spiketrains[0].annotations,
                         self.annotations)
        self.assertEqual(res.events[0].annotations,
                         self.annotations)
        self.assertEqual(res.epochs[0].annotations,
                         self.annotations)
Exemplo n.º 9
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = 'ChannelIndex'
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, ChannelIndex))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']

        self.assertEqual(len(res.units), 1)
        unit = res.units[0]
        self.assertEqual(unit.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 1)
        self.assertEqual(res.analogsignals[0].annotations,
                         self.annotations)

        self.assertEqual(len(unit.spiketrains), 1)
        self.assertEqual(unit.spiketrains[0].annotations,
                         self.annotations)
Exemplo n.º 10
0
    def setUp(self):
        self.nchildren = 2
        blk = fake_neo(Block, seed=0, n=self.nchildren)
        self.unit1, self.unit2, self.unit3, self.unit4 = blk.list_units
        self.seg1, self.seg2 = blk.segments
        self.targobj = self.seg1
        self.seed1 = self.seg1.annotations['seed']
        self.seed2 = self.seg2.annotations['seed']

        del self.seg1.annotations['i']
        del self.seg2.annotations['i']
        del self.seg1.annotations['j']
        del self.seg2.annotations['j']

        self.sigarrs1 = self.seg1.analogsignals
        self.sigarrs2 = self.seg2.analogsignals
        self.irsigs1 = self.seg1.irregularlysampledsignals
        self.irsigs2 = self.seg2.irregularlysampledsignals

        self.trains1 = self.seg1.spiketrains
        self.trains2 = self.seg2.spiketrains

        self.epcs1 = self.seg1.epochs
        self.epcs2 = self.seg2.epochs
        self.evts1 = self.seg1.events
        self.evts2 = self.seg2.events

        self.sigarrs1a = clone_object(self.sigarrs1, n=2)
        self.irsigs1a = clone_object(self.irsigs1)

        self.trains1a = clone_object(self.trains1)

        self.epcs1a = clone_object(self.epcs1)
        self.evts1a = clone_object(self.evts1)
Exemplo n.º 11
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = Segment
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 1)
        self.assertEqual(len(res.irregularlysampledsignals), 1)
        self.assertEqual(len(res.spiketrains), 1)
        self.assertEqual(len(res.events), 1)
        self.assertEqual(len(res.epochs), 1)
        for child in res.children:
            del child.annotations['i']
            del child.annotations['j']

        self.assertEqual(res.analogsignals[0].annotations, self.annotations)
        self.assertEqual(res.irregularlysampledsignals[0].annotations,
                         self.annotations)
        self.assertEqual(res.spiketrains[0].annotations, self.annotations)
        self.assertEqual(res.events[0].annotations, self.annotations)
        self.assertEqual(res.epochs[0].annotations, self.annotations)
Exemplo n.º 12
0
    def setUp(self):
        self.nchildren = 2
        blk = fake_neo(Block, seed=0, n=self.nchildren)
        self.unit1, self.unit2, self.unit3, self.unit4 = blk.list_units
        self.seg1, self.seg2 = blk.segments
        self.targobj = self.seg1
        self.seed1 = self.seg1.annotations['seed']
        self.seed2 = self.seg2.annotations['seed']

        del self.seg1.annotations['i']
        del self.seg2.annotations['i']
        del self.seg1.annotations['j']
        del self.seg2.annotations['j']

        self.sigarrs1 = self.seg1.analogsignals
        self.sigarrs2 = self.seg2.analogsignals
        self.irsigs1 = self.seg1.irregularlysampledsignals
        self.irsigs2 = self.seg2.irregularlysampledsignals

        self.trains1 = self.seg1.spiketrains
        self.trains2 = self.seg2.spiketrains

        self.epcs1 = self.seg1.epochs
        self.epcs2 = self.seg2.epochs
        self.evts1 = self.seg1.events
        self.evts2 = self.seg2.events

        self.sigarrs1a = clone_object(self.sigarrs1, n=2)
        self.irsigs1a = clone_object(self.irsigs1)

        self.trains1a = clone_object(self.trains1)

        self.epcs1a = clone_object(self.epcs1)
        self.evts1a = clone_object(self.evts1)
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.rcg1 = fake_neo(RecordingChannelGroup,
                             seed=self.seed1, n=self.nchildren)
        self.rcg2 = fake_neo(RecordingChannelGroup,
                             seed=self.seed2, n=self.nchildren)
        self.targobj = self.rcg1

        self.rchans1 = self.rcg1.recordingchannels
        self.rchans2 = self.rcg2.recordingchannels
        self.units1 = self.rcg1.units
        self.units2 = self.rcg2.units
        self.sigarrs1 = self.rcg1.analogsignalarrays
        self.sigarrs2 = self.rcg2.analogsignalarrays

        self.rchans1a = clone_object(self.rchans1)
        self.units1a = clone_object(self.units1)
        self.sigarrs1a = clone_object(self.sigarrs1, n=2)

        self.spikes1 = [[spike for spike in unit.spikes]
                        for unit in self.units1]
        self.spikes2 = [[spike for spike in unit.spikes]
                        for unit in self.units2]
        self.trains1 = [[train for train in unit.spiketrains]
                        for unit in self.units1]
        self.trains2 = [[train for train in unit.spiketrains]
                        for unit in self.units2]
        self.sigs1 = [[sig for sig in rchan.analogsignals]
                      for rchan in self.rchans1]
        self.sigs2 = [[sig for sig in rchan.analogsignals]
                      for rchan in self.rchans2]
        self.irsigs1 = [[irsig for irsig in rchan.irregularlysampledsignals]
                        for rchan in self.rchans1]
        self.irsigs2 = [[irsig for irsig in rchan.irregularlysampledsignals]
                        for rchan in self.rchans2]

        self.spikes1 = sum(self.spikes1, [])
        self.spikes2 = sum(self.spikes2, [])
        self.trains1 = sum(self.trains1, [])
        self.trains2 = sum(self.trains2, [])
        self.sigs1 = sum(self.sigs1, [])
        self.sigs2 = sum(self.sigs2, [])
        self.irsigs1 = sum(self.irsigs1, [])
        self.irsigs2 = sum(self.irsigs2, [])
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.rchan1 = fake_neo(RecordingChannel,
                               seed=self.seed1, n=self.nchildren)
        self.rchan2 = fake_neo(RecordingChannel,
                               seed=self.seed2, n=self.nchildren)
        self.targobj = self.rchan1

        self.sigs1 = self.rchan1.analogsignals
        self.sigs2 = self.rchan2.analogsignals
        self.irsigs1 = self.rchan1.irregularlysampledsignals
        self.irsigs2 = self.rchan2.irregularlysampledsignals

        self.sigs1a = clone_object(self.sigs1)
        self.irsigs1a = clone_object(self.irsigs1)
Exemplo n.º 15
0
    def test__merge(self):
        unit1a = fake_neo(Unit, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.unit1, unit1a)
        unit1a.annotate(seed=self.seed2)
        unit1a.spiketrains.append(self.trains2[0])
        unit1a.merge(self.unit2)

        assert_same_sub_schema(self.trains1a + self.trains2,
                               unit1a.spiketrains)
Exemplo n.º 16
0
    def test__fake_neo__cascade(self):
        self.annotations["seed"] = None
        obj_type = "Event"
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Event))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
Exemplo n.º 17
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'AnalogSignal'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, AnalogSignal))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
Exemplo n.º 18
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = AnalogSignal
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, AnalogSignal))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
Exemplo n.º 19
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = Epoch
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Epoch))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'IrregularlySampledSignal'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, IrregularlySampledSignal))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
Exemplo n.º 21
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = IrregularlySampledSignal
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, IrregularlySampledSignal))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
Exemplo n.º 22
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'Epoch'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Epoch))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)
Exemplo n.º 23
0
 def test_property_change(self):
     """ Make sure all attributes are saved properly after the change,
     including quantities, units, types etc."""
     iom = NeoHdf5IO(filename=self.test_file)
     for obj_type in objectnames:
         obj = fake_neo(obj_type, cascade=False)
         iom.save(obj)
         self.assertTrue(hasattr(obj, "hdf5_path"))
         replica = iom.get(obj.hdf5_path, cascade=False)
         assert_objects_equivalent(obj, replica)
Exemplo n.º 24
0
    def test__merge(self):
        unit1a = fake_neo(Unit, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.unit1, unit1a)
        unit1a.annotate(seed=self.seed2)
        unit1a.spiketrains.append(self.trains2[0])
        unit1a.merge(self.unit2)
        self.check_creation(self.unit2)

        assert_same_sub_schema(self.trains1a + self.trains2,
                               unit1a.spiketrains)
    def setUp(self):
        self.nchildren = 2
        self.seed1 = 0
        self.seed2 = 10000
        self.rchan1 = fake_neo(RecordingChannel,
                               seed=self.seed1,
                               n=self.nchildren)
        self.rchan2 = fake_neo(RecordingChannel,
                               seed=self.seed2,
                               n=self.nchildren)
        self.targobj = self.rchan1

        self.sigs1 = self.rchan1.analogsignals
        self.sigs2 = self.rchan2.analogsignals
        self.irsigs1 = self.rchan1.irregularlysampledsignals
        self.irsigs2 = self.rchan2.irregularlysampledsignals

        self.sigs1a = clone_object(self.sigs1)
        self.irsigs1a = clone_object(self.irsigs1)
Exemplo n.º 26
0
 def test_property_change(self):
     """ Make sure all attributes are saved properly after the change,
     including quantities, units, types etc."""
     iom = NeoHdf5IO(filename=self.test_file)
     for obj_type in objectnames:
         obj = fake_neo(obj_type, cascade=False)
         iom.save(obj)
         self.assertTrue(hasattr(obj, "hdf5_path"))
         replica = iom.get(obj.hdf5_path, cascade=False)
         assert_objects_equivalent(obj, replica)
Exemplo n.º 27
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = Unit
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Unit))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.spiketrains), 0)
Exemplo n.º 28
0
    def test__merge(self):
        chx1a = fake_neo(ChannelIndex, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.chx1, chx1a)
        chx1a.annotate(seed=self.seed2)
        chx1a.analogsignals.append(self.sigarrs2[0])
        chx1a.merge(self.chx2)

        assert_same_sub_schema(self.sigarrs1a + self.sigarrs2,
                               chx1a.analogsignals,
                               exclude=['channel_index'])
        assert_same_sub_schema(self.units1a + self.units2, chx1a.units)
    def test__merge(self):
        rchan1a = fake_neo(RecordingChannel, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.rchan1, rchan1a)
        rchan1a.annotate(seed=self.seed2)
        rchan1a.analogsignals.append(self.sigs2[0])
        rchan1a.merge(self.rchan2)
        self.check_creation(self.rchan2)

        assert_same_sub_schema(self.sigs1a + self.sigs2, rchan1a.analogsignals)
        assert_same_sub_schema(self.irsigs1a + self.irsigs2,
                               rchan1a.irregularlysampledsignals)
Exemplo n.º 30
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = 'Block'

        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']

        self.assertTrue(isinstance(res, Block))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.segments), 1)
        seg = res.segments[0]
        self.assertEqual(seg.annotations, self.annotations)

        self.assertEqual(len(res.channel_indexes), 1)
        chx = res.channel_indexes[0]
        self.assertEqual(chx.annotations, self.annotations)

        self.assertEqual(len(seg.analogsignals), 1)
        self.assertEqual(len(seg.analogsignals), 1)
        self.assertEqual(len(seg.irregularlysampledsignals), 1)
        self.assertEqual(len(seg.spiketrains), 1)
        self.assertEqual(len(seg.events), 1)
        self.assertEqual(len(seg.epochs), 1)
        self.assertEqual(seg.analogsignals[0].annotations,
                         self.annotations)
        self.assertEqual(seg.analogsignals[0].annotations,
                         self.annotations)
        self.assertEqual(seg.irregularlysampledsignals[0].annotations,
                         self.annotations)
        self.assertEqual(seg.spiketrains[0].annotations,
                         self.annotations)
        self.assertEqual(seg.events[0].annotations,
                         self.annotations)
        self.assertEqual(seg.epochs[0].annotations,
                         self.annotations)

        self.assertEqual(len(chx.units), 1)
        unit = chx.units[0]
        self.assertEqual(unit.annotations, self.annotations)

        self.assertEqual(len(chx.analogsignals), 1)
        self.assertEqual(chx.analogsignals[0].annotations,
                         self.annotations)

        self.assertEqual(len(unit.spiketrains), 1)
        self.assertEqual(unit.spiketrains[0].annotations,
                         self.annotations)
Exemplo n.º 31
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = Block
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Block))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.segments), 0)
        self.assertEqual(len(res.channel_indexes), 0)
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'RecordingChannel'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, RecordingChannel))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
Exemplo n.º 33
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = 'Block'

        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']

        self.assertTrue(isinstance(res, Block))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.segments), 1)
        seg = res.segments[0]
        self.assertEqual(seg.annotations, self.annotations)

        self.assertEqual(len(res.channel_indexes), 1)
        chx = res.channel_indexes[0]
        self.assertEqual(chx.annotations, self.annotations)

        self.assertEqual(len(seg.analogsignals), 1)
        self.assertEqual(len(seg.analogsignals), 1)
        self.assertEqual(len(seg.irregularlysampledsignals), 1)
        self.assertEqual(len(seg.spiketrains), 1)
        self.assertEqual(len(seg.events), 1)
        self.assertEqual(len(seg.epochs), 1)
        self.assertEqual(seg.analogsignals[0].annotations,
                         self.annotations)
        self.assertEqual(seg.analogsignals[0].annotations,
                         self.annotations)
        self.assertEqual(seg.irregularlysampledsignals[0].annotations,
                         self.annotations)
        self.assertEqual(seg.spiketrains[0].annotations,
                         self.annotations)
        self.assertEqual(seg.events[0].annotations,
                         self.annotations)
        self.assertEqual(seg.epochs[0].annotations,
                         self.annotations)

        self.assertEqual(len(chx.units), 1)
        unit = chx.units[0]
        self.assertEqual(unit.annotations, self.annotations)

        self.assertEqual(len(chx.analogsignals), 1)
        self.assertEqual(chx.analogsignals[0].annotations,
                         self.annotations)

        self.assertEqual(len(unit.spiketrains), 1)
        self.assertEqual(unit.spiketrains[0].annotations,
                         self.annotations)
Exemplo n.º 34
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = ChannelIndex
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, ChannelIndex))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.units), 0)
        self.assertEqual(len(res.analogsignals), 0)
Exemplo n.º 35
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = ChannelIndex
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, ChannelIndex))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.units), 0)
        self.assertEqual(len(res.analogsignals), 0)
Exemplo n.º 36
0
    def test__merge(self):
        blk1a = fake_neo(Block, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.blk1, blk1a)
        blk1a.annotate(seed=self.seed2)
        blk1a.segments.append(self.segs2[0])
        blk1a.merge(self.blk2)

        segs1a = clone_object(self.blk1).segments
        chxs1a = clone_object(self.chxs1)

        assert_same_sub_schema(chxs1a + self.chxs2, blk1a.channel_indexes)
        assert_same_sub_schema(segs1a + self.segs2, blk1a.segments)
Exemplo n.º 37
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = Block
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Block))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.segments), 0)
        self.assertEqual(len(res.channel_indexes), 0)
    def test__merge(self):
        rchan1a = fake_neo(RecordingChannel, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.rchan1, rchan1a)
        rchan1a.annotate(seed=self.seed2)
        rchan1a.analogsignals.append(self.sigs2[0])
        rchan1a.merge(self.rchan2)
        self.check_creation(self.rchan2)

        assert_same_sub_schema(self.sigs1a + self.sigs2,
                               rchan1a.analogsignals)
        assert_same_sub_schema(self.irsigs1a + self.irsigs2,
                               rchan1a.irregularlysampledsignals)
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'RecordingChannel'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, RecordingChannel))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
Exemplo n.º 40
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = RecordingChannelGroup
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, RecordingChannelGroup))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.recordingchannels), 0)
        self.assertEqual(len(res.units), 0)
        self.assertEqual(len(res.analogsignalarrays), 0)
Exemplo n.º 41
0
    def test__merge(self):
        blk1a = fake_neo(Block, seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.blk1, blk1a)
        blk1a.annotate(seed=self.seed2)
        blk1a.segments.append(self.segs2[0])
        blk1a.merge(self.blk2)

        segs1a = clone_object(self.blk1).segments
        rcgs1a = clone_object(self.rcgs1)

        assert_same_sub_schema(rcgs1a + self.rcgs2,
                               blk1a.recordingchannelgroups)
        assert_same_sub_schema(segs1a + self.segs2, blk1a.segments)
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = RecordingChannelGroup
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, RecordingChannelGroup))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.recordingchannels), 0)
        self.assertEqual(len(res.units), 0)
        self.assertEqual(len(res.analogsignalarrays), 0)
Exemplo n.º 43
0
 def test_attr_changes(self):
     """ gets an object, changes its attributes, saves it, then compares how
     good the changes were saved. """
     iom = NeoHdf5IO(filename=self.test_file)
     for obj_type in objectnames:
         obj = fake_neo(obj_type=obj_type, cascade=False)
         iom.save(obj)
         orig_obj = iom.get(obj.hdf5_path)
         for attr in obj._all_attrs:
             if hasattr(orig_obj, attr[0]):
                 setattr(obj, attr[0], get_fake_value(*attr))
         iom.save(orig_obj)
         test_obj = iom.get(orig_obj.hdf5_path)
         assert_objects_equivalent(orig_obj, test_obj)
Exemplo n.º 44
0
    def test__merge(self):
        chx1a = fake_neo(ChannelIndex,
                         seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.chx1, chx1a)
        chx1a.annotate(seed=self.seed2)
        chx1a.analogsignals.append(self.sigarrs2[0])
        chx1a.merge(self.chx2)
        self.check_creation(self.chx2)

        assert_same_sub_schema(self.sigarrs1a + self.sigarrs2,
                               chx1a.analogsignals,
                               exclude=['channel_index'])
        assert_same_sub_schema(self.units1a + self.units2,
                               chx1a.units)
Exemplo n.º 45
0
 def test_create(self):
     """
     Create test file with signals, segments, blocks etc.
     """
     iom = NeoHdf5IO(filename=self.test_file)
     b1 = fake_neo()  # creating a structure
     iom.save(b1)  # saving
     # must be assigned after save
     self.assertTrue(hasattr(b1, "hdf5_path"))
     iom.close()
     iom.connect(filename=self.test_file)
     b2 = iom.get(b1.hdf5_path)  # new object
     assert_neo_object_is_compliant(b2)
     assert_same_sub_schema(b1, b2)
Exemplo n.º 46
0
 def test_attr_changes(self):
     """ gets an object, changes its attributes, saves it, then compares how
     good the changes were saved. """
     iom = NeoHdf5IO(filename=self.test_file)
     for obj_type in objectnames:
         obj = fake_neo(obj_type=obj_type, cascade=False)
         iom.save(obj)
         orig_obj = iom.get(obj.hdf5_path)
         for attr in obj._all_attrs:
             if hasattr(orig_obj, attr[0]):
                 setattr(obj, attr[0], get_fake_value(*attr))
         iom.save(orig_obj)
         test_obj = iom.get(orig_obj.hdf5_path)
         assert_objects_equivalent(orig_obj, test_obj)
Exemplo n.º 47
0
 def test_create(self):
     """
     Create test file with signals, segments, blocks etc.
     """
     iom = NeoHdf5IO(filename=self.test_file)
     b1 = fake_neo()  # creating a structure
     iom.save(b1)  # saving
     # must be assigned after save
     self.assertTrue(hasattr(b1, "hdf5_path"))
     iom.close()
     iom.connect(filename=self.test_file)
     b2 = iom.get(b1.hdf5_path)  # new object
     assert_neo_object_is_compliant(b2)
     assert_same_sub_schema(b1, b2)
Exemplo n.º 48
0
    def test__merge(self):
        seg1a = fake_neo(Block, seed=self.seed1, n=self.nchildren).segments[0]
        assert_same_sub_schema(self.seg1, seg1a)
        seg1a.epochs.append(self.epcs2[0])
        seg1a.merge(self.seg2)

        assert_same_sub_schema(self.sigarrs1a + self.sigarrs2,
                               seg1a.analogsignals)
        assert_same_sub_schema(self.irsigs1a + self.irsigs2,
                               seg1a.irregularlysampledsignals)

        assert_same_sub_schema(self.epcs1 + self.epcs2, seg1a.epochs)
        assert_same_sub_schema(self.evts1 + self.evts2, seg1a.events)

        assert_same_sub_schema(self.trains1 + self.trains2, seg1a.spiketrains)
Exemplo n.º 49
0
    def test__merge(self):
        blk1a = fake_neo(Block,
                         seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.blk1, blk1a)
        blk1a.annotate(seed=self.seed2)
        blk1a.segments.append(self.segs2[0])
        blk1a.merge(self.blk2)

        segs1a = clone_object(self.blk1).segments
        rcgs1a = clone_object(self.rcgs1)

        assert_same_sub_schema(rcgs1a + self.rcgs2,
                               blk1a.recordingchannelgroups)
        assert_same_sub_schema(segs1a + self.segs2,
                               blk1a.segments)
Exemplo n.º 50
0
    def test__merge(self):
        blk1a = fake_neo(Block,
                         seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.blk1, blk1a)
        blk1a.annotate(seed=self.seed2)
        blk1a.segments.append(self.segs2[0])
        blk1a.merge(self.blk2)

        segs1a = clone_object(self.blk1).segments
        chxs1a = clone_object(self.chxs1)

        assert_same_sub_schema(chxs1a + self.chxs2,
                               blk1a.channel_indexes)
        assert_same_sub_schema(segs1a + self.segs2,
                               blk1a.segments)
Exemplo n.º 51
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'Segment'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 0)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 0)
Exemplo n.º 52
0
    def test__fake_neo__nocascade(self):
        self.annotations['seed'] = None
        obj_type = 'Segment'
        cascade = False
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Segment))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 0)
        self.assertEqual(len(res.irregularlysampledsignals), 0)
        self.assertEqual(len(res.spiketrains), 0)
        self.assertEqual(len(res.events), 0)
        self.assertEqual(len(res.epochs), 0)
Exemplo n.º 53
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = 'Unit'
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Unit))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.spiketrains), 1)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']
        self.assertEqual(res.spiketrains[0].annotations, self.annotations)
Exemplo n.º 54
0
    def test__merge(self):
        rcg1a = fake_neo(RecordingChannelGroup,
                         seed=self.seed1,
                         n=self.nchildren)
        assert_same_sub_schema(self.rcg1, rcg1a)
        rcg1a.annotate(seed=self.seed2)
        rcg1a.analogsignalarrays.append(self.sigarrs2[0])
        rcg1a.merge(self.rcg2)
        self.check_creation(self.rcg2)

        assert_same_sub_schema(self.sigarrs1a + self.sigarrs2,
                               rcg1a.analogsignalarrays,
                               exclude=['channel_index'])
        assert_same_sub_schema(self.units1a + self.units2, rcg1a.units)
        assert_same_sub_schema(self.rchans1a + self.rchans2,
                               rcg1a.recordingchannels,
                               exclude=['channel_index'])
    def test__merge(self):
        rcg1a = fake_neo(RecordingChannelGroup,
                         seed=self.seed1, n=self.nchildren)
        assert_same_sub_schema(self.rcg1, rcg1a)
        rcg1a.annotate(seed=self.seed2)
        rcg1a.analogsignalarrays.append(self.sigarrs2[0])
        rcg1a.merge(self.rcg2)
        self.check_creation(self.rcg2)

        assert_same_sub_schema(self.sigarrs1a + self.sigarrs2,
                               rcg1a.analogsignalarrays,
                               exclude=['channel_index'])
        assert_same_sub_schema(self.units1a + self.units2,
                               rcg1a.units)
        assert_same_sub_schema(self.rchans1a + self.rchans2,
                               rcg1a.recordingchannels,
                               exclude=['channel_index'])
Exemplo n.º 56
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = 'Unit'
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, Unit))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.spiketrains), 1)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']
        self.assertEqual(res.spiketrains[0].annotations,
                         self.annotations)
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = RecordingChannel
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, RecordingChannel))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        self.assertEqual(len(res.analogsignals), 1)
        self.assertEqual(len(res.irregularlysampledsignals), 1)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']
        self.assertEqual(res.analogsignals[0].annotations, self.annotations)
        self.assertEqual(res.irregularlysampledsignals[0].annotations,
                         self.annotations)
Exemplo n.º 58
0
    def test__fake_neo__cascade(self):
        self.annotations['seed'] = None
        obj_type = 'RecordingChannelGroup'
        cascade = True
        res = fake_neo(obj_type=obj_type, cascade=cascade)

        self.assertTrue(isinstance(res, RecordingChannelGroup))
        assert_neo_object_is_compliant(res)
        self.assertEqual(res.annotations, self.annotations)

        for child in res.children_recur:
            del child.annotations['i']
            del child.annotations['j']

        self.assertEqual(len(res.recordingchannels), 1)
        rchan = res.recordingchannels[0]
        self.assertEqual(rchan.annotations, self.annotations)

        self.assertEqual(len(res.units), 1)
        unit = res.units[0]
        self.assertEqual(unit.annotations, self.annotations)

        self.assertEqual(len(res.analogsignalarrays), 1)
        self.assertEqual(res.analogsignalarrays[0].annotations,
                         self.annotations)

        self.assertEqual(len(rchan.analogsignals), 1)
        self.assertEqual(len(rchan.irregularlysampledsignals), 1)
        self.assertEqual(rchan.analogsignals[0].annotations, self.annotations)
        self.assertEqual(rchan.irregularlysampledsignals[0].annotations,
                         self.annotations)

        self.assertEqual(len(unit.spiketrains), 1)
        self.assertEqual(len(unit.spikes), 1)
        self.assertEqual(unit.spiketrains[0].annotations, self.annotations)
        self.assertEqual(unit.spikes[0].annotations, self.annotations)