Skip to content

Commit

Permalink
Merge pull request #83 from EMMC-ASBL/fix-deprecation-warnings
Browse files Browse the repository at this point in the history
Remove some deprecation warnings
  • Loading branch information
jesper-friis authored Feb 5, 2023
2 parents 4ddc21d + 4679fec commit a6eb19d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
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

0 comments on commit a6eb19d

Please # to comment.