示例#1
0
 def __getitem__(self, expression):
     if isinstance(expression, int):
         return self.getFeatureByIndex(expression)
     elif isinstance(parse_literal(expression), int):
         return self.getFeatureByIndex(parse_literal(expression))
     else:
         try:
             field, value = expression.split('=')
         except AttributeError:
             raise KeyError('invalid expression')
         feat = self.getFeatureByAttribute(field, parse_literal(value))
         return feature2vector(feat, ref=self)
def test_parse_literal():
    assert anc.parse_literal(['1', '2.2', 'a']) == [1, 2.2, 'a']
    with pytest.raises(IOError):
        anc.parse_literal(1)
示例#3
0
 def test_parse_literal_error(self):
     with self.assertRaises(IOError):
         anc.parse_literal(1)
示例#4
0
 def test_parse_literal(self):
     self.assertEqual(anc.parse_literal(['1', '2.2', 'a']), [1, 2.2, 'a'])