aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bsfs/schema/__init__.py2
-rw-r--r--bsfs/schema/schema.py2
-rw-r--r--bsfs/schema/serialize.py4
-rw-r--r--bsfs/schema/types.py28
-rw-r--r--test/graph/test_resolve.py2
-rw-r--r--test/query/test_validator.py22
-rw-r--r--test/schema/test_schema.py40
-rw-r--r--test/schema/test_serialize.py126
-rw-r--r--test/schema/test_types.py108
-rw-r--r--test/triple_store/sparql/test_parse_filter.py2
-rw-r--r--test/triple_store/sparql/test_sparql.py10
11 files changed, 173 insertions, 173 deletions
diff --git a/bsfs/schema/__init__.py b/bsfs/schema/__init__.py
index dc24313..5162a01 100644
--- a/bsfs/schema/__init__.py
+++ b/bsfs/schema/__init__.py
@@ -10,7 +10,7 @@ import typing
# inner-module imports
from .schema import Schema
from .serialize import from_string, to_string
-from .types import Literal, Node, Predicate, _Vertex # FIXME: _Vertex
+from .types import Literal, Node, Predicate, Vertex, ROOT_FEATURE, ROOT_LITERAL, ROOT_NODE, ROOT_NUMBER, ROOT_PREDICATE, ROOT_VERTEX
# exports
__all__: typing.Sequence[str] = (
diff --git a/bsfs/schema/schema.py b/bsfs/schema/schema.py
index 1c4c807..80cb58a 100644
--- a/bsfs/schema/schema.py
+++ b/bsfs/schema/schema.py
@@ -83,7 +83,7 @@ class Schema():
prange = {pred.range for pred in predicates}
nodes |= {vert for vert in prange if isinstance(vert, types.Node)}
literals |= {vert for vert in prange if isinstance(vert, types.Literal)}
- # NOTE: ROOT_PREDICATE has a _Vertex as range which is neither in nodes nor literals
+ # NOTE: ROOT_PREDICATE has a Vertex as range which is neither in nodes nor literals
# FIXME: with the ROOT_VERTEX missing, the schema is not complete anymore!
# include parents in nodes and literals sets
diff --git a/bsfs/schema/serialize.py b/bsfs/schema/serialize.py
index 1222aa6..c1ac9a9 100644
--- a/bsfs/schema/serialize.py
+++ b/bsfs/schema/serialize.py
@@ -125,10 +125,10 @@ def from_string(schema_str: str) -> schema.Schema:
# get distance
distance = _fetch_value(uri, rdflib.URIRef(ns.bsfs.distance), URI)
# return feature
- return parent.get_child(URI(uri), domain=dom, range=rng, unique=unique,
+ return parent.child(URI(uri), domain=dom, range=rng, unique=unique,
dtype=dtype, dimension=dimension, distance=distance, **annotations)
# handle non-feature predicate
- return parent.get_child(URI(uri), domain=dom, range=rng, unique=unique, **annotations)
+ return parent.child(URI(uri), domain=dom, range=rng, unique=unique, **annotations)
predicates = _fetch_hierarchically(_build_predicate, types.ROOT_PREDICATE)
return schema.Schema(predicates, nodes, literals)
diff --git a/bsfs/schema/types.py b/bsfs/schema/types.py
index e737263..4f49efe 100644
--- a/bsfs/schema/types.py
+++ b/bsfs/schema/types.py
@@ -114,7 +114,7 @@ class _Type():
yield curr
curr = curr.parent
- def get_child(
+ def child(
self,
uri: URI,
**kwargs,
@@ -201,21 +201,21 @@ class _Type():
return False
-class _Vertex(_Type):
+class Vertex(_Type):
"""Graph vertex types. Can be a Node or a Literal."""
- parent: typing.Optional['_Vertex']
- def __init__(self, uri: URI, parent: typing.Optional['_Vertex'], **kwargs):
+ parent: typing.Optional['Vertex']
+ def __init__(self, uri: URI, parent: typing.Optional['Vertex'], **kwargs):
super().__init__(uri, parent, **kwargs)
-class Node(_Vertex):
+class Node(Vertex):
"""Node type."""
parent: typing.Optional['Node']
def __init__(self, uri: URI, parent: typing.Optional['Node'], **kwargs):
super().__init__(uri, parent, **kwargs)
-class Literal(_Vertex):
+class Literal(Vertex):
"""Literal type."""
parent: typing.Optional['Literal']
def __init__(self, uri: URI, parent: typing.Optional['Literal'] ,**kwargs):
@@ -229,7 +229,7 @@ class Predicate(_Type):
domain: Node
# destination type.
- range: _Vertex
+ range: Vertex
# maximum cardinality of type.
unique: bool
@@ -241,7 +241,7 @@ class Predicate(_Type):
parent: '_PredicateBase',
# Predicate members
domain: Node,
- range: _Vertex, # pylint: disable=redefined-builtin
+ range: Vertex, # pylint: disable=redefined-builtin
unique: bool,
**kwargs,
):
@@ -265,11 +265,11 @@ class Predicate(_Type):
and self.range == other.range \
and self.unique == other.unique
- def get_child(
+ def child(
self,
uri: URI,
domain: typing.Optional[Node] = None,
- range: typing.Optional[_Vertex] = None, # pylint: disable=redefined-builtin
+ range: typing.Optional[Vertex] = None, # pylint: disable=redefined-builtin
unique: typing.Optional[bool] = None,
**kwargs,
):
@@ -287,7 +287,7 @@ class Predicate(_Type):
raise errors.ConsistencyError(f'{range} must be a subclass of {self.range}')
if unique is None:
unique = self.unique
- return super().get_child(
+ return super().child(
uri=uri,
domain=domain,
range=range,
@@ -337,7 +337,7 @@ class Feature(Predicate):
and self.dtype == other.dtype \
and self.distance == other.distance
- def get_child(
+ def child(
self,
uri: URI,
domain: typing.Optional[Node] = None,
@@ -355,7 +355,7 @@ class Feature(Predicate):
dtype = self.dtype
if distance is None:
distance = self.distance
- return super().get_child(
+ return super().child(
uri=uri,
domain=domain,
range=range,
@@ -368,7 +368,7 @@ class Feature(Predicate):
# essential vertices
-ROOT_VERTEX = _Vertex(
+ROOT_VERTEX = Vertex(
uri=ns.bsfs.Vertex,
parent=None,
)
diff --git a/test/graph/test_resolve.py b/test/graph/test_resolve.py
index 5bc99e4..f515320 100644
--- a/test/graph/test_resolve.py
+++ b/test/graph/test_resolve.py
@@ -65,7 +65,7 @@ class TestFilter(unittest.TestCase):
{URI('http://example.com/me/entity#1234'), URI('http://example.com/me/entity#4321')})
tags = graph.nodes(ns.bsfs.Tag,
{URI('http://example.com/me/tag#1234'), URI('http://example.com/me/tag#4321')})
- invalid = nodes.Nodes(None, '', schema.node(ns.bsfs.Node).get_child(ns.bsfs.Invalid),
+ invalid = nodes.Nodes(None, '', schema.node(ns.bsfs.Node).child(ns.bsfs.Invalid),
{'http://example.com/you/invalid#1234', 'http://example.com/you/invalid#4321'})
resolver = Filter(schema)
diff --git a/test/query/test_validator.py b/test/query/test_validator.py
index 4f8364a..bf3ceeb 100644
--- a/test/query/test_validator.py
+++ b/test/query/test_validator.py
@@ -69,8 +69,8 @@ class TestFilter(unittest.TestCase):
self.assertRaises(TypeError, self.validate, '1234', None)
self.assertRaises(TypeError, self.validate, self.schema.literal(ns.bsfs.URI), None)
# root_type must exist in the schema
- self.assertRaises(errors.ConsistencyError, self.validate, self.schema.node(ns.bsfs.Node).get_child(ns.bsfs.Image), None)
- self.assertRaises(errors.ConsistencyError, self.validate, self.schema.node(ns.bsfs.Entity).get_child(ns.bsfs.Image), None)
+ self.assertRaises(errors.ConsistencyError, self.validate, self.schema.node(ns.bsfs.Node).child(ns.bsfs.Image), None)
+ self.assertRaises(errors.ConsistencyError, self.validate, self.schema.node(ns.bsfs.Entity).child(ns.bsfs.Image), None)
# valid query returns true
self.assertTrue(self.validate(self.schema.node(ns.bsfs.Entity),
ast.filter.Any(ast.filter.OneOf(ns.bse.tag, ns.bse.buddy),
@@ -130,7 +130,7 @@ class TestFilter(unittest.TestCase):
# type must be a node
self.assertRaises(errors.ConsistencyError, self.validate._branch, self.schema.literal(ns.bsfs.Literal), None)
# type must be in the schema
- self.assertRaises(errors.ConsistencyError, self.validate._branch, self.schema.node(ns.bsfs.Node).get_child(ns.bsfs.Invalid), None)
+ self.assertRaises(errors.ConsistencyError, self.validate._branch, self.schema.node(ns.bsfs.Node).child(ns.bsfs.Invalid), None)
# predicate is verified
self.assertRaises(errors.ConsistencyError, self.validate._branch, self.schema.node(ns.bsfs.Entity),
ast.filter.Any(ns.bsfs.Invalid, ast.filter.Is('http://example.com/entity#1234')))
@@ -187,7 +187,7 @@ class TestFilter(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, self.validate._has, self.schema.literal(ns.bsfs.Literal),
ast.filter.Has(ns.bse.tag))
# type must be in the schema
- self.assertRaises(errors.ConsistencyError, self.validate._has, self.schema.node(ns.bsfs.Node).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._has, self.schema.node(ns.bsfs.Node).child(ns.bsfs.Invalid),
ast.filter.Has(ns.bse.tag))
# has checks predicate
self.assertRaises(errors.ConsistencyError, self.validate._has, self.schema.node(ns.bsfs.Entity),
@@ -206,7 +206,7 @@ class TestFilter(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, self.validate._is, self.schema.literal(ns.bsfs.Literal),
ast.filter.Is('http://example.com/foo'))
# type must be in the schema
- self.assertRaises(errors.ConsistencyError, self.validate._is, self.schema.node(ns.bsfs.Node).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._is, self.schema.node(ns.bsfs.Node).child(ns.bsfs.Invalid),
ast.filter.Is('http://example.com/foo'))
# is accepts correct expressions
self.assertIsNone(self.validate._is(self.schema.node(ns.bsfs.Entity), ast.filter.Is('http://example.com/entity#1234')))
@@ -222,13 +222,13 @@ class TestFilter(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.node(ns.bsfs.Node),
ast.filter.EndsWith('hello world'))
# type must be in the schema
- self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).child(ns.bsfs.Invalid),
ast.filter.Equals('hello world'))
- self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).child(ns.bsfs.Invalid),
ast.filter.Substring('hello world'))
- self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).child(ns.bsfs.Invalid),
ast.filter.StartsWith('hello world'))
- self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._value, self.schema.literal(ns.bsfs.Literal).child(ns.bsfs.Invalid),
ast.filter.EndsWith('hello world'))
# value accepts correct expressions
self.assertIsNone(self.validate._value(self.schema.literal(ns.xsd.string), ast.filter.Equals('hello world')))
@@ -243,9 +243,9 @@ class TestFilter(unittest.TestCase):
self.assertRaises(errors.ConsistencyError, self.validate._bounded, self.schema.node(ns.bsfs.Node),
ast.filter.LessThan(0))
# type must be in the schema
- self.assertRaises(errors.ConsistencyError, self.validate._bounded, self.schema.literal(ns.bsfs.Literal).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._bounded, self.schema.literal(ns.bsfs.Literal).child(ns.bsfs.Invalid),
ast.filter.GreaterThan(0))
- self.assertRaises(errors.ConsistencyError, self.validate._bounded, self.schema.literal(ns.bsfs.Literal).get_child(ns.bsfs.Invalid),
+ self.assertRaises(errors.ConsistencyError, self.validate._bounded, self.schema.literal(ns.bsfs.Literal).child(ns.bsfs.Invalid),
ast.filter.LessThan(0))
# bounded accepts correct expressions
self.assertIsNone(self.validate._bounded(self.schema.literal(ns.xsd.integer), ast.filter.LessThan(0)))
diff --git a/test/schema/test_schema.py b/test/schema/test_schema.py
index 1b45db0..ca21f87 100644
--- a/test/schema/test_schema.py
+++ b/test/schema/test_schema.py
@@ -73,9 +73,9 @@ class TestSchema(unittest.TestCase):
# predicates
self.p_root = types.ROOT_PREDICATE
self.f_root = types.ROOT_FEATURE
- self.p_tag = self.p_root.get_child(ns.bse.tag, self.n_ent, self.n_tag, False)
- self.p_group = self.p_tag.get_child(ns.bse.group, self.n_img, self.n_tag, False)
- self.p_comment = self.p_root.get_child(ns.bse.comment, self.n_root, self.l_string, True)
+ self.p_tag = self.p_root.child(ns.bse.tag, self.n_ent, self.n_tag, False)
+ self.p_group = self.p_tag.child(ns.bse.group, self.n_img, self.n_tag, False)
+ self.p_comment = self.p_root.child(ns.bse.comment, self.n_root, self.l_string, True)
self.predicates = [self.p_root, self.f_root, self.p_tag, self.p_group, self.p_comment]
def test_construction(self):
@@ -217,16 +217,16 @@ class TestSchema(unittest.TestCase):
self.assertNotEqual(hash(schema),
hash(Schema([self.p_group, self.p_tag, self.p_root], self.nodes, self.literals)))
self.assertNotEqual(schema,
- Schema(self.predicates + [self.p_root.get_child(ns.bse.filesize, self.n_ent, self.l_integer)], self.nodes, self.literals))
+ Schema(self.predicates + [self.p_root.child(ns.bse.filesize, self.n_ent, self.l_integer)], self.nodes, self.literals))
self.assertNotEqual(hash(schema),
- hash(Schema(self.predicates + [self.p_root.get_child(ns.bse.filesize, self.n_ent, self.l_integer)], self.nodes, self.literals)))
+ hash(Schema(self.predicates + [self.p_root.child(ns.bse.filesize, self.n_ent, self.l_integer)], self.nodes, self.literals)))
def test_order(self):
# setup
class Foo(): pass
- p_foo = self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_string, True)
- p_sub = p_foo.get_child(ns.bse.sub, self.n_ent, self.l_string, True)
- p_bar = self.p_root.get_child(ns.bse.bar, self.n_ent, self.l_string, True)
+ p_foo = self.p_root.child(ns.bse.foo, self.n_ent, self.l_string, True)
+ p_sub = p_foo.child(ns.bse.sub, self.n_ent, self.l_string, True)
+ p_bar = self.p_root.child(ns.bse.bar, self.n_ent, self.l_string, True)
# can only compare schema to other schema
# <
@@ -305,44 +305,44 @@ class TestSchema(unittest.TestCase):
# inconsistent schema cannot be a subset
self.assertFalse(operator.le(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
self.assertFalse(operator.le(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
+ self.p_root.child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
self.assertFalse(operator.le(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
self.assertFalse(operator.le(Schema({}, {self.n_img}), Schema({}, {
types.Node(ns.bsfs.Image, types.Node(ns.bsfs.Node, None))})))
self.assertFalse(operator.le(Schema({}, {}, {self.l_integer}), Schema({}, {}, {
types.Literal(ns.xsd.integer, types.Literal(ns.xsd.number, types.Literal(ns.bsfs.Literal, None)))})))
# inconsistent schema cannot be a true subset
self.assertFalse(operator.lt(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
self.assertFalse(operator.lt(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
+ self.p_root.child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
self.assertFalse(operator.lt(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
self.assertFalse(operator.lt(Schema({}, {self.n_img}), Schema({}, {
types.Node(ns.bsfs.Image, types.Node(ns.bsfs.Node, None))})))
self.assertFalse(operator.lt(Schema({}, {}, {self.l_integer}), Schema({}, {}, {
types.Literal(ns.xsd.integer, types.Literal(ns.xsd.number, types.Literal(ns.bsfs.Literal, None)))})))
# inconsistent schema cannot be a superset
self.assertFalse(operator.ge(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
self.assertFalse(operator.ge(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
+ self.p_root.child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
self.assertFalse(operator.ge(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
self.assertFalse(operator.ge(Schema({}, {self.n_img}), Schema({}, {
types.Node(ns.bsfs.Image, types.Node(ns.bsfs.Node, None))})))
self.assertFalse(operator.ge(Schema({}, {}, {self.l_integer}), Schema({}, {}, {
types.Literal(ns.xsd.integer, types.Literal(ns.xsd.number, types.Literal(ns.bsfs.Literal, None)))})))
# inconsistent schema cannot be a true superset
self.assertFalse(operator.gt(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_integer, True)}))) # inconsistent w.r.t. literal
self.assertFalse(operator.gt(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
+ self.p_root.child(ns.bse.foo, self.n_img, self.l_string, True)}))) # inconsistent w.r.t. node
self.assertFalse(operator.gt(Schema({p_foo}), Schema({
- self.p_root.get_child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
+ self.p_root.child(ns.bse.foo, self.n_ent, self.l_string, False)}))) # inconsistent w.r.t. unique
self.assertFalse(operator.gt(Schema({}, {self.n_img}), Schema({}, {
types.Node(ns.bsfs.Image, types.Node(ns.bsfs.Node, None))})))
self.assertFalse(operator.gt(Schema({}, {}, {self.l_integer}), Schema({}, {}, {
diff --git a/test/schema/test_serialize.py b/test/schema/test_serialize.py
index 7392cc0..b9d8599 100644
--- a/test/schema/test_serialize.py
+++ b/test/schema/test_serialize.py
@@ -66,7 +66,7 @@ class TestFromString(unittest.TestCase):
''')
# additional nodes can be defined
- n_unused = types.ROOT_NODE.get_child(ns.bsfs.unused)
+ n_unused = types.ROOT_NODE.child(ns.bsfs.unused)
self.assertEqual(Schema({}, {n_unused}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -77,10 +77,10 @@ class TestFromString(unittest.TestCase):
'''))
# a node can have multiple children
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- n_tag = types.ROOT_NODE.get_child(ns.bsfs.Tag)
- n_doc = n_ent.get_child(ns.bsfs.Document)
- n_image = n_ent.get_child(ns.bsfs.Image)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ n_tag = types.ROOT_NODE.child(ns.bsfs.Tag)
+ n_doc = n_ent.child(ns.bsfs.Document)
+ n_image = n_ent.child(ns.bsfs.Image)
self.assertEqual(Schema({}, {n_ent, n_tag, n_doc, n_image}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -97,9 +97,9 @@ class TestFromString(unittest.TestCase):
'''))
# additional nodes can be defined and used
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- p_filename = types.ROOT_PREDICATE.get_child(ns.bse.filename,
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ p_filename = types.ROOT_PREDICATE.child(ns.bse.filename,
n_ent, l_string, False)
self.assertEqual(Schema({p_filename}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@@ -168,7 +168,7 @@ class TestFromString(unittest.TestCase):
''')
# additional literals can be defined
- l_unused = types.ROOT_LITERAL.get_child(ns.xsd.unused)
+ l_unused = types.ROOT_LITERAL.child(ns.xsd.unused)
self.assertEqual(Schema({}, {}, {l_unused}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -179,10 +179,10 @@ class TestFromString(unittest.TestCase):
'''))
# a literal can have multiple children
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- l_integer = types.ROOT_LITERAL.get_child(ns.xsd.integer)
- l_unsigned = l_integer.get_child(ns.xsd.unsigned)
- l_signed = l_integer.get_child(ns.xsd.signed)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ l_integer = types.ROOT_LITERAL.child(ns.xsd.integer)
+ l_unsigned = l_integer.child(ns.xsd.unsigned)
+ l_signed = l_integer.child(ns.xsd.signed)
self.assertEqual(Schema({}, {}, {l_string, l_integer, l_unsigned, l_signed}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -199,9 +199,9 @@ class TestFromString(unittest.TestCase):
'''))
# additional literals can be defined and used
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- p_filename = types.ROOT_PREDICATE.get_child(ns.bse.filename,
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ p_filename = types.ROOT_PREDICATE.child(ns.bse.filename,
n_ent, l_string, False)
self.assertEqual(Schema({p_filename}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@@ -317,9 +317,9 @@ class TestFromString(unittest.TestCase):
''')
# additional predicates can be defined
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- p_comment = types.ROOT_PREDICATE.get_child(ns.bse.comment, domain=n_ent, range=l_string, unique=False)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ p_comment = types.ROOT_PREDICATE.child(ns.bse.comment, domain=n_ent, range=l_string, unique=False)
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -336,10 +336,10 @@ class TestFromString(unittest.TestCase):
'''))
# predicates inherit properties from parents
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- p_annotation = types.ROOT_PREDICATE.get_child(ns.bsfs.Annotation, domain=n_ent, range=l_string)
- p_comment = p_annotation.get_child(ns.bse.comment, unique=True)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ p_annotation = types.ROOT_PREDICATE.child(ns.bsfs.Annotation, domain=n_ent, range=l_string)
+ p_comment = p_annotation.child(ns.bse.comment, unique=True)
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -358,10 +358,10 @@ class TestFromString(unittest.TestCase):
'''))
# we can define partial predicates (w/o specifying a usable range)
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- p_annotation = types.ROOT_PREDICATE.get_child(ns.bsfs.Annotation, domain=n_ent)
- p_comment = p_annotation.get_child(ns.bse.comment, range=l_string, unique=False)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ p_annotation = types.ROOT_PREDICATE.child(ns.bsfs.Annotation, domain=n_ent)
+ p_comment = p_annotation.child(ns.bse.comment, range=l_string, unique=False)
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -381,8 +381,8 @@ class TestFromString(unittest.TestCase):
# predicate definition can be split across multiple statements.
# statements can be repeated
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- p_foo = types.ROOT_PREDICATE.get_child(ns.bse.foo, domain=n_ent, range=types.ROOT_NODE, unique=True)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ p_foo = types.ROOT_PREDICATE.child(ns.bse.foo, domain=n_ent, range=types.ROOT_NODE, unique=True)
self.assertEqual(Schema({p_foo}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -400,11 +400,11 @@ class TestFromString(unittest.TestCase):
'''))
# domain must be a subtype of parent's domain
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- n_image = n_ent.get_child(ns.bsfs.Image)
- p_foo = types.ROOT_PREDICATE.get_child(ns.bse.foo, domain=types.ROOT_NODE)
- p_bar = p_foo.get_child(ns.bse.bar, domain=n_ent)
- p_foobar = p_bar.get_child(ns.bse.foobar, domain=n_image)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ n_image = n_ent.child(ns.bsfs.Image)
+ p_foo = types.ROOT_PREDICATE.child(ns.bse.foo, domain=types.ROOT_NODE)
+ p_bar = p_foo.child(ns.bse.bar, domain=n_ent)
+ p_foobar = p_bar.child(ns.bse.foobar, domain=n_image)
self.assertEqual(Schema({p_foobar}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -439,11 +439,11 @@ class TestFromString(unittest.TestCase):
''')
# range must be a subtype of parent's range
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- n_image = n_ent.get_child(ns.bsfs.Image)
- p_foo = types.ROOT_PREDICATE.get_child(ns.bse.foo, range=types.ROOT_NODE)
- p_bar = p_foo.get_child(ns.bse.bar, range=n_ent)
- p_foobar = p_bar.get_child(ns.bse.foobar, range=n_image)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ n_image = n_ent.child(ns.bsfs.Image)
+ p_foo = types.ROOT_PREDICATE.child(ns.bse.foo, range=types.ROOT_NODE)
+ p_bar = p_foo.child(ns.bse.bar, range=n_ent)
+ p_foobar = p_bar.child(ns.bse.foobar, range=n_image)
self.assertEqual(Schema({p_foobar}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -658,9 +658,9 @@ class TestFromString(unittest.TestCase):
''')
# additional predicates can be defined
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_array = types.ROOT_LITERAL.get_child(ns.bsfs.array)
- p_comment = types.ROOT_FEATURE.get_child(ns.bse.colors, domain=n_ent, range=l_array, unique=False)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_array = types.ROOT_LITERAL.child(ns.bsfs.array)
+ p_comment = types.ROOT_FEATURE.child(ns.bse.colors, domain=n_ent, range=l_array, unique=False)
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -678,12 +678,12 @@ class TestFromString(unittest.TestCase):
'''))
# features inherit properties from parents
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- l_array = types.ROOT_LITERAL.get_child(ns.bsfs.array)
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- p_annotation = types.ROOT_FEATURE.get_child(ns.bsfs.Annotation, domain=n_ent, range=l_array,
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ l_array = types.ROOT_LITERAL.child(ns.bsfs.array)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ p_annotation = types.ROOT_FEATURE.child(ns.bsfs.Annotation, domain=n_ent, range=l_array,
dimension=1234, dtype=ns.xsd.string)
- p_comment = p_annotation.get_child(ns.bse.colors, unique=True)
+ p_comment = p_annotation.child(ns.bse.colors, unique=True)
self.assertEqual(Schema({p_comment}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -706,8 +706,8 @@ class TestFromString(unittest.TestCase):
# feature definition can be split across multiple statements.
# statements can be repeated
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- p_foo = types.ROOT_FEATURE.get_child(ns.bse.foo, domain=n_ent, unique=True,
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ p_foo = types.ROOT_FEATURE.child(ns.bse.foo, domain=n_ent, unique=True,
dimension=1234, dtype=ns.bsfs.f32)
self.assertEqual(Schema({p_foo}), from_string('''
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
@@ -887,24 +887,24 @@ class TestFromString(unittest.TestCase):
def test_integration(self):
# nodes
- n_ent = types.ROOT_NODE.get_child(ns.bsfs.Entity)
- n_tag = types.ROOT_NODE.get_child(ns.bsfs.Tag)
- n_image = n_ent.get_child(ns.bsfs.Image)
+ n_ent = types.ROOT_NODE.child(ns.bsfs.Entity)
+ n_tag = types.ROOT_NODE.child(ns.bsfs.Tag)
+ n_image = n_ent.child(ns.bsfs.Image)
# literals
- l_string = types.ROOT_LITERAL.get_child(ns.xsd.string)
- l_array = types.ROOT_LITERAL.get_child(ns.bsfs.array)
- l_integer = types.ROOT_LITERAL.get_child(ns.xsd.integer)
- l_boolean = types.ROOT_LITERAL.get_child(ns.xsd.boolean)
+ l_string = types.ROOT_LITERAL.child(ns.xsd.string)
+ l_array = types.ROOT_LITERAL.child(ns.bsfs.array)
+ l_integer = types.ROOT_LITERAL.child(ns.xsd.integer)
+ l_boolean = types.ROOT_LITERAL.child(ns.xsd.boolean)
# predicates
- p_annotation = types.ROOT_PREDICATE.get_child(ns.bsfs.Annotation)
- p_tag = types.ROOT_PREDICATE.get_child(ns.bse.tag, domain=n_ent, range=n_tag)
- p_group = p_tag.get_child(ns.bse.group, domain=n_image, unique=True)
- p_comment = p_annotation.get_child(ns.bse.comment, range=l_string)
+ p_annotation = types.ROOT_PREDICATE.child(ns.bsfs.Annotation)
+ p_tag = types.ROOT_PREDICATE.child(ns.bse.tag, domain=n_ent, range=n_tag)
+ p_group = p_tag.child(ns.bse.group, domain=n_image, unique=True)
+ p_comment = p_annotation.child(ns.bse.comment, range=l_string)
# features
- f_colors = types.ROOT_FEATURE.get_child(URI('http://bsfs.ai/schema/Feature/colors_spatial'),
+ f_colors = types.ROOT_FEATURE.child(URI('http://bsfs.ai/schema/Feature/colors_spatial'),
domain=n_ent, range=l_array, unique=True, dtype=ns.bsfs.f16, distance=ns.bsfs.euclidean)
- f_colors1234 = f_colors.get_child(URI('http://bsfs.ai/schema/Feature/colors_spatial#1234'), dimension=1024)
- f_colors4321 = f_colors.get_child(URI('http://bsfs.ai/schema/Feature/colors_spatial#4321'), dimension=2048)
+ f_colors1234 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors_spatial#1234'), dimension=1024)
+ f_colors4321 = f_colors.child(URI('http://bsfs.ai/schema/Feature/colors_spatial#4321'), dimension=2048)
# schema
ref = Schema(
{p_annotation, p_tag, p_group, p_comment, f_colors, f_colors1234, f_colors4321},
diff --git a/test/schema/test_types.py b/test/schema/test_types.py
index af47f0d..26da270 100644
--- a/test/schema/test_types.py
+++ b/test/schema/test_types.py
@@ -14,7 +14,7 @@ from bsfs.schema.types import ROOT_PREDICATE, ROOT_VERTEX, ROOT_FEATURE
from bsfs.utils import errors
# objects to test
-from bsfs.schema.types import _Type, _Vertex, Node, Literal, Predicate, Feature
+from bsfs.schema.types import _Type, Vertex, Node, Literal, Predicate, Feature
## code ##
@@ -47,8 +47,8 @@ class TestType(unittest.TestCase):
self.assertEqual(
hash(_Type('Foo', None, foo='bar', bar='foo')),
hash(_Type('Foo', None, hello='world', foobar=1234)))
- # annotations can be passed to get_child
- self.assertDictEqual(_Type('First', foo='bar').get_child('Second', bar='foo').annotations, {
+ # annotations can be passed to child
+ self.assertDictEqual(_Type('First', foo='bar').child('Second', bar='foo').annotations, {
'bar': 'foo'})
def test_string_conversion(self):
@@ -71,16 +71,16 @@ class TestType(unittest.TestCase):
self.assertEqual(str(_Type('Foo', SubType('Bar'))), '_Type(Foo)')
self.assertEqual(repr(_Type('Foo', SubType('Bar'))), '_Type(Foo, SubType(Bar, None))')
- def test_get_child(self):
+ def test_child(self):
# callee is used as parent
- self.assertEqual(_Type('First').get_child('Second'), _Type('Second', _Type('First')))
+ self.assertEqual(_Type('First').child('Second'), _Type('Second', _Type('First')))
# works with multiple parents
- self.assertEqual(_Type('First').get_child('Second').get_child('Third'), _Type('Third', _Type('Second', _Type('First'))))
+ self.assertEqual(_Type('First').child('Second').child('Third'), _Type('Third', _Type('Second', _Type('First'))))
# type persists
class Foo(_Type): pass
- self.assertEqual(Foo('First').get_child('Second'), Foo('Second', Foo('First')))
+ self.assertEqual(Foo('First').child('Second'), Foo('Second', Foo('First')))
# annotations are respected
- self.assertDictEqual(_Type('First', foo='bar').get_child('Second', bar='foo').annotations, {
+ self.assertDictEqual(_Type('First', foo='bar').child('Second', bar='foo').annotations, {
'bar': 'foo'})
def test_equality(self):
@@ -174,7 +174,7 @@ class TestPredicate(unittest.TestCase):
# range must be a Literal, a Node, or the root Vertex
self.assertRaises(TypeError, Predicate, ns.bse.foo, None, Node(ns.bsfs.Node, None), None, True)
self.assertRaises(TypeError, Predicate, ns.bse.foo, None, Node(ns.bsfs.Node, None), 1234, True)
- self.assertRaises(TypeError, Predicate, ns.bse.foo, None, Node(ns.bsfs.Node, None), _Vertex(ns.bsfs.Foo, None), True)
+ self.assertRaises(TypeError, Predicate, ns.bse.foo, None, Node(ns.bsfs.Node, None), Vertex(ns.bsfs.Foo, None), True)
self.assertRaises(TypeError, Predicate, ns.bse.foo, None, Node(ns.bsfs.Node, None), _Type(ns.bsfs.Foo, None), True)
class Foo(): pass
self.assertRaises(TypeError, Predicate, ns.bse.foo, None, Node(ns.bsfs.Node, None), Foo(), True)
@@ -213,7 +213,7 @@ class TestPredicate(unittest.TestCase):
self.assertNotEqual(tag, Predicate(ns.bse.tag, root, n_root, n_tag, True))
self.assertNotEqual(hash(tag), hash(Predicate(ns.bse.tag, root, n_root, n_tag, True)))
- def test_get_child(self):
+ def test_child(self):
n_root = Node(ns.bsfs.Node, None)
l_root = Literal(ns.bsfs.Literal, None)
n_ent = Node(ns.bsfs.Entity, Node(ns.bsfs.Node, None))
@@ -227,45 +227,45 @@ class TestPredicate(unittest.TestCase):
unique=False,
)
- # get_child returns Predicate
- self.assertIsInstance(tag.get_child(ns.bse.foo), Predicate)
+ # child returns Predicate
+ self.assertIsInstance(tag.child(ns.bse.foo), Predicate)
# uri is respected
- self.assertEqual(ns.bse.foo, tag.get_child(ns.bse.foo).uri)
+ self.assertEqual(ns.bse.foo, tag.child(ns.bse.foo).uri)
# domain is respected
dom = Node(ns.bsfs.Image, n_ent)
- self.assertEqual(dom, tag.get_child(ns.bse.foo, domain=dom).domain)
+ self.assertEqual(dom, tag.child(ns.bse.foo, domain=dom).domain)
# range is respected
rng = Node(ns.bsfs.Group, n_tag)
- self.assertEqual(rng, tag.get_child(ns.bse.foo, range=rng).range)
+ self.assertEqual(rng, tag.child(ns.bse.foo, range=rng).range)
# cannot set range to None
- self.assertEqual(n_tag, tag.get_child(ns.bse.foo, range=None).range)
+ self.assertEqual(n_tag, tag.child(ns.bse.foo, range=None).range)
# unique is respected
- self.assertTrue(tag.get_child(ns.bse.foo, unique=True).unique)
+ self.assertTrue(tag.child(ns.bse.foo, unique=True).unique)
# annotations are respected
- self.assertDictEqual(tag.get_child(ns.bse.foo, foo='bar', bar=123).annotations, {
+ self.assertDictEqual(tag.child(ns.bse.foo, foo='bar', bar=123).annotations, {
'foo': 'bar',
'bar': 123,
})
# domain is inherited from parent
- self.assertEqual(n_root, root.get_child(ns.bse.foo).domain)
- self.assertEqual(n_ent, tag.get_child(ns.bse.foo).domain)
+ self.assertEqual(n_root, root.child(ns.bse.foo).domain)
+ self.assertEqual(n_ent, tag.child(ns.bse.foo).domain)
# range is inherited from parent
- self.assertEqual(ROOT_VERTEX, root.get_child(ns.bse.foo).range)
- self.assertEqual(n_tag, tag.get_child(ns.bse.foo).range)
+ self.assertEqual(ROOT_VERTEX, root.child(ns.bse.foo).range)
+ self.assertEqual(n_tag, tag.child(ns.bse.foo).range)
# uniqueness is inherited from parent
- self.assertFalse(tag.get_child(ns.bse.foo).unique)
+ self.assertFalse(tag.child(ns.bse.foo).unique)
# domain must be subtype of parent's domain
- self.assertRaises(errors.ConsistencyError, tag.get_child, ns.bse.foo, domain=n_root)
- self.assertRaises(errors.ConsistencyError, tag.get_child, ns.bse.foo, domain=Node(ns.bsfs.Image, n_root))
+ self.assertRaises(errors.ConsistencyError, tag.child, ns.bse.foo, domain=n_root)
+ self.assertRaises(errors.ConsistencyError, tag.child, ns.bse.foo, domain=Node(ns.bsfs.Image, n_root))
# range must be subtype of parent's range
- self.assertRaises(errors.ConsistencyError, tag.get_child, ns.bse.foo, range=n_root)
- self.assertRaises(errors.ConsistencyError, tag.get_child, ns.bse.foo, range=Node(ns.bsfs.Image, n_root))
- self.assertRaises(TypeError, tag.get_child, ns.bse.foo, range=Literal(ns.bsfs.Tag, l_root))
+ self.assertRaises(errors.ConsistencyError, tag.child, ns.bse.foo, range=n_root)
+ self.assertRaises(errors.ConsistencyError, tag.child, ns.bse.foo, range=Node(ns.bsfs.Image, n_root))
+ self.assertRaises(TypeError, tag.child, ns.bse.foo, range=Literal(ns.bsfs.Tag, l_root))
# range can be subtyped from ROOT_VERTEX to Node or Literal
- self.assertEqual(n_root, root.get_child(ns.bse.foo, range=n_root).range)
- self.assertEqual(l_root, root.get_child(ns.bse.foo, range=l_root).range)
+ self.assertEqual(n_root, root.child(ns.bse.foo, range=n_root).range)
+ self.assertEqual(l_root, root.child(ns.bse.foo, range=l_root).range)
class TestFeature(unittest.TestCase):
@@ -308,7 +308,7 @@ class TestFeature(unittest.TestCase):
self.assertNotEqual(colors, Feature(ns.bse.colors, ROOT_FEATURE, n_ent, l_array, False, 1234, ns.bsfs.float, ns.bsfs.cosine))
self.assertNotEqual(hash(colors), hash(Feature(ns.bse.colors, ROOT_FEATURE, n_ent, l_array, False, 1234, ns.bsfs.float, ns.bsfs.cosine)))
- def test_get_child(self):
+ def test_child(self):
n_root = Node(ns.bsfs.Node, None)
n_ent = Node(ns.bsfs.Entity, n_root)
l_root = Literal(ns.bsfs.Literal, None)
@@ -324,53 +324,53 @@ class TestFeature(unittest.TestCase):
distance=ns.bsfs.euclidean,
)
- # get_child returns Feature
- self.assertIsInstance(colors.get_child(ns.bse.foo), Feature)
+ # child returns Feature
+ self.assertIsInstance(colors.child(ns.bse.foo), Feature)
# uri is respected
- self.assertEqual(ns.bse.foo, colors.get_child(ns.bse.foo).uri)
+ self.assertEqual(ns.bse.foo, colors.child(ns.bse.foo).uri)
# domain is respected
dom = Node(ns.bsfs.Image, n_ent)
- self.assertEqual(dom, colors.get_child(ns.bse.foo, domain=dom).domain)
+ self.assertEqual(dom, colors.child(ns.bse.foo, domain=dom).domain)
# range is respected
rng = Literal(ns.bse.foo, l_array)
- self.assertEqual(rng, colors.get_child(ns.bse.foo, range=rng).range)
+ self.assertEqual(rng, colors.child(ns.bse.foo, range=rng).range)
# cannot set range to None
- self.assertEqual(l_array, colors.get_child(ns.bse.foo, range=None).range)
+ self.assertEqual(l_array, colors.child(ns.bse.foo, range=None).range)
# unique is respected
- self.assertTrue(colors.get_child(ns.bse.foo, unique=True).unique)
+ self.assertTrue(colors.child(ns.bse.foo, unique=True).unique)
# dimension is respected
- self.assertEqual(4321, colors.get_child(ns.bse.foo, dimension=4321).dimension)
+ self.assertEqual(4321, colors.child(ns.bse.foo, dimension=4321).dimension)
# dtype is respected
- self.assertEqual(ns.bsfs.integer, colors.get_child(ns.bse.foo, dtype=ns.bsfs.integer).dtype)
+ self.assertEqual(ns.bsfs.integer, colors.child(ns.bse.foo, dtype=ns.bsfs.integer).dtype)
# distance is respected
- self.assertEqual(ns.bsfs.cosine, colors.get_child(ns.bse.foo, distance=ns.bsfs.cosine).distance)
+ self.assertEqual(ns.bsfs.cosine, colors.child(ns.bse.foo, distance=ns.bsfs.cosine).distance)
# annotations are respected
- self.assertDictEqual(colors.get_child(ns.bse.foo, foo='bar', bar=123).annotations, {
+ self.assertDictEqual(colors.child(ns.bse.foo, foo='bar', bar=123).annotations, {
'foo': 'bar',
'bar': 123,
})
# domain is inherited from parent
- self.assertEqual(n_root, ROOT_FEATURE.get_child(ns.bse.foo).domain)
- self.assertEqual(n_ent, colors.get_child(ns.bse.foo).domain)
+ self.assertEqual(n_root, ROOT_FEATURE.child(ns.bse.foo).domain)
+ self.assertEqual(n_ent, colors.child(ns.bse.foo).domain)
# range is inherited from parent
- self.assertEqual(l_array, colors.get_child(ns.bse.foo).range)
+ self.assertEqual(l_array, colors.child(ns.bse.foo).range)
# uniqueness is inherited from parent
- self.assertFalse(colors.get_child(ns.bse.foo).unique)
+ self.assertFalse(colors.child(ns.bse.foo).unique)
# dimension is inherited from parent
- self.assertEqual(1234, colors.get_child(ns.bse.foo).dimension)
+ self.assertEqual(1234, colors.child(ns.bse.foo).dimension)
# dtype is inherited from parent
- self.assertEqual(ns.bsfs.float, colors.get_child(ns.bse.foo).dtype)
+ self.assertEqual(ns.bsfs.float, colors.child(ns.bse.foo).dtype)
# distance is inherited from parent
- self.assertEqual(ns.bsfs.euclidean, colors.get_child(ns.bse.foo).distance)
+ self.assertEqual(ns.bsfs.euclidean, colors.child(ns.bse.foo).distance)
# domain must be subtype of parent's domain
- self.assertRaises(errors.ConsistencyError, colors.get_child, ns.bse.foo, domain=n_root)
- self.assertRaises(errors.ConsistencyError, colors.get_child, ns.bse.foo, domain=Node(ns.bsfs.Image, n_root))
+ self.assertRaises(errors.ConsistencyError, colors.child, ns.bse.foo, domain=n_root)
+ self.assertRaises(errors.ConsistencyError, colors.child, ns.bse.foo, domain=Node(ns.bsfs.Image, n_root))
# range must be subtype of parent's range
- self.assertRaises(errors.ConsistencyError, colors.get_child, ns.bse.foo, range=Literal(ns.bsfs.Literal, None))
- self.assertRaises(errors.ConsistencyError, colors.get_child, ns.bse.foo, range=Literal(ns.bsfs.foo, Literal(ns.bsfs.Literal, None)))
- self.assertRaises(TypeError, colors.get_child, ns.bse.foo, range=Node(ns.bsfs.Tag, n_root))
+ self.assertRaises(errors.ConsistencyError, colors.child, ns.bse.foo, range=Literal(ns.bsfs.Literal, None))
+ self.assertRaises(errors.ConsistencyError, colors.child, ns.bse.foo, range=Literal(ns.bsfs.foo, Literal(ns.bsfs.Literal, None)))
+ self.assertRaises(TypeError, colors.child, ns.bse.foo, range=Node(ns.bsfs.Tag, n_root))
## main ##
diff --git a/test/triple_store/sparql/test_parse_filter.py b/test/triple_store/sparql/test_parse_filter.py
index bd19803..bd967e5 100644
--- a/test/triple_store/sparql/test_parse_filter.py
+++ b/test/triple_store/sparql/test_parse_filter.py
@@ -124,7 +124,7 @@ class TestParseFilter(unittest.TestCase):
# __call__ requires a valid root type
self.assertRaises(errors.BackendError, self.parser, self.schema.literal(ns.bsfs.Literal), None)
- self.assertRaises(errors.ConsistencyError, self.parser, self.schema.node(ns.bsfs.Node).get_child(ns.bsfs.Invalid), None)
+ self.assertRaises(errors.ConsistencyError, self.parser, self.schema.node(ns.bsfs.Node).child(ns.bsfs.Invalid), None)
# __call__ requires a parseable root
self.assertRaises(errors.BackendError, self.parser, self.schema.node(ns.bsfs.Entity), ast.filter.FilterExpression())
# __call__ returns an executable query
diff --git a/test/triple_store/sparql/test_sparql.py b/test/triple_store/sparql/test_sparql.py
index 3d81de1..25a0b15 100644
--- a/test/triple_store/sparql/test_sparql.py
+++ b/test/triple_store/sparql/test_sparql.py
@@ -108,7 +108,7 @@ class TestSparqlStore(unittest.TestCase):
store.create(store.schema.node(ns.bsfs.PDF), {URI('http://example.com/me/pdf#1234')})
# node_type must be in the schema
- self.assertRaises(errors.ConsistencyError, store._has_type, URI('http://example.com/me/entity#1234'), store.schema.node(ns.bsfs.Node).get_child(ns.bsfs.invalid))
+ self.assertRaises(errors.ConsistencyError, store._has_type, URI('http://example.com/me/entity#1234'), store.schema.node(ns.bsfs.Node).child(ns.bsfs.invalid))
# returns False on inexistent nodes
self.assertFalse(store._has_type(URI('http://example.com/me/entity#4321'), store.schema.node(ns.bsfs.Entity)))
@@ -509,7 +509,7 @@ class TestSparqlStore(unittest.TestCase):
store.set(ent_type, {URI('http://example.com/me/entity#1234')}, self.schema.predicate(ns.bse.filesize), {1234})
store.set(ent_type, {URI('http://example.com/me/entity#4321')}, self.schema.predicate(ns.bse.filesize), {4321})
# node_type must be in the schema
- self.assertRaises(errors.ConsistencyError, set, store.get(self.schema.node(ns.bsfs.Node).get_child(ns.bsfs.Invalid), ast.filter.IsIn(ent_ids)))
+ self.assertRaises(errors.ConsistencyError, set, store.get(self.schema.node(ns.bsfs.Node).child(ns.bsfs.Invalid), ast.filter.IsIn(ent_ids)))
# query must be a filter expression
class Foo(): pass
self.assertRaises(TypeError, set, store.get(ent_type, 1234))
@@ -574,7 +574,7 @@ class TestSparqlStore(unittest.TestCase):
store.schema = self.schema
# node type must be valid
- self.assertRaises(errors.ConsistencyError, store.create, self.schema.node(ns.bsfs.Entity).get_child(ns.bsfs.invalid), {
+ self.assertRaises(errors.ConsistencyError, store.create, self.schema.node(ns.bsfs.Entity).child(ns.bsfs.invalid), {
URI('http://example.com/me/entity#1234'), URI('http://example.com/me/entity#4321')})
# can create some nodes
@@ -636,7 +636,7 @@ class TestSparqlStore(unittest.TestCase):
p_comment = store.schema.predicate(ns.bse.comment)
p_author = store.schema.predicate(ns.bse.author)
p_tag = store.schema.predicate(ns.bse.tag)
- p_invalid = store.schema.predicate(ns.bsfs.Predicate).get_child(ns.bsfs.foo, range=store.schema.node(ns.bsfs.Tag))
+ p_invalid = store.schema.predicate(ns.bsfs.Predicate).child(ns.bsfs.foo, range=store.schema.node(ns.bsfs.Tag))
# create node instances
ent_ids = {
URI('http://example.com/me/entity#1234'),
@@ -659,7 +659,7 @@ class TestSparqlStore(unittest.TestCase):
store.create(user_type, user_ids)
# invalid node_type is not permitted
- self.assertRaises(errors.ConsistencyError, store.set, self.schema.node(ns.bsfs.Node).get_child(ns.bse.foo),
+ self.assertRaises(errors.ConsistencyError, store.set, self.schema.node(ns.bsfs.Node).child(ns.bse.foo),
ent_ids, p_comment, {'hello world'})
# invalid predicate is not permitted