Fixes, upgrade, and stuff
This commit is contained in:
@@ -7,7 +7,7 @@ use std::io::{self, BufRead};
|
||||
|
||||
use approx::assert_abs_diff_eq;
|
||||
use kickscore as ks;
|
||||
use time::Date;
|
||||
use time::{macros::date, Date};
|
||||
|
||||
#[test]
|
||||
fn nba_history() {
|
||||
@@ -18,7 +18,8 @@ fn nba_history() {
|
||||
let mut teams = HashSet::new();
|
||||
let mut observations = Vec::new();
|
||||
|
||||
let cutoff = time::date!(2019 - 06 - 01);
|
||||
let cutoff = date!(2019 - 06 - 01);
|
||||
let format = time::format_description::parse("[year]-[month]-[day]").unwrap();
|
||||
|
||||
for line in reader.lines().skip(1) {
|
||||
let line = line.unwrap();
|
||||
@@ -26,7 +27,7 @@ fn nba_history() {
|
||||
|
||||
assert!(data.len() == 5);
|
||||
|
||||
let t = Date::parse(data[0], "%F").unwrap();
|
||||
let t = Date::parse(data[0], &format).unwrap();
|
||||
|
||||
if t > cutoff {
|
||||
break;
|
||||
@@ -75,9 +76,9 @@ fn nba_history() {
|
||||
model.fit();
|
||||
|
||||
let (p_win, _) = model.probabilities(
|
||||
&[&"CHI"],
|
||||
&[&"BOS"],
|
||||
time::date!(1996 - 01 - 01)
|
||||
&["CHI"],
|
||||
&["BOS"],
|
||||
date!(1996 - 01 - 01)
|
||||
.midnight()
|
||||
.assume_utc()
|
||||
.unix_timestamp() as f64,
|
||||
@@ -86,9 +87,9 @@ fn nba_history() {
|
||||
assert_abs_diff_eq!(p_win, 0.9002599772490479, epsilon = f64::EPSILON);
|
||||
|
||||
let (p_win, _) = model.probabilities(
|
||||
&[&"CHI"],
|
||||
&[&"BOS"],
|
||||
time::date!(2001 - 01 - 01)
|
||||
&["CHI"],
|
||||
&["BOS"],
|
||||
date!(2001 - 01 - 01)
|
||||
.midnight()
|
||||
.assume_utc()
|
||||
.unix_timestamp() as f64,
|
||||
@@ -97,9 +98,9 @@ fn nba_history() {
|
||||
assert_abs_diff_eq!(p_win, 0.22837870685441986, epsilon = f64::EPSILON);
|
||||
|
||||
let (p_win, _) = model.probabilities(
|
||||
&[&"CHI"],
|
||||
&[&"BOS"],
|
||||
time::date!(2020 - 01 - 01)
|
||||
&["CHI"],
|
||||
&["BOS"],
|
||||
date!(2020 - 01 - 01)
|
||||
.midnight()
|
||||
.assume_utc()
|
||||
.unix_timestamp() as f64,
|
||||
|
||||
Reference in New Issue
Block a user