Skip to content

Commit

Permalink
remove AuthorWrapper class
Browse files Browse the repository at this point in the history
  • Loading branch information
nanglo123 committed Jun 13, 2024
1 parent 1413468 commit 26a789d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
27 changes: 2 additions & 25 deletions mira/metamodel/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,9 @@
import sympy

from .comparison import TemplateModelComparison, get_dkg_refinement_closure
from .template_model import Author, Annotations, TemplateModel
from .template_model import Annotations, TemplateModel


class AuthorWrapper:
"""Wrapper around the Author class.
This wrapper class allows for Author object comparison based on the
"name" attribute of the Author object such that when
annotations are merged between two template models, Author names won't
be duplicated if the two template models being composed share an author.
"""

def __init__(self, author: Author):
self.author = author

def __hash__(self):
return hash(self.author.name)

def __eq__(self, other):
if isinstance(other, AuthorWrapper):
return self.author.name == other.author.name
return False


def compose(tm_list):
"""Compose a list of template models into a single template model
Expand Down Expand Up @@ -375,11 +355,8 @@ def annotation_composition(tm0_annot, tm1_annot):
new_license = (f"First Template Model License: {tm0_annot.license}"
f"\nSecond Template Model License: {tm1_annot.license}")

# Use the AuthorWrapper class here to create a list of Author
# objects with unique name attributes
new_authors = tm0_annot.authors + tm1_annot.authors
new_authors = set(AuthorWrapper(author) for author in new_authors)
new_authors = [wrapper.author for wrapper in new_authors]
new_authors = list({author.name: author for author in new_authors}.values())

new_references = list(
set(tm0_annot.references) | set(tm1_annot.references))
Expand Down
1 change: 0 additions & 1 deletion mira/metamodel/template_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"Time",
"model_has_grounding",
"Concept",
"Author"
]

import datetime
Expand Down

0 comments on commit 26a789d

Please sign in to comment.