Пример #1
0
def _make_triple_from_graph(triple_tuple) -> 'P(A x A)':
    """Return a `triple` created from the rdflib triple tuple ``triple_tuple``."""
    return _rdf.make_triple(
        subject=_convert_identifier_to_mathobject(triple_tuple[0]),
        predicate=_convert_identifier_to_mathobject(triple_tuple[1]),
        object_=_convert_identifier_to_mathobject(triple_tuple[2])
    )
Пример #2
0
def _make_triple_from_graph(triple_tuple) -> 'P(A x A)':
    """Return a `triple` created from the `~.rdflib` triple tuple ``triple_tuple``."""
    return _rdf.make_triple(
        subject=_convert_identifier_to_mathobject(triple_tuple[0]),
        predicate=_convert_identifier_to_mathobject(triple_tuple[1]),
        object_=_convert_identifier_to_mathobject(triple_tuple[2])
    )
Пример #3
0
 def test_is_absolute_graph(self):
     """Test identifying an absolute graph."""
     graph = Set({make_triple(1, 2, 3)})
     self.assertTrue(is_absolute_graph(graph))
     # not a clan
     not_graph = Atom('a')
     self.assertFalse(is_absolute_graph(not_graph))
     # not regular
     not_graph = Set({Couplet('a', 1), Couplet('a', 2), Couplet('a', 3)})
     self.assertFalse(is_absolute_graph(not_graph))
     # left set is not spo
     not_graph = Set({Couplet('a', 1), Couplet('b', 2), Couplet('c', 3)})
     self.assertFalse(is_absolute_graph(not_graph))
Пример #4
0
 def test_is_absolute_graph(self):
     """Test identifying an absolute graph."""
     graph = Set({make_triple(1, 2, 3)})
     self.assertTrue(is_absolute_graph(graph))
     # not a clan
     not_graph = Atom('a')
     self.assertFalse(is_absolute_graph(not_graph))
     # not regular
     not_graph = Set({Couplet('a', 1), Couplet('a', 2), Couplet('a', 3)})
     self.assertFalse(is_absolute_graph(not_graph))
     # left set is not spo
     not_graph = Set({Couplet('a', 1), Couplet('b', 2), Couplet('c', 3)})
     self.assertFalse(is_absolute_graph(not_graph))
Пример #5
0
 def test_make_triple(self):
     self.assertEqual(
         make_triple(1, 2, 3),
         Set([Couplet('s', 1), Couplet('p', 2), Couplet('o', 3)])
     )
Пример #6
0
 def test_make_triple(self):
     self.assertEqual(
         make_triple(1, 2, 3),
         Set([Couplet('s', 1),
              Couplet('p', 2),
              Couplet('o', 3)]))