Commit 927e430
committed
Prefix matrix/vector/scalar helper functions with module name
The metadata/utility helpers in matrix.py, vector.py, and scalar.py
were named after generic concepts (`new`, `free`, `type`, `format`,
`shape`, `size`, etc.). Several of those names shadow Python builtins
(`type`, `format`) or collide with common variables, making bare
imports awkward (`from suitesparse_graphblas.matrix import type` is
asking for trouble). Prefix every helper with its module name so each
function is unambiguous on import:
matrix.py (16 helpers):
free / new / type / nrows / ncols / nvals / shape / format /
set_format / sparsity_status / sparsity_control /
set_sparsity_control / hyper_switch / set_hyper_switch /
bitmap_switch / set_bitmap_switch
-> matrix_free, matrix_new, matrix_type, ...,
matrix_set_bitmap_switch
vector.py (5 helpers):
free / new / type / size / nvals
-> vector_free, vector_new, vector_type, vector_size, vector_nvals
scalar.py (3 helpers):
free / new / type
-> scalar_free, scalar_new, scalar_type
The element setters/getters (set_bool, get_bool, set_int8, get_int8,
..., set_fc64, get_fc64) are NOT renamed -- they already have a clear
set_*/get_* naming convention.
Internal cross-references updated:
- `def matrix_new(T, ..., *, free=matrix_free)` -- the default value of
the `free` keyword argument now references the renamed module-level
function. The kwarg parameter name itself stays as `free` so existing
callers passing `free=None` or `free=my_func` still work.
- `matrix_shape()` body now calls `matrix_nrows(A)` and `matrix_ncols(A)`.
- All in-module doctests updated: `>>> A = new(...)` -> `>>> A = matrix_new(...)`,
`>>> nrows(A)` -> `>>> matrix_nrows(A)`, etc. Element setter/getter
doctests that call `new(...)` to construct test instances are also
updated to use the prefixed name.
- Local variable shadows (e.g. `format = ffi.new(...)` inside
`matrix_format()`) and kwarg parameter names (e.g. `format` in
`matrix_set_format(A, format)`) are intentionally left alone -- they
are local and don't reference the renamed functions.
- `ffi.new(...)` (cffi calls) is preserved -- distinguished from the
renamed `new(...)` via a negative lookbehind in the rename pattern.
External call sites updated:
- `suitesparse_graphblas/__init__.py`: `burble` class doctest
references `matrix.matrix_new(...)` and `matrix.matrix_nvals(...)`.
- `suitesparse_graphblas/io/binary.py`: 13 `matrix.X(...)` call sites
in the binread/binwrite serialization paths now call
`matrix.matrix_X(...)`.
- `suitesparse_graphblas/io/serialize.py`: 2 docstring prose mentions
plus 2 attribute references (`matrix.free` -> `matrix.matrix_free`,
`vector.free` -> `vector.vector_free`) used as the default GC
callback in `deserialize_matrix` / `deserialize_vector`.
- `suitesparse_graphblas/tests/test_io.py`: 17 external call sites
updated to the prefixed names.
Verified by rebuilding the Docker test image and running both the full
doctest suite and the pytest suite inside the container:
matrix: 97 attempted, 0 failed
vector: 90 attempted, 0 failed
scalar: 81 attempted, 0 failed
TOTAL doctest: 268 attempted, 0 failed
pytest: 9 passed
test_doctest, test_exceptions, test_io (matrix and vector
serialization round-trip), test_jit, test_package, test_scalar1 parent a062434 commit 927e430
7 files changed
Lines changed: 176 additions & 176 deletions
File tree
- suitesparse_graphblas
- io
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
228 | 228 | | |
229 | 229 | | |
230 | 230 | | |
231 | | - | |
| 231 | + | |
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
| |||
239 | 239 | | |
240 | 240 | | |
241 | 241 | | |
242 | | - | |
| 242 | + | |
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | 249 | | |
250 | | - | |
| 250 | + | |
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
138 | | - | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
446 | 446 | | |
447 | 447 | | |
448 | 448 | | |
449 | | - | |
| 449 | + | |
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| |||
546 | 546 | | |
547 | 547 | | |
548 | 548 | | |
549 | | - | |
550 | | - | |
551 | | - | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
552 | 552 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
91 | | - | |
| 91 | + | |
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
136 | 136 | | |
137 | 137 | | |
138 | 138 | | |
139 | | - | |
| 139 | + | |
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| |||
0 commit comments