1- from  suitesparse_graphblas  import  check_status , ffi , lib 
1+ from  suitesparse_graphblas  import  check_status , ffi , lib ,  vararg 
22
33from  .io .serialize  import  deserialize_matrix  as  deserialize   # noqa 
44from  .io .serialize  import  serialize_matrix  as  serialize   # noqa 
@@ -109,7 +109,7 @@ def format(A):
109109
110110    """ 
111111    format  =  ffi .new ("GxB_Format_Value*" )
112-     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_FORMAT , format ))
112+     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_FORMAT , vararg ( format ) ))
113113    return  format [0 ]
114114
115115
@@ -122,58 +122,60 @@ def set_format(A, format):
122122    True 
123123
124124    """ 
125-     check_status (
126-         A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_FORMAT , ffi .cast ("GxB_Format_Value" , format ))
127-     )
125+     format_val  =  ffi .cast ("GxB_Format_Value" , format )
126+     check_status (A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_FORMAT , vararg (format_val )))
128127
129128
130129def  sparsity_status (A ):
131130    """Get the sparsity status of the matrix.""" 
132131    sparsity_status  =  ffi .new ("int32_t*" )
133-     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_SPARSITY_STATUS , sparsity_status ))
132+     check_status (
133+         A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_SPARSITY_STATUS , vararg (sparsity_status ))
134+     )
134135    return  sparsity_status [0 ]
135136
136137
137138def  sparsity_control (A ):
138139    """Get the sparsity control of the matrix.""" 
139140    sparsity_control  =  ffi .new ("int32_t*" )
140-     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_SPARSITY_CONTROL , sparsity_control ))
141+     check_status (
142+         A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_SPARSITY_CONTROL , vararg (sparsity_control ))
143+     )
141144    return  sparsity_control [0 ]
142145
143146
144147def  set_sparsity_control (A , sparsity ):
145148    """Set the sparsity control of the matrix.""" 
149+     sparsity_control  =  ffi .cast ("int32_t" , sparsity )
146150    check_status (
147-         A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_SPARSITY_CONTROL , ffi . cast ( "int" ,  sparsity ))
151+         A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_SPARSITY_CONTROL , vararg ( sparsity_control ))
148152    )
149153
150154
151155def  hyper_switch (A ):
152156    """Get the hyper switch of the matrix.""" 
153157    hyper_switch  =  ffi .new ("double*" )
154-     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_HYPER_SWITCH , hyper_switch ))
158+     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_HYPER_SWITCH , vararg ( hyper_switch ) ))
155159    return  hyper_switch [0 ]
156160
157161
158162def  set_hyper_switch (A , hyper_switch ):
159163    """Set the hyper switch of the matrix.""" 
160-     check_status (
161-         A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_HYPER_SWITCH , ffi .cast ("double" , hyper_switch ))
162-     )
164+     hyper_switch  =  ffi .cast ("double" , hyper_switch )
165+     check_status (A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_HYPER_SWITCH , vararg (hyper_switch )))
163166
164167
165168def  bitmap_switch (A ):
166169    """Get the bitmap switch of the matrix.""" 
167170    bitmap_switch  =  ffi .new ("double*" )
168-     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_BITMAP_SWITCH , bitmap_switch ))
171+     check_status (A , lib .GxB_Matrix_Option_get (A [0 ], lib .GxB_BITMAP_SWITCH , vararg ( bitmap_switch ) ))
169172    return  bitmap_switch [0 ]
170173
171174
172175def  set_bitmap_switch (A , bitmap_switch ):
173176    """Set the bitmap switch of the matrix.""" 
174-     check_status (
175-         A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_BITMAP_SWITCH , ffi .cast ("double" , bitmap_switch ))
176-     )
177+     bitmap_switch  =  ffi .cast ("double" , bitmap_switch )
178+     check_status (A , lib .GxB_Matrix_Option_set (A [0 ], lib .GxB_BITMAP_SWITCH , vararg (bitmap_switch )))
177179
178180
179181def  set_bool (A , value , i , j ):
0 commit comments