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)
    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)
    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)
    def test_EpochArray_merge(self):
        params1 = {'testarg2': 'yes', 'testarg3': True}
        params2 = {'testarg2': 'no', 'testarg4': False}
        paramstarg = {'testarg2': 'yes;no',
                      'testarg3': True,
                      'testarg4': False}
        epca1 = EpochArray([1.1, 1.5, 1.7]*pq.ms,
                           durations=[20, 40, 60]*pq.us,
                           labels=np.array(['test epoch 1 1',
                                            'test epoch 1 2',
                                            'test epoch 1 3'], dtype='S'),
                           name='test', description='tester 1',
                           file_origin='test.file',
                           testarg1=1, **params1)
        epca2 = EpochArray([2.1, 2.5, 2.7]*pq.us,
                           durations=[3, 5, 7]*pq.ms,
                           labels=np.array(['test epoch 2 1',
                                            'test epoch 2 2',
                                            'test epoch 2 3'], dtype='S'),
                           name='test', description='tester 2',
                           file_origin='test.file',
                           testarg1=1, **params2)
        epcatarg = EpochArray([1.1, 1.5, 1.7, .0021, .0025, .0027]*pq.ms,
                              durations=[20, 40, 60, 3000, 5000, 7000]*pq.ns,
                              labels=np.array(['test epoch 1 1',
                                               'test epoch 1 2',
                                               'test epoch 1 3',
                                               'test epoch 2 1',
                                               'test epoch 2 2',
                                               'test epoch 2 3'], dtype='S'),
                              name='test',
                              description='merge(tester 1, tester 2)',
                              file_origin='test.file',
                              testarg1=1, **paramstarg)
        assert_neo_object_is_compliant(epca1)
        assert_neo_object_is_compliant(epca2)
        assert_neo_object_is_compliant(epcatarg)

        epcares = epca1.merge(epca2)
        assert_neo_object_is_compliant(epcares)
        assert_same_sub_schema(epcatarg, epcares)
    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'])