Skip to content

Commit

Permalink
Merge pull request #75 from BatsResearch/__str__4_templates
Browse files Browse the repository at this point in the history
Assigning __str__() for templates and voters
  • Loading branch information
dotpyu authored Jul 5, 2024
2 parents d8a935c + 9a4772b commit e67fc57
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions alfred/template/image_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,10 @@ def __call__(
:rtype: Query
"""
return self.apply(example, **kawrgs)

def __str__(self):
return (
f"ImageTemplate(id={self._id}, name={self._name}, reference={self._reference}, "
f"template={self._template}, metadata={self._metadata}, "
f"candidate_replacement={self._candidate_replacement})"
)
7 changes: 7 additions & 0 deletions alfred/template/string_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,10 @@ def __call__(
:rtype: Query
"""
return self.apply(example, **kawrgs)

def __str__(self):
return (
f"StringTemplate(id={self._id}, name={self._name}, reference={self._reference}, "
f"template={self._template}, metadata={self._metadata}, "
f"answer_choices={self._answer_choices})"
)
6 changes: 6 additions & 0 deletions alfred/voter/voter.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,3 +164,9 @@ def __call__(
Vote for the responses based on the matching function and the label maps
"""
return self.vote(responses, matching_function, label_map, **kwargs)

def __str__(self):
return (
f"Voter(label_map={self._label_map}, matching_fn={self._matching_fn}, "
f"calibration={self._calibration})"
)

0 comments on commit e67fc57

Please sign in to comment.