Skip to content

Commit

Permalink
nits and typo
Browse files Browse the repository at this point in the history
  • Loading branch information
oflatt committed Oct 27, 2023
1 parent 53386e6 commit 2da79bf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/explain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ impl<L: Language + Display + FromOp> Explanation<L> {
let mut seen_adjacent = Default::default();
let mut sum: ProofCost = Saturating(0);
for e in self.explanation_trees.iter() {
sum = sum + self.tree_size(&mut seen, &mut seen_adjacent, e);
sum += self.tree_size(&mut seen, &mut seen_adjacent, e);
}
sum
}
Expand Down Expand Up @@ -273,7 +273,7 @@ impl<L: Language + Display + FromOp> Explanation<L> {

for child_proof in &current.child_proofs {
for child in child_proof {
my_size = self.tree_size(seen, seen_adjacent, child);
my_size += self.tree_size(seen, seen_adjacent, child);
}
}
my_size
Expand Down Expand Up @@ -1492,7 +1492,6 @@ impl<L: Language> Explain<L> {
) {
self.shortest_explanation_memo
.insert((right, right), (Saturating(0), right));
let mut last_cost = Saturating(0);
for connection in left_connections.iter().rev() {
let next = connection.next;
let current = connection.current;
Expand All @@ -1502,7 +1501,6 @@ impl<L: Language> Explain<L> {
.unwrap()
.0;
let dist = self.connection_distance(connection, distance_memo);
last_cost = dist + next_cost;
self.replace_distance(current, next, right, next_cost + dist);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ These are not considered part of the public api.

use std::{fmt::Display, fs::File, io::Write, path::PathBuf};

use saturating::Saturating;

use crate::*;

pub fn env_var<T>(s: &str) -> Option<T>
Expand Down Expand Up @@ -102,14 +104,14 @@ pub fn test_runner<L, A>(
let flattened = explained.make_flat_explanation().clone();
let vanilla_len = flattened.len();
explained.check_proof(rules);
assert!(explained.get_tree_size() > 0);
assert!(explained.get_tree_size() > Saturating(0));

runner = runner.with_explanation_length_optimization();
let mut explained_short = runner.explain_matches(&start, &goal.ast, &subst);
explained_short.get_string_with_let();
let short_len = explained_short.get_flat_strings().len();
assert!(short_len <= vanilla_len);
assert!(explained_short.get_tree_size() > 0);
assert!(explained_short.get_tree_size() > Saturating(0));
explained_short.check_proof(rules);
}
}
Expand Down

0 comments on commit 2da79bf

Please sign in to comment.