当前位置: 首页>>代码示例>>Python>>正文


Python tools.assert_arrays_equal函数代码示例

本文整理汇总了Python中neo.test.tools.assert_arrays_equal函数的典型用法代码示例。如果您正苦于以下问题:Python assert_arrays_equal函数的具体用法?Python assert_arrays_equal怎么用?Python assert_arrays_equal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了assert_arrays_equal函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test__time_slice__different_units

    def test__time_slice__different_units(self):
        self.signal2.t_start = 10.0 * pq.ms
        assert_neo_object_is_compliant(self.signal2)

        t_start = 2 * pq.s + 10.0 * pq.ms
        t_stop = 4 * pq.s + 10.0 * pq.ms

        result = self.signal2.time_slice(t_start, t_stop)
        self.assertIsInstance(result, AnalogSignalArray)
        assert_neo_object_is_compliant(result)
        self.assertEqual(result.name, 'spam')
        self.assertEqual(result.description, 'eggs')
        self.assertEqual(result.file_origin, 'testfile.txt')
        self.assertEqual(result.annotations, {'arg1': 'test'})

        targ = AnalogSignalArray(np.array([[2, 3], [2, 3]]).T,
                                 t_start=t_start.rescale(pq.ms),
                                 sampling_rate=1.0*pq.Hz, units='mV',
                                 name='spam', description='eggs',
                                 file_origin='testfile.txt', arg1='test')
        assert_neo_object_is_compliant(result)

        assert_neo_object_is_compliant(self.signal2)
        self.assertEqual(self.signal2.t_start, 10.0 * pq.ms)
        self.assertAlmostEqual(result.t_stop, t_stop, delta=1e-12*pq.ms)
        self.assertAlmostEqual(result.t_start, t_start, delta=1e-12*pq.ms)
        assert_arrays_almost_equal(result.times, targ.times, 1e-12*pq.ms)
        self.assertEqual(result.sampling_rate, targ.sampling_rate)
        assert_arrays_equal(result, targ)
        assert_same_sub_schema(result, targ)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:30,代码来源:test_analogsignalarray.py

示例2: test_read_spiketrain_using_eager

 def test_read_spiketrain_using_eager(self):
     io = self.io_cls(self.test_file)
     st3 = io.read_spiketrain(lazy=False, channel_index=3)
     self.assertIsInstance(st3, SpikeTrain)
     assert_arrays_equal(
         st3, SpikeTrain(numpy.arange(3, 104, dtype=float), t_start=0 * pq.s, t_stop=104 * pq.s, units=pq.ms)
     )
开发者ID:uservidya,项目名称:python-neo,代码行数:7,代码来源:test_pynnio.py

示例3: test_recordingchannelgroup__merge

    def test_recordingchannelgroup__merge(self):
        self.rcg1.merge(self.rcg2)

        chanres1 = [chan.name for chan in self.rcg1.recordingchannels]
        chanres2 = [chan.name for chan in self.rcg2.recordingchannels]

        unitres1 = [unit.name for unit in self.rcg1.units]
        unitres2 = [unit.name for unit in self.rcg2.units]

        sigarrres1 = [sigarr.name for sigarr in self.rcg1.analogsignalarrays]
        sigarrres2 = [sigarr.name for sigarr in self.rcg2.analogsignalarrays]

        self.assertEqual(chanres1, self.rchannames)
        self.assertEqual(chanres2, self.rchannames2)

        self.assertEqual(unitres1, self.unitnames)
        self.assertEqual(unitres2, self.unitnames2)

        self.assertEqual(sigarrres1, self.sigarrnames)
        self.assertEqual(sigarrres2, self.sigarrnames2)

        for res, targ in zip(self.rcg1.analogsignalarrays, self.sigarr):
            assert_arrays_equal(res, targ)

        for res, targ in zip(self.rcg2.analogsignalarrays,  self.sigarr2):
            assert_arrays_equal(res, targ)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:26,代码来源:test_recordingchannelgroup.py

示例4: test_recordingchannelgroup__compliance

    def test_recordingchannelgroup__compliance(self):
        assert_neo_object_is_compliant(self.rcg1)
        assert_neo_object_is_compliant(self.rcg2)

        self.assertEqual(self.rcg1.name, 'test')
        self.assertEqual(self.rcg2.name, 'test')

        self.assertEqual(self.rcg1.description, 'tester 1')
        self.assertEqual(self.rcg2.description, 'tester 2')

        self.assertEqual(self.rcg1.file_origin, 'test.file')
        self.assertEqual(self.rcg2.file_origin, 'test.file')

        self.assertEqual(self.rcg1.annotations['testarg0'], [1, 2, 3])
        self.assertEqual(self.rcg2.annotations['testarg10'], [1, 2, 3])

        self.assertEqual(self.rcg1.annotations['testarg1'], 1.1)
        self.assertEqual(self.rcg2.annotations['testarg1'], 1)
        self.assertEqual(self.rcg2.annotations['testarg11'], 1.1)

        self.assertEqual(self.rcg1.annotations['testarg2'], 'yes')
        self.assertEqual(self.rcg2.annotations['testarg2'], 'yes')

        self.assertTrue(self.rcg1.annotations['testarg3'])
        self.assertTrue(self.rcg2.annotations['testarg3'])

        self.assertTrue(hasattr(self.rcg1, 'units'))
        self.assertTrue(hasattr(self.rcg2, 'units'))

        self.assertEqual(len(self.rcg1.units), 2)
        self.assertEqual(len(self.rcg2.units), 3)

        self.assertEqual(self.rcg1.units, self.units1)
        self.assertEqual(self.rcg2.units, self.units2)

        self.assertTrue(hasattr(self.rcg1, 'recordingchannels'))
        self.assertTrue(hasattr(self.rcg2, 'recordingchannels'))

        self.assertEqual(len(self.rcg1.recordingchannels), 2)
        self.assertEqual(len(self.rcg2.recordingchannels), 3)

        for res, targ in zip(self.rcg1.recordingchannels, self.rchan1):
            self.assertEqual(res.name, targ.name)

        for res, targ in zip(self.rcg2.recordingchannels, self.rchan2):
            self.assertEqual(res.name, targ.name)

        self.assertTrue(hasattr(self.rcg1, 'analogsignalarrays'))
        self.assertTrue(hasattr(self.rcg2, 'analogsignalarrays'))

        self.assertEqual(len(self.rcg1.analogsignalarrays), 2)
        self.assertEqual(len(self.rcg2.analogsignalarrays), 3)

        for res, targ in zip(self.rcg1.analogsignalarrays, self.sigarr1):
            assert_arrays_equal(res, targ)
            self.assertEqual(res.name, targ.name)

        for res, targ in zip(self.rcg2.analogsignalarrays, self.sigarr2):
            assert_arrays_equal(res, targ)
            self.assertEqual(res.name, targ.name)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:60,代码来源:test_recordingchannelgroup.py

示例5: test_unit_merge

    def test_unit_merge(self):
        self.unit1.merge(self.unit2)

        spikeres1 = [sig.name for sig in self.unit1.spikes]
        spikeres2 = [sig.name for sig in self.unit2.spikes]

        trainres1 = [sig.name for sig in self.unit1.spiketrains]
        trainres2 = [sig.name for sig in self.unit2.spiketrains]

        self.assertEqual(spikeres1, self.spikenames)
        self.assertEqual(spikeres2, self.spikenames2)

        self.assertEqual(trainres1, self.trainnames)
        self.assertEqual(trainres2, self.trainnames2)

        for res, targ in zip(self.unit1.spikes, self.spike):
            self.assertEqual(res, targ)

        for res, targ in zip(self.unit2.spikes, self.spike2):
            self.assertEqual(res, targ)

        for res, targ in zip(self.unit1.spiketrains, self.train):
            assert_arrays_equal(res, targ)

        for res, targ in zip(self.unit2.spiketrains, self.train2):
            assert_arrays_equal(res, targ)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:26,代码来源:test_unit.py

示例6: test__add_two_consistent_signals_should_preserve_data_complement

    def test__add_two_consistent_signals_should_preserve_data_complement(self):
        data2 = np.arange(10.0, 20.0)
        data2quant = data2 * pq.mV
        signal2 = AnalogSignal(data2quant, sampling_rate=1 * pq.kHz)
        assert_neo_object_is_compliant(signal2)

        result = self.signal1 + signal2
        self.assertIsInstance(result, AnalogSignal)
        assert_neo_object_is_compliant(result)
        self.assertEqual(result.name, "spam")
        self.assertEqual(result.description, "eggs")
        self.assertEqual(result.file_origin, "testfile.txt")
        self.assertEqual(result.annotations, {"arg1": "test"})

        targ = AnalogSignal(
            np.arange(10.0, 30.0, 2.0),
            units="mV",
            sampling_rate=1 * pq.kHz,
            name="spam",
            description="eggs",
            file_origin="testfile.txt",
            arg1="test",
        )
        assert_neo_object_is_compliant(targ)

        assert_arrays_equal(result, targ)
        assert_same_sub_schema(result, targ)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:27,代码来源:test_analogsignal.py

示例7: test__time_slice__offset

    def test__time_slice__offset(self):
        self.signal2.t_start = 10.0 * pq.s
        assert_neo_object_is_compliant(self.signal2)

        t_start = 12 * pq.s
        t_stop = 14 * pq.s

        result = self.signal2.time_slice(t_start, t_stop)
        self.assertIsInstance(result, AnalogSignalArray)
        assert_neo_object_is_compliant(result)
        self.assertEqual(result.name, 'spam')
        self.assertEqual(result.description, 'eggs')
        self.assertEqual(result.file_origin, 'testfile.txt')
        self.assertEqual(result.annotations, {'arg1': 'test'})

        targ = AnalogSignalArray(np.array([[2, 3], [2, 3]]).T,
                                 t_start=12.0*pq.ms,
                                 sampling_rate=1.0*pq.Hz, units='mV',
                                 name='spam', description='eggs',
                                 file_origin='testfile.txt', arg1='test')
        assert_neo_object_is_compliant(result)

        self.assertEqual(self.signal2.t_start, 10.0 * pq.s)
        self.assertEqual(result.t_stop, t_stop)
        self.assertEqual(result.t_start, t_start)
        self.assertEqual(result.sampling_rate, targ.sampling_rate)
        assert_arrays_equal(result, targ)
        assert_same_sub_schema(result, targ)
开发者ID:NeuroArchive,项目名称:python-neo,代码行数:28,代码来源:test_analogsignalarray.py

示例8: test_comparison_operators

 def test_comparison_operators(self):
     assert_arrays_equal(self.signal1 >= 5*pq.nA,
                         np.array([False, False, False, False, False,
                                   True, True, True, True, True]))
     assert_arrays_equal(self.signal1 >= 5*pq.pA,
                         np.array([False, True, True, True, True,
                                   True, True, True, True, True]))
开发者ID:ChrisNolan1992,项目名称:python-neo,代码行数:7,代码来源:test_analogsignal.py

示例9: test_time_slice_differnt_units

    def test_time_slice_differnt_units(self):
        targdataquant = [[1.0], [2.0], [3.0]] * pq.mV
        targtime = np.logspace(1, 5, 10)
        targtimequant = targtime[1:4] * pq.ms
        targ_signal = IrregularlySampledSignal(targtimequant, signal=targdataquant, name='spam',
                                               description='eggs', file_origin='testfile.txt',
                                               arg1='test')

        t_start = 15
        t_stop = 250

        t_start = 0.015 * pq.s
        t_stop = .250 * pq.s

        result = self.signal1.time_slice(t_start, t_stop)

        assert_array_equal(result, targ_signal)
        assert_array_equal(result.times, targtimequant)
        self.assertEqual(result.units, 1 * pq.mV)
        self.assertIsInstance(result, IrregularlySampledSignal)
        assert_neo_object_is_compliant(result)
        self.assertEqual(result.name, 'spam')
        self.assertEqual(result.description, 'eggs')
        self.assertEqual(result.file_origin, 'testfile.txt')
        self.assertEqual(result.annotations, {'arg1': 'test'})
        assert_arrays_equal(result.array_annotations['anno1'], np.array([23]))
        assert_arrays_equal(result.array_annotations['anno2'], np.array(['A']))
        self.assertIsInstance(result.array_annotations, ArrayDict)
开发者ID:INM-6,项目名称:python-neo,代码行数:28,代码来源:test_irregularysampledsignal.py

示例10: test__create_from_array

 def test__create_from_array(self):
     times = numpy.arange(10)
     t_start = 0.0*pq.s
     t_stop = 10000.0*pq.ms
     st = SpikeTrain(times, t_start=t_start, t_stop=t_stop, units="s")
     self.assertEqual(st.t_stop, t_stop)
     assert_arrays_equal(st, times*pq.s)
开发者ID:gentnerlab-user,项目名称:python-neo,代码行数:7,代码来源:test_spiketrain.py

示例11: check_creation

    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)
开发者ID:ChrisNolan1992,项目名称:python-neo,代码行数:30,代码来源:test_recordingchannel.py

示例12: check_creation

    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)
开发者ID:ChrisNolan1992,项目名称:python-neo,代码行数:28,代码来源:test_unit.py

示例13: test__pickle

    def test__pickle(self):
        arr_ann = {'index': np.arange(3), 'test': ['a', 'b', 'c']}
        epoch1 = Epoch(np.arange(0, 30, 10) * pq.s, durations=[1, 2, 3] * pq.s,
                       labels=np.array(['t0', 't1', 't2'], dtype='S'), units='s',
                       annotation1="foo", annotation2="bar", array_annotations=arr_ann)
        fobj = open('./pickle', 'wb')
        pickle.dump(epoch1, fobj)
        fobj.close()

        fobj = open('./pickle', 'rb')
        try:
            epoch2 = pickle.load(fobj)
        except ValueError:
            epoch2 = None

        fobj.close()
        assert_array_equal(epoch1.times, epoch2.times)
        self.assertEqual(epoch2.annotations, epoch1.annotations)
        assert_arrays_equal(epoch2.array_annotations['index'], np.array(arr_ann['index']))
        assert_arrays_equal(epoch2.array_annotations['test'], np.array(arr_ann['test']))
        self.assertIsInstance(epoch2.array_annotations, ArrayDict)
        # Make sure the dict can perform correct checks after unpickling
        epoch2.array_annotations['anno3'] = list(range(3, 6))
        with self.assertRaises(ValueError):
            epoch2.array_annotations['anno4'] = [2, 1]
        os.remove('./pickle')
开发者ID:INM-6,项目名称:python-neo,代码行数:26,代码来源:test_epoch.py

示例14: test_time_slice_differnt_units

    def test_time_slice_differnt_units(self):
        params = {'test2': 'y1', 'test3': True}
        arr_ann = {'index': np.arange(3), 'test': ['a', 'b', 'c']}
        epc = Epoch([1.1, 1.5, 1.7] * pq.ms, durations=[20, 40, 60] * pq.ns,
                    labels=np.array(['test epoch 1', 'test epoch 2', 'test epoch 3'], dtype='S'),
                    name='test', description='tester', file_origin='test.file', test1=1,
                    array_annotations=arr_ann, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        targ = Epoch([1.5] * pq.ms, durations=[40] * pq.ns,
                     labels=np.array(['test epoch 2'], dtype='S'), name='test',
                     description='tester', file_origin='test.file', test1=1,
                     array_annotations={'index': [1], 'test': ['b']}, **params)
        targ.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(targ)

        t_start = 0.0012 * pq.s
        t_stop = 0.0016 * pq.s
        result = epc.time_slice(t_start, t_stop)

        assert_arrays_equal(result.times, targ.times)
        assert_arrays_equal(result.durations, targ.durations)
        assert_arrays_equal(result.labels, targ.labels)
        self.assertEqual(result.name, targ.name)
        self.assertEqual(result.description, targ.description)
        self.assertEqual(result.file_origin, targ.file_origin)
        self.assertEqual(result.annotations['test0'], targ.annotations['test0'])
        self.assertEqual(result.annotations['test1'], targ.annotations['test1'])
        self.assertEqual(result.annotations['test2'], targ.annotations['test2'])
        assert_arrays_equal(result.array_annotations['index'], np.array([1]))
        assert_arrays_equal(result.array_annotations['test'], np.array(['b']))
        self.assertIsInstance(result.array_annotations, ArrayDict)
开发者ID:INM-6,项目名称:python-neo,代码行数:33,代码来源:test_epoch.py

示例15: test_time_slice_empty

    def test_time_slice_empty(self):
        params = {'test2': 'y1', 'test3': True}
        epc = Epoch([] * pq.ms, durations=[] * pq.ns, labels=np.array([], dtype='S'), name='test',
                    description='tester', file_origin='test.file', test1=1, **params)
        epc.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epc)

        targ = Epoch([] * pq.ms, durations=[] * pq.ns, labels=np.array([], dtype='S'), name='test',
                     description='tester', file_origin='test.file', test1=1, **params)
        targ.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(targ)

        t_start = 1.2
        t_stop = 1.6
        result = epc.time_slice(t_start, t_stop)

        assert_arrays_equal(result.times, targ.times)
        assert_arrays_equal(result.durations, targ.durations)
        assert_arrays_equal(result.labels, targ.labels)
        self.assertEqual(result.name, targ.name)
        self.assertEqual(result.description, targ.description)
        self.assertEqual(result.file_origin, targ.file_origin)
        self.assertEqual(result.annotations['test0'], targ.annotations['test0'])
        self.assertEqual(result.annotations['test1'], targ.annotations['test1'])
        self.assertEqual(result.annotations['test2'], targ.annotations['test2'])
        assert_arrays_equal(result.array_annotations['durations'],
                            np.array([], dtype='float64') * pq.ns)
        assert_arrays_equal(result.array_annotations['labels'], np.array([], dtype='S'))
        self.assertIsInstance(result.array_annotations, ArrayDict)
开发者ID:INM-6,项目名称:python-neo,代码行数:29,代码来源:test_epoch.py


注:本文中的neo.test.tools.assert_arrays_equal函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。