Skip to content

Commit

Permalink
Fix sorting in ISA scoring (#245)
Browse files Browse the repository at this point in the history
  • Loading branch information
Theodus authored Nov 10, 2022
1 parent 4ffbb06 commit 482671a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions indexer-selection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ itertools = "0.10"
lazy_static = "1.4"
num-traits = "0.2"
ordered-float = "3.0"
permutation = "0.4"
prelude = { path = "../prelude" }
prometheus = { version = "0.13", default-features = false }
rand_distr = "0.4"
Expand Down
17 changes: 5 additions & 12 deletions indexer-selection/src/score.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,18 +138,11 @@ impl MetaIndexer<'_> {
let mut perf_success: V<f64> = self.0.iter().map(|f| f.perf_success).collect();
let mut slashable_usd: V<f64> = self.0.iter().map(|f| f.slashable_usd).collect();

let mut order = (0..perf_success.len()).collect::<V<usize>>();
order.sort_unstable_by_key(|i| NotNan::try_from(perf_success[*i]).unwrap());
macro_rules! sort_by_perf_success {
($v:ident) => {
for i in 0..$v.len() {
$v.swap(i, order[i]);
}
};
}
sort_by_perf_success!(reliability);
sort_by_perf_success!(perf_success);
sort_by_perf_success!(slashable_usd);
let mut permutation =
permutation::sort_unstable_by_key(&perf_success, |n| NotNan::try_from(*n).unwrap());
permutation.apply_slice_in_place(&mut reliability);
permutation.apply_slice_in_place(&mut perf_success);
permutation.apply_slice_in_place(&mut slashable_usd);

// BQN: pf ← ×`1-r
let pf = reliability
Expand Down

0 comments on commit 482671a

Please sign in to comment.