def check_creation(self, chx):
        assert_neo_object_is_compliant(chx)

        seed = chx.annotations['seed']

        # for i, unit in enumerate(chx.units):
        #     for sigarr in chx.analogsignals:
        #         self.assertEqual(unit.channel_indexes[0],
        #                          sigarr.channel_index[i])

        targ2 = get_fake_value('name', str, seed=seed + 4, obj=ChannelIndex)
        self.assertEqual(chx.name, targ2)

        targ3 = get_fake_value('description',
                               str,
                               seed=seed + 5,
                               obj=ChannelIndex)
        self.assertEqual(chx.description, targ3)

        targ4 = get_fake_value('file_origin', str)
        self.assertEqual(chx.file_origin, targ4)

        targ5 = get_annotations()
        targ5['seed'] = seed
        self.assertEqual(chx.annotations, targ5)

        self.assertTrue(hasattr(chx, 'units'))
        self.assertTrue(hasattr(chx, 'analogsignals'))

        self.assertEqual(len(chx.units), self.nchildren)
        self.assertEqual(len(chx.analogsignals), self.nchildren)
    def check_creation(self, rcg):
        assert_neo_object_is_compliant(rcg)

        seed = rcg.annotations['seed']

        for i, rchan in enumerate(rcg.recordingchannels):
            self.assertEqual(rchan.name, rcg.channel_names[i].astype(str))
            self.assertEqual(rchan.index, rcg.channel_indexes[i])
        for i, unit in enumerate(rcg.units):
            for sigarr in rcg.analogsignalarrays:
                self.assertEqual(unit.channel_indexes[0],
                                 sigarr.channel_index[i])

        targ2 = get_fake_value('name', str, seed=seed+2,
                               obj=RecordingChannelGroup)
        self.assertEqual(rcg.name, targ2)

        targ3 = get_fake_value('description', str,
                               seed=seed+3, obj=RecordingChannelGroup)
        self.assertEqual(rcg.description, targ3)

        targ4 = get_fake_value('file_origin', str)
        self.assertEqual(rcg.file_origin, targ4)

        targ5 = get_annotations()
        targ5['seed'] = seed
        self.assertEqual(rcg.annotations, targ5)

        self.assertTrue(hasattr(rcg, 'recordingchannels'))
        self.assertTrue(hasattr(rcg, 'units'))
        self.assertTrue(hasattr(rcg, 'analogsignalarrays'))

        self.assertEqual(len(rcg.recordingchannels), self.nchildren)
        self.assertEqual(len(rcg.units), self.nchildren)
        self.assertEqual(len(rcg.analogsignalarrays), self.nchildren)
Beispiel #3
0
    def check_creation(self, unit):
        assert_neo_object_is_compliant(unit)

        seed = unit.annotations['seed']

        targ0 = get_fake_value('channel_indexes', np.ndarray, dim=1, dtype='i',
                               seed=seed+0)
        assert_arrays_equal(unit.channel_indexes, targ0)

        targ1 = get_fake_value('name', str, seed=seed+1, obj=Unit)
        self.assertEqual(unit.name, targ1)

        targ2 = get_fake_value('description', str,
                               seed=seed+2, obj=Unit)
        self.assertEqual(unit.description, targ2)

        targ3 = get_fake_value('file_origin', str)
        self.assertEqual(unit.file_origin, targ3)

        targ4 = get_annotations()
        targ4['seed'] = seed
        self.assertEqual(unit.annotations, targ4)

        self.assertTrue(hasattr(unit, 'spikes'))
        self.assertTrue(hasattr(unit, 'spiketrains'))

        self.assertEqual(len(unit.spikes), self.nchildren)
        self.assertEqual(len(unit.spiketrains), self.nchildren)
    def check_creation(self, chx):
        assert_neo_object_is_compliant(chx)

        seed = chx.annotations['seed']

        # for i, unit in enumerate(chx.units):
        #     for sigarr in chx.analogsignals:
        #         self.assertEqual(unit.channel_indexes[0],
        #                          sigarr.channel_index[i])

        targ2 = get_fake_value('name', str, seed=seed+4,
                               obj=ChannelIndex)
        self.assertEqual(chx.name, targ2)

        targ3 = get_fake_value('description', str,
                               seed=seed+5, obj=ChannelIndex)
        self.assertEqual(chx.description, targ3)

        targ4 = get_fake_value('file_origin', str)
        self.assertEqual(chx.file_origin, targ4)

        targ5 = get_annotations()
        targ5['seed'] = seed
        self.assertEqual(chx.annotations, targ5)

        self.assertTrue(hasattr(chx, 'units'))
        self.assertTrue(hasattr(chx, 'analogsignals'))

        self.assertEqual(len(chx.units), self.nchildren)
        self.assertEqual(len(chx.analogsignals), self.nchildren)
Beispiel #5
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
        labels = get_fake_value('labels', np.ndarray, seed=1, dim=1, dtype='S')
        name = get_fake_value('name', str, seed=2, obj=Event)
        description = get_fake_value('description', str, seed=3, obj='Event')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {
            'name': name,
            'description': description,
            'file_origin': file_origin
        }
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Event, annotate=False, seed=0)
        res12 = get_fake_values('Event', annotate=False, seed=0)
        res21 = get_fake_values(Event, annotate=True, seed=0)
        res22 = get_fake_values('Event', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('times'), times)
        assert_arrays_equal(res12.pop('times'), times)
        assert_arrays_equal(res21.pop('times'), times)
        assert_arrays_equal(res22.pop('times'), times)

        assert_arrays_equal(res11.pop('labels'), labels)
        assert_arrays_equal(res12.pop('labels'), labels)
        assert_arrays_equal(res21.pop('labels'), labels)
        assert_arrays_equal(res22.pop('labels'), labels)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        index = get_fake_value('index', int, seed=0)
        coordinate = get_fake_value('coordinate', pq.Quantity, seed=1, dim=1)
        name = get_fake_value('name', str, seed=2, obj=RecordingChannel)
        description = get_fake_value('description',
                                     str,
                                     seed=3,
                                     obj='RecordingChannel')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {
            'index': index,
            'name': name,
            'description': description,
            'file_origin': file_origin
        }
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(RecordingChannel, annotate=False, seed=0)
        res12 = get_fake_values('RecordingChannel', annotate=False, seed=0)
        res21 = get_fake_values(RecordingChannel, annotate=True, seed=0)
        res22 = get_fake_values('RecordingChannel', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('coordinate'), coordinate)
        assert_arrays_equal(res12.pop('coordinate'), coordinate)
        assert_arrays_equal(res21.pop('coordinate'), coordinate)
        assert_arrays_equal(res22.pop('coordinate'), coordinate)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
Beispiel #7
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
        labels = get_fake_value('labels', np.ndarray, seed=1, dim=1, dtype='S')
        name = get_fake_value('name', str, seed=2, obj=Event)
        description = get_fake_value('description', str,
                                     seed=3, obj='Event')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Event, annotate=False, seed=0)
        res12 = get_fake_values('Event', annotate=False, seed=0)
        res21 = get_fake_values(Event, annotate=True, seed=0)
        res22 = get_fake_values('Event', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('times'), times)
        assert_arrays_equal(res12.pop('times'), times)
        assert_arrays_equal(res21.pop('times'), times)
        assert_arrays_equal(res22.pop('times'), times)

        assert_arrays_equal(res11.pop('labels'), labels)
        assert_arrays_equal(res12.pop('labels'), labels)
        assert_arrays_equal(res21.pop('labels'), labels)
        assert_arrays_equal(res22.pop('labels'), labels)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
Beispiel #8
0
    def test__get_fake_values(self):
        self.annotations["seed"] = 0
        time = get_fake_value("time", pq.Quantity, seed=0, dim=0)
        label = get_fake_value("label", str, seed=1)
        name = get_fake_value("name", str, seed=2, obj=Event)
        description = get_fake_value("description", str, seed=3, obj="Event")
        file_origin = get_fake_value("file_origin", str)
        attrs1 = {"label": label, "name": name, "description": description, "file_origin": file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Event, annotate=False, seed=0)
        res12 = get_fake_values("Event", annotate=False, seed=0)
        res21 = get_fake_values(Event, annotate=True, seed=0)
        res22 = get_fake_values("Event", annotate=True, seed=0)

        assert_arrays_equal(res11.pop("time"), time)
        assert_arrays_equal(res12.pop("time"), time)
        assert_arrays_equal(res21.pop("time"), time)
        assert_arrays_equal(res22.pop("time"), time)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
Beispiel #9
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        channel_indexes = get_fake_value('channel_indexes', np.ndarray, seed=0,
                                         dim=1, dtype='i')
        name = get_fake_value('name', str, seed=1, obj=Unit)
        description = get_fake_value('description', str, seed=2, obj='Unit')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Unit, annotate=False, seed=0)
        res12 = get_fake_values('Unit', annotate=False, seed=0)
        res21 = get_fake_values(Unit, annotate=True, seed=0)
        res22 = get_fake_values('Unit', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('channel_indexes'), channel_indexes)
        assert_arrays_equal(res12.pop('channel_indexes'), channel_indexes)
        assert_arrays_equal(res21.pop('channel_indexes'), channel_indexes)
        assert_arrays_equal(res22.pop('channel_indexes'), channel_indexes)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        index = get_fake_value('index', int, seed=0)
        coordinate = get_fake_value('coordinate', pq.Quantity, seed=1, dim=1)
        name = get_fake_value('name', str, seed=2, obj=RecordingChannel)
        description = get_fake_value('description', str, seed=3,
                                     obj='RecordingChannel')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'index': index,
                  'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(RecordingChannel, annotate=False, seed=0)
        res12 = get_fake_values('RecordingChannel', annotate=False, seed=0)
        res21 = get_fake_values(RecordingChannel, annotate=True, seed=0)
        res22 = get_fake_values('RecordingChannel', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('coordinate'), coordinate)
        assert_arrays_equal(res12.pop('coordinate'), coordinate)
        assert_arrays_equal(res21.pop('coordinate'), coordinate)
        assert_arrays_equal(res22.pop('coordinate'), coordinate)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def check_creation(self, rchan):
        assert_neo_object_is_compliant(rchan)

        seed = rchan.annotations['seed']

        targ0 = get_fake_value('index', int, seed=seed+0, obj=RecordingChannel)
        self.assertEqual(rchan.index, targ0)

        targ1 = get_fake_value('coordinate', pq.Quantity, dim=1, seed=seed+1)
        assert_arrays_equal(rchan.coordinate, targ1)

        targ2 = get_fake_value('name', str, seed=seed+2, obj=RecordingChannel)
        self.assertEqual(rchan.name, targ2)

        targ3 = get_fake_value('description', str,
                               seed=seed+3, obj=RecordingChannel)
        self.assertEqual(rchan.description, targ3)

        targ4 = get_fake_value('file_origin', str)
        self.assertEqual(rchan.file_origin, targ4)

        targ5 = get_annotations()
        targ5['seed'] = seed
        self.assertEqual(rchan.annotations, targ5)

        self.assertTrue(hasattr(rchan, 'analogsignals'))
        self.assertTrue(hasattr(rchan, 'irregularlysampledsignals'))

        self.assertEqual(len(rchan.analogsignals), self.nchildren)
        self.assertEqual(len(rchan.irregularlysampledsignals), self.nchildren)
Beispiel #12
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
        signal = get_fake_value('signal', pq.Quantity, seed=1, dim=2)
        name = get_fake_value('name',
                              str,
                              seed=2,
                              obj=IrregularlySampledSignal)
        description = get_fake_value('description',
                                     str,
                                     seed=3,
                                     obj='IrregularlySampledSignal')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {
            'name': name,
            'description': description,
            'file_origin': file_origin
        }
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(IrregularlySampledSignal,
                                annotate=False,
                                seed=0)
        res12 = get_fake_values('IrregularlySampledSignal',
                                annotate=False,
                                seed=0)
        res21 = get_fake_values(IrregularlySampledSignal,
                                annotate=True,
                                seed=0)
        res22 = get_fake_values('IrregularlySampledSignal',
                                annotate=True,
                                seed=0)

        assert_array_equal(res11.pop('times'), times)
        assert_array_equal(res12.pop('times'), times)
        assert_array_equal(res21.pop('times'), times)
        assert_array_equal(res22.pop('times'), times)

        assert_array_equal(res11.pop('signal'), signal)
        assert_array_equal(res12.pop('signal'), signal)
        assert_array_equal(res21.pop('signal'), signal)
        assert_array_equal(res22.pop('signal'), signal)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__float(self):
        name = 'test__float'
        datatype = float
        targ = 1000. * np.random.random()

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, float))
        self.assertEqual(targ, res)
    def test__int(self):
        name = 'test__int'
        datatype = int
        targ = np.random.randint(100)

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, int))
        self.assertEqual(targ, res)
    def test__float(self):
        name = 'test__float'
        datatype = float
        targ = 1000. * np.random.random()

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, float))
        self.assertEqual(targ, res)
    def test__datetime(self):
        name = 'test__datetime'
        datatype = datetime
        targ = datetime.fromtimestamp(1000000000 * np.random.random())

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, datetime))
        self.assertEqual(res, targ)
    def test__str(self):
        name = 'test__str'
        datatype = str
        targ = str(np.random.randint(100000))

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)
    def test__int(self):
        name = 'test__int'
        datatype = int
        targ = np.random.randint(100)

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, int))
        self.assertEqual(targ, res)
    def test__datetime(self):
        name = 'test__datetime'
        datatype = datetime
        targ = datetime.fromtimestamp(1000000000 * np.random.random())

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, datetime))
        self.assertEqual(res, targ)
    def test__str(self):
        name = 'test__str'
        datatype = str
        targ = str(np.random.randint(100000))

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)
    def test__file_origin(self):
        name = 'file_origin'
        datatype = str
        targ = 'test_file.txt'

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__file_origin(self):
        name = 'file_origin'
        datatype = str
        targ = 'test_file.txt'

        res = get_fake_value(name, datatype, seed=0)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        signal = get_fake_value('signal', pq.Quantity, seed=0, dim=2)
        sampling_rate = get_fake_value('sampling_rate',
                                       pq.Quantity,
                                       seed=1,
                                       dim=0)
        t_start = get_fake_value('t_start', pq.Quantity, seed=2, dim=0)
        channel_index = get_fake_value('channel_index',
                                       np.ndarray,
                                       seed=3,
                                       dim=1,
                                       dtype='i')
        name = get_fake_value('name', str, seed=4, obj=AnalogSignalArray)
        description = get_fake_value('description',
                                     str,
                                     seed=5,
                                     obj='AnalogSignalArray')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {
            'name': name,
            'description': description,
            'file_origin': file_origin
        }
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(AnalogSignalArray, annotate=False, seed=0)
        res12 = get_fake_values('AnalogSignalArray', annotate=False, seed=0)
        res21 = get_fake_values(AnalogSignalArray, annotate=True, seed=0)
        res22 = get_fake_values('AnalogSignalArray', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('signal'), signal)
        assert_arrays_equal(res12.pop('signal'), signal)
        assert_arrays_equal(res21.pop('signal'), signal)
        assert_arrays_equal(res22.pop('signal'), signal)

        assert_arrays_equal(res11.pop('sampling_rate'), sampling_rate)
        assert_arrays_equal(res12.pop('sampling_rate'), sampling_rate)
        assert_arrays_equal(res21.pop('sampling_rate'), sampling_rate)
        assert_arrays_equal(res22.pop('sampling_rate'), sampling_rate)

        assert_arrays_equal(res11.pop('t_start'), t_start)
        assert_arrays_equal(res12.pop('t_start'), t_start)
        assert_arrays_equal(res21.pop('t_start'), t_start)
        assert_arrays_equal(res22.pop('t_start'), t_start)

        assert_arrays_equal(res11.pop('channel_index'), channel_index)
        assert_arrays_equal(res12.pop('channel_index'), channel_index)
        assert_arrays_equal(res21.pop('channel_index'), channel_index)
        assert_arrays_equal(res22.pop('channel_index'), channel_index)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__sampling_rate(self):
        name = 'sampling_rate'
        datatype = pq.Quantity
        targ = 10000.0 * pq.Hz

        res = get_fake_value(name, datatype)
        self.assertTrue(isinstance(res, pq.Quantity))
        self.assertEqual(res.units, pq.Hz)
        assert_arrays_equal(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__t_stop(self):
        name = 't_stop'
        datatype = pq.Quantity
        targ = 1.0 * pq.millisecond

        res = get_fake_value(name, datatype)
        self.assertTrue(isinstance(res, pq.Quantity))
        self.assertEqual(res.units, pq.millisecond)
        assert_arrays_equal(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
Beispiel #26
0
    def check_creation(self, unit):
        assert_neo_object_is_compliant(unit)

        seed = unit.annotations['seed']

        targ1 = get_fake_value('name', str, seed=seed, obj=Unit)
        self.assertEqual(unit.name, targ1)

        targ2 = get_fake_value('description', str, seed=seed + 1, obj=Unit)
        self.assertEqual(unit.description, targ2)

        targ3 = get_fake_value('file_origin', str)
        self.assertEqual(unit.file_origin, targ3)

        targ4 = get_annotations()
        targ4['seed'] = seed
        self.assertEqual(unit.annotations, targ4)

        self.assertTrue(hasattr(unit, 'spiketrains'))

        self.assertEqual(len(unit.spiketrains), self.nchildren)
    def test__name(self):
        name = 'name'
        datatype = str
        obj = 'Block'
        targ = 'Block' + str(np.random.randint(100000))

        res = get_fake_value(name, datatype, seed=0, obj=obj)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__description(self):
        name = 'description'
        datatype = str
        obj = Segment
        targ = 'test Segment ' + str(np.random.randint(100000))

        res = get_fake_value(name, datatype, seed=0, obj=obj)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__sampling_rate(self):
        name = 'sampling_rate'
        datatype = pq.Quantity
        targ = 10000.0 * pq.Hz

        res = get_fake_value(name, datatype)
        self.assertTrue(isinstance(res, pq.Quantity))
        self.assertEqual(res.units, pq.Hz)
        assert_arrays_equal(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__t_stop(self):
        name = 't_stop'
        datatype = pq.Quantity
        targ = 1.0 * pq.millisecond

        res = get_fake_value(name, datatype)
        self.assertTrue(isinstance(res, pq.Quantity))
        self.assertEqual(res.units, pq.millisecond)
        assert_arrays_equal(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
    def test__description(self):
        name = 'description'
        datatype = str
        obj = Segment
        targ = 'test Segment ' + str(np.random.randint(100000))

        res = get_fake_value(name, datatype, seed=0, obj=obj)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
Beispiel #32
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0

        name = get_fake_value('name', str, seed=0, obj=Unit)
        description = get_fake_value('description', str, seed=1, obj='Unit')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Unit, annotate=False, seed=0)
        res12 = get_fake_values('Unit', annotate=False, seed=0)
        res21 = get_fake_values(Unit, annotate=True, seed=0)
        res22 = get_fake_values('Unit', annotate=True, seed=0)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__name(self):
        name = 'name'
        datatype = str
        obj = 'Block'
        targ = 'Block' + str(np.random.randint(100000))

        res = get_fake_value(name, datatype, seed=0, obj=obj)
        self.assertTrue(isinstance(res, str))
        self.assertEqual(targ, res)

        self.assertRaises(ValueError, get_fake_value, name, datatype, dim=1)
        self.assertRaises(ValueError, get_fake_value, name, np.ndarray)
Beispiel #34
0
    def check_creation(self, blk):
        assert_neo_object_is_compliant(blk)

        seed = blk.annotations['seed']

        targ0 = get_fake_value('file_datetime', datetime, seed=seed+0)
        self.assertEqual(blk.file_datetime, targ0)

        targ1 = get_fake_value('rec_datetime', datetime, seed=seed+1)
        self.assertEqual(blk.rec_datetime, targ1)

        targ2 = get_fake_value('index', int, seed=seed+2, obj=Block)
        self.assertEqual(blk.index, targ2)

        targ3 = get_fake_value('name', str, seed=seed+3, obj=Block)
        self.assertEqual(blk.name, targ3)

        targ4 = get_fake_value('description', str, seed=seed+4, obj=Block)
        self.assertEqual(blk.description, targ4)

        targ5 = get_fake_value('file_origin', str)
        self.assertEqual(blk.file_origin, targ5)

        targ6 = get_annotations()
        targ6['seed'] = seed
        self.assertEqual(blk.annotations, targ6)

        self.assertTrue(hasattr(blk, 'channel_indexes'))
        self.assertTrue(hasattr(blk, 'segments'))

        self.assertEqual(len(blk.channel_indexes), self.nchildren)
        self.assertEqual(len(blk.segments), self.nchildren)
Beispiel #35
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        file_datetime = get_fake_value('file_datetime', datetime, seed=0)
        rec_datetime = get_fake_value('rec_datetime', datetime, seed=1)
        index = get_fake_value('index', int, seed=2)
        name = get_fake_value('name', str, seed=3, obj=Block)
        description = get_fake_value('description', str, seed=4, obj='Block')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'file_datetime': file_datetime,
                  'rec_datetime': rec_datetime,
                  'index': index,
                  'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Block, annotate=False, seed=0)
        res12 = get_fake_values('Block', annotate=False, seed=0)
        res21 = get_fake_values(Block, annotate=True, seed=0)
        res22 = get_fake_values('Block', annotate=True, seed=0)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
Beispiel #36
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        file_datetime = get_fake_value('file_datetime', datetime, seed=0)
        rec_datetime = get_fake_value('rec_datetime', datetime, seed=1)
        index = get_fake_value('index', int, seed=2)
        name = get_fake_value('name', str, seed=3, obj=Segment)
        description = get_fake_value('description', str, seed=4, obj='Segment')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {
            'file_datetime': file_datetime,
            'rec_datetime': rec_datetime,
            'index': index,
            'name': name,
            'description': description,
            'file_origin': file_origin
        }
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Segment, annotate=False, seed=0)
        res12 = get_fake_values('Segment', annotate=False, seed=0)
        res21 = get_fake_values(Segment, annotate=True, seed=0)
        res22 = get_fake_values('Segment', annotate=True, seed=0)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
Beispiel #37
0
    def check_creation(self, blk):
        assert_neo_object_is_compliant(blk)

        seed = blk.annotations['seed']

        targ0 = get_fake_value('file_datetime', datetime, seed=seed + 0)
        self.assertEqual(blk.file_datetime, targ0)

        targ1 = get_fake_value('rec_datetime', datetime, seed=seed + 1)
        self.assertEqual(blk.rec_datetime, targ1)

        targ2 = get_fake_value('index', int, seed=seed + 2, obj=Block)
        self.assertEqual(blk.index, targ2)

        targ3 = get_fake_value('name', str, seed=seed + 3, obj=Block)
        self.assertEqual(blk.name, targ3)

        targ4 = get_fake_value('description', str, seed=seed + 4, obj=Block)
        self.assertEqual(blk.description, targ4)

        targ5 = get_fake_value('file_origin', str)
        self.assertEqual(blk.file_origin, targ5)

        targ6 = get_annotations()
        targ6['seed'] = seed
        self.assertEqual(blk.annotations, targ6)

        self.assertTrue(hasattr(blk, 'channel_indexes'))
        self.assertTrue(hasattr(blk, 'segments'))

        self.assertEqual(len(blk.channel_indexes), self.nchildren)
        self.assertEqual(len(blk.segments), self.nchildren)
Beispiel #38
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
        durations = get_fake_value('durations', pq.Quantity, seed=1, dim=1)
        labels = get_fake_value('labels', np.ndarray, seed=2, dim=1, dtype='U')
        name = get_fake_value('name', str, seed=3, obj=Epoch)
        description = get_fake_value('description', str, seed=4, obj='Epoch')
        file_origin = get_fake_value('file_origin', str)
        arr_ann = get_fake_value('array_annotations',
                                 dict,
                                 seed=6,
                                 obj=Epoch,
                                 n=5)
        attrs1 = {
            'name': name,
            'description': description,
            'file_origin': file_origin
        }
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)
        attrs2['array_annotations'] = arr_ann

        res11 = get_fake_values(Epoch, annotate=False, seed=0)
        res12 = get_fake_values('Epoch', annotate=False, seed=0)
        res21 = get_fake_values(Epoch, annotate=True, seed=0)
        res22 = get_fake_values('Epoch', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('times'), times)
        assert_arrays_equal(res12.pop('times'), times)
        assert_arrays_equal(res21.pop('times'), times)
        assert_arrays_equal(res22.pop('times'), times)

        assert_arrays_equal(res11.pop('durations'), durations)
        assert_arrays_equal(res12.pop('durations'), durations)
        assert_arrays_equal(res21.pop('durations'), durations)
        assert_arrays_equal(res22.pop('durations'), durations)

        assert_arrays_equal(res11.pop('labels'), labels)
        assert_arrays_equal(res12.pop('labels'), labels)
        assert_arrays_equal(res21.pop('labels'), labels)
        assert_arrays_equal(res22.pop('labels'), labels)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        # Array annotations need to be compared separately
        # because numpy arrays define equality differently
        arr_ann_res21 = res21.pop('array_annotations')
        arr_ann_attrs2 = attrs2.pop('array_annotations')
        self.assertEqual(res21, attrs2)
        assert_arrays_equal(arr_ann_res21['valid'], arr_ann_attrs2['valid'])
        assert_arrays_equal(arr_ann_res21['number'], arr_ann_attrs2['number'])
        arr_ann_res22 = res22.pop('array_annotations')
        self.assertEqual(res22, attrs2)
        assert_arrays_equal(arr_ann_res22['valid'], arr_ann_attrs2['valid'])
        assert_arrays_equal(arr_ann_res22['number'], arr_ann_attrs2['number'])
Beispiel #39
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        time = get_fake_value('time', pq.Quantity, seed=0, dim=0)
        duration = get_fake_value('duration', pq.Quantity, seed=1)
        label = get_fake_value('label', str, seed=2)
        name = get_fake_value('name', str, seed=3, obj=Epoch)
        description = get_fake_value('description', str, seed=4, obj='Epoch')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'label': label,
                  'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(Epoch, annotate=False, seed=0)
        res12 = get_fake_values('Epoch', annotate=False, seed=0)
        res21 = get_fake_values(Epoch, annotate=True, seed=0)
        res22 = get_fake_values('Epoch', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('time'), time)
        assert_arrays_equal(res12.pop('time'), time)
        assert_arrays_equal(res21.pop('time'), time)
        assert_arrays_equal(res22.pop('time'), time)

        assert_arrays_equal(res11.pop('duration'), duration)
        assert_arrays_equal(res12.pop('duration'), duration)
        assert_arrays_equal(res21.pop('duration'), duration)
        assert_arrays_equal(res22.pop('duration'), duration)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__ndarray(self):
        name = 'test__ndarray'
        datatype = np.ndarray
        dim = 2

        size = []
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = np.random.random(size) * 1000

        res = get_fake_value(name, datatype, dim=dim, seed=0)
        self.assertTrue(isinstance(res, np.ndarray))
        assert_arrays_equal(targ, res)
    def test__list(self):
        name = 'test__list'
        datatype = list
        dim = 2

        size = []
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = (np.random.random(size) * 1000).tolist()

        res = get_fake_value(name, datatype, dim=dim, seed=0)
        self.assertTrue(isinstance(res, list))
        self.assertEqual(targ, res)
    def test__ndarray(self):
        name = 'test__ndarray'
        datatype = np.ndarray
        dim = 2

        size = []
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = np.random.random(size) * 1000

        res = get_fake_value(name, datatype, dim=dim, seed=0)
        self.assertTrue(isinstance(res, np.ndarray))
        assert_arrays_equal(targ, res)
    def test__list(self):
        name = 'test__list'
        datatype = list
        dim = 2

        size = []
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = (np.random.random(size) * 1000).tolist()

        res = get_fake_value(name, datatype, dim=dim, seed=0)
        self.assertTrue(isinstance(res, list))
        self.assertEqual(targ, res)
Beispiel #44
0
    def check_creation(self, unit):
        assert_neo_object_is_compliant(unit)

        seed = unit.annotations['seed']

        targ1 = get_fake_value('name', str, seed=seed, obj=Unit)
        self.assertEqual(unit.name, targ1)

        targ2 = get_fake_value('description', str,
                               seed=seed + 1, obj=Unit)
        self.assertEqual(unit.description, targ2)

        targ3 = get_fake_value('file_origin', str)
        self.assertEqual(unit.file_origin, targ3)

        targ4 = get_annotations()
        targ4['seed'] = seed
        self.assertEqual(unit.annotations, targ4)

        self.assertTrue(hasattr(unit, 'spiketrains'))

        self.assertEqual(len(unit.spiketrains), self.nchildren)
Beispiel #45
0
    def check_creation(self, rcg):
        assert_neo_object_is_compliant(rcg)

        seed = rcg.annotations['seed']

        for i, rchan in enumerate(rcg.recordingchannels):
            self.assertEqual(rchan.name, rcg.channel_names[i].astype(str))
            self.assertEqual(rchan.index, rcg.channel_indexes[i])
        for i, unit in enumerate(rcg.units):
            for sigarr in rcg.analogsignalarrays:
                self.assertEqual(unit.channel_indexes[0],
                                 sigarr.channel_index[i])

        targ2 = get_fake_value('name',
                               str,
                               seed=seed + 2,
                               obj=RecordingChannelGroup)
        self.assertEqual(rcg.name, targ2)

        targ3 = get_fake_value('description',
                               str,
                               seed=seed + 3,
                               obj=RecordingChannelGroup)
        self.assertEqual(rcg.description, targ3)

        targ4 = get_fake_value('file_origin', str)
        self.assertEqual(rcg.file_origin, targ4)

        targ5 = get_annotations()
        targ5['seed'] = seed
        self.assertEqual(rcg.annotations, targ5)

        self.assertTrue(hasattr(rcg, 'recordingchannels'))
        self.assertTrue(hasattr(rcg, 'units'))
        self.assertTrue(hasattr(rcg, 'analogsignalarrays'))

        self.assertEqual(len(rcg.recordingchannels), self.nchildren)
        self.assertEqual(len(rcg.units), self.nchildren)
        self.assertEqual(len(rcg.analogsignalarrays), self.nchildren)
    def check_creation(self, rchan):
        assert_neo_object_is_compliant(rchan)

        seed = rchan.annotations['seed']

        targ0 = get_fake_value('index',
                               int,
                               seed=seed + 0,
                               obj=RecordingChannel)
        self.assertEqual(rchan.index, targ0)

        targ1 = get_fake_value('coordinate', pq.Quantity, dim=1, seed=seed + 1)
        assert_arrays_equal(rchan.coordinate, targ1)

        targ2 = get_fake_value('name',
                               str,
                               seed=seed + 2,
                               obj=RecordingChannel)
        self.assertEqual(rchan.name, targ2)

        targ3 = get_fake_value('description',
                               str,
                               seed=seed + 3,
                               obj=RecordingChannel)
        self.assertEqual(rchan.description, targ3)

        targ4 = get_fake_value('file_origin', str)
        self.assertEqual(rchan.file_origin, targ4)

        targ5 = get_annotations()
        targ5['seed'] = seed
        self.assertEqual(rchan.annotations, targ5)

        self.assertTrue(hasattr(rchan, 'analogsignals'))
        self.assertTrue(hasattr(rchan, 'irregularlysampledsignals'))

        self.assertEqual(len(rchan.analogsignals), self.nchildren)
        self.assertEqual(len(rchan.irregularlysampledsignals), self.nchildren)
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
        signal = get_fake_value('signal', pq.Quantity, seed=1, dim=2)
        name = get_fake_value('name', str, seed=2,
                              obj=IrregularlySampledSignal)
        description = get_fake_value('description', str, seed=3,
                                     obj='IrregularlySampledSignal')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(IrregularlySampledSignal,
                                annotate=False, seed=0)
        res12 = get_fake_values('IrregularlySampledSignal',
                                annotate=False, seed=0)
        res21 = get_fake_values(IrregularlySampledSignal,
                                annotate=True, seed=0)
        res22 = get_fake_values('IrregularlySampledSignal',
                                annotate=True, seed=0)

        assert_array_equal(res11.pop('times'), times)
        assert_array_equal(res12.pop('times'), times)
        assert_array_equal(res21.pop('times'), times)
        assert_array_equal(res22.pop('times'), times)

        assert_array_equal(res11.pop('signal'), signal)
        assert_array_equal(res12.pop('signal'), signal)
        assert_array_equal(res21.pop('signal'), signal)
        assert_array_equal(res22.pop('signal'), signal)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
    def test__quantity_force_units(self):
        name = 'test__quantity'
        datatype = np.ndarray
        dim = 2
        units = pq.ohm

        size = []
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = pq.Quantity(np.random.random(size) * 1000, units=units)

        res = get_fake_value(name, datatype, dim=dim, seed=0, units=units)
        self.assertTrue(isinstance(res, np.ndarray))
        assert_arrays_equal(targ, res)
Beispiel #49
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)
    def test__quantity_force_units(self):
        name = 'test__quantity'
        datatype = np.ndarray
        dim = 2
        units = pq.ohm

        size = []
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = pq.Quantity(np.random.random(size) * 1000, units=units)

        res = get_fake_value(name, datatype, dim=dim, seed=0, units=units)
        self.assertTrue(isinstance(res, np.ndarray))
        assert_arrays_equal(targ, res)
 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)
    def test__quantity(self):
        name = 'test__quantity'
        datatype = pq.Quantity
        dim = 2

        size = []
        units = np.random.choice(['nA', 'mA', 'A', 'mV', 'V'])
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = pq.Quantity(np.random.random(size) * 1000, units=units)

        res = get_fake_value(name, datatype, dim=dim, seed=0)
        self.assertTrue(isinstance(res, pq.Quantity))
        self.assertEqual(res.units, getattr(pq, units))
        assert_arrays_equal(targ, res)
    def test__quantity(self):
        name = 'test__quantity'
        datatype = pq.Quantity
        dim = 2

        size = []
        units = np.random.choice(['nA', 'mA', 'A', 'mV', 'V'])
        for i in range(int(dim)):
            size.append(np.random.randint(5) + 1)
        targ = pq.Quantity(np.random.random(size) * 1000, units=units)

        res = get_fake_value(name, datatype, dim=dim, seed=0)
        self.assertTrue(isinstance(res, pq.Quantity))
        self.assertEqual(res.units, getattr(pq, units))
        assert_arrays_equal(targ, res)
Beispiel #54
0
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        times = get_fake_value('times', pq.Quantity, seed=0, dim=1)
        durations = get_fake_value('durations', pq.Quantity, seed=1, dim=1)
        labels = get_fake_value('labels', np.ndarray, seed=2, dim=1, dtype='S')
        name = get_fake_value('name', str, seed=3, obj=Epoch)
        description = get_fake_value('description', str, seed=4, obj='Epoch')
        file_origin = get_fake_value('file_origin', str)
        arr_ann = get_fake_value('array_annotations', dict, seed=6, obj=Epoch, n=5)
        attrs1 = {'name': name, 'description': description, 'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)
        attrs2['array_annotations'] = arr_ann

        res11 = get_fake_values(Epoch, annotate=False, seed=0)
        res12 = get_fake_values('Epoch', annotate=False, seed=0)
        res21 = get_fake_values(Epoch, annotate=True, seed=0)
        res22 = get_fake_values('Epoch', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('times'), times)
        assert_arrays_equal(res12.pop('times'), times)
        assert_arrays_equal(res21.pop('times'), times)
        assert_arrays_equal(res22.pop('times'), times)

        assert_arrays_equal(res11.pop('durations'), durations)
        assert_arrays_equal(res12.pop('durations'), durations)
        assert_arrays_equal(res21.pop('durations'), durations)
        assert_arrays_equal(res22.pop('durations'), durations)

        assert_arrays_equal(res11.pop('labels'), labels)
        assert_arrays_equal(res12.pop('labels'), labels)
        assert_arrays_equal(res21.pop('labels'), labels)
        assert_arrays_equal(res22.pop('labels'), labels)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        # Array annotations need to be compared separately
        # because numpy arrays define equality differently
        arr_ann_res21 = res21.pop('array_annotations')
        arr_ann_attrs2 = attrs2.pop('array_annotations')
        self.assertEqual(res21, attrs2)
        assert_arrays_equal(arr_ann_res21['valid'], arr_ann_attrs2['valid'])
        assert_arrays_equal(arr_ann_res21['number'], arr_ann_attrs2['number'])
        arr_ann_res22 = res22.pop('array_annotations')
        self.assertEqual(res22, attrs2)
        assert_arrays_equal(arr_ann_res22['valid'], arr_ann_attrs2['valid'])
        assert_arrays_equal(arr_ann_res22['number'], arr_ann_attrs2['number'])
    def test__get_fake_values(self):
        self.annotations['seed'] = 0
        signal = get_fake_value('signal', pq.Quantity, seed=0, dim=2)
        sampling_rate = get_fake_value('sampling_rate', pq.Quantity,
                                       seed=1, dim=0)
        t_start = get_fake_value('t_start', pq.Quantity, seed=2, dim=0)
        channel_index = get_fake_value('channel_index', np.ndarray, seed=3,
                                       dim=1, dtype='i')
        name = get_fake_value('name', str, seed=4, obj=AnalogSignalArray)
        description = get_fake_value('description', str, seed=5,
                                     obj='AnalogSignalArray')
        file_origin = get_fake_value('file_origin', str)
        attrs1 = {'name': name,
                  'description': description,
                  'file_origin': file_origin}
        attrs2 = attrs1.copy()
        attrs2.update(self.annotations)

        res11 = get_fake_values(AnalogSignalArray, annotate=False, seed=0)
        res12 = get_fake_values('AnalogSignalArray', annotate=False, seed=0)
        res21 = get_fake_values(AnalogSignalArray, annotate=True, seed=0)
        res22 = get_fake_values('AnalogSignalArray', annotate=True, seed=0)

        assert_arrays_equal(res11.pop('signal'), signal)
        assert_arrays_equal(res12.pop('signal'), signal)
        assert_arrays_equal(res21.pop('signal'), signal)
        assert_arrays_equal(res22.pop('signal'), signal)

        assert_arrays_equal(res11.pop('sampling_rate'), sampling_rate)
        assert_arrays_equal(res12.pop('sampling_rate'), sampling_rate)
        assert_arrays_equal(res21.pop('sampling_rate'), sampling_rate)
        assert_arrays_equal(res22.pop('sampling_rate'), sampling_rate)

        assert_arrays_equal(res11.pop('t_start'), t_start)
        assert_arrays_equal(res12.pop('t_start'), t_start)
        assert_arrays_equal(res21.pop('t_start'), t_start)
        assert_arrays_equal(res22.pop('t_start'), t_start)

        assert_arrays_equal(res11.pop('channel_index'), channel_index)
        assert_arrays_equal(res12.pop('channel_index'), channel_index)
        assert_arrays_equal(res21.pop('channel_index'), channel_index)
        assert_arrays_equal(res22.pop('channel_index'), channel_index)

        self.assertEqual(res11, attrs1)
        self.assertEqual(res12, attrs1)
        self.assertEqual(res21, attrs2)
        self.assertEqual(res22, attrs2)
Beispiel #56
0
    def check_creation(self, seg):
        assert_neo_object_is_compliant(seg)

        seed = seg.annotations['seed']

        targ0 = get_fake_value('file_datetime', datetime, seed=seed+0)
        self.assertEqual(seg.file_datetime, targ0)

        targ1 = get_fake_value('rec_datetime', datetime, seed=seed+1)
        self.assertEqual(seg.rec_datetime, targ1)

        targ2 = get_fake_value('index', int, seed=seed+2)
        self.assertEqual(seg.index, targ2)

        targ3 = get_fake_value('name', str, seed=seed+3, obj=Segment)
        self.assertEqual(seg.name, targ3)

        targ4 = get_fake_value('description', str,
                               seed=seed+4, obj=Segment)
        self.assertEqual(seg.description, targ4)

        targ5 = get_fake_value('file_origin', str)
        self.assertEqual(seg.file_origin, targ5)

        targ6 = get_annotations()
        targ6['seed'] = seed
        self.assertEqual(seg.annotations, targ6)

        self.assertTrue(hasattr(seg, 'analogsignals'))
        self.assertTrue(hasattr(seg, 'analogsignalarrays'))
        self.assertTrue(hasattr(seg, 'irregularlysampledsignals'))

        self.assertTrue(hasattr(seg, 'epochs'))
        self.assertTrue(hasattr(seg, 'epocharrays'))
        self.assertTrue(hasattr(seg, 'events'))
        self.assertTrue(hasattr(seg, 'eventarrays'))

        self.assertTrue(hasattr(seg, 'spikes'))
        self.assertTrue(hasattr(seg, 'spiketrains'))

        self.assertEqual(len(seg.analogsignals), self.nchildren**2)
        self.assertEqual(len(seg.analogsignalarrays), self.nchildren)
        self.assertEqual(len(seg.irregularlysampledsignals), self.nchildren**2)

        self.assertEqual(len(seg.epochs), self.nchildren)
        self.assertEqual(len(seg.epocharrays), self.nchildren)
        self.assertEqual(len(seg.events), self.nchildren)
        self.assertEqual(len(seg.eventarrays), self.nchildren)

        self.assertEqual(len(seg.spikes), self.nchildren**2)
        self.assertEqual(len(seg.spiketrains), self.nchildren**2)