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

Add code for computing optional sequence diffs #2865

Merged
merged 3 commits into from
Jan 24, 2025
Merged

Add code for computing optional sequence diffs #2865

merged 3 commits into from
Jan 24, 2025

Conversation

t0yv0
Copy link
Member

@t0yv0 t0yv0 commented Jan 23, 2025

Originating from t0yv0/godifft - this may be useful for computing list diffs for display. Compared to the https://github.com/t0yv0/godifft version adds rapid tests and a function to apply the edit sequence.

Note that memory is still O(N^2) for large strings, and the naive matrix implementation may allocate a lot of memory. This is intended for comparing fairly short strings <1000 in length.

@t0yv0 t0yv0 requested a review from VenelinMartinov January 23, 2025 17:39
Copy link

codecov bot commented Jan 23, 2025

Codecov Report

Attention: Patch coverage is 76.36364% with 26 lines in your changes missing coverage. Please review.

Project coverage is 67.51%. Comparing base (deacda0) to head (718f2d7).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
unstable/difft/difft.go 74.25% 21 Missing and 5 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2865      +/-   ##
==========================================
+ Coverage   67.48%   67.51%   +0.02%     
==========================================
  Files         325      327       +2     
  Lines       41633    41743     +110     
==========================================
+ Hits        28097    28181      +84     
- Misses      11957    11978      +21     
- Partials     1579     1584       +5     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@VenelinMartinov VenelinMartinov left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks for adding the property based test

ys []T
}

func (d *differ[T]) difflen() *matrix {
Copy link
Contributor

Choose a reason for hiding this comment

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

What does difflen stand for? I assumed this was "diff length" at first look.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that's right. It may be better termed edit distance or cost matrix.

unstable/difft/difft_test.go Show resolved Hide resolved
@t0yv0 t0yv0 merged commit 140a0fb into master Jan 24, 2025
71 checks passed
@t0yv0 t0yv0 deleted the t0yv0/diff branch January 24, 2025 16:12
@pulumi-bot
Copy link
Contributor

This PR has been shipped in release v3.102.0.

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.

3 participants