Binary sparse storage scheme for SuiteSparse::GraphBLAS utilizing netCDF4
The format specification is found here.
sscdf contains a convenience method to save a single object.
write(file, obj, comment=None)
filecan be a filename or a file-like object opened in "write" mode.objis the graphblas object (Matrix, Vector, or Scalar)commentis optional
Loading the primary object can be done with a convenience method.
read(file)
filecan be a filename or a file-like object opened in "read" mode.
This returns the primary object in the file, reconstituted as a graphblas object (Matrix, Vector, or Scalar).
When writing multiple associated graphblas objects to a single sscdf file,
the preferred method is using a Writer in a with block.
with sscdf.Writer(filename) as w:
w.write(my_matrix, comment="Data came from the internet")
w.write(my_matrix.reduce_rowwise(), name="row_degrees")When a sscdf file contains multiple objects, the easiest way to access the named
objects is using a Reader in a with block.
with sscdf.Reader(filename) as r:
my_matrix = r.read()
row_degrees = r.read('row_degrees')To view what objects exist in an sscdf file, use the info() method.
This will show the metadata and attributes of the primary as well as any
secondary objects in the file.
>>> sscdf.info(filename)
{'version': '1.0',
'format': 'CSR',
'shape': [5, 5],
'data_types': {
'pointers_0': 'uint64',
'indices_1': 'uint64',
'values': 'float32'},
'comment': 'Data came from the internet',
'SECONDARY': {
'row_degrees': {
'version': '1.0',
'format': 'VEC',
'shape': [5],
'data_types': {
'indices_0': 'uint64',
'values': 'float32'},
}
}
}