Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Truncate golden CosineScores to 6 decimals to reduce noisy diffs. #4718

Merged
merged 6 commits into from
Nov 7, 2024

Conversation

clincoln8
Copy link
Contributor

Reduces CosineScores to 6 decimals to reduce the diffs that are generated when updating the integration_test goldens.

This is to reduce noise in reviews and should not fundamentally affect the actual tests.

@clincoln8 clincoln8 requested a review from chejennifer November 6, 2024 22:21
Copy link
Contributor

@chejennifer chejennifer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for updating!

for i, score in enumerate(part.get('CosineScore', [])):
part['CosineScore'][i] = float("{:.6f}".format(score))
for i, score in enumerate(dbg['props_matching'].get('CosineScore', [])):
dbg['props_matching']['CosineScore'][i] = float("{:.6f}".format(score))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: instead of re-writing this formatting code, could we have a function to format_scores which takes a list of scores and returns a list of formatted scores, so that if we ever want to change how we format the scores, we do it in one place and won't run the risk of missing a spot?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed! I reformatted to use helper functions, is that better?

resp_var_to_score[sv] = float("{:.6f}".format(score))
truncated_score = _format_score(dbg['sv_matching']['CosineScore'][i])
resp_var_to_score[sv] = truncated_score
dbg['sv_matching']['CosineScore'][i] = truncated_score
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we can move this part outside of the for loop & just have dbg['sv_matching']['CosineScore'] = _format_scores(dbg['sv_matching'].get('CosineScore', [])

& that way we just need one of the two helper functions & can read score from this formatted list

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Contributor

@chejennifer chejennifer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for fixing this!

@clincoln8 clincoln8 merged commit 9d1d4e0 into datacommonsorg:master Nov 7, 2024
9 checks passed
@clincoln8 clincoln8 deleted the biomed branch November 7, 2024 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants