You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A ``dict`` equivalent to a parsed JSON binsparse descriptor of an array. See :ref:`sparse_interchange` for details.
1262
1262
"""
1263
1263
1264
-
def__binsparse__(self) ->dict[str, array]:
1264
+
def__binsparse__(
1265
+
self, /, *, descriptor: Optional[dict] =None
1266
+
) ->dict[str, array]:
1265
1267
"""
1266
1268
Returns a key-value store of the constituent arrays of a sparse array, as specified by the `binsparse specification <https://graphblas.org/binsparse-specification/>`_.
1267
1269
1268
1270
Parameters
1269
1271
----------
1270
1272
self: array
1271
1273
array instance.
1274
+
descriptor: Optional[dict]
1275
+
If ``descriptor`` is not ``None``, the data returned must be in the format specified by it. If the format is unsupported, a ``TypeError`` must be raised.
1272
1276
1273
1277
Returns
1274
1278
-------
1275
1279
out: dict[str, array]
1276
1280
A ``dict`` equivalent to a parsed JSON binsparse descriptor of an array. See :ref:`sparse_interchange` for details.
1281
+
1282
+
Raises
1283
+
------
1284
+
TypeError
1285
+
If ``descriptor`` is not ``None``, and the array library does not support converting to it.
Returns a new array containing the data from another (array) object with a ``__binsparse__`` method.
18
+
Returns a new array containing the data from another (array) object with a ``__binsparse__`` method,
19
+
assuming the format specified in `descriptor` is supported in this library.
11
20
12
21
Parameters
13
22
----------
14
-
arrays: dict[str, array]
15
-
input constituent arrays.
16
-
descriptor: dict
17
-
The parsed binsparse descriptor of the array.
23
+
x: object
24
+
input (array) object.
25
+
descriptor: Optional[dict]
26
+
If ``descriptor`` is ``None``, the array must be returned in the format in which it is stored or materializable to.
27
+
Otherwise, it must be converted to the format specified by ``descriptor``.
28
+
29
+
If ``copy`` is ``False``, no conversion should be performed, and only stored data should be returned.
30
+
31
+
If the format specified by ``descriptor`` is unsupported by the library, a ``TypeError`` must be raised.
32
+
device: Optional[device]
33
+
device on which to place the created array. If ``device`` is ``None`` and ``x`` supports binsparse, the output array
34
+
must be on the same device as ``x``. Default: ``None``.
35
+
36
+
The v2023.12 standard only mandates that a compliant library should offer a way for ``from_binsparse`` to return an array
37
+
whose underlying memory is accessible to the Python interpreter, when the corresponding ``device`` is provided. If the
38
+
array library does not support such cases at all, the function must raise ``BufferError``. If a copy must be made to
39
+
enable this support but ``copy`` is set to ``False``, the function must raise ``ValueError``.
40
+
41
+
Other device kinds will be considered for standardization in a future version of this API standard.
42
+
copy: Optional[bool]
43
+
boolean indicating whether or not to copy the input. If ``True``, the function must always copy. If ``False``, the function must never copy, and raise ``BufferError`` in case a copy is deemed necessary (e.g. if a cross-device data movement is requested, and it is not possible without a copy). If ``None``, the function must reuse the existing memory buffer if possible and copy otherwise. Default: ``None``.
0 commit comments