Repository navigation
Conversation
A query could hold only one condition ('Only one condition is allowed'),
so [natoms > 50, volume < 60] or a range [x > 1, x < 5] failed. Each
condition now becomes its own FILTER, which SPARQL combines with AND, and
a term used twice is selected once. Operands of & / | that are appended
for their paths no longer carry their own condition, so an OR is never
narrowed to an AND.
Every destination was required, so a sample missing any one property dropped out of the results. term.optional (like .any / .only) marks a destination whose triple patterns, type constraint and condition are wrapped in an OPTIONAL block; a condition on an optional value therefore only leaves it unbound instead of removing the row.
[[hasMaterial, hasAltName]] raised IndexError: when merging the path from an object property, its range class was appended as well, shifting every following node into the wrong triple position. The object of the property now takes the place of the range class.
Result cells were always rdflib terms in object columns, so every value had to be converted before plotting or arithmetic. With python_values=True literals become Python values and IRIs strings; numeric columns get a numeric dtype, with NaN for missing optional values. The default is unchanged.
Condition and type lines inside an OPTIONAL block were indented less than its triple patterns.
Adds a section for each to the advanced query building example, with outputs, and lists them in its summary. Existing cells are unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #76. The base is
audit-fixes, so this diff shows only these 6 commits. Once #76 is merged and its branch deleted, GitHub will retarget this PR tomain.Adds the three query features whose absence meant queries against the atomRDF knowledge graph were being written as raw SPARQL.
Several independent conditions
A query could hold only one condition (
ValueError: Only one condition is allowed), so[natoms > 50, volume < 60]or a range[x > 1, x < 5]had to be squeezed into a single&expression. Now:FILTER, which SPARQL combines with AND.SELECT.&/|expression that are added only for their paths no longer carry their own condition, so an OR is never narrowed to an AND.test_prepare_destinations_multiple_conditions_errorasserted the old limit, so it is replaced by a test that accepts several conditions.Optional destinations:
term.optionalEvery destination was required, so a sample missing any one property dropped out of the results.
term.optionalhas the same shape as.any/.only:OPTIONAL { }block.[hasCell, volume.optional]._get_tripleskeeps its signature. The per-destination triple patterns it now builds on are available from_get_triples_per_destination.query(..., python_values=True)Result cells are rdflib terms in
objectcolumns by default. Withpython_values=True:toPython()) and IRIs become strings.The default is unchanged, so atomRDF, which passes its arguments through, is not affected.
Also included
[[hasMaterial, hasAltName]], raisedIndexError(this also happens onmain). When the path was merged, the property's range class was appended as well, shifting later nodes into the wrong triple positions.examples/02_advanced_query_building.ipynb, with outputs; existing cells are unchanged.Verification
tests/test_features.py, and each fails without its change.prepareQuery(..., initNs={}).https://matkg.pyscal.org/sparqlcombining all three features returns the expected rows, with anint64column forhasNumberOfAtoms.