This PR provides a Rank data structure as part of a new osrank::collections module, which implements an Iterator to iterate over the labeled elements of a data structure. It allows things like these:
#[test]
fn test_rank_into_iter() {
let mtrx = arr2(&[[1], [9], [7]]);
let rows = vec!["foo", "bar", "baz"]
.into_iter()
.map(String::from)
.collect::<Vec<String>>();
let cols = vec!["quux", "lorem", "ipsum"]
.into_iter()
.map(String::from)
.collect::<Vec<String>>();
let labels = (rows.as_slice(), cols.as_slice());
let lbld = mtrx.labeled(labels);
let rank = Rank::from(lbld).unwrap_or_else(|e| panic!(e));
assert_eq!(
rank.into_iter()
.sorted_by(|(_, v1), (_, v2)| v2.cmp(v1))
.take(2)
.collect::<Vec<(&str, &i32)>>(),
vec![("bar", &9), ("baz", &7)]
);
}
Thanks to this I have managed to sort the page ranks and to display them labeled, but there is something fishy going on, as papito cannot possibly be the most influential project in the Rust ecosystem :
cc @MeBrei
This PR provides a
Rank
data structure as part of a newosrank::collections
module, which implements anIterator
to iterate over the labeled elements of a data structure. It allows things like these:Thanks to this I have managed to sort the page ranks and to display them labeled,
but there is something fishy going on, as:papito
cannot possibly be the most influential project in the Rust ecosystemLooks reasonable!