Skip to content

Commit

Permalink
Support pickle for Matrix (see issue #47).
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmtroffaes committed Sep 13, 2024
1 parent 90fe593 commit e4d82ef
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cython/pycddlib.pxi
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,12 @@ cdef class Matrix:
dd_FreeMatrix(self.dd_mat)
self.dd_mat = NULL

def __reduce__(self):
return (
matrix_from_array,
(self.array, self.lin_set, self.rep_type, self.obj_type, self.obj_func),
)

# wrap pointer into Matrix class
# https://cython.readthedocs.io/en/latest/src/userguide/extension_types.html#instantiation-from-existing-c-c-pointers
cdef matrix_from_ptr(dd_MatrixPtr dd_mat):
Expand Down

0 comments on commit e4d82ef

Please sign in to comment.