Skip to content

Commit

Permalink
Fix cases where empty list was assumed instead of None
Browse files Browse the repository at this point in the history
  • Loading branch information
pkalita-lbl committed Oct 31, 2024
1 parent d4a9a24 commit de75da2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/gocam/translation/cx2/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ def _add_input_output_nodes(

# Add edges for causal associations between activity nodes
for activity in gocam.activities:
if activity.causal_associations is None:
continue

for association in activity.causal_associations:
if association.downstream_activity in activity_nodes_by_activity_id:
relation_style = RELATIONS.get(association.predicate, None)
Expand Down
6 changes: 6 additions & 0 deletions src/gocam/translation/minerva_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,8 @@ def _iter_activities_by_fact_subject(
for activity, term, evs in _iter_activities_by_fact_subject(
fact_property=HAS_INPUT
):
if activity.has_input is None:
activity.has_input = []
activity.has_input.append(MoleculeAssociation(term=term, evidence=evs))

for activity, term, evs in _iter_activities_by_fact_subject(
Expand All @@ -333,6 +335,8 @@ def _iter_activities_by_fact_subject(
for activity, term, evs in _iter_activities_by_fact_subject(
fact_property=HAS_OUTPUT
):
if activity.has_output is None:
activity.has_output = []
activity.has_output.append(MoleculeAssociation(term=term, evidence=evs))

for activity, term, evs in _iter_activities_by_fact_subject(
Expand Down Expand Up @@ -366,6 +370,8 @@ def _iter_activities_by_fact_subject(
downstream_activity=object_activity.id,
evidence=evs,
)
if subject_activity.causal_associations is None:
subject_activity.causal_associations = []
subject_activity.causal_associations.append(rel)

annotations = _annotations(obj)
Expand Down

0 comments on commit de75da2

Please sign in to comment.