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)
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)