Skip to content

Commit

Permalink
Fixes #170 - remove dbg print instead of error
Browse files Browse the repository at this point in the history
  • Loading branch information
Baxter Eaves committed Jan 25, 2024
1 parent de802d3 commit 17eb5c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Added
- `DataParseError::CodebookAndDataRowsMismatch` variant for when the number of rows in the codebook and the number of rows in the data do not match.

### Fixed
- Initializing an engine with a codebook that has a different number of rows than the data will result in an error instead of printing a bunch on nonsense.

## [python-0.6.0] - 2024-01-23

### Added
Expand Down
17 changes: 7 additions & 10 deletions lace/src/data/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,17 +287,14 @@ pub fn df_to_col_models<R: rand::Rng>(
})
.collect::<Result<_, DataParseError>>()?;

if col_models
.iter()
.any(|cm| cm.len() != codebook.row_names.len())
{
dbg!(
col_models.iter().map(|cm| cm.len()).collect::<Vec<_>>(),
codebook.row_names.len()
);
// FIXME!
// return Err(CsvParseError::CodebookAndDataRowMismatch);
let n_codebook_rows = codebook.row_names.len();
if let Some(cm) = col_models.iter().find(|cm| cm.len() != n_codebook_rows) {
return Err(DataParseError::CodebookAndDataRowsMismatch {
n_codebook_rows,
n_data_rows: cm.len(),
});
}

Ok((codebook, col_models))
}

Expand Down
10 changes: 8 additions & 2 deletions lace/src/interface/engine/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ pub enum DataParseError {
/// The supplied data source is not currently supported for this operation
#[error("Provided an unsupported data source")]
UnsupportedDataSource,
/// The user supplied column_metdata in the codebook but provided an empty
/// The user supplied column_metadata in the codebook but provided an empty
/// data source
#[error("non-empty column_metdata the codebook but empty DataSource")]
#[error("non-empty column_metadata the codebook but empty DataSource")]
ColumnMetadataSuppliedForEmptyData,
/// The user supplied row_names in the codebook but provided an empty
/// data source
Expand All @@ -36,6 +36,12 @@ pub enum DataParseError {
/// externally
#[error("Column `{col_name}` has type `{col_type}`, which is unsupported for external data sources")]
UnsupportedColumnType { col_name: String, col_type: String },
/// The codebook and the data have a different number of rows
#[error("The codebook contains {n_codebook_rows} rows, but the data contain {n_data_rows} rows")]
CodebookAndDataRowsMismatch {
n_codebook_rows: usize,
n_data_rows: usize,
},
}

/// Errors that can arise when creating a new engine
Expand Down

0 comments on commit 17eb5c0

Please sign in to comment.