Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: simphony/simphony-osp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 9eea4b225aac9120a5946fb5b2086b9711df0337
Choose a base ref
..
head repository: simphony/simphony-osp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 7c0edf2a69ecd19784f6b7f8b96b06d0105c54e3
Choose a head ref
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -17,7 +17,7 @@ repos:
args: [--profile, black, --filter-files, --line-length, "79"]

- repo: https://github.com/psf/black
rev: 23.10.0
rev: 23.10.1
hooks:
- id: black
args: [--line-length, "79"]
2 changes: 1 addition & 1 deletion examples/sessions.py
Original file line number Diff line number Diff line change
@@ -132,7 +132,7 @@
}}
"""
)(citizen=OntologyIndividual, age=int)
for citizen, age in result:
for (citizen, age) in result:
print(citizen.name, age)

# Session contents can be exported to RDF,
1 change: 1 addition & 0 deletions simphony_osp/interfaces/interface.py
Original file line number Diff line number Diff line change
@@ -913,6 +913,7 @@ def cache_clear(self):
def _compute_entity_modifications(
self,
) -> Tuple[Set[OntologyEntity], Set[OntologyEntity], Set[OntologyEntity]]:

# Find out from the triples which entities were added, updated and
# deleted.
class Tracker:
16 changes: 8 additions & 8 deletions simphony_osp/ontology/individual.py
Original file line number Diff line number Diff line change
@@ -1518,7 +1518,7 @@ def get(
)
else:
result = []
for i, r, t in relationship_set.iter_low_level():
for (i, r, t) in relationship_set.iter_low_level():
if not t:
continue
session = self.session
@@ -1650,16 +1650,16 @@ def iter(
iterator = iter(relationship_set)
else:

def iterator() -> (
Iterator[Tuple[OntologyIndividual, OntologyRelationship]]
):
def iterator() -> Iterator[
Tuple[OntologyIndividual, OntologyRelationship]
]:
"""Helper iterator.
The purpose of defining this iterator is to be able to
return it, instead of using the `yield` keyword on the main
function, as described on the comment above.
"""
for i, r, t in relationship_set.iter_low_level():
for (i, r, t) in relationship_set.iter_low_level():
if not t:
continue
session = self.session
@@ -2242,9 +2242,9 @@ def relationships_iter(
Iterator with the queried ontology individuals.
"""

def individuals_and_relationships() -> (
Iterator[OntologyIndividual, OntologyEntity]
):
def individuals_and_relationships() -> Iterator[
OntologyIndividual, OntologyEntity
]:
for s, p, o in self.session.graph.triples(
(
self.identifier,
1 change: 1 addition & 0 deletions simphony_osp/session/session.py
Original file line number Diff line number Diff line change
@@ -1051,6 +1051,7 @@ def iter(
)

if identifiers:

# The yield statement is encapsulated inside a function so that the
# main function uses the return statement instead of yield. In this
# way, exceptions are checked when the `iter` method is called
1 change: 1 addition & 0 deletions simphony_osp/tools/semantic2dot.py
Original file line number Diff line number Diff line change
@@ -498,6 +498,7 @@ def terminal():

namespaces = set()
for x in args.plot:

try:
namespaces.add(Session.default_ontology.get_namespace(x))
logger.warning("Using installed version of namespace %s" % x)
2 changes: 2 additions & 0 deletions simphony_osp/utils/cache.py
Original file line number Diff line number Diff line change
@@ -84,11 +84,13 @@ def lru_cache_timestamp(
"""

def decorator(func: Callable):

holder: Dict[Any, Tuple[datetime, Callable]] = dict()
"""For each instance, holds its timestamp and the cached function."""

@wraps(func)
def wrapper(self, *args, **kwargs):

internal_timestamp, cached_function = holder.get(
self, (None, None)
)