support unit-aware sparse computation: CSR
, CSC
, COO
#80
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant updates to the
brainunit
package, focusing on the addition of sparse matrix support and enhancements to data type promotion functions. Key changes include the integration of theSparseMatrix
class, updates to arithmetic operations to handle sparse matrices, and new utility functions for data type promotion.Sparse Matrix Support:
SparseMatrix
class inbrainunit/_sparse_base.py
with various arithmetic operations (__add__
,__sub__
,__mul__
, etc.) and placeholder methods for future implementation.brainunit/_base.py
to handle instances ofSparseMatrix
. [1] [2] [3] [4] [5] [6] [7]brainunit/sparse/__init__.py
to expose theCOO
,CSR
, andCSC
classes and their associated functions.COO
class inbrainunit/sparse/coo_test.py
to validate matrix operations likematvec
,matmul
,add
,sub
,mul
,div
,mod
,pos
,neg
, andabs
.Data Type Promotion Enhancements:
promote_dtypes
function inbrainunit/math/_fun_keep_unit.py
to promote the data types of input arrays to a common type.get_promote_dtypes
function inbrainunit/math/_fun_remove_unit.py
to facilitate data type promotion for input arrays.Documentation:
docs/apis/brainunit.sparse.rst
to include documentation for the new sparse data structures and operations.Import and Export Updates:
sparse
module inbrainunit/__init__.py
and updated the__all__
list to reflect the new module. [1] [2]SparseMatrix
inbrainunit/_base.py
and addedsplit_mantissa_unit
function. [1] [2] [3]promote_dtypes
fromjax
inbrainunit/math/_fun_keep_unit.py
. [1] [2]These changes significantly enhance the functionality and versatility of the
brainunit
package, particularly in handling sparse matrices and promoting data types efficiently.