Skip to content

Commit 6ca4577

Browse files
committed
Use i64 instead of u64 to represent timestamps
1 parent 93a11dd commit 6ca4577

File tree

5 files changed

+10
-7
lines changed

5 files changed

+10
-7
lines changed

crates/augurs-prophet/src/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,5 @@ pub enum Error {
6969
/// This can happen if the dates are not evenly spaced, and
7070
/// there is no frequency that appears more often than others.
7171
#[error("Unable to infer frequency from dates: {0:?}")]
72-
UnableToInferFrequency(Vec<u64>),
72+
UnableToInferFrequency(Vec<TimestampSeconds>),
7373
}

crates/augurs-prophet/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ mod testdata;
1919
mod util;
2020

2121
/// A timestamp represented as seconds since the epoch.
22-
pub type TimestampSeconds = u64;
22+
pub type TimestampSeconds = i64;
2323

2424
// Re-export everything at the root so that users don't have to
2525
// navigate the module hierarchy.

crates/augurs-prophet/src/prophet.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ impl Prophet {
226226
};
227227
let freq = Self::infer_freq(history_dates)?;
228228
let last_date = *history_dates.last().ok_or(Error::NotEnoughData)?;
229-
let n = horizon.get() as u64 + 1;
229+
let n = (horizon.get() as u64 + 1) as TimestampSeconds;
230230
let dates = (last_date..last_date + n * freq)
231231
.step_by(freq as usize)
232232
.filter(|ds| *ds > last_date)

crates/augurs-prophet/src/prophet/options.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
use std::{collections::HashMap, num::NonZeroU32};
88

9-
use crate::{FeatureMode, Holiday, PositiveFloat, TrendIndicator};
9+
use crate::{FeatureMode, Holiday, PositiveFloat, TimestampSeconds, TrendIndicator};
1010

1111
/// The type of growth to use.
1212
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
@@ -83,7 +83,7 @@ pub struct OptProphetOptions {
8383
/// An optional list of changepoints.
8484
///
8585
/// If not provided, changepoints will be automatically selected.
86-
pub changepoints: Option<Vec<u64>>,
86+
pub changepoints: Option<Vec<TimestampSeconds>>,
8787

8888
/// The number of potential changepoints to include.
8989
///
@@ -215,7 +215,7 @@ pub struct ProphetOptions {
215215
/// An optional list of changepoints.
216216
///
217217
/// If not provided, changepoints will be automatically selected.
218-
pub changepoints: Option<Vec<u64>>,
218+
pub changepoints: Option<Vec<TimestampSeconds>>,
219219

220220
/// The number of potential changepoints to include.
221221
///

crates/augurs-prophet/src/prophet/prep.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,10 @@ impl Prophet {
577577
Ok(n)
578578
}
579579

580-
fn construct_holidays(&self, _ds: &[u64]) -> Result<HashMap<String, Holiday>, Error> {
580+
fn construct_holidays(
581+
&self,
582+
_ds: &[TimestampSeconds],
583+
) -> Result<HashMap<String, Holiday>, Error> {
581584
let mut all_holidays = self.opts.holidays.clone();
582585
// TODO: handle country holidays.
583586

0 commit comments

Comments
 (0)