Skip to content

Scores with value 0.0 are not presented in the string representation #564

@guenthermi

Description

@guenthermi

If a named score is created with a score (distance) of 0.0, the score will not be present in the string representation:
print(NamedScore(value=0.0)) shows {}
However, the score is still there:
print(NamedScore(value=0.0)._data) shows NamedScoreData(_reference_ns={}, value=0.0, op_name=None, description=None, ref_id=None)
which is different if it is not set:
print(NamedScore()._data) shows NamedScoreData(_reference_ns={}, value=None, op_name=None, description=None, ref_id=None)

Some users found this behavior confusing since the 0.0 scores are not shown in the summary of documents after executing the match function.
This behavior is caused by the _non_empty_fields function in the NamedScoreDataClasss which is called to filter out empty values in the string representation:
https://github.com/jina-ai/docarray/blob/d9af0c235af28bc5724b2e53cbd9801272781fd4/docarray/score/data.py#L30-L31

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions