1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//! Temporal sampling metadata (series length / regularity).
//!
//! Node keys and dense unfolding indexes live in `antecedent-core`.
//!
//! SPDX-License-Identifier: MIT OR Apache-2.0
pub use antecedent_core::{TemporalIndexError, TemporalIndexer, TemporalNodeKey};
/// Sampling regularity metadata (not used as lag duration for irregular data).
#[derive(Clone, Debug, Eq, PartialEq)]
pub enum SamplingRegularity {
/// Regular sampling with interval nanoseconds.
Regular {
/// Interval between samples in nanoseconds.
interval_ns: u64,
},
/// Irregular sampling.
Irregular,
}
/// Time index metadata for series data.
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct TimeIndex {
/// Regularity.
pub regularity: SamplingRegularity,
/// Number of time points.
pub length: usize,
}
#[cfg(test)]
mod tests {
use antecedent_core::VariableId;
use super::*;
#[test]
fn reexport_indexer_round_trip() {
let idx = TemporalIndexer::new(3, 2, 4).unwrap();
let key = TemporalNodeKey { variable: VariableId::from_raw(1), offset: -1 };
let dense = idx.dense_id(key).unwrap();
assert_eq!(idx.key_of(dense).unwrap(), key);
}
}