aboutsummaryrefslogtreecommitdiffstats
path: root/bsfs/schema
diff options
context:
space:
mode:
Diffstat (limited to 'bsfs/schema')
-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
4 files changed, 18 insertions, 18 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,
)