From e4d82efabddcd56cf4f69179435640ee6137047c Mon Sep 17 00:00:00 2001 From: "Matthias C. M. Troffaes" Date: Fri, 13 Sep 2024 14:32:05 +0100 Subject: [PATCH] Support pickle for Matrix (see issue #47). --- cython/pycddlib.pxi | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cython/pycddlib.pxi b/cython/pycddlib.pxi index 202ca6e..cca05d7 100644 --- a/cython/pycddlib.pxi +++ b/cython/pycddlib.pxi @@ -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):