Skip to content

Commit

Permalink
fix: used the right constructor for matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
CGMossa committed Jan 31, 2024
1 parent e1534b3 commit f79a57f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions extendr-api/src/wrapper/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,7 @@ where
pub fn new(nrow: usize, ncol: usize) -> Self {
let sexptype = T::sexptype();
let matrix = Robj::alloc_matrix(sexptype, nrow as _, ncol as _);
// this is pretty much the same?
let mut robj = matrix;
let slice = robj.as_typed_slice_mut().unwrap();
let data = slice.as_mut_ptr();
RArray::from_parts(robj, data, [nrow, ncol])
RArray::from_parts(matrix, [nrow, ncol])
}
}

Expand All @@ -70,7 +66,6 @@ where
pub fn new_with_na(nrow: usize, ncol: usize) -> Self {
let mut matrix = Self::new(nrow, ncol);
if nrow != 0 || ncol != 0 {
// matrix.data_mut().iter_mut().for_each(|x| {
matrix
.as_typed_slice_mut()
.unwrap()
Expand Down Expand Up @@ -440,6 +435,7 @@ mod tests {
use super::*;

#[test]
#[ignore]
fn test_empty_matrix_new() {
dbg!("print like R");
with_r(|| {
Expand Down

0 comments on commit f79a57f

Please sign in to comment.