text
stringlengths
81
112k
legend needs to be a list, tuple or None def set_legend(self, legend): """legend needs to be a list, tuple or None""" assert(isinstance(legend, list) or isinstance(legend, tuple) or legend is None) if legend: self.legend = [quote(a) for a in legend] else: ...
Sets legend position. Default is 'r'. b - At the bottom of the chart, legend entries in a horizontal row. bv - At the bottom of the chart, legend entries in a vertical column. t - At the top of the chart, legend entries in a horizontal row. tv - At the top of the chart, legend entries i...
Determines the appropriate data encoding type to give satisfactory resolution (http://code.google.com/apis/chart/#chart_data). def data_class_detection(self, data): """Determines the appropriate data encoding type to give satisfactory resolution (http://code.google.com/apis/chart/#chart_data). ...
Return a 2-tuple giving the minimum and maximum x-axis data range. def data_x_range(self): """Return a 2-tuple giving the minimum and maximum x-axis data range. """ try: lower = min([min(self._filter_none(s)) for type, s in self.annotated_dat...
Scale `self.data` as appropriate for the given data encoding (data_class) and return it. An optional `y_range` -- a 2-tuple (lower, upper) -- can be given to specify the y-axis bounds. If not given, the range is inferred from the data: (0, <max-value>) presuming no negative valu...
Set the country code map for the data. Codes given in a list. i.e. DE - Germany AT - Austria US - United States def set_codes(self, codes): '''Set the country code map for the data. Codes given in a list. i.e. DE - Germany AT - Austria ...
Sets the geo area for the map. * africa * asia * europe * middle_east * south_america * usa * world def set_geo_area(self, area): '''Sets the geo area for the map. * africa * asia * europe * middle_east * south_am...
Sets the data and country codes via a dictionary. i.e. {'DE': 50, 'GB': 30, 'AT': 70} def add_data_dict(self, datadict): '''Sets the data and country codes via a dictionary. i.e. {'DE': 50, 'GB': 30, 'AT': 70} ''' self.set_codes(list(datadict.keys())) self.add_data(li...
5.4.3 Datatype Constraints Determine whether "a value of the lexical form of n can be cast to the target type v per XPath Functions 3.1 section 19 Casting[xpath-functions]." def can_cast_to(v: Literal, dt: str) -> bool: """ 5.4.3 Datatype Constraints Determine whether "a value of the lexical form of ...
5.4.5 XML Schema Numberic Facet Constraints totaldigits and fractiondigits constraints on values not derived from xsd:decimal fail. def total_digits(n: Literal) -> Optional[int]: """ 5.4.5 XML Schema Numberic Facet Constraints totaldigits and fractiondigits constraints on values not derived from xsd:de...
5.4.5 XML Schema Numeric Facet Constraints for "fractiondigits" constraints, v is less than or equals the number of digits to the right of the decimal place in the XML Schema canonical form[xmlschema-2] of the value of n, ignoring trailing zeros. def fraction_digits(n: Literal) -> Optional[int]: """ 5.4.5...
Map `5.6.2 Flags <https://www.w3.org/TR/xpath-functions-31/#flags>`_ to python :param expr: match pattern :param xpath_flags: xpath flags :returns: python flags / modified match pattern def _map_xpath_flags_to_re(expr: str, xpath_flags: str) -> Tuple[int, str]: """ Map `5.6.2 Flags <https://www.w3.or...
`PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`_ does not add identifying types to ObjectLiterals. This routine re-identifies the types def map_object_literal(v: Union[str, jsonasobj.JsonObj]) -> ShExJ.ObjectLiteral: """ `PyShEx.jsg <https://github.com/hsolbrig/ShExJSG/ShExJSG/ShExJ.jsg>`...
Uncomment any lines that start with #import in the .pth file def do_enable(): """ Uncomment any lines that start with #import in the .pth file """ try: _lines = [] with open(vext_pth, mode='r') as f: for line in f.readlines(): if line.startswith('#') and line...
Comment any lines that start with import in the .pth file def do_disable(): """ Comment any lines that start with import in the .pth file """ from vext import vext_pth try: _lines = [] with open(vext_pth, mode='r') as f: for line in f.readlines(): if not...
Attempt to import everything in the 'test-imports' section of specified vext_files :param: list of vext filenames (without paths), '*' matches all. :return: True if test_imports was successful from all files def do_check(vext_files): """ Attempt to import everything in the 'test-imports' section o...
Convert path pointing subdirectory of virtualenv site-packages to system site-packages. Destination directory must exist for this to work. >>> fix_path('C:\\some-venv\\Lib\\site-packages\\gnome') 'C:\\Python27\\lib\\site-packages\\gnome' def fix_path(p): """ Convert path pointing subdirectory...
Fixup paths added in .pth file that point to the virtualenv instead of the system site packages. In depth: .PTH can execute arbitrary code, which might manipulate the PATH or sys.path :return: def fixup_paths(): """ Fixup paths added in .pth file that point to the virtualenv instead of t...
Wrapper for site.addpackage Try and work out which directories are added by the .pth and add them to the known_dirs set :param sys_sitedir: system site-packages directory :param pthfile: path file to add :param known_dirs: set of known directories def addpackage(sys_sitedir, pthfile, known_dirs):...
convert a filename like html5lib-0.999.egg-info to html5lib def filename_to_module(filename): """ convert a filename like html5lib-0.999.egg-info to html5lib """ find = re.compile(r"^[^.|-]*") name = re.search(find, filename).group(0) return name
Add any new modules that are directories to the PATH def init_path(): """ Add any new modules that are directories to the PATH """ sitedirs = getsyssitepackages() for sitedir in sitedirs: env_path = os.environ['PATH'].split(os.pathsep) for module in allowed_modules: p = ...
If in a virtualenv then load spec files to decide which modules can be imported from system site-packages and install path hook. def install_importer(): """ If in a virtualenv then load spec files to decide which modules can be imported from system site-packages and install path hook. """ ...
Only lets modules in allowed_modules be loaded, others will get an ImportError def load_module(self, name): """ Only lets modules in allowed_modules be loaded, others will get an ImportError """ # Get the name relative to SITEDIR .. filepath = self.module_info[1...
:return: extra paths def extra_paths(): """ :return: extra paths """ # TODO - this is only tested on Ubuntu for now # there must be a better way of getting # the sip directory. dirs = {} try: @vext.env.run_in_syspy def run(*args): import sipconf...
Simply convert a string type to bytes if the value is a string and is an instance of six.string_types but not of six.binary_type in python2 struct.pack("<Q") is both string_types and binary_type but in python3 struct.pack("<Q") is binary_type but not a string_types :param value: :param binary: :...
Evaluate focus node `focus` in graph `g` against shape `shape` in ShEx schema `schema` :param g: Graph containing RDF :param schema: ShEx Schema -- if str, it will be parsed :param focus: focus node in g. If not specified, all URI subjects in G will be evaluated. :param start: Starting shape. If omitt...
`5.2 Validation Definition <http://shex.io/shex-semantics/#validation>`_ The expression isValid(G, m) indicates that for every nodeSelector/shapeLabel pair (n, s) in m, s has a corresponding shape expression se and satisfies(n, se, G, m). satisfies is defined below for each form of shape expression...
Check that imports in 'test_imports' succeed otherwise display message in 'install_hints' def check_sysdeps(vext_files): """ Check that imports in 'test_imports' succeed otherwise display message in 'install_hints' """ @run_in_syspy def run(*modules): result = {} for m in m...
copy vext_file to sys.prefix + '/share/vext/specs' (PIP7 seems to remove data_files so we recreate something similar here) def install_vexts(vext_files, verify=True): """ copy vext_file to sys.prefix + '/share/vext/specs' (PIP7 seems to remove data_files so we recreate something similar here) """...
Create the default PTH file :return: def create_pth(): """ Create the default PTH file :return: """ if prefix == '/usr': print("Not creating PTH in real prefix: %s" % prefix) return False with open(vext_pth, 'w') as f: f.write(DEFAULT_PTH_CONTENT) return True
Return the turtle representation of subj as a collection :param g: Graph containing subj :param subj: subject of list :param max_entries: maximum number of list elements to return, None means all :param nentries: used for recursion :return: List of formatted entries if subj heads a well formed col...
:param name: name in format helper.path_name sip.default_sip_dir def get_extra_path(name): """ :param name: name in format helper.path_name sip.default_sip_dir """ # Paths are cached in path_cache helper_name, _, key = name.partition(".") helper = path_helpers.get(helper_name) if ...
setuptools 12.2 can trigger a really nasty bug that eats all memory, so upgrade it to 18.8, which is known to be good. def upgrade_setuptools(): """ setuptools 12.2 can trigger a really nasty bug that eats all memory, so upgrade it to 18.8, which is known to be good. """ # Note - I trie...
:return: list of installed packages def installed_packages(self): """ :return: list of installed packages """ packages = [] CMDLINE = [sys.executable, "-mpip", "freeze"] try: for package in subprocess.check_output(CMDLINE) \ .decode('utf-8'). \ ...
:return: list of package info on installed packages def package_info(self): """ :return: list of package info on installed packages """ import subprocess # create a commandline like pip show Pillow show package_names = self.installed_packages() if not package_na...
List of packages that depend on dependency :param dependency: package name, e.g. 'vext' or 'Pillow' def depends_on(self, dependency): """ List of packages that depend on dependency :param dependency: package name, e.g. 'vext' or 'Pillow' """ packages = self.package_inf...
:return: Absolute paths to any provided vext files def find_vext_files(self): """ :return: Absolute paths to any provided vext files """ packages = self.depends_on("vext") vext_files = [] for location in [package.get("location") for package in packages]: if...
Need to find any pre-existing vext contained in dependent packages and install them example: you create a setup.py with install_requires["vext.gi"]: - vext.gi gets installed using bdist_egg - vext itself is now called with bdist_egg and we end up here Vext now needs t...
Iter to a list of servers and instantiate Protocol class. :param servers: A list of servers :type servers: list :return: Returns nothing :rtype: None def set_servers(self, servers): """ Iter to a list of servers and instantiate Protocol class. :param servers: A...
Send a command to server flush|delete all keys. :param time: Time to wait until flush in seconds. :type time: int :return: True in case of success, False in case of failure :rtype: bool def flush_all(self, time=0): """ Send a command to server flush|delete all keys. ...
Return server stats. :param key: Optional if you want status from a key. :type key: six.string_types :return: A dict with server stats :rtype: dict def stats(self, key=None): """ Return server stats. :param key: Optional if you want status from a key. :...
Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html def house_explosions(): """ Data from http://indexed.blogspot.com/2007/12/meltdown-indeed.html """ chart = PieChart2D(int(settings.width * 1.7), settings.height) chart.add_data([10, 10, 30, 200]) chart.set_pie_labels([ '...
http://shex.io/shex-semantics/#values Implements "n = vsv" where vsv is an objectValue and n is a Node Note that IRIREF is a string pattern, so the matching type is str def objectValueMatches(n: Node, vsv: ShExJ.objectValue) -> bool: """ http://shex.io/shex-semantics/#values Implements "n = vsv" whe...
Compare :py:class:`rdflib.URIRef` value with :py:class:`ShExJ.IRIREF` value def uriref_matches_iriref(v1: URIRef, v2: Union[str, ShExJ.IRIREF]) -> bool: """ Compare :py:class:`rdflib.URIRef` value with :py:class:`ShExJ.IRIREF` value """ return str(v1) == str(v2)
Determine whether a :py:class:`rdflib.URIRef` value starts with the text of a :py:class:`ShExJ.IRIREF` value def uriref_startswith_iriref(v1: URIRef, v2: Union[str, ShExJ.IRIREF]) -> bool: """ Determine whether a :py:class:`rdflib.URIRef` value starts with the text of a :py:class:`ShExJ.IRIREF` value """ retur...
Compare :py:class:`rdflib.Literal` with :py:class:`ShExJ.objectLiteral` def literal_matches_objectliteral(v1: Literal, v2: ShExJ.ObjectLiteral) -> bool: """ Compare :py:class:`rdflib.Literal` with :py:class:`ShExJ.objectLiteral` """ v2_lit = Literal(str(v2.value), datatype=iriref_to_uriref(v2.type), lang=str(v...
`5.4.1 Semantics <http://shex.io/shex-semantics/#node-constraint-semantics>`_ For a node n and constraint nc, satisfies2(n, nc) if and only if for every nodeKind, datatype, xsFacet and values constraint value v present in nc nodeSatisfies(n, v). The following sections define nodeSatisfies for each of these...
`5.4.2 Node Kind Constraints <http://shex.io/shex-semantics/#nodeKind>`_ For a node n and constraint value v, nodeSatisfies(n, v) if: * v = "iri" and n is an IRI. * v = "bnode" and n is a blank node. * v = "literal" and n is a Literal. * v = "nonliteral" and n is an IRI or blank no...
`5.4.3 Datatype Constraints <http://shex.io/shex-semantics/#datatype>`_ For a node n and constraint value v, nodeSatisfies(n, v) if n is an Literal with the datatype v and, if v is in the set of SPARQL operand data types[sparql11-query], an XML schema string with a value of the lexical form of n can be cas...
`5.4.5 XML Schema String Facet Constraints <ttp://shex.io/shex-semantics/#xs-string>`_ String facet constraints apply to the lexical form of the RDF Literals and IRIs and blank node identifiers (see note below regarding access to blank node identifiers). def nodeSatisfiesStringFacet(cntxt: Context, n: Node,...
`5.4.5 XML Schema Numeric Facet Constraints <http://shex.io/shex-semantics/#xs-numeric>`_ Numeric facet constraints apply to the numeric value of RDF Literals with datatypes listed in SPARQL 1.1 Operand Data Types[sparql11-query]. Numeric constraints on non-numeric values fail. totaldigits and fractiondigi...
`5.4.5 Values Constraint <http://shex.io/shex-semantics/#values>`_ For a node n and constraint value v, nodeSatisfies(n, v) if n matches some valueSetValue vsv in v. def nodeSatisfiesValues(cntxt: Context, n: Node, nc: ShExJ.NodeConstraint, _c: DebugContext) -> bool: """ `5.4.5 Values Constraint <http://shex...
A term matches a valueSetValue if: * vsv is an objectValue and n = vsv. * vsv is a Language with langTag lt and n is a language-tagged string with a language tag l and l = lt. * vsv is a IriStem, LiteralStem or LanguageStem with stem st and nodeIn(n, st). * vsv is a IriStemRange, Literal...
**nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a :py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`. The expression `nodeInIriStem(n, s)` is satisfied iff: #) `s` is a :py:class:`ShExJ.WildCard` or #) `n` is an :py:cl...
http://shex.io/shex-semantics/#values **nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a :py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`. The expression `nodeInLiteralStem(n, s)` is satisfied iff: #) `s` is a :py...
http://shex.io/shex-semantics/#values **nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a :py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`. The expression `nodeInLanguageStem(n, s)` is satisfied iff: #) `s` is a :p...
http://shex.io/shex-semantics/#values **nodeIn**: asserts that an RDF node n is equal to an RDF term s or is in a set defined by a :py:class:`ShExJ.IriStem`, :py:class:`LiteralStem` or :py:class:`LanguageStem`. The expression `nodeInBnodeStem(n, s)` is satisfied iff: #) `s` is a :py:c...
Decorator to run a function in the system python :param f: :return: def run_in_syspy(f): """ Decorator to run a function in the system python :param f: :return: """ fname = f.__name__ code_lines = inspect.getsource(f).splitlines() code = dedent("\n".join(code_lines[1:])) # s...
:return: True if in running from a virtualenv Has to detect the case where the python binary is run directly, so VIRTUAL_ENV may not be set def in_venv(): """ :return: True if in running from a virtualenv Has to detect the case where the python binary is run directly, so VIRTUAL_ENV may not b...
:return: list of site-packages from system python def getsyssitepackages(): """ :return: list of site-packages from system python """ global _syssitepackages if not _syssitepackages: if not in_venv(): _syssitepackages = get_python_lib() return _syssitepackages ...
:return: system python executable def findsyspy(): """ :return: system python executable """ if not in_venv(): return sys.executable python = basename(realpath(sys.executable)) prefix = None if HAS_ORIG_PREFIX_TXT: with open(ORIG_PREFIX_TXT) as op: prefix = op.r...
Delete a key/value from server. If key does not exist, it returns True. :param key: Key's name to be deleted :param cas: CAS of the key :return: True in case o success and False in case of failure. def delete(self, key, cas=0): """ Delete a key/value from server. If key does no...
Set a value for a key on server. :param key: Key's name :type key: str :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your key will expire. :type time: int :param compress_level: How much to compress. ...
Set multiple keys with it's values on server. :param mappings: A dict with keys/values :type mappings: dict :param time: Time in seconds that your key will expire. :type time: int :param compress_level: How much to compress. 0 = no compression, 1 = fastest, 9 = slowe...
Add a key/value to server ony if it does not exist. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your key will expire. :type time: int :param compress_level:...
Replace a key/value to server ony if it does exist. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your key will expire. :type time: int :param compress_level:...
Get multiple keys from server. :param keys: A list of keys to from server. :type keys: list :param get_cas: If get_cas is true, each value is (data, cas), with each result's CAS value. :type get_cas: boolean :return: A dict with all requested keys. :rtype: dict def get_...
Set a value for a key on server if its CAS value matches cas. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param cas: The CAS value previously obtained from a call to get*. :type cas: int :p...
Increment a key, if it exists, returns it's actual value, if it don't, return 0. :param key: Key's name :type key: six.string_types :param value: Number to be incremented :type value: int :return: Actual value of the key on server :rtype: int def incr(self, key, value):...
Decrement a key, if it exists, returns it's actual value, if it don't, return 0. Minimum value of decrement return is 0. :param key: Key's name :type key: six.string_types :param value: Number to be decremented :type value: int :return: Actual value of the key on server ...
`5.5.2 Semantics <http://shex.io/shex-semantics/#triple-expressions-semantics>`_ For a node `n`, shape `S`, graph `G`, and shapeMap `m`, `satisfies(n, S, G, m)` if and only if: * `neigh(G, n)` can be partitioned into two sets matched and remainder such that `matches(matched, expression, m)`. If expressi...
Let **outs** be the arcsOut in remainder: `outs = remainder ∩ arcsOut(G, n)`. Let **matchables** be the triples in outs whose predicate appears in a TripleConstraint in `expression`. If `expression` is absent, matchables = Ø (the empty set). * There is no triple in **matchables** which matches a TripleCon...
**matches**: asserts that a triple expression is matched by a set of triples that come from the neighbourhood of a node in an RDF graph. The expression `matches(T, expr, m)` indicates that a set of triples `T` can satisfy these rules: * expr has semActs and `matches(T, expr, m)` by the remaining rules in t...
Evaluate cardinality expression expr has a cardinality of min and/or max not equal to 1, where a max of -1 is treated as unbounded, and T can be partitioned into k subsets T1, T2,…Tk such that min ≤ k ≤ max and for each Tn, matches(Tn, expr, m) by the remaining rules in this list. def matchesCardinality(c...
Evaluate the expression def matchesExpr(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExpr, _: DebugContext) -> bool: """ Evaluate the expression """ if isinstance(expr, ShExJ.OneOf): return matchesOneOf(cntxt, T, expr) elif isinstance(expr, ShExJ.EachOf): return matchesEachOf(cntxt,...
expr is a OneOf and there is some shape expression se2 in shapeExprs such that a matches(T, se2, m). def matchesOneOf(cntxt: Context, T: RDFGraph, expr: ShExJ.OneOf, _: DebugContext) -> bool: """ expr is a OneOf and there is some shape expression se2 in shapeExprs such that a matches(T, se2, m). """ re...
expr is an EachOf and there is some partition of T into T1, T2,… such that for every expression expr1, expr2,… in shapeExprs, matches(Tn, exprn, m). def matchesEachOf(cntxt: Context, T: RDFGraph, expr: ShExJ.EachOf, _: DebugContext) -> bool: """ expr is an EachOf and there is some partition of T into T1, T2,…...
expr is a TripleConstraint and: * t is a triple * t's predicate equals expr's predicate. Let value be t's subject if inverse is true, else t's object. * if inverse is true, t is in arcsIn, else t is in arcsOut. def matchesTripleConstraint(cntxt: Context, t: RDFTriple, expr: ShExJ.TripleConstraint, c...
expr is an tripleExprRef and satisfies(value, tripleExprWithId(tripleExprRef), G, m). The tripleExprWithId function is defined in Triple Expression Reference Requirement below. def matchesTripleExprRef(cntxt: Context, T: RDFGraph, expr: ShExJ.tripleExprLabel, _: DebugContext) -> bool: """ expr is an triple...
Get a key from server. :param key: Key's name :type key: six.string_types :param get_cas: If true, return (value, cas), where cas is the new CAS value. :type get_cas: boolean :return: Returns a key data from server. :rtype: object def get(self, key, get_cas=False): ...
Get a key from server, returning the value and its CAS key. This method is for API compatibility with other implementations. :param key: Key's name :type key: six.string_types :return: Returns (key data, value), or (None, None) if the value is not in cache. :rtype: object def ...
Get multiple keys from server. :param keys: A list of keys to from server. :type keys: list :param get_cas: If get_cas is true, each value is (data, cas), with each result's CAS value. :type get_cas: boolean :return: A dict with all requested keys. :rtype: dict def get_...
Set a value for a key on server. :param key: Key's name :type key: str :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your key will expire. :type time: int :param compress_level: How much to compress. ...
Set multiple keys with it's values on server. :param mappings: A dict with keys/values :type mappings: dict :param time: Time in seconds that your key will expire. :type time: int :param compress_level: How much to compress. 0 = no compression, 1 = fastest, 9 = slowe...
Delete a key/value from server. If key does not exist, it returns True. :param key: Key's name to be deleted :param cas: CAS of the key :return: True in case o success and False in case of failure. def delete(self, key, cas=0): """ Delete a key/value from server. If key does no...
Increment a key, if it exists, returns it's actual value, if it don't, return 0. :param key: Key's name :type key: six.string_types :param value: Number to be incremented :type value: int :return: Actual value of the key on server :rtype: int def incr(self, key, value):...
Decrement a key, if it exists, returns it's actual value, if it don't, return 0. Minimum value of decrement return is 0. :param key: Key's name :type key: six.string_types :param value: Number to be decremented :type value: int :return: Actual value of the key on server ...
Set the result of the evaluation. If the result is true, prune all of the children that didn't cut it :param rval: Result of evaluation def set_result(self, rval: bool) -> None: """ Set the result of the evaluation. If the result is true, prune all of the children that didn't cut it :param rv...
Return the shape expression in the schema referenced by selector, if any :param cntxt: Context node or ShEx Schema :param selector: identifier of element to select within the schema :return: def reference_of(selector: shapeLabel, cntxt: Union[Context, ShExJ.Schema] ) -> Optional[ShExJ.shapeExpr]: """ ...
Search for the label in a Schema def triple_reference_of(label: ShExJ.tripleExprLabel, cntxt: Context) -> Optional[ShExJ.tripleExpr]: """ Search for the label in a Schema """ te: Optional[ShExJ.tripleExpr] = None if cntxt.schema.start is not None: te = triple_in_shape(cntxt.schema.start, label, cnt...
Search for the label in a shape expression def triple_in_shape(expr: ShExJ.shapeExpr, label: ShExJ.tripleExprLabel, cntxt: Context) \ -> Optional[ShExJ.tripleExpr]: """ Search for the label in a shape expression """ te = None if isinstance(expr, (ShExJ.ShapeOr, ShExJ.ShapeAnd)): for expr2 i...
Return the set of predicates that "appears in a TripleConstraint in an expression See: `5.5.2 Semantics <http://shex.io/shex-semantics/#triple-expressions-semantics>`_ for details :param expression: Expression to scan for predicates :param cntxt: Context of evaluation :return: List of predicates ...
Directed predicates in expression -- return all predicates in shapeExpr along with which direction(s) they evaluate :param expression: Expression to scan :param cntxt: :return: def directed_predicates_in_expression(expression: ShExJ.shapeExpr, cntxt: Context) -> Dict[IRIREF, PredDirection]: """ Di...
taken from `Stack Overflow <https://codereview.stackexchange.com/questions/1526/finding-all-k-subset-partitions>`_ def algorithm_u(ns, m): """ taken from `Stack Overflow <https://codereview.stackexchange.com/questions/1526/finding-all-k-subset-partitions>`_ """ def visit(nv, av): ps = [[] for ...
Partition a list of integers into a list of partitions def integer_partition(size: int, nparts: int) -> Iterator[List[List[int]]]: """ Partition a list of integers into a list of partitions """ for part in algorithm_u(range(size), nparts): yield part
Partition T into all possible partitions of T of size nparts :param T: Set of RDF triples to be partitioned :param nparts: number of partitions (e.g. 2 means return all possible 2 set partitions :return: Iterator that returns partitions We don't actually partition the triples directly -- instead, we pa...
Partition T into all possible combinations of two subsets :param T: RDF Graph to partition :return: def partition_2(T: RDFGraph) -> List[Tuple[RDFGraph, RDFGraph]]: """ Partition T into all possible combinations of two subsets :param T: RDF Graph to partition :return: """ for p in parti...
numeric denotes typed literals with datatypes xsd:integer, xsd:decimal, xsd:float, and xsd:double. def is_strict_numeric(n: Node) -> bool: """ numeric denotes typed literals with datatypes xsd:integer, xsd:decimal, xsd:float, and xsd:double. """ return is_typed_literal(n) and cast(Literal, n).datatype in [XSD....
simple literal denotes a plain literal with no language tag. def is_simple_literal(n: Node) -> bool: """ simple literal denotes a plain literal with no language tag. """ return is_typed_literal(n) and cast(Literal, n).datatype is None and cast(Literal, n).language is None
`5.7.1 Semantic Actions Semantics <http://shex.io/shex-semantics/#semantic-actions-semantics>`_ The evaluation semActsSatisfied on a list of SemActs returns success or failure. The evaluation of an individual SemAct is implementation-dependent. def semActsSatisfied(acts: Optional[List[ShExJ.SemAct]], cntxt: C...