Skip to content

Commit a062434

Browse files
committed
Rename element getters to get_* in functional API
The element getter functions in matrix.py, vector.py, and scalar.py were named after their GraphBLAS type suffix — `bool`, `int8`, `fp32`, `fc64`, etc. — which can be confused with concrete type objects (e.g. NumPy's `int8` dtype). Prefix every getter with `get_`, mirroring the existing `set_` prefix on the corresponding setters: `bool` -> `get_bool`, `int32` -> `get_int32`, `fc64` -> `get_fc64`, etc. The setters (`set_bool`, `set_int8`, ...) are NOT renamed. This is a pure rename, not an API redesign. Implementations and doctests are otherwise unchanged. Each setter's doctest already referenced its corresponding getter for round-trip verification, so both setter and getter docstrings were updated. Affected: - 13 getter `def` lines per file (one per element type) - 26 doctest references per file (one in each setter doctest, one in each getter doctest) - 3 files * (13 + 26) = 117 line replacements total Verified by rebuilding the Docker test image and rerunning the full doctest suite inside the container: matrix: 97 attempted, 0 failed vector: 90 attempted, 0 failed scalar: 81 attempted, 0 failed TOTAL: 268 attempted, 0 failed test_run_doctests: OK Both the direct `doctest.testmod` invocation and the official `tests/test_doctest.py::test_run_doctests` entry point pass, including the complex `get_fc32` / `get_fc64` doctests that depend on `supports_complex()`.
1 parent a85dc40 commit a062434

3 files changed

Lines changed: 117 additions & 117 deletions

File tree

suitesparse_graphblas/matrix.py

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -181,19 +181,19 @@ def set_bool(A, value, i, j):
181181
182182
>>> A = new(lib.GrB_BOOL, 3, 3)
183183
>>> set_bool(A, True, 2, 2)
184-
>>> bool(A, 2, 2) == True
184+
>>> get_bool(A, 2, 2) == True
185185
True
186186
187187
"""
188188
check_status(A, lib.GrB_Matrix_setElement_BOOL(A[0], value, i, j))
189189

190190

191-
def bool(A, i, j):
191+
def get_bool(A, i, j):
192192
"""Get a boolean value from the matrix at row `i` column `j`.
193193
194194
>>> A = new(lib.GrB_BOOL, 3, 3)
195195
>>> set_bool(A, True, 2, 2)
196-
>>> bool(A, 2, 2) == True
196+
>>> get_bool(A, 2, 2) == True
197197
True
198198
199199
"""
@@ -207,19 +207,19 @@ def set_int8(A, value, i, j):
207207
208208
>>> A = new(lib.GrB_INT8, 3, 3)
209209
>>> set_int8(A, 7, 2, 2)
210-
>>> int8(A, 2, 2) == 7
210+
>>> get_int8(A, 2, 2) == 7
211211
True
212212
213213
"""
214214
check_status(A, lib.GrB_Matrix_setElement_INT8(A[0], value, i, j))
215215

216216

217-
def int8(A, i, j):
217+
def get_int8(A, i, j):
218218
"""Get an int8 value from the matrix at row `i` column `j`.
219219
220220
>>> A = new(lib.GrB_INT8, 3, 3)
221221
>>> set_int8(A, 7, 2, 2)
222-
>>> int8(A, 2, 2) == 7
222+
>>> get_int8(A, 2, 2) == 7
223223
True
224224
225225
"""
@@ -233,19 +233,19 @@ def set_int16(A, value, i, j):
233233
234234
>>> A = new(lib.GrB_INT16, 3, 3)
235235
>>> set_int16(A, 7, 2, 2)
236-
>>> int16(A, 2, 2) == 7
236+
>>> get_int16(A, 2, 2) == 7
237237
True
238238
239239
"""
240240
check_status(A, lib.GrB_Matrix_setElement_INT16(A[0], value, i, j))
241241

242242

243-
def int16(A, i, j):
243+
def get_int16(A, i, j):
244244
"""Get an int16 value from the matrix at row `i` column `j`.
245245
246246
>>> A = new(lib.GrB_INT16, 3, 3)
247247
>>> set_int16(A, 7, 2, 2)
248-
>>> int16(A, 2, 2) == 7
248+
>>> get_int16(A, 2, 2) == 7
249249
True
250250
251251
"""
@@ -259,19 +259,19 @@ def set_int32(A, value, i, j):
259259
260260
>>> A = new(lib.GrB_INT32, 3, 3)
261261
>>> set_int32(A, 7, 2, 2)
262-
>>> int32(A, 2, 2) == 7
262+
>>> get_int32(A, 2, 2) == 7
263263
True
264264
265265
"""
266266
check_status(A, lib.GrB_Matrix_setElement_INT32(A[0], value, i, j))
267267

268268

269-
def int32(A, i, j):
269+
def get_int32(A, i, j):
270270
"""Get an int32 value from the matrix at row `i` column `j`.
271271
272272
>>> A = new(lib.GrB_INT32, 3, 3)
273273
>>> set_int32(A, 7, 2, 2)
274-
>>> int32(A, 2, 2) == 7
274+
>>> get_int32(A, 2, 2) == 7
275275
True
276276
277277
"""
@@ -285,19 +285,19 @@ def set_int64(A, value, i, j):
285285
286286
>>> A = new(lib.GrB_INT64, 3, 3)
287287
>>> set_int64(A, 7, 2, 2)
288-
>>> int64(A, 2, 2) == 7
288+
>>> get_int64(A, 2, 2) == 7
289289
True
290290
291291
"""
292292
check_status(A, lib.GrB_Matrix_setElement_INT64(A[0], value, i, j))
293293

294294

295-
def int64(A, i, j):
295+
def get_int64(A, i, j):
296296
"""Get an int64 value from the matrix at row `i` column `j`.
297297
298298
>>> A = new(lib.GrB_INT64, 3, 3)
299299
>>> set_int64(A, 7, 2, 2)
300-
>>> int64(A, 2, 2) == 7
300+
>>> get_int64(A, 2, 2) == 7
301301
True
302302
303303
"""
@@ -311,19 +311,19 @@ def set_uint8(A, value, i, j):
311311
312312
>>> A = new(lib.GrB_UINT8, 3, 3)
313313
>>> set_uint8(A, 7, 2, 2)
314-
>>> uint8(A, 2, 2) == 7
314+
>>> get_uint8(A, 2, 2) == 7
315315
True
316316
317317
"""
318318
check_status(A, lib.GrB_Matrix_setElement_UINT8(A[0], value, i, j))
319319

320320

321-
def uint8(A, i, j):
321+
def get_uint8(A, i, j):
322322
"""Get a uint8 value from the matrix at row `i` column `j`.
323323
324324
>>> A = new(lib.GrB_UINT8, 3, 3)
325325
>>> set_uint8(A, 7, 2, 2)
326-
>>> uint8(A, 2, 2) == 7
326+
>>> get_uint8(A, 2, 2) == 7
327327
True
328328
329329
"""
@@ -337,19 +337,19 @@ def set_uint16(A, value, i, j):
337337
338338
>>> A = new(lib.GrB_UINT16, 3, 3)
339339
>>> set_uint16(A, 7, 2, 2)
340-
>>> uint16(A, 2, 2) == 7
340+
>>> get_uint16(A, 2, 2) == 7
341341
True
342342
343343
"""
344344
check_status(A, lib.GrB_Matrix_setElement_UINT16(A[0], value, i, j))
345345

346346

347-
def uint16(A, i, j):
347+
def get_uint16(A, i, j):
348348
"""Get a uint16 value from the matrix at row `i` column `j`.
349349
350350
>>> A = new(lib.GrB_UINT16, 3, 3)
351351
>>> set_uint16(A, 7, 2, 2)
352-
>>> uint16(A, 2, 2) == 7
352+
>>> get_uint16(A, 2, 2) == 7
353353
True
354354
355355
"""
@@ -363,19 +363,19 @@ def set_uint32(A, value, i, j):
363363
364364
>>> A = new(lib.GrB_UINT32, 3, 3)
365365
>>> set_uint32(A, 7, 2, 2)
366-
>>> uint32(A, 2, 2) == 7
366+
>>> get_uint32(A, 2, 2) == 7
367367
True
368368
369369
"""
370370
check_status(A, lib.GrB_Matrix_setElement_UINT32(A[0], value, i, j))
371371

372372

373-
def uint32(A, i, j):
373+
def get_uint32(A, i, j):
374374
"""Get a uint32 value from the matrix at row `i` column `j`.
375375
376376
>>> A = new(lib.GrB_UINT32, 3, 3)
377377
>>> set_uint32(A, 7, 2, 2)
378-
>>> uint32(A, 2, 2) == 7
378+
>>> get_uint32(A, 2, 2) == 7
379379
True
380380
381381
"""
@@ -389,19 +389,19 @@ def set_uint64(A, value, i, j):
389389
390390
>>> A = new(lib.GrB_UINT64, 3, 3)
391391
>>> set_uint64(A, 7, 2, 2)
392-
>>> uint64(A, 2, 2) == 7
392+
>>> get_uint64(A, 2, 2) == 7
393393
True
394394
395395
"""
396396
check_status(A, lib.GrB_Matrix_setElement_UINT64(A[0], value, i, j))
397397

398398

399-
def uint64(A, i, j):
399+
def get_uint64(A, i, j):
400400
"""Get a uint64 value from the matrix at row `i` column `j`.
401401
402402
>>> A = new(lib.GrB_UINT64, 3, 3)
403403
>>> set_uint64(A, 7, 2, 2)
404-
>>> uint64(A, 2, 2) == 7
404+
>>> get_uint64(A, 2, 2) == 7
405405
True
406406
407407
"""
@@ -415,19 +415,19 @@ def set_fp32(A, value, i, j):
415415
416416
>>> A = new(lib.GrB_FP32, 3, 3)
417417
>>> set_fp32(A, 1.5, 2, 2)
418-
>>> fp32(A, 2, 2) == 1.5
418+
>>> get_fp32(A, 2, 2) == 1.5
419419
True
420420
421421
"""
422422
check_status(A, lib.GrB_Matrix_setElement_FP32(A[0], value, i, j))
423423

424424

425-
def fp32(A, i, j):
425+
def get_fp32(A, i, j):
426426
"""Get an fp32 value from the matrix at row `i` column `j`.
427427
428428
>>> A = new(lib.GrB_FP32, 3, 3)
429429
>>> set_fp32(A, 1.5, 2, 2)
430-
>>> fp32(A, 2, 2) == 1.5
430+
>>> get_fp32(A, 2, 2) == 1.5
431431
True
432432
433433
"""
@@ -441,19 +441,19 @@ def set_fp64(A, value, i, j):
441441
442442
>>> A = new(lib.GrB_FP64, 3, 3)
443443
>>> set_fp64(A, 1.5, 2, 2)
444-
>>> fp64(A, 2, 2) == 1.5
444+
>>> get_fp64(A, 2, 2) == 1.5
445445
True
446446
447447
"""
448448
check_status(A, lib.GrB_Matrix_setElement_FP64(A[0], value, i, j))
449449

450450

451-
def fp64(A, i, j):
451+
def get_fp64(A, i, j):
452452
"""Get an fp64 value from the matrix at row `i` column `j`.
453453
454454
>>> A = new(lib.GrB_FP64, 3, 3)
455455
>>> set_fp64(A, 1.5, 2, 2)
456-
>>> fp64(A, 2, 2) == 1.5
456+
>>> get_fp64(A, 2, 2) == 1.5
457457
True
458458
459459
"""
@@ -469,18 +469,18 @@ def set_fc32(A, value, i, j):
469469
470470
>>> A = new(lib.GxB_FC32, 3, 3)
471471
>>> set_fc32(A, 2+3j, 2, 2)
472-
>>> fc32(A, 2, 2) == 2+3j
472+
>>> get_fc32(A, 2, 2) == 2+3j
473473
True
474474
475475
"""
476476
check_status(A, lib.GxB_Matrix_setElement_FC32(A[0], value, i, j))
477477

478-
def fc32(A, i, j):
478+
def get_fc32(A, i, j):
479479
"""Get an fc32 value from the matrix at row `i` column `j`.
480480
481481
>>> A = new(lib.GxB_FC32, 3, 3)
482482
>>> set_fc32(A, 2+3j, 2, 2)
483-
>>> fc32(A, 2, 2) == 2+3j
483+
>>> get_fc32(A, 2, 2) == 2+3j
484484
True
485485
486486
"""
@@ -493,18 +493,18 @@ def set_fc64(A, value, i, j):
493493
494494
>>> A = new(lib.GxB_FC64, 3, 3)
495495
>>> set_fc64(A, 2+3j, 2, 2)
496-
>>> fc64(A, 2, 2) == 2+3j
496+
>>> get_fc64(A, 2, 2) == 2+3j
497497
True
498498
499499
"""
500500
check_status(A, lib.GxB_Matrix_setElement_FC64(A[0], value, i, j))
501501

502-
def fc64(A, i, j):
502+
def get_fc64(A, i, j):
503503
"""Get an fc64 value from the matrix at row `i` column `j`.
504504
505505
>>> A = new(lib.GxB_FC64, 3, 3)
506506
>>> set_fc64(A, 2+3j, 2, 2)
507-
>>> fc64(A, 2, 2) == 2+3j
507+
>>> get_fc64(A, 2, 2) == 2+3j
508508
True
509509
510510
"""

0 commit comments

Comments
 (0)