Exemplo n.º 1
0
    def test_vector_conversions(self):
        def same_seq(seq1, seq2):
            self.assertEqual(len(seq1), len(seq2))
            for i in range(len(seq1)):
                self.assertEqual(seq1[i], seq2[i])

        list = [1.1, 2.2, 3.3]
        v = gpstk.seqToVector(list)
        self.assertIsInstance(v, gpstk.vector_double)
        same_seq(list, v)

        list = [1.1, 2.2, 3.3]
        v = gpstk.seqToVector(list, outtype='vector_double')
        self.assertIsInstance(v, gpstk.vector_double)
        same_seq(list, v)

        list = ['bar!', 'foo?']
        v = gpstk.seqToVector(list)
        self.assertIsInstance(v, gpstk.vector_string)
        same_seq(list, v)

        v = gpstk.vector_int()
        v.push_back(3)
        v.push_back(5)
        list = gpstk.vectorToSeq(v)
        same_seq(list, v)

        list = [1.1, 2.2, 3.3]
        self.assertRaises(TypeError, gpstk.seqToVector, list, 'vector_doesnotexist')

        list = [1, 2.2, 'c']  # mismatching types not allowed
        self.assertRaises(TypeError, gpstk.seqToVector, list)
Exemplo n.º 2
0
    def test_vector_conversions(self):
        def same_seq(seq1, seq2):
            self.assertEqual(len(seq1), len(seq2))
            for i in range(len(seq1)):
                self.assertEqual(seq1[i], seq2[i])

        list = [1.1, 2.2, 3.3]
        v = gpstk.seqToVector(list)
        self.assertIsInstance(v, gpstk.vector_double)
        same_seq(list, v)

        list = [1.1, 2.2, 3.3]
        v = gpstk.seqToVector(list, outtype='vector_double')
        self.assertIsInstance(v, gpstk.vector_double)
        same_seq(list, v)

        list = ['bar!', 'foo?']
        v = gpstk.seqToVector(list)
        self.assertIsInstance(v, gpstk.vector_string)
        same_seq(list, v)

        v = gpstk.vector_int()
        v.push_back(3)
        v.push_back(5)
        list = gpstk.vectorToSeq(v)
        same_seq(list, v)

        list = [1.1, 2.2, 3.3]
        self.assertRaises(TypeError, gpstk.seqToVector, list, 'vector_doesnotexist')

        list = [1, 2.2, 'c']  # mismatching types not allowed
        self.assertRaises(TypeError, gpstk.seqToVector, list)

        list = [1000L, 2000L]  # PyLongs are not templated
        self.assertRaises(TypeError, gpstk.seqToVector, list)
Exemplo n.º 3
0
 def test_vector_iter(self):
     v = gpstk.vector_int()
     v.push_back(5)
     v.push_back(3)
     v.push_back(10)
     i = 0
     for x in v:
         self.assertEqual(v[i], x)
         i += 1
Exemplo n.º 4
0
 def test_vector_iter(self):
     v = gpstk.vector_int()
     v.push_back(5)
     v.push_back(3)
     v.push_back(10)
     i = 0
     for x in v:
         self.assertEqual(v[i], x)
         i += 1
Exemplo n.º 5
0
 def test_vector(self):
     v = gpstk.vector_int()
     v.push_back(5)
     v.push_back(3)
     v.push_back(10)
     self.assertEqual(5, v[0])
     self.assertEqual(3, v[1])
     self.assertEqual(10, v[2])
     v = gpstk.vector_double()
     v.push_back(1.5)
     v.push_back(2.5)
     self.assertEqual(1.5, v[0])
     self.assertEqual(2.5, v[1])
     self.assertEqual(2, len(v))
Exemplo n.º 6
0
 def test_vector(self):
     v = gpstk.vector_int()
     v.push_back(5)
     v.push_back(3)
     v.push_back(10)
     self.assertEqual(5, v[0])
     self.assertEqual(3, v[1])
     self.assertEqual(10, v[2])
     v = gpstk.vector_double()
     v.push_back(1.5)
     v.push_back(2.5)
     self.assertEqual(1.5, v[0])
     self.assertEqual(2.5, v[1])
     self.assertEqual(2, len(v))