Skip to content

Commit

Permalink
Merge pull request #41 from ghuls/fix_names_argument_in_pybigtools
Browse files Browse the repository at this point in the history
Fix behaviour of names argument in bigWigAverageOverBed of pybigtools.
  • Loading branch information
jackh726 authored Jun 13, 2024
2 parents 42fdb15 + 49cea3f commit 9e29c8b
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions pybigtools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,24 +1175,21 @@ fn bigWigAverageOverBed(
Some(names) => match names.extract::<bool>(py) {
Ok(b) => {
if b {
(Name::Column(4), true)
(Name::Column(3), true)
} else {
(Name::None, true)
}
}
Err(_) => match names.extract::<isize>(py) {
Ok(col) => {
if col < 0 {
Ok(col) => match col {
0 => (Name::None, true),
1.. => (Name::Column((col - 1) as usize), true),
_ => {
return Err(PyErr::new::<exceptions::PyException, _>(
"Invalid names argument. Must be >= 0.",
));
}
if col == 0 {
(Name::None, true)
} else {
(Name::Column(col as usize), true)
}
}
},
Err(_) => {
return Err(PyErr::new::<exceptions::PyException, _>("Invalid names argument. Should be either `None`, a `bool`, or an `int`"));
}
Expand Down

0 comments on commit 9e29c8b

Please # to comment.