Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some deprecation warnings #83

Merged
merged 2 commits into from
Feb 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from tripper import EMMO, MAP, Triplestore

ts = Triplestore(backend="collection")
assert not list(ts.triples((None, None, None)))
assert not list(ts.triples())

STRUCTURE = ts.bind("structure", "http://onto-ns.com/meta/0.1/Structure#")
CIF = ts.bind("cif", "http://emmo.info/0.1/cif-ontology#")
Expand All @@ -16,15 +16,15 @@
]

ts.add_triples(triples)
assert set(ts.triples((None, None, None))) == set(triples)
assert set(ts.triples()) == set(triples)

ts.remove((None, None, EMMO.Mass))
assert set(ts.triples((None, None, None))) == set(triples[:-1])
ts.remove(object=EMMO.Mass)
assert set(ts.triples()) == set(triples[:-1])


# Test that we can initialise from an existing collection
coll = dlite.Collection()
for triple in triples:
coll.add_relation(*triple)
ts2 = Triplestore(backend="collection", collection=coll)
assert set(ts2.triples((None, None, None))) == set(triples)
assert set(ts2.triples()) == set(triples)
2 changes: 1 addition & 1 deletion tests/test_triplestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def test_backend_sparqlwrapper() -> None:
base_iri="http://vocabs.ardc.edu.au/repository/api/sparql/"
"csiro_international-chronostratigraphic-chart_geologic-time-scale-2020",
)
for s, p, o in store.triples((None, SKOS.notation, None)):
for s, p, o in store.triples(predicate=SKOS.notation):
assert s
assert p
assert o
Expand Down
3 changes: 2 additions & 1 deletion tripper/triplestore.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ def __init__(
self.closed = False
self.backend_name = backend
self.backend = cls(base_iri=base_iri, database=database, **kwargs)

# Keep functions in the triplestore for convienence even though
# they usually do not belong to the triplestore per se.
self.function_repo: "Dict[str, Union[float, Callable[[], float], None]]" = {}
Expand Down Expand Up @@ -459,7 +460,7 @@ def set(self, triple):
the given `triple`.
"""
s, p, _ = triple
self.remove((s, p, None))
self.remove(s, p)
self.add(triple)

def has(
Expand Down