|
5 | 5 | import numpy as np |
6 | 6 |
|
7 | 7 | from contextlib import contextmanager |
8 | | -from ctypes import addressof, cast, get_errno, memmove, POINTER |
| 8 | +from ctypes import addressof, get_errno, memmove, POINTER |
9 | 9 | from os import strerror |
10 | 10 | from typing import ( |
11 | 11 | Any, |
|
32 | 32 | igraph_matrix_int_init_array, |
33 | 33 | igraph_matrix_int_ncol, |
34 | 34 | igraph_matrix_int_nrow, |
35 | | - igraph_matrix_int_e_ptr, |
36 | 35 | igraph_matrix_init_array, |
37 | 36 | igraph_matrix_ncol, |
38 | 37 | igraph_matrix_nrow, |
39 | | - igraph_matrix_e_ptr, |
40 | 38 | igraph_vector_bool_get, |
41 | 39 | igraph_vector_bool_get_ptr, |
42 | 40 | igraph_vector_bool_init_array, |
@@ -824,17 +822,15 @@ def igraph_matrix_t_to_numpy_array(matrix: _Matrix) -> RealArray: |
824 | 822 | shape = igraph_matrix_nrow(matrix), igraph_matrix_ncol(matrix) |
825 | 823 | result = np.zeros(shape, dtype=np_type_of_igraph_real_t) |
826 | 824 | if result.size > 0: |
827 | | - memmove(result.ctypes.data, igraph_matrix_e_ptr(matrix, 0, 0), result.nbytes) |
| 825 | + memmove(result.ctypes.data, matrix.unwrap().data.stor_begin, result.nbytes) |
828 | 826 | return result |
829 | 827 |
|
830 | 828 |
|
831 | 829 | def igraph_matrix_int_t_to_numpy_array(matrix: _MatrixInt) -> IntArray: |
832 | 830 | shape = igraph_matrix_int_nrow(matrix), igraph_matrix_int_ncol(matrix) |
833 | 831 | result = np.zeros(shape, dtype=np_type_of_igraph_integer_t) |
834 | 832 | if result.size > 0: |
835 | | - memmove( |
836 | | - result.ctypes.data, igraph_matrix_int_e_ptr(matrix, 0, 0), result.nbytes |
837 | | - ) |
| 833 | + memmove(result.ctypes.data, matrix.unwrap().data.stor_begin, result.nbytes) |
838 | 834 | return result |
839 | 835 |
|
840 | 836 |
|
|
0 commit comments