@@ -186,8 +186,6 @@ def _decode_and_free_string(self, s) -> str:
186
186
187
187
188
188
class CffiApiUtil (object ):
189
- _ADV_TYPES = False # class variable, changed globally
190
-
191
189
def __init__ (self , ffi , lib , ctx = None ):
192
190
self .owns_ctx = True
193
191
self .codec = codec
@@ -199,10 +197,9 @@ def __init__(self, ffi, lib, ctx=None):
199
197
else :
200
198
self .lib = CtxLib (ctx , lib )
201
199
200
+ self ._allow_complex = False
202
201
self .init_buffers ()
203
202
204
- # Just in case the user has set the env var DSS_CAPI_ARRAY_DIMS=1
205
- CffiApiUtil ._ADV_TYPES = self .lib .DSS_Get_EnableArrayDimensions ()
206
203
207
204
208
205
# def __delete__(self):
@@ -252,7 +249,7 @@ def get_float64_array(self, func, *args) -> Float64Array:
252
249
res = np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 8 ), dtype = np .float64 ).copy ()
253
250
self .lib .DSS_Dispose_PDouble (ptr )
254
251
255
- if self ._ADV_TYPES and cnt [3 ]:
252
+ if self ._allow_complex and cnt [3 ]:
256
253
# If the last element is filled, we have a matrix. Otherwise, the
257
254
# matrix feature is disabled or the result is indeed a vector
258
255
return res .reshape ((cnt [2 ], cnt [3 ]), order = 'F' )
@@ -261,7 +258,7 @@ def get_float64_array(self, func, *args) -> Float64Array:
261
258
262
259
263
260
def get_complex128_array (self , func , * args ) -> Float64ArrayOrComplexArray :
264
- if not self ._ADV_TYPES :
261
+ if not self ._allow_complex :
265
262
return self .get_float64_array (func , * args )
266
263
267
264
# Currently we use the same as API as get_float64_array, may change later
@@ -280,7 +277,7 @@ def get_complex128_array(self, func, *args) -> Float64ArrayOrComplexArray:
280
277
281
278
282
279
def get_complex128_simple (self , func , * args ) -> Float64ArrayOrSimpleComplex :
283
- if not self ._ADV_TYPES :
280
+ if not self ._allow_complex :
284
281
return self .get_float64_array (func , * args )
285
282
286
283
# Currently we use the same as API as get_float64_array, may change later
@@ -296,26 +293,26 @@ def get_complex128_simple(self, func, *args) -> Float64ArrayOrSimpleComplex:
296
293
297
294
def get_float64_gr_array (self ) -> Float64Array :
298
295
ptr , cnt = self .gr_float64_pointers
299
- if self ._ADV_TYPES and cnt [3 ]:
296
+ if self ._allow_complex and cnt [3 ]:
300
297
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 8 ), dtype = np .float64 ).copy ().reshape ((cnt [2 ], cnt [3 ]), order = 'F' )
301
298
302
299
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 8 ), dtype = np .float64 ).copy ()
303
300
304
301
305
302
def get_complex128_gr_array (self ) -> ComplexArray :
306
- if not self ._ADV_TYPES :
303
+ if not self ._allow_complex :
307
304
return self .get_float64_gr_array ()
308
305
309
306
# Currently we use the same as API as get_float64_array, may change later
310
307
ptr , cnt = self .gr_float64_pointers
311
- if self ._ADV_TYPES and cnt [3 ]:
308
+ if self ._allow_complex and cnt [3 ]:
312
309
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 8 ), dtype = complex ).copy ().reshape ((cnt [2 ], cnt [3 ]), order = 'F' )
313
310
314
311
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 8 ), dtype = complex ).copy ()
315
312
316
313
317
314
def get_complex128_gr_simple (self ) -> Float64ArrayOrSimpleComplex :
318
- if not self ._ADV_TYPES :
315
+ if not self ._allow_complex :
319
316
return self .get_float64_gr_array ()
320
317
321
318
# Currently we use the same as API as get_float64_array, may change later
@@ -331,7 +328,7 @@ def get_int32_array(self, func: Callable, *args) -> Int32Array:
331
328
res = np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 4 ), dtype = np .int32 ).copy ()
332
329
self .lib .DSS_Dispose_PInteger (ptr )
333
330
334
- if self ._ADV_TYPES and cnt [3 ]:
331
+ if self ._allow_complex and cnt [3 ]:
335
332
# If the last element is filled, we have a matrix. Otherwise, the
336
333
# matrix feature is disabled or the result is indeed a vector
337
334
return res .reshape ((cnt [2 ], cnt [3 ]))
@@ -349,7 +346,7 @@ def get_ptr_array(self, func: Callable, *args):
349
346
350
347
def get_int32_gr_array (self ) -> Int32Array :
351
348
ptr , cnt = self .gr_int32_pointers
352
- if self ._ADV_TYPES and cnt [3 ]:
349
+ if self ._allow_complex and cnt [3 ]:
353
350
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 4 ), dtype = np .int32 ).copy ().reshape ((cnt [2 ], cnt [3 ]))
354
351
355
352
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 4 ), dtype = np .int32 ).copy ()
@@ -362,7 +359,7 @@ def get_int8_array(self, func: Callable, *args: Any) -> Int8Array:
362
359
res = np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 1 ), dtype = np .int8 ).copy ()
363
360
self .lib .DSS_Dispose_PByte (ptr )
364
361
365
- if self ._ADV_TYPES and cnt [3 ]:
362
+ if self ._allow_complex and cnt [3 ]:
366
363
# If the last element is filled, we have a matrix. Otherwise, the
367
364
# matrix feature is disabled or the result is indeed a vector
368
365
return res .reshape ((cnt [2 ], cnt [3 ]))
@@ -371,7 +368,7 @@ def get_int8_array(self, func: Callable, *args: Any) -> Int8Array:
371
368
372
369
def get_int8_gr_array (self ) -> Int8Array :
373
370
ptr , cnt = self .gr_int8_pointers
374
- if self ._ADV_TYPES and cnt [3 ]:
371
+ if self ._allow_complex and cnt [3 ]:
375
372
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 1 ), dtype = np .int8 ).copy ().reshape ((cnt [2 ], cnt [3 ]), order = 'F' )
376
373
377
374
return np .frombuffer (self .ffi .buffer (ptr [0 ], cnt [0 ] * 1 ), dtype = np .int8 ).copy ()
0 commit comments