boreholeio 0.1.0

A library for interacting with borehole.io, a subsurface data management, delivery and visualisation platform
Documentation
use boreholeio::strided_array_file::ArrayProxy;
use fake::Fake;
use rand::SeedableRng;

pub(crate) fn generate_array<T: Clone + fake::Dummy<fake::Faker>>(
    shape: &Vec<usize>,
) -> ndarray::Array<T, ndarray::IxDyn> {
    let ref mut rng = rand::rngs::StdRng::seed_from_u64(3452134u64);
    ndarray::ArrayD::from_shape_fn(ndarray::IxDyn(&shape[..]), |_| {
        fake::Faker.fake_with_rng::<T, rand::rngs::StdRng>(rng)
    })
}

pub(crate) fn assert_eq_views<'a, T>(lhs: &ArrayProxy<'a>, rhs: &ArrayProxy<'a>) -> usize
where
    T: 'static + std::cmp::PartialEq + std::fmt::Debug,
{
    assert_eq!(lhs.shape(), rhs.shape());
    assert_eq!(lhs.element_type(), rhs.element_type());
    let lhs = lhs.try_as::<T>();
    let rhs = rhs.try_as::<T>();
    assert!(lhs.is_ok() && rhs.is_ok());
    for (a, b) in std::iter::zip(lhs.unwrap(), rhs.unwrap()) {
        assert_eq!(a, b);
    }
    1
}