Skip to content

Commit

Permalink
Fix major bug in write_ben_file function
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrrock2 committed Apr 9, 2024
1 parent 839dd82 commit c5af77f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "binary-ensemble"
version = "0.1.1"
version = "0.1.2"
edition = "2021"
authors = ["Peter Rock <[email protected]>"]
exclude = ["example/"]
Expand Down
9 changes: 9 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,12 @@
- [ ] Make a special MCMC writer for ben that add a self-loop counter to the start of
the next item. This will be really useful for reducing the size of any chain that
has a high rejection ratio (e.g. reversible)

- [ ] Add an overwrite option to `reben` rather than just doing it by default

- [ ] Change the `-s` flag in the "shapefile" parameter in `reben` to a `-d`

- [ ] Add a reverse mode to reben to make reverting the labeling a little bit
easier for the end user

- [ ] Add a `jsonl` mode to reben to relabel the `jsonl` file.
2 changes: 1 addition & 1 deletion src/bin/ben.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ enum Mode {
#[command(
name = "Binary Ensamble CLI Tool",
about = "This is a command line tool for encoding and decoding binary ensamble files.",
version = "0.1.1"
version = "0.1.2"
)]
struct Args {
/// Mode to run the program in (encode, decode, or read).
Expand Down
5 changes: 4 additions & 1 deletion src/bin/reben.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ enum Mode {
"This is a command line tool for relabeling binary ensambles ",
"to help improve compression ratios for BEN and XBEN files."
),
version = "0.1.1"
version = "0.1.2"
)]

// TODO: Change the name of shape_file to dual_graph_file.
struct Args {
/// Input file to read from.
#[arg()]
Expand Down Expand Up @@ -66,6 +68,7 @@ fn main() {

match &args.mode {
Mode::Json => {
// TODO: Change the input file here to the shape file.
let input_file = File::open(&args.input_file).expect("Could not open input file.");
let reader = BufReader::new(input_file);

Expand Down
4 changes: 2 additions & 2 deletions src/encode/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub mod translate;

use crate::utils::*;
use serde_json::Value;
use std::io::{self, BufRead, Cursor, Result, Write};
use std::io::{self, BufRead, Cursor, Read, Result, Write};
use xz2::write::XzEncoder;

use self::translate::ben_to_ben32_lines;
Expand Down Expand Up @@ -117,7 +117,7 @@ impl<W: Write> XBenEncoder<W> {
// Create a new reader that prepends buff back onto the original reader
let mut reader = if buff != b"STANDARD BEN FILE".as_slice() {
let cursor = Cursor::new(buff.to_vec());
let reader = reader.chain(cursor);
let reader = cursor.chain(reader);
Box::new(reader) as Box<dyn BufRead>
} else {
Box::new(reader)
Expand Down

0 comments on commit c5af77f

Please sign in to comment.