Skip to content

Commit

Permalink
Merge pull request #9 from AdeelH/repr-simplify
Browse files Browse the repository at this point in the history
Simpler implementation of #8
  • Loading branch information
AdeelH authored Oct 14, 2022
2 parents 96bb124 + e1dd0e8 commit 2477bf6
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions focal_loss.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ def __init__(self,
def __repr__(self):
arg_keys = ['alpha', 'gamma', 'ignore_index', 'reduction']
arg_vals = [self.__dict__[k] for k in arg_keys]
arg_vals = [f'\'{v}\'' if isinstance(v, str) else v for v in arg_vals]
arg_strs = [f'{k}={v}' for k, v in zip(arg_keys, arg_vals)]
arg_strs = [f'{k}={v!r}' for k, v in zip(arg_keys, arg_vals)]
arg_str = ', '.join(arg_strs)
return f'{type(self).__name__}({arg_str})'

Expand Down

0 comments on commit 2477bf6

Please sign in to comment.