Skip to content

Commit

Permalink
deprecate Progress
Browse files Browse the repository at this point in the history
  • Loading branch information
krukah committed Oct 15, 2024
1 parent 870fb6f commit c528117
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/clustering/abstractor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::cards::observation::Observation;
use crate::cards::street::Street;
use crate::clustering::abstraction::Abstraction;
use crate::clustering::histogram::Histogram;
use crate::clustering::progress::Progress;
// use crate::clustering::progress::Progress;
use std::collections::BTreeMap;

/// this is the output of the clustering module
Expand Down Expand Up @@ -68,7 +68,7 @@ impl Abstractor {
use std::fs::File;
use std::io::Write;
let ref mut file = File::create(format!("{}.abstraction.pgcopy", name)).expect("new file");
let ref mut progress = Progress::new(self.0.len(), 10);
// let ref mut progress = Progress::new(self.0.len(), 10);
file.write_all(b"PGCOPY\n\xff\r\n\0").expect("header");
file.write_u32::<BigEndian>(0).expect("flags");
file.write_u32::<BigEndian>(0).expect("extension");
Expand All @@ -81,7 +81,7 @@ impl Abstractor {
file.write_i64::<BigEndian>(obs).expect("observation");
file.write_u32::<BigEndian>(8).expect("8-bytes field");
file.write_i64::<BigEndian>(abs).expect("abstraction");
progress.tick();
// progress.tick();
}
file.write_u16::<BigEndian>(0xFFFF).expect("trailer");
}
Expand Down
18 changes: 15 additions & 3 deletions src/clustering/layer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@ impl Layer {

/// simply go to the previous street
fn inner_street(&self) -> Street {
log::info!("advancing from {} to {}", self.street, self.street.prev());
log::info!(
"advancing street from {} to {}",
self.street,
self.street.prev()
);
self.street.prev()
}
/// compute the outer product of the `Abstraction -> Histogram`s at the current layer,
Expand All @@ -86,7 +90,11 @@ impl Layer {
/// we symmetrize the distance by averaging the EMDs in both directions.
/// the distnace isn't symmetric in the first place only because our heuristic algo is not fully accurate
fn inner_metric(&self) -> Metric {
log::info!("computing metric {}", self.street);
log::info!(
"computing metric from {} to {}",
self.street,
self.street.prev()
);
let mut metric = BTreeMap::new();
for a in self.kmeans.0.keys() {
for b in self.kmeans.0.keys() {
Expand All @@ -110,7 +118,11 @@ impl Layer {
/// 3. use `self.abstractor` to map each into an `Abstraction`
/// 4. collect `Abstraction`s into a `Histogram`, for each `Observation`
fn inner_points(&self) -> ObservationSpace {
log::info!("computing projections {}", self.street);
log::info!(
"computing projections from {} to {}",
self.street,
self.street.prev()
);
ObservationSpace(
Observation::exhaust(self.street.prev())
.filter(|o| Isomorphism::is_canonical(o))
Expand Down
6 changes: 3 additions & 3 deletions src/clustering/metric.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::clustering::abstraction::Abstraction;
use crate::clustering::histogram::Histogram;
use crate::clustering::progress::Progress;
// use crate::clustering::progress::Progress;
use crate::clustering::xor::Pair;
use std::collections::BTreeMap;

Expand Down Expand Up @@ -121,7 +121,7 @@ impl Metric {
use std::fs::File;
use std::io::Write;
let ref mut file = File::create(format!("{}.metric.pgcopy", path)).expect("new file");
let ref mut progress = Progress::new(self.0.len(), 10);
// let ref mut progress = Progress::new(self.0.len(), 10);
file.write_all(b"PGCOPY\n\xff\r\n\0").expect("header");
file.write_u32::<BigEndian>(0).expect("flags");
file.write_u32::<BigEndian>(0).expect("extension");
Expand All @@ -131,7 +131,7 @@ impl Metric {
file.write_i64::<BigEndian>(i64::from(*pair)).expect("pair");
file.write_u32::<BigEndian>(4).expect("4-bytes field");
file.write_f32::<BigEndian>(*distance).expect("distance");
progress.tick();
// progress.tick();
}
file.write_u16::<BigEndian>(0xFFFF).expect("trailer");
}
Expand Down
3 changes: 2 additions & 1 deletion src/clustering/progress.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#[deprecated]
use std::time::Instant;

/// A struct to track and display progress of a long-running operation.
Expand All @@ -10,7 +11,7 @@ pub struct Progress {
}
impl Progress {
pub fn new(total: usize, n: usize) -> Self {
let check = total / n;
let check = (total / n).min(1);
let now = Instant::now();
Self {
total,
Expand Down

0 comments on commit c528117

Please sign in to comment.