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


Python AnalogSignal.merge方法代码示例

本文整理汇总了Python中neo.core.analogsignal.AnalogSignal.merge方法的典型用法代码示例。如果您正苦于以下问题:Python AnalogSignal.merge方法的具体用法?Python AnalogSignal.merge怎么用?Python AnalogSignal.merge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在neo.core.analogsignal.AnalogSignal的用法示例。


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

示例1: test__merge

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import merge [as 别名]
    def test__merge(self):
        self.signal1.description = None
        self.signal1.file_origin = None
        assert_neo_object_is_compliant(self.signal1)

        data3 = np.arange(1000.0, 1066.0).reshape((11, 6)) * pq.uV
        data3scale = data3.rescale(self.data1quant.units)

        signal2 = AnalogSignal(self.data1quant,
                                    sampling_rate=1*pq.kHz,
                                    name='signal2',
                                    description='test signal',
                                    file_origin='testfile.txt')
        signal3 = AnalogSignal(data3,
                                    units="uV", sampling_rate=1*pq.kHz,
                                    name='signal3',
                                    description='test signal',
                                    file_origin='testfile.txt')
        signal4 = AnalogSignal(data3,
                                    units="uV", sampling_rate=1*pq.kHz,
                                    name='signal4',
                                    description='test signal',
                                    file_origin='testfile.txt')
        
        merged13 = self.signal1.merge(signal3)        
        merged23 = signal2.merge(signal3)
        merged24 = signal2.merge(signal4)
        mergeddata13 = np.array(merged13)
        mergeddata23 = np.array(merged23)
        mergeddata24 = np.array(merged24)

        targdata13 = np.hstack([self.data1quant, data3scale])
        targdata23 = np.hstack([self.data1quant, data3scale])
        targdata24 = np.hstack([self.data1quant, data3scale])

        assert_neo_object_is_compliant(signal2)
        assert_neo_object_is_compliant(signal3)
        assert_neo_object_is_compliant(merged13)
        assert_neo_object_is_compliant(merged23)
        assert_neo_object_is_compliant(merged24)

        self.assertEqual(merged13[0, 4], 4*pq.mV)
        self.assertEqual(merged23[0, 4], 4*pq.mV)
        self.assertEqual(merged13[0, 5], 1*pq.mV)
        self.assertEqual(merged23[0, 5], 1*pq.mV)
        self.assertEqual(merged13[10, 10], 1.065*pq.mV)
        self.assertEqual(merged23[10, 10], 1.065*pq.mV)
        self.assertEqual(merged13.t_stop, self.signal1.t_stop)
        self.assertEqual(merged23.t_stop, self.signal1.t_stop)

        self.assertEqual(merged13.name, 'merge(spam, signal3)')
        self.assertEqual(merged23.name, 'merge(signal2, signal3)')
        self.assertEqual(merged13.description, 'merge(None, test signal)')
        self.assertEqual(merged23.description, 'test signal')
        self.assertEqual(merged13.file_origin, 'merge(None, testfile.txt)')
        self.assertEqual(merged23.file_origin, 'testfile.txt')

        assert_arrays_equal(mergeddata13, targdata13)
        assert_arrays_equal(mergeddata23, targdata23)
        assert_arrays_equal(mergeddata24, targdata24)
开发者ID:msenoville,项目名称:python-neo,代码行数:62,代码来源:test_analogsignalarray.py

示例2: test__merge

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import merge [as 别名]
    def test__merge(self):
        self.signal1.description = None
        self.signal1.file_origin = None
        assert_neo_object_is_compliant(self.signal1)

        data3 = np.arange(1000.0, 1066.0).reshape((11, 6)) * pq.uV
        data3scale = data3.rescale(self.data1quant.units)
        arr_ann3 = {'anno1': np.arange(5, 11), 'anno3': ['h', 'i', 'j', 'k', 'l', 'm']}
        arr_ann4 = {'anno1': np.arange(100, 106), 'anno3': ['o', 'p', 'q', 'r', 's', 't']}

        signal2 = AnalogSignal(self.data1quant, sampling_rate=1 * pq.kHz, name='signal2',
                               description='test signal', file_origin='testfile.txt',
                               array_annotations=self.arr_ann1)
        signal3 = AnalogSignal(data3, units="uV", sampling_rate=1 * pq.kHz, name='signal3',
                               description='test signal', file_origin='testfile.txt',
                               array_annotations=arr_ann3)
        signal4 = AnalogSignal(data3, units="uV", sampling_rate=1 * pq.kHz, name='signal4',
                               description='test signal', file_origin='testfile.txt',
                               array_annotations=arr_ann4)

        with warnings.catch_warnings(record=True) as w:
            warnings.filterwarnings('always')
            merged13 = self.signal1.merge(signal3)
            merged23 = signal2.merge(signal3)
            merged24 = signal2.merge(signal4)

            self.assertTrue(len(w) == 3)
            self.assertEqual(w[-1].category, UserWarning)
            self.assertSequenceEqual(str(w[2].message), str(w[0].message))
            self.assertSequenceEqual(str(w[2].message), str(w[1].message))
            self.assertSequenceEqual(str(w[2].message), "The following array annotations were "
                                                        "omitted, because they were only present"
                                                        " in one of the merged objects: "
                                                        "['anno2'] from the one that was merged "
                                                        "into and ['anno3'] from the one that "
                                                        "was merged into the other")

        mergeddata13 = np.array(merged13)
        mergeddata23 = np.array(merged23)
        mergeddata24 = np.array(merged24)

        targdata13 = np.hstack([self.data1quant, data3scale])
        targdata23 = np.hstack([self.data1quant, data3scale])
        targdata24 = np.hstack([self.data1quant, data3scale])

        assert_neo_object_is_compliant(signal2)
        assert_neo_object_is_compliant(signal3)
        assert_neo_object_is_compliant(merged13)
        assert_neo_object_is_compliant(merged23)
        assert_neo_object_is_compliant(merged24)

        self.assertEqual(merged13[0, 4], 4 * pq.mV)
        self.assertEqual(merged23[0, 4], 4 * pq.mV)
        self.assertEqual(merged13[0, 5], 1 * pq.mV)
        self.assertEqual(merged23[0, 5], 1 * pq.mV)
        self.assertEqual(merged13[10, 10], 1.065 * pq.mV)
        self.assertEqual(merged23[10, 10], 1.065 * pq.mV)
        self.assertEqual(merged13.t_stop, self.signal1.t_stop)
        self.assertEqual(merged23.t_stop, self.signal1.t_stop)

        self.assertEqual(merged13.name, 'merge(spam, signal3)')
        self.assertEqual(merged23.name, 'merge(signal2, signal3)')
        self.assertEqual(merged13.description, 'merge(None, test signal)')
        self.assertEqual(merged23.description, 'test signal')
        self.assertEqual(merged13.file_origin, 'merge(None, testfile.txt)')
        self.assertEqual(merged23.file_origin, 'testfile.txt')

        assert_arrays_equal(merged13.array_annotations['anno1'], np.arange(11))
        self.assertIsInstance(merged13.array_annotations, ArrayDict)
        self.assertNotIn('anno2', merged13.array_annotations)
        self.assertNotIn('anno3', merged13.array_annotations)
        assert_arrays_equal(merged23.array_annotations['anno1'], np.arange(11))
        self.assertIsInstance(merged23.array_annotations, ArrayDict)
        self.assertNotIn('anno2', merged23.array_annotations)
        self.assertNotIn('anno3', merged23.array_annotations)
        assert_arrays_equal(merged24.array_annotations['anno1'],
                            np.array([0, 1, 2, 3, 4, 100, 101, 102, 103, 104, 105]))
        self.assertIsInstance(merged24.array_annotations, ArrayDict)
        self.assertNotIn('anno2', merged24.array_annotations)
        self.assertNotIn('anno3', merged24.array_annotations)

        assert_arrays_equal(mergeddata13, targdata13)
        assert_arrays_equal(mergeddata23, targdata23)
        assert_arrays_equal(mergeddata24, targdata24)
开发者ID:INM-6,项目名称:python-neo,代码行数:86,代码来源:test_analogsignalarray.py

示例3: TestAnalogSignalArrayCombination

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import merge [as 别名]

#.........这里部分代码省略.........
        result = self.signal1 * 2
        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'})
        assert_arrays_equal(result.array_annotations['anno1'], np.arange(5))
        assert_arrays_equal(result.array_annotations['anno2'], np.array(['a', 'b', 'c', 'd', 'e']))
        self.assertIsInstance(result.array_annotations, ArrayDict)

        self.assertEqual(np.array(self.signal1[1, 4]), 9)
        self.assertEqual(np.array(result[1, 4]), 18)
        assert_arrays_equal(result, self.data1 * 2)
        self.assertEqual(self.signal1.sampling_rate, result.sampling_rate)

    def test__divide_by_const_should_preserve_data_complement(self):
        result = self.signal1 / 0.5
        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'})
        assert_arrays_equal(result.array_annotations['anno1'], np.arange(5))
        assert_arrays_equal(result.array_annotations['anno2'], np.array(['a', 'b', 'c', 'd', 'e']))
        self.assertIsInstance(result.array_annotations, ArrayDict)

        self.assertEqual(np.array(self.signal1[1, 4]), 9)
        self.assertEqual(np.array(result[1, 4]), 18)
        assert_arrays_equal(result, self.data1 / 0.5)
        self.assertEqual(self.signal1.sampling_rate, result.sampling_rate)

    def test__merge(self):
        self.signal1.description = None
        self.signal1.file_origin = None
        assert_neo_object_is_compliant(self.signal1)

        data3 = np.arange(1000.0, 1066.0).reshape((11, 6)) * pq.uV
        data3scale = data3.rescale(self.data1quant.units)
        arr_ann3 = {'anno1': np.arange(5, 11), 'anno3': ['h', 'i', 'j', 'k', 'l', 'm']}
        arr_ann4 = {'anno1': np.arange(100, 106), 'anno3': ['o', 'p', 'q', 'r', 's', 't']}

        signal2 = AnalogSignal(self.data1quant, sampling_rate=1 * pq.kHz, name='signal2',
                               description='test signal', file_origin='testfile.txt',
                               array_annotations=self.arr_ann1)
        signal3 = AnalogSignal(data3, units="uV", sampling_rate=1 * pq.kHz, name='signal3',
                               description='test signal', file_origin='testfile.txt',
                               array_annotations=arr_ann3)
        signal4 = AnalogSignal(data3, units="uV", sampling_rate=1 * pq.kHz, name='signal4',
                               description='test signal', file_origin='testfile.txt',
                               array_annotations=arr_ann4)

        with warnings.catch_warnings(record=True) as w:
            warnings.filterwarnings('always')
            merged13 = self.signal1.merge(signal3)
            merged23 = signal2.merge(signal3)
            merged24 = signal2.merge(signal4)

            self.assertTrue(len(w) == 3)
            self.assertEqual(w[-1].category, UserWarning)
            self.assertSequenceEqual(str(w[2].message), str(w[0].message))
            self.assertSequenceEqual(str(w[2].message), str(w[1].message))
            self.assertSequenceEqual(str(w[2].message), "The following array annotations were "
                                                        "omitted, because they were only present"
                                                        " in one of the merged objects: "
开发者ID:INM-6,项目名称:python-neo,代码行数:70,代码来源:test_analogsignalarray.py

示例4: TestAnalogSignalArrayCombination

# 需要导入模块: from neo.core.analogsignal import AnalogSignal [as 别名]
# 或者: from neo.core.analogsignal.AnalogSignal import merge [as 别名]

#.........这里部分代码省略.........
        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'})

        self.assertEqual(np.array(self.signal1[1, 4]), 9)
        self.assertEqual(np.array(result[1, 4]), 1)
        assert_arrays_equal(result, 10 - self.data1)
        self.assertEqual(self.signal1.sampling_rate, result.sampling_rate)

    def test__mult_by_const_float_should_preserve_data_complement(self):
        result = self.signal1*2
        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'})

        self.assertEqual(np.array(self.signal1[1, 4]), 9)
        self.assertEqual(np.array(result[1, 4]), 18)
        assert_arrays_equal(result, self.data1*2)
        self.assertEqual(self.signal1.sampling_rate, result.sampling_rate)

    def test__divide_by_const_should_preserve_data_complement(self):
        result = self.signal1/0.5
        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'})

        self.assertEqual(np.array(self.signal1[1, 4]), 9)
        self.assertEqual(np.array(result[1, 4]), 18)
        assert_arrays_equal(result, self.data1/0.5)
        self.assertEqual(self.signal1.sampling_rate, result.sampling_rate)

    def test__merge(self):
        self.signal1.description = None
        self.signal1.file_origin = None
        assert_neo_object_is_compliant(self.signal1)

        data3 = np.arange(1000.0, 1066.0).reshape((11, 6)) * pq.uV
        data3scale = data3.rescale(self.data1quant.units)

        signal2 = AnalogSignal(self.data1quant,
                                    sampling_rate=1*pq.kHz,
                                    name='signal2',
                                    description='test signal',
                                    file_origin='testfile.txt')
        signal3 = AnalogSignal(data3,
                                    units="uV", sampling_rate=1*pq.kHz,
                                    name='signal3',
                                    description='test signal',
                                    file_origin='testfile.txt')
        signal4 = AnalogSignal(data3,
                                    units="uV", sampling_rate=1*pq.kHz,
                                    name='signal4',
                                    description='test signal',
                                    file_origin='testfile.txt')
        
        merged13 = self.signal1.merge(signal3)        
        merged23 = signal2.merge(signal3)
        merged24 = signal2.merge(signal4)
        mergeddata13 = np.array(merged13)
        mergeddata23 = np.array(merged23)
        mergeddata24 = np.array(merged24)

        targdata13 = np.hstack([self.data1quant, data3scale])
        targdata23 = np.hstack([self.data1quant, data3scale])
        targdata24 = np.hstack([self.data1quant, data3scale])

        assert_neo_object_is_compliant(signal2)
        assert_neo_object_is_compliant(signal3)
        assert_neo_object_is_compliant(merged13)
        assert_neo_object_is_compliant(merged23)
        assert_neo_object_is_compliant(merged24)

        self.assertEqual(merged13[0, 4], 4*pq.mV)
        self.assertEqual(merged23[0, 4], 4*pq.mV)
        self.assertEqual(merged13[0, 5], 1*pq.mV)
        self.assertEqual(merged23[0, 5], 1*pq.mV)
        self.assertEqual(merged13[10, 10], 1.065*pq.mV)
        self.assertEqual(merged23[10, 10], 1.065*pq.mV)
        self.assertEqual(merged13.t_stop, self.signal1.t_stop)
        self.assertEqual(merged23.t_stop, self.signal1.t_stop)

        self.assertEqual(merged13.name, 'merge(spam, signal3)')
        self.assertEqual(merged23.name, 'merge(signal2, signal3)')
        self.assertEqual(merged13.description, 'merge(None, test signal)')
        self.assertEqual(merged23.description, 'test signal')
        self.assertEqual(merged13.file_origin, 'merge(None, testfile.txt)')
        self.assertEqual(merged23.file_origin, 'testfile.txt')

        assert_arrays_equal(mergeddata13, targdata13)
        assert_arrays_equal(mergeddata23, targdata23)
        assert_arrays_equal(mergeddata24, targdata24)
开发者ID:msenoville,项目名称:python-neo,代码行数:104,代码来源:test_analogsignalarray.py


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