當前位置: 首頁>>代碼示例>>Python>>正文


Python AnalogSignal.std方法代碼示例

本文整理匯總了Python中neo.core.analogsignal.AnalogSignal.std方法的典型用法代碼示例。如果您正苦於以下問題:Python AnalogSignal.std方法的具體用法?Python AnalogSignal.std怎麽用?Python AnalogSignal.std使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在neo.core.analogsignal.AnalogSignal的用法示例。


在下文中一共展示了AnalogSignal.std方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestAnalogSignalArrayArrayMethods

# 需要導入模塊: from neo.core.analogsignal import AnalogSignal [as 別名]
# 或者: from neo.core.analogsignal.AnalogSignal import std [as 別名]

#.........這裏部分代碼省略.........
        assert_arrays_equal(result.array_annotations['anno2'], np.array(['a', 'b', 'c', 'd', 'e']))
        self.assertIsInstance(result.array_annotations, ArrayDict)

        self.assertEqual(result.shape, (5, 5))
        self.assertEqual(result.t_start, self.signal1.t_start + 2 * self.signal1.sampling_period)
        self.assertEqual(result.t_stop, self.signal1.t_start + 7 * self.signal1.sampling_period)
        self.assertEqual(result.sampling_rate, self.signal1.sampling_rate)
        assert_arrays_equal(result, self.data1[2:7])

    def test__getitem_should_return_single_quantity(self):
        # quantities drops the units in this case
        self.assertEqual(self.signal1[9, 3], 48000 * pq.pA)
        self.assertEqual(self.signal1[9][3], self.signal1[9, 3])
        self.assertTrue(hasattr(self.signal1[9, 3], 'units'))
        self.assertRaises(IndexError, self.signal1.__getitem__, (99, 73))

    def test_comparison_operators(self):
        assert_arrays_equal(self.signal1[0:3, 0:3] >= 5 * pq.nA, np.array(
            [[False, False, False], [True, True, True], [True, True, True]]))
        assert_arrays_equal(self.signal1[0:3, 0:3] >= 5 * pq.pA, np.array(
            [[False, True, True], [True, True, True], [True, True, True]]))
        assert_arrays_equal(self.signal1[0:3, 0:3] == 5 * pq.nA, np.array(
            [[False, False, False], [True, False, False], [False, False, False]]))
        assert_arrays_equal(self.signal1[0:3, 0:3] == self.signal1[0:3, 0:3],
                            np.array([[True, True, True], [True, True, True], [True, True, True]]))

    def test__comparison_with_inconsistent_units_should_raise_Exception(self):
        self.assertRaises(ValueError, self.signal1.__gt__, 5 * pq.mV)

    def test__simple_statistics(self):
        self.assertEqual(self.signal1.max(), 54000 * pq.pA)
        self.assertEqual(self.signal1.min(), 0 * pq.nA)
        self.assertEqual(self.signal1.mean(), 27 * pq.nA)
        self.assertEqual(self.signal1.std(), self.signal1.magnitude.std() * pq.nA)
        self.assertEqual(self.signal1.var(), self.signal1.magnitude.var() * pq.nA ** 2)

    def test__rescale_same(self):
        result = self.signal1.copy()
        result = result.rescale(pq.nA)

        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(result.units, 1 * pq.nA)
        assert_arrays_equal(result, self.data1)
        assert_same_sub_schema(result, self.signal1)

    def test__rescale_new(self):
        result = self.signal1.copy()
        result = result.rescale(pq.pA)

        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']))
開發者ID:INM-6,項目名稱:python-neo,代碼行數:70,代碼來源:test_analogsignalarray.py


注:本文中的neo.core.analogsignal.AnalogSignal.std方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。