1use seams::{ChillOptions, Error, NeighbourOptions, RingOptions, System};
9use std::env;
10
11const FIXTURE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/tests/data/ice1h.lammpstrj");
12
13#[cfg(test)]
15const CANON: &str = "pairs 512 rings 0 0 0 0 0 0 256 chill 0 128 0 0 0 0 0 0 0";
16
17fn joined(values: &[i32]) -> String {
18 values
19 .iter()
20 .map(|value| value.to_string())
21 .collect::<Vec<_>>()
22 .join(" ")
23}
24
25fn census(path: &str) -> Result<String, Error> {
26 let mut frame = System::new()?;
27 frame.read(path, 1, -1)?;
28 let pairs = frame.neighbours(&NeighbourOptions::default())?.nnz()?;
29 let rings = frame
30 .rings(&RingOptions {
31 max_size: 6,
32 ..RingOptions::default()
33 })?
34 .histogram(6)?;
35 let chill = frame.chill_plus(&ChillOptions::default())?;
36 Ok(format!(
37 "pairs {pairs} rings {} chill {}",
38 joined(&rings),
39 joined(&chill.counts)
40 ))
41}
42
43fn main() -> Result<(), Error> {
44 let path = env::args().nth(1).unwrap_or_else(|| FIXTURE.to_string());
45 println!("{}", census(&path)?);
46 Ok(())
47}
48
49#[test]
50fn matches_the_other_language_fronts() {
51 seams::set_num_threads(1).unwrap();
52 assert_eq!(census(FIXTURE).unwrap(), CANON);
53}