コード例 #1
0
    def test__children(self):
        params = {'test2': 'y1', 'test3': True}
        epca = EpochArray([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, **params)
        epca.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epca)

        segment = Segment(name='seg1')
        segment.epocharrays = [epca]
        segment.create_many_to_one_relationship()

        self.assertEqual(epca._single_parent_objects, ('Segment',))
        self.assertEqual(epca._multi_parent_objects, ())

        self.assertEqual(epca._single_parent_containers, ('segment',))
        self.assertEqual(epca._multi_parent_containers, ())

        self.assertEqual(epca._parent_objects, ('Segment',))
        self.assertEqual(epca._parent_containers, ('segment',))

        self.assertEqual(len(epca.parents), 1)
        self.assertEqual(epca.parents[0].name, 'seg1')

        assert_neo_object_is_compliant(epca)
コード例 #2
0
    def test__pretty(self):
        epca = EpochArray([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')
        epca.annotate(test1=1.1, test0=[1, 2])
        assert_neo_object_is_compliant(epca)

        prepr = pretty(epca)
        targ = ("EpochArray\nname: '%s'\ndescription: '%s'\nannotations: %s" %
                (epca.name, epca.description, pretty(epca.annotations)))

        self.assertEqual(prepr, targ)
コード例 #3
0
    def test_EpochArray_repr(self):
        params = {'testarg2': 'yes', 'testarg3': True}
        epca = EpochArray([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',
                          testarg1=1, **params)
        epca.annotate(testarg1=1.1, testarg0=[1, 2, 3])
        assert_neo_object_is_compliant(epca)

        targ = ('<EventArray: test epoch [email protected] ms for 20.0 ns, ' +
                'test epoch [email protected] ms for 40.0 ns, ' +
                'test epoch [email protected] ms for 60.0 ns>')

        res = repr(epca)

        self.assertEqual(targ, res)
コード例 #4
0
    def test_EpochArray_creation(self):
        params = {'testarg2': 'yes', 'testarg3': True}
        epca = EpochArray([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',
                          testarg1=1, **params)
        epca.annotate(testarg1=1.1, testarg0=[1, 2, 3])
        assert_neo_object_is_compliant(epca)

        assert_arrays_equal(epca.times, [1.1, 1.5, 1.7]*pq.ms)
        assert_arrays_equal(epca.durations, [20, 40, 60]*pq.ns)
        assert_arrays_equal(epca.labels, np.array(['test epoch 1',
                                                   'test epoch 2',
                                                   'test epoch 3'], dtype='S'))
        self.assertEqual(epca.name, 'test')
        self.assertEqual(epca.description, 'tester')
        self.assertEqual(epca.file_origin, 'test.file')
        self.assertEqual(epca.annotations['testarg0'], [1, 2, 3])
        self.assertEqual(epca.annotations['testarg1'], 1.1)
        self.assertEqual(epca.annotations['testarg2'], 'yes')
        self.assertTrue(epca.annotations['testarg3'])