Skip to content

Commit

Permalink
fix: remove check of default value in _non_empty_fields (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
guenthermi authored Sep 27, 2022
1 parent d9af0c2 commit 2fceb67
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 1 addition & 6 deletions docarray/score/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,7 @@ def _non_empty_fields(self) -> Tuple[str]:
if not f_name.startswith('_'):
v = getattr(self, f_name)
if v is not None:
if f_name not in default_values:
r.append(f_name)
else:
dv = default_values[f_name]
if v != dv:
r.append(f_name)
r.append(f_name)

return tuple(r)

Expand Down
7 changes: 7 additions & 0 deletions tests/unit/test_named_score.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from docarray.score import NamedScore


def test_str_representation():
assert str(NamedScore(value=0.0)) == str({'value': 0.0})
assert str(NamedScore(value=None)) == str(dict())
assert str(NamedScore(value=0.3)) == str({'value': 0.3})

0 comments on commit 2fceb67

Please sign in to comment.