Skip to content

Commit

Permalink
Document sparse matrix creation
Browse files Browse the repository at this point in the history
  • Loading branch information
slinnarsson committed Feb 15, 2018
1 parent f8b4a7b commit b05c94b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions doc/apiwalkthrough/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ For example, the following creates a loom file with a 100x100 main matrix, one r
col_attrs = { "SomeColAttr": np.arange(100) }
loompy.create(filename, matrix, row_attrs, col_attrs)
``loompy.create`` accepts numpy dense matrices (``np.ndarray``) as well as scipy sparse matrices (``scipy.coo_matrix``, ``scipy.csc_matrix``,
or ``scipy.csr_matrix``). For example:

.. code:: python
import numpy as np
import loompy
import scipy.sparse as sparse
filename = "test.loom"
matrix = sparse.coo_matrix((100, 100))
row_attrs = { "SomeRowAttr": np.arange(100) }
col_attrs = { "SomeColAttr": np.arange(100) }
loompy.create(filename, matrix, row_attrs, col_attrs)
You can also create a file by combining existing loom files. The files will be concatenated along the column
axis, and therefore must have the same number of rows. If the rows are potentially not in the same order,
you can supply a ``key`` argument; the row attribute corresponding to the key will be used to sort the files.
Expand Down

0 comments on commit b05c94b

Please sign in to comment.