Skip to content
Snippets Groups Projects
Commit 90d3b2cb authored by Martin Larralde's avatar Martin Larralde
Browse files

Avoid error on missing symbols in `CountMatrix.__init__`

parent 404a6b44
No related branches found
No related tags found
No related merge requests found
......@@ -124,22 +124,18 @@ impl CountMatrix {
let mut data: Option<DenseMatrix<u32, <lightmotif::Dna as Alphabet>::K>> = None;
for s in lightmotif::Dna::symbols() {
let key = String::from(s.as_char());
let column = values
.get_item(&key)
.ok_or(PyKeyError::new_err(key))?
.downcast::<PyList>()?;
if data.is_none() {
data = Some(DenseMatrix::new(column.len()));
}
let matrix = data.as_mut().unwrap();
if matrix.rows() != column.len() {
return Err(PyValueError::new_err("Invalid number of rows"));
}
for (i, x) in column.iter().enumerate() {
matrix[i][s.as_index()] = x.extract::<u32>()?;
if let Some(res) = values.get_item(&key) {
let column = res.downcast::<PyList>()?;
if data.is_none() {
data = Some(DenseMatrix::new(column.len()));
}
let matrix = data.as_mut().unwrap();
if matrix.rows() != column.len() {
return Err(PyValueError::new_err("Invalid number of rows"));
}
for (i, x) in column.iter().enumerate() {
matrix[i][s.as_index()] = x.extract::<u32>()?;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment