use crate::misc;
use std::fmt;
#[cfg(any(feature = "python", feature = "python-stubgen"))]
use pyo3::prelude::*;
#[cfg(feature = "python-stubgen")]
use pyo3_stub_gen_derive::gen_stub_pyclass;
#[cfg(test)]
mod test;
pub mod ffi;
#[cfg_attr(feature = "python-stubgen", gen_stub_pyclass)]
#[cfg_attr(
any(feature = "python", feature = "python-stubgen"),
pyclass(get_all, set_all, from_py_object)
)]
#[derive(Clone, Debug)]
pub struct Baseline {
pub ant1_index: usize,
pub ant2_index: usize,
}
impl Baseline {
pub(crate) fn populate_baselines(num_ants: usize) -> Vec<Self> {
let num_baselines = misc::get_baseline_count(num_ants);
let mut bls: Vec<Baseline> = vec![
Baseline {
ant1_index: 0,
ant2_index: 0
};
num_baselines
];
let mut bl_index = 0;
for a1 in 0..num_ants {
for a2 in a1..num_ants {
bls[bl_index].ant1_index = a1;
bls[bl_index].ant2_index = a2;
bl_index += 1;
}
}
bls
}
}
impl fmt::Display for Baseline {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{},{}", self.ant1_index, self.ant2_index,)
}
}