Add more themes and rustfmt
This commit is contained in:
@@ -13,8 +13,6 @@ impl CharFilter {
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn filter_text(&self, text: &str) -> String {
|
||||
text.chars()
|
||||
.filter(|&ch| self.is_allowed(ch))
|
||||
.collect()
|
||||
text.chars().filter(|&ch| self.is_allowed(ch)).collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,8 +48,7 @@ impl KeyStatsStore {
|
||||
if stat.sample_count == 1 {
|
||||
stat.filtered_time_ms = time_ms;
|
||||
} else {
|
||||
stat.filtered_time_ms =
|
||||
EMA_ALPHA * time_ms + (1.0 - EMA_ALPHA) * stat.filtered_time_ms;
|
||||
stat.filtered_time_ms = EMA_ALPHA * time_ms + (1.0 - EMA_ALPHA) * stat.filtered_time_ms;
|
||||
}
|
||||
|
||||
stat.best_time_ms = stat.best_time_ms.min(stat.filtered_time_ms);
|
||||
@@ -64,10 +63,7 @@ impl KeyStatsStore {
|
||||
}
|
||||
|
||||
pub fn get_confidence(&self, key: char) -> f64 {
|
||||
self.stats
|
||||
.get(&key)
|
||||
.map(|s| s.confidence)
|
||||
.unwrap_or(0.0)
|
||||
self.stats.get(&key).map(|s| s.confidence).unwrap_or(0.0)
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
@@ -104,7 +100,10 @@ mod tests {
|
||||
let conf = store.get_confidence('t');
|
||||
// At 175 CPM target, target_time = 60000/175 = 342.8ms
|
||||
// With 200ms typing time, confidence = 342.8/200 = 1.71
|
||||
assert!(conf > 1.0, "confidence should be > 1.0 for fast typing, got {conf}");
|
||||
assert!(
|
||||
conf > 1.0,
|
||||
"confidence should be > 1.0 for fast typing, got {conf}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -115,6 +114,9 @@ mod tests {
|
||||
}
|
||||
let conf = store.get_confidence('a');
|
||||
// target_time = 342.8ms, typing at 1000ms -> conf = 342.8/1000 = 0.34
|
||||
assert!(conf < 1.0, "confidence should be < 1.0 for slow typing, got {conf}");
|
||||
assert!(
|
||||
conf < 1.0,
|
||||
"confidence should be < 1.0 for slow typing, got {conf}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +78,8 @@ pub struct BranchDefinition {
|
||||
const LOWERCASE_LEVELS: &[LevelDefinition] = &[LevelDefinition {
|
||||
name: "Frequency Order",
|
||||
keys: &[
|
||||
'e', 't', 'a', 'o', 'i', 'n', 's', 'h', 'r', 'd', 'l', 'c', 'u', 'm', 'w', 'f', 'g',
|
||||
'y', 'p', 'b', 'v', 'k', 'j', 'x', 'q', 'z',
|
||||
'e', 't', 'a', 'o', 'i', 'n', 's', 'h', 'r', 'd', 'l', 'c', 'u', 'm', 'w', 'f', 'g', 'y',
|
||||
'p', 'b', 'v', 'k', 'j', 'x', 'q', 'z',
|
||||
],
|
||||
}];
|
||||
|
||||
@@ -293,10 +293,7 @@ impl SkillTree {
|
||||
status: BranchStatus::Locked,
|
||||
current_level: 0,
|
||||
};
|
||||
self.progress
|
||||
.branches
|
||||
.get(id.to_key())
|
||||
.unwrap_or(&DEFAULT)
|
||||
self.progress.branches.get(id.to_key()).unwrap_or(&DEFAULT)
|
||||
}
|
||||
|
||||
pub fn branch_progress_mut(&mut self, id: BranchId) -> &mut BranchProgress {
|
||||
@@ -663,8 +660,14 @@ mod tests {
|
||||
#[test]
|
||||
fn test_initial_state() {
|
||||
let tree = SkillTree::default();
|
||||
assert_eq!(*tree.branch_status(BranchId::Lowercase), BranchStatus::InProgress);
|
||||
assert_eq!(*tree.branch_status(BranchId::Capitals), BranchStatus::Locked);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Lowercase),
|
||||
BranchStatus::InProgress
|
||||
);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Capitals),
|
||||
BranchStatus::Locked
|
||||
);
|
||||
assert_eq!(*tree.branch_status(BranchId::Numbers), BranchStatus::Locked);
|
||||
}
|
||||
|
||||
@@ -711,12 +714,30 @@ mod tests {
|
||||
tree.update(&stats);
|
||||
}
|
||||
|
||||
assert_eq!(*tree.branch_status(BranchId::Lowercase), BranchStatus::Complete);
|
||||
assert_eq!(*tree.branch_status(BranchId::Capitals), BranchStatus::Available);
|
||||
assert_eq!(*tree.branch_status(BranchId::Numbers), BranchStatus::Available);
|
||||
assert_eq!(*tree.branch_status(BranchId::ProsePunctuation), BranchStatus::Available);
|
||||
assert_eq!(*tree.branch_status(BranchId::Whitespace), BranchStatus::Available);
|
||||
assert_eq!(*tree.branch_status(BranchId::CodeSymbols), BranchStatus::Available);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Lowercase),
|
||||
BranchStatus::Complete
|
||||
);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Capitals),
|
||||
BranchStatus::Available
|
||||
);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Numbers),
|
||||
BranchStatus::Available
|
||||
);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::ProsePunctuation),
|
||||
BranchStatus::Available
|
||||
);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Whitespace),
|
||||
BranchStatus::Available
|
||||
);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::CodeSymbols),
|
||||
BranchStatus::Available
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -726,7 +747,10 @@ mod tests {
|
||||
tree.branch_progress_mut(BranchId::Capitals).status = BranchStatus::Available;
|
||||
|
||||
tree.start_branch(BranchId::Capitals);
|
||||
assert_eq!(*tree.branch_status(BranchId::Capitals), BranchStatus::InProgress);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Capitals),
|
||||
BranchStatus::InProgress
|
||||
);
|
||||
assert_eq!(tree.branch_progress(BranchId::Capitals).current_level, 0);
|
||||
}
|
||||
|
||||
@@ -745,7 +769,10 @@ mod tests {
|
||||
tree.update(&stats);
|
||||
|
||||
assert_eq!(tree.branch_progress(BranchId::Capitals).current_level, 1);
|
||||
assert_eq!(*tree.branch_status(BranchId::Capitals), BranchStatus::InProgress);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Capitals),
|
||||
BranchStatus::InProgress
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -766,7 +793,10 @@ mod tests {
|
||||
tree.update(&stats);
|
||||
}
|
||||
|
||||
assert_eq!(*tree.branch_status(BranchId::Capitals), BranchStatus::Complete);
|
||||
assert_eq!(
|
||||
*tree.branch_status(BranchId::Capitals),
|
||||
BranchStatus::Complete
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user