Skip to content

Add Missing Tests for AICosineSimilarityDistanceTest#53

Merged
jordanmontt merged 2 commits intopharo-ai:masterfrom
pankaj-bind:AICosineSimilarityDistanceTest
May 12, 2025
Merged

Add Missing Tests for AICosineSimilarityDistanceTest#53
jordanmontt merged 2 commits intopharo-ai:masterfrom
pankaj-bind:AICosineSimilarityDistanceTest

Conversation

@pankaj-bind
Copy link
Contributor

Added test for

  • Checks that the Cosine Similarity between zero vectors returns 1.0 or is handled gracefully.
  • Checks that the Cosine Similarity between identical vectors is 1.0.
  • Checks that the Cosine Similarity between orthogonal vectors is 0.0.
  • Checks that an error is raised for collections of different lengths.
  • Checks that an error is raised for non-numeric inputs.

From AICosineSimilarityDistance.class.st I have removed previous method and added new.
Why?
The previous method lacks zero-vector handling (causing division-by-zero errors), uses non-standard array operations (*), and doesn’t validate inputs. The new method is more robust, portable, and includes input validation (length and numeric checks) and zero-vector handling, making it the better choice for reliable cosine similarity computation.

@pankaj-bind
Copy link
Contributor Author

Hey @jordanmontt, please review this PR

@jordanmontt jordanmontt merged commit 1779e63 into pharo-ai:master May 12, 2025
1 of 6 checks passed
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

Comments