From 332ca5582b4315d508f73c5ab28d1f493635488e Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 11 Sep 2025 15:20:00 -0500 Subject: [PATCH 1/7] cargo format --- .../{floating_point.rs => floating-point.rs} | 31 ++++++++++++------ src/algorithms/lcs.rs | 4 ++- src/algorithms/mod.rs | 1 - src/algorithms/myers.rs | 25 +++++++++++---- src/algorithms/patience.rs | 4 ++- src/common.rs | 32 ++++++++++++------- 6 files changed, 67 insertions(+), 30 deletions(-) rename examples/{floating_point.rs => floating-point.rs} (80%) diff --git a/examples/floating_point.rs b/examples/floating-point.rs similarity index 80% rename from examples/floating_point.rs rename to examples/floating-point.rs index de71f7f..b6bfe6a 100644 --- a/examples/floating_point.rs +++ b/examples/floating-point.rs @@ -9,10 +9,10 @@ fn main() { // Strict comparison would show many differences due to measurement noise // FP comparison with 0.05 tolerance treats small variations as equal let ops = capture_diff_slices_fp( - Algorithm::Myers, - &baseline_readings, - ¤t_readings, - 0.05 + Algorithm::Myers, + &baseline_readings, + ¤t_readings, + 0.05, ); println!("Baseline: {:?}", baseline_readings); @@ -20,7 +20,9 @@ fn main() { println!("With epsilon=0.05: {} diff operations", ops.len()); for op in &ops { - let changes: Vec<_> = op.iter_changes(&baseline_readings, ¤t_readings).collect(); + let changes: Vec<_> = op + .iter_changes(&baseline_readings, ¤t_readings) + .collect(); for change in changes { match change.tag() { ChangeTag::Equal => println!(" ✓ Equal: {}", change.value()), @@ -41,8 +43,16 @@ fn main() { for &epsilon in &[0.0001, 0.001, 0.01] { let ops = capture_diff_slices_fp(Algorithm::Myers, &old, &new, epsilon); let all_equal = ops.len() == 1 && matches!(ops[0], likewise::DiffOp::Equal { len: 3, .. }); - println!(" epsilon={}: {} ({})", epsilon, ops.len(), - if all_equal { "all equal" } else { "differences found" }); + println!( + " epsilon={}: {} ({})", + epsilon, + ops.len(), + if all_equal { + "all equal" + } else { + "differences found" + } + ); } // Example 3: Edge cases with NaN and infinity @@ -61,5 +71,8 @@ fn main() { let new_f64 = vec![1.0000000000002, 2.0, 3.141592653589794]; let ops_f64 = capture_diff_slices_fp_f64(Algorithm::Myers, &old_f64, &new_f64, 1e-12); - println!("f64 comparison with epsilon=1e-12: {} operations", ops_f64.len()); -} \ No newline at end of file + println!( + "f64 comparison with epsilon=1e-12: {} operations", + ops_f64.len() + ); +} diff --git a/src/algorithms/lcs.rs b/src/algorithms/lcs.rs index b052bad..d70b2e3 100644 --- a/src/algorithms/lcs.rs +++ b/src/algorithms/lcs.rs @@ -320,5 +320,7 @@ pub fn diff_fp_f64_deadline( where D: DiffHook, { - crate::algorithms::myers::diff_fp_f64_deadline(d, old, old_range, new, new_range, epsilon, deadline) + crate::algorithms::myers::diff_fp_f64_deadline( + d, old, old_range, new, new_range, epsilon, deadline, + ) } diff --git a/src/algorithms/mod.rs b/src/algorithms/mod.rs index 0e252e1..0a43afc 100644 --- a/src/algorithms/mod.rs +++ b/src/algorithms/mod.rs @@ -132,4 +132,3 @@ where { diff_deadline(alg, d, old, 0..old.len(), new, 0..new.len(), deadline) } - diff --git a/src/algorithms/myers.rs b/src/algorithms/myers.rs index 2fda69f..e660319 100644 --- a/src/algorithms/myers.rs +++ b/src/algorithms/myers.rs @@ -21,7 +21,10 @@ use std::ops::{Index, IndexMut, Range}; -use crate::algorithms::utils::{common_prefix_len, common_suffix_len, common_prefix_len_fp, common_suffix_len_fp, common_prefix_len_fp_f64, common_suffix_len_fp_f64, is_empty_range}; +use crate::algorithms::utils::{ + common_prefix_len, common_prefix_len_fp, common_prefix_len_fp_f64, common_suffix_len, + common_suffix_len_fp, common_suffix_len_fp_f64, is_empty_range, +}; use crate::algorithms::DiffHook; use crate::deadline_support::{deadline_exceeded, Instant}; @@ -457,7 +460,9 @@ where let max_d = max_d(old_range.len(), new_range.len()); let mut vb = V::new(max_d); let mut vf = V::new(max_d); - conquer_fp(d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline)?; + conquer_fp( + d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline, + )?; d.finish() } @@ -477,7 +482,9 @@ where let max_d = max_d(old_range.len(), new_range.len()); let mut vb = V::new(max_d); let mut vf = V::new(max_d); - conquer_fp_f64(d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline)?; + conquer_fp_f64( + d, old, old_range, new, new_range, epsilon, &mut vf, &mut vb, deadline, + )?; d.finish() } @@ -681,7 +688,8 @@ where D: DiffHook, { // Check for common prefix - let common_prefix_len = common_prefix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon); + let common_prefix_len = + common_prefix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon); if common_prefix_len > 0 { d.equal(old_range.start, new_range.start, common_prefix_len)?; } @@ -689,7 +697,8 @@ where new_range.start += common_prefix_len; // Check for common suffix - let common_suffix_len = common_suffix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon); + let common_suffix_len = + common_suffix_len_fp(old, old_range.clone(), new, new_range.clone(), epsilon); let common_suffix = ( old_range.end - common_suffix_len, new_range.end - common_suffix_len, @@ -753,7 +762,8 @@ where D: DiffHook, { // Check for common prefix - let common_prefix_len = common_prefix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon); + let common_prefix_len = + common_prefix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon); if common_prefix_len > 0 { d.equal(old_range.start, new_range.start, common_prefix_len)?; } @@ -761,7 +771,8 @@ where new_range.start += common_prefix_len; // Check for common suffix - let common_suffix_len = common_suffix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon); + let common_suffix_len = + common_suffix_len_fp_f64(old, old_range.clone(), new, new_range.clone(), epsilon); let common_suffix = ( old_range.end - common_suffix_len, new_range.end - common_suffix_len, diff --git a/src/algorithms/patience.rs b/src/algorithms/patience.rs index c5d757e..b687376 100644 --- a/src/algorithms/patience.rs +++ b/src/algorithms/patience.rs @@ -224,5 +224,7 @@ pub fn diff_fp_f64_deadline( where D: DiffHook, { - crate::algorithms::myers::diff_fp_f64_deadline(d, old, old_range, new, new_range, epsilon, deadline) + crate::algorithms::myers::diff_fp_f64_deadline( + d, old, old_range, new, new_range, epsilon, deadline, + ) } diff --git a/src/common.rs b/src/common.rs index 51f76c0..3f7ff26 100644 --- a/src/common.rs +++ b/src/common.rs @@ -124,9 +124,15 @@ fn capture_diff_fp_deadline( ) -> Vec { let mut d = Compact::new(Replace::new(Capture::new()), old, new); let result = match alg { - Algorithm::Myers => crate::algorithms::myers::diff_fp_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline), - Algorithm::Patience => crate::algorithms::patience::diff_fp_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline), - Algorithm::Lcs => crate::algorithms::lcs::diff_fp_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline), + Algorithm::Myers => crate::algorithms::myers::diff_fp_deadline( + &mut d, old, old_range, new, new_range, epsilon, deadline, + ), + Algorithm::Patience => crate::algorithms::patience::diff_fp_deadline( + &mut d, old, old_range, new, new_range, epsilon, deadline, + ), + Algorithm::Lcs => crate::algorithms::lcs::diff_fp_deadline( + &mut d, old, old_range, new, new_range, epsilon, deadline, + ), }; result.unwrap(); d.into_inner().into_inner().into_ops() @@ -143,9 +149,15 @@ fn capture_diff_fp_f64_deadline( ) -> Vec { let mut d = Compact::new(Replace::new(Capture::new()), old, new); let result = match alg { - Algorithm::Myers => crate::algorithms::myers::diff_fp_f64_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline), - Algorithm::Patience => crate::algorithms::patience::diff_fp_f64_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline), - Algorithm::Lcs => crate::algorithms::lcs::diff_fp_f64_deadline(&mut d, old, old_range, new, new_range, epsilon, deadline), + Algorithm::Myers => crate::algorithms::myers::diff_fp_f64_deadline( + &mut d, old, old_range, new, new_range, epsilon, deadline, + ), + Algorithm::Patience => crate::algorithms::patience::diff_fp_f64_deadline( + &mut d, old, old_range, new, new_range, epsilon, deadline, + ), + Algorithm::Lcs => crate::algorithms::lcs::diff_fp_f64_deadline( + &mut d, old, old_range, new, new_range, epsilon, deadline, + ), }; result.unwrap(); d.into_inner().into_inner().into_ops() @@ -268,10 +280,10 @@ fn test_non_string_iter_change() { fn test_fp_epsilon() { let old = vec![1.0, 2.0, 3.0]; let new = vec![1.001, 2.0, 2.999]; - + let ops_tight = capture_diff_slices_fp(Algorithm::Myers, &old, &new, 0.0001); assert!(ops_tight.len() > 1); - + let ops_loose = capture_diff_slices_fp(Algorithm::Myers, &old, &new, 0.01); assert_eq!(ops_loose.len(), 1); } @@ -280,9 +292,7 @@ fn test_fp_epsilon() { fn test_fp_nan() { let old = vec![f32::NAN]; let new = vec![f32::NAN]; - + let ops = capture_diff_slices_fp(Algorithm::Myers, &old, &new, 0.001); assert_eq!(ops.len(), 1); } - - From 773ccde3619c6950efba50e385bc3d5127b3fc6d Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 11 Sep 2025 15:24:09 -0500 Subject: [PATCH 2/7] update --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index df09b35..37c7461 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,14 @@ fn main() { * Patience diff * Hunt–McIlroy / Hunt–Szymanski LCS diff * Diffing on arbitrary comparable sequences +* **Floating point comparison with epsilon tolerance** * Line, word, character and grapheme level diffing * Text and Byte diffing * Unified diff generation ## Related Projects -* [similar](https://github.com/mitsuhiko/similar) +* [similar](https://github.com/mitsuhiko/similar) the original library * [insta](https://insta.rs) snapshot testing library * [similar-asserts](https://github.com/mitsuhiko/similar-asserts) assertion library From e78319df2b3e86cc15960255208f5d275e20f5d2 Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 11 Sep 2025 15:28:48 -0500 Subject: [PATCH 3/7] updates --- Cargo.toml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index b4b9238..04a2e24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "likewise" -version = "3.0.0" +version = "3.1.0" authors = [ "Barrett Ruth ", "Armin Ronacher ", diff --git a/README.md b/README.md index 37c7461..1e3576a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ > This crate is a fork of [similar](https://github.com/mitsuhiko/similar) library, which, as of 11/9/25, is rather inactive. [![Crates.io](https://img.shields.io/crates/d/likewise.svg)](https://crates.io/crates/likewise) -[![License](https://img.shields.io/github/license/frozen/likewise)](https://github.com/frozen/likewise/blob/main/LICENSE) +[![License](https://img.shields.io/github/license/barrett-ruth/likewise)](https://github.com/barrett-ruth/likewise/blob/main/LICENSE) [![rustc 1.66.0](https://img.shields.io/badge/rust-1.66%2B-orange.svg)](https://img.shields.io/badge/rust-1.65%2B-orange.svg) [![Documentation](https://docs.rs/likewise/badge.svg)](https://docs.rs/likewise) From 66a392e610a35f6b72bc52c139c9abe32a274baf Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Thu, 11 Sep 2025 15:31:36 -0500 Subject: [PATCH 4/7] update docstrings --- src/algorithms/lcs.rs | 8 ++++++++ src/algorithms/myers.rs | 6 ++++++ src/algorithms/patience.rs | 8 ++++++++ 3 files changed, 22 insertions(+) diff --git a/src/algorithms/lcs.rs b/src/algorithms/lcs.rs index d70b2e3..bbcf112 100644 --- a/src/algorithms/lcs.rs +++ b/src/algorithms/lcs.rs @@ -293,6 +293,10 @@ fn test_bad_range_regression() { ); } +/// LCS diff algorithm with f32 epsilon comparison. +/// +/// Diff `old`, between indices `old_range` and `new` between indices `new_range`. +/// Values are considered equal if their absolute difference is within `epsilon`. pub fn diff_fp_deadline( d: &mut D, old: &[f32], @@ -308,6 +312,10 @@ where crate::algorithms::myers::diff_fp_deadline(d, old, old_range, new, new_range, epsilon, deadline) } +/// LCS diff algorithm with f64 epsilon comparison. +/// +/// Diff `old`, between indices `old_range` and `new` between indices `new_range`. +/// Values are considered equal if their absolute difference is within `epsilon`. pub fn diff_fp_f64_deadline( d: &mut D, old: &[f64], diff --git a/src/algorithms/myers.rs b/src/algorithms/myers.rs index e660319..72405e4 100644 --- a/src/algorithms/myers.rs +++ b/src/algorithms/myers.rs @@ -445,6 +445,9 @@ fn test_finish_called() { } /// Myers' diff algorithm with f32 epsilon comparison. +/// +/// Diff `old`, between indices `old_range` and `new` between indices `new_range`. +/// Values are considered equal if their absolute difference is within `epsilon`. pub fn diff_fp_deadline( d: &mut D, old: &[f32], @@ -467,6 +470,9 @@ where } /// Myers' diff algorithm with f64 epsilon comparison. +/// +/// Diff `old`, between indices `old_range` and `new` between indices `new_range`. +/// Values are considered equal if their absolute difference is within `epsilon`. pub fn diff_fp_f64_deadline( d: &mut D, old: &[f64], diff --git a/src/algorithms/patience.rs b/src/algorithms/patience.rs index b687376..ec5f1bb 100644 --- a/src/algorithms/patience.rs +++ b/src/algorithms/patience.rs @@ -197,6 +197,10 @@ fn test_finish_called() { assert!(d.0); } +/// Patience diff algorithm with f32 epsilon comparison. +/// +/// Diff `old`, between indices `old_range` and `new` between indices `new_range`. +/// Values are considered equal if their absolute difference is within `epsilon`. pub fn diff_fp_deadline( d: &mut D, old: &[f32], @@ -212,6 +216,10 @@ where crate::algorithms::myers::diff_fp_deadline(d, old, old_range, new, new_range, epsilon, deadline) } +/// Patience diff algorithm with f64 epsilon comparison. +/// +/// Diff `old`, between indices `old_range` and `new` between indices `new_range`. +/// Values are considered equal if their absolute difference is within `epsilon`. pub fn diff_fp_f64_deadline( d: &mut D, old: &[f64], From 5c3280edfd9320123487ee90b43de7ed04afec6a Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 10 Jan 2026 12:16:04 -0500 Subject: [PATCH 5/7] feat: github name rename --- CLAUDE.md | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 2 +- README.md | 8 ++--- 3 files changed, 104 insertions(+), 5 deletions(-) create mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..20e8d51 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,99 @@ +# Likewise - Floating Point Diff Implementation + +## Codebase Structure + +``` +src/ +├── lib.rs # Main entry, re-exports +├── types.rs # DiffOp, Change, ChangeTag, Algorithm enums +├── common.rs # capture_diff_slices(), get_diff_ratio() +├── algorithms/ # myers.rs, patience.rs, lcs.rs, hook.rs, utils.rs +├── text/ # TextDiff, DiffableStr trait +├── udiff.rs # Unified diff output +└── utils.rs # Text utilities +``` + +## Current Diff Flow + +1. `capture_diff_slices(alg, &old, &new)` → `Vec` +2. `DiffOp::iter_changes(&old, &new)` → `Iterator>` +3. Requires `T: Hash + Eq + Ord` + +## Key Types + +```rust +pub enum DiffOp { + Equal { old_index: usize, new_index: usize, len: usize }, + Delete { old_index: usize, old_len: usize, new_index: usize }, + Insert { old_index: usize, new_index: usize, new_len: usize }, + Replace { old_index: usize, old_len: usize, new_index: usize, new_len: usize }, +} + +pub struct Change { + pub(crate) tag: ChangeTag, + pub(crate) old_index: Option, + pub(crate) new_index: Option, + pub(crate) value: T, +} +``` + +## Algorithm Trait + +```rust +pub trait DiffHook { + type Error; + fn equal(&mut self, old: usize, new: usize, len: usize) -> Result<(), Self::Error>; + fn delete(&mut self, old: usize, old_len: usize, new: usize) -> Result<(), Self::Error>; + fn insert(&mut self, old: usize, new: usize, new_len: usize) -> Result<(), Self::Error>; + fn replace(&mut self, old: usize, old_len: usize, new: usize, new_len: usize) -> Result<(), Self::Error>; +} +``` + +## Task: FP Comparison + +Add eps/ulps floating point comparison for f32/f64 slices. + +### Implementation Points + +1. **New comparison trait** alongside existing `PartialEq` requirement +2. **Algorithm modification** to use FP-aware comparison in core loops +3. **API surface** for specifying epsilon/ulps parameters +4. **Testing** edge cases: NaN, infinity, subnormals, precision boundaries + +### Files to Modify + +- `src/algorithms/myers.rs` - Core comparison logic +- `src/algorithms/patience.rs` - Core comparison logic +- `src/algorithms/lcs.rs` - Core comparison logic +- `src/common.rs` - Add FP-aware `capture_diff_slices_fp()` +- `examples/floating_point.rs` - Usage demonstration + +### Example Usage Goal + +```rust +let old = vec![1.0, 2.0, 3.0]; +let new = vec![1.000001, 2.0, 3.1]; + +// Absolute epsilon +let ops = capture_diff_slices_fp_eps(Algorithm::Myers, &old, &new, 0.0001); + +// Relative ulps +let ops = capture_diff_slices_fp_ulps(Algorithm::Myers, &old, &new, 4); +``` + +### Testing Strategy + +Use existing `insta` snapshot testing framework. Test matrices: +- Normal values with various epsilon/ulps settings +- Edge cases: ±0.0, NaN, ±infinity +- Precision boundaries and subnormal values +- Mixed normal/edge case arrays + +### Status + +- [x] CI fixed (Rust 1.66 MSRV) +- [x] Codebase analysis complete +- [ ] Design FP comparison API +- [ ] Implement core FP comparison logic +- [ ] Add comprehensive tests +- [ ] Create usage examples \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index 04a2e24..6f514c5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ edition = "2018" rust-version = "1.66" license = "Apache-2.0" description = "A diff library for Rust (fork of similar)" -repository = "https://github.com/barrett-ruth/likewise" +repository = "https://github.com/barrettruth/likewise" keywords = ["diff", "difference", "patience", "compare", "changes"] readme = "README.md" exclude = ["assets/*"] diff --git a/README.md b/README.md index 1e3576a..b2e6f5f 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ > This crate is a fork of [similar](https://github.com/mitsuhiko/similar) library, which, as of 11/9/25, is rather inactive. [![Crates.io](https://img.shields.io/crates/d/likewise.svg)](https://crates.io/crates/likewise) -[![License](https://img.shields.io/github/license/barrett-ruth/likewise)](https://github.com/barrett-ruth/likewise/blob/main/LICENSE) +[![License](https://img.shields.io/github/license/barrettruth/likewise)](https://github.com/barrett-ruth/likewise/blob/main/LICENSE) [![rustc 1.66.0](https://img.shields.io/badge/rust-1.66%2B-orange.svg)](https://img.shields.io/badge/rust-1.65%2B-orange.svg) [![Documentation](https://docs.rs/likewise/badge.svg)](https://docs.rs/likewise) @@ -58,6 +58,6 @@ fn main() { ## License and Links * [Documentation](https://docs.rs/likewise/) -* [Issue Tracker](https://github.com/barrett-ruth/likewise/issues) -* [Examples](https://github.com/barrett-ruth/likewise/tree/main/examples) -* License: [Apache-2.0](https://github.com/barrett-ruth/likewise/blob/main/LICENSE) +* [Issue Tracker](https://github.com/barrettruth/likewise/issues) +* [Examples](https://github.com/barrettruth/likewise/tree/main/examples) +* License: [Apache-2.0](https://github.com/barrettruth/likewise/blob/main/LICENSE) From 10951a01a1263da79a025c53bb2a3ff627b6426d Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 10 Jan 2026 12:17:45 -0500 Subject: [PATCH 6/7] remove claude --- CLAUDE.md | 99 ------------------------------------------------------- 1 file changed, 99 deletions(-) delete mode 100644 CLAUDE.md diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index 20e8d51..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,99 +0,0 @@ -# Likewise - Floating Point Diff Implementation - -## Codebase Structure - -``` -src/ -├── lib.rs # Main entry, re-exports -├── types.rs # DiffOp, Change, ChangeTag, Algorithm enums -├── common.rs # capture_diff_slices(), get_diff_ratio() -├── algorithms/ # myers.rs, patience.rs, lcs.rs, hook.rs, utils.rs -├── text/ # TextDiff, DiffableStr trait -├── udiff.rs # Unified diff output -└── utils.rs # Text utilities -``` - -## Current Diff Flow - -1. `capture_diff_slices(alg, &old, &new)` → `Vec` -2. `DiffOp::iter_changes(&old, &new)` → `Iterator>` -3. Requires `T: Hash + Eq + Ord` - -## Key Types - -```rust -pub enum DiffOp { - Equal { old_index: usize, new_index: usize, len: usize }, - Delete { old_index: usize, old_len: usize, new_index: usize }, - Insert { old_index: usize, new_index: usize, new_len: usize }, - Replace { old_index: usize, old_len: usize, new_index: usize, new_len: usize }, -} - -pub struct Change { - pub(crate) tag: ChangeTag, - pub(crate) old_index: Option, - pub(crate) new_index: Option, - pub(crate) value: T, -} -``` - -## Algorithm Trait - -```rust -pub trait DiffHook { - type Error; - fn equal(&mut self, old: usize, new: usize, len: usize) -> Result<(), Self::Error>; - fn delete(&mut self, old: usize, old_len: usize, new: usize) -> Result<(), Self::Error>; - fn insert(&mut self, old: usize, new: usize, new_len: usize) -> Result<(), Self::Error>; - fn replace(&mut self, old: usize, old_len: usize, new: usize, new_len: usize) -> Result<(), Self::Error>; -} -``` - -## Task: FP Comparison - -Add eps/ulps floating point comparison for f32/f64 slices. - -### Implementation Points - -1. **New comparison trait** alongside existing `PartialEq` requirement -2. **Algorithm modification** to use FP-aware comparison in core loops -3. **API surface** for specifying epsilon/ulps parameters -4. **Testing** edge cases: NaN, infinity, subnormals, precision boundaries - -### Files to Modify - -- `src/algorithms/myers.rs` - Core comparison logic -- `src/algorithms/patience.rs` - Core comparison logic -- `src/algorithms/lcs.rs` - Core comparison logic -- `src/common.rs` - Add FP-aware `capture_diff_slices_fp()` -- `examples/floating_point.rs` - Usage demonstration - -### Example Usage Goal - -```rust -let old = vec![1.0, 2.0, 3.0]; -let new = vec![1.000001, 2.0, 3.1]; - -// Absolute epsilon -let ops = capture_diff_slices_fp_eps(Algorithm::Myers, &old, &new, 0.0001); - -// Relative ulps -let ops = capture_diff_slices_fp_ulps(Algorithm::Myers, &old, &new, 4); -``` - -### Testing Strategy - -Use existing `insta` snapshot testing framework. Test matrices: -- Normal values with various epsilon/ulps settings -- Edge cases: ±0.0, NaN, ±infinity -- Precision boundaries and subnormal values -- Mixed normal/edge case arrays - -### Status - -- [x] CI fixed (Rust 1.66 MSRV) -- [x] Codebase analysis complete -- [ ] Design FP comparison API -- [ ] Implement core FP comparison logic -- [ ] Add comprehensive tests -- [ ] Create usage examples \ No newline at end of file From 59aa9796560a14e8efc161771ff3be39b3ae233e Mon Sep 17 00:00:00 2001 From: Barrett Ruth Date: Sat, 10 Jan 2026 12:25:31 -0500 Subject: [PATCH 7/7] one more fix --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b2e6f5f..574aac6 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ > This crate is a fork of [similar](https://github.com/mitsuhiko/similar) library, which, as of 11/9/25, is rather inactive. [![Crates.io](https://img.shields.io/crates/d/likewise.svg)](https://crates.io/crates/likewise) -[![License](https://img.shields.io/github/license/barrettruth/likewise)](https://github.com/barrett-ruth/likewise/blob/main/LICENSE) +[![License](https://img.shields.io/github/license/barrettruth/likewise)](https://github.com/barrettruth/likewise/blob/main/LICENSE) [![rustc 1.66.0](https://img.shields.io/badge/rust-1.66%2B-orange.svg)](https://img.shields.io/badge/rust-1.65%2B-orange.svg) [![Documentation](https://docs.rs/likewise/badge.svg)](https://docs.rs/likewise)