Graphegon / pygraphblas

GraphBLAS for Python
https://graphegon.github.io/pygraphblas/pygraphblas/index.html
Apache License 2.0
343 stars 27 forks source link

Matrix.extract_vector with TransposeA causes GrB_DIMENSION_MISMATCH #29

Closed marci543 closed 4 years ago

marci543 commented 4 years ago
A = Matrix.from_lists(
    [0, 0, 1, 3, 3, 4, 1],
    [1, 3, 2, 4, 5, 2, 5],
    [9, 3, 8, 6, 1, 4, 7],
    nrows=5, ncols=6)

print(A.to_string())
print(A[1].to_string())
    0 1 2 3 4 5
 0|   9   3    | 0
 1|     8     7| 1
 2|            | 2
 3|         6 1| 3
 4|     4      | 4
    0 1 2 3 4 5

---------------------------------------------------------------------------
DimensionMismatch                         Traceback (most recent call last)
<ipython-input-18-e2fe2690f885> in <module>
      6 
      7 print(A.to_string())
----> 8 print(A[1].to_string())

~/pygraphblas/matrix.py in __getitem__(self, index)
    894         if isinstance(index, int):
    895             # a[3] extract single row
--> 896             return self.extract_vector(index, None, desc=TransposeA)
    897         if isinstance(index, slice):
    898             # a[3:] extract submatrix of rows

~/pygraphblas/matrix.py in extract_vector(self, col_index, row_slice, out, **kwargs)
    887             ni,
    888             col_index,
--> 889             desc
    890             ))
    891         return out

~/pygraphblas/base.py in _check(res)
    111 def _check(res):
    112     if res != lib.GrB_SUCCESS:
--> 113         raise _error_codes[res](ffi.string(lib.GrB_error()))
    114 
    115 def _check_no_val_key_error(res):

DimensionMismatch: b'GraphBLAS error: GrB_DIMENSION_MISMATCH\nfunction: GrB_Col_extract (w, M, accum, A, I, ni, j, desc)\nDimensions not compatible:\nrequired size of output is 6-by-1\nbut actual size output is  5-by-1\n\n'
michelp commented 4 years ago

Not sure why this didn't automatically close when I merged #30?