block
An intelligent block matrix library for numpy, PyTorch, and beyond.
Science Score: 23.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
✓Committers with academic emails
2 of 6 committers (33.3%) from academic institutions -
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (10.8%) to scientific vocabulary
Keywords
Repository
An intelligent block matrix library for numpy, PyTorch, and beyond.
Basic Info
Statistics
- Stars: 310
- Watchers: 13
- Forks: 32
- Open Issues: 5
- Releases: 0
Topics
Metadata Files
README.md
Block •

An intelligent block matrix library for numpy, PyTorch, and beyond. Crafted by Brandon Amos with significant contributions by Eric Wong.
Why do we need an intelligent block matrix library?
Let's try to construct the KKT matrix from Mattingley and Boyd's CVXGEN paper in numpy and PyTorch:

Without block, there is no way to infer the appropriate sizes of
the zero and identity matrix blocks.
It is an inconvenience to think about what size these
matrices should be.

What does block do?
Block acts a lot like np.bmat and replaces:
- Any constant with an appropriately shaped block matrix filled with that constant.
- The string
'I'with an appropriately shaped identity matrix. - The string
'-I'with an appropriately shaped negated identity matrix. - [Request more features.]
Isn't constructing large block matrices with a lot of zeros inefficient?
Yes, block is meant to be a quick prototyping tool and
there's probably a more efficient way to solve your system
if it has a lot of zeros or identity elements.
How does block handle numpy and PyTorch with the same interface?
I wrote the logic to handle matrix sizing to be agnostic of the matrix library being used. numpy and PyTorch are just backends. More backends can easily be added for your favorite Python matrix library.
```Python class Backend(metaclass=ABCMeta):
@abstractmethod
def extract_shape(self, x): pass
@abstractmethod
def build_eye(self, n): pass
@abstractmethod
def build_full(self, shape, fill_val): pass
@abstractmethod
def build(self, rows): pass
@abstractmethod
def is_complete(self, rows): pass
```
Getting Started
- Install:
pip install block - Usage:
from block import block - Run tests in
test.py:nosetests test.py
Issues and Contributions
I'd be happy to hear from you about any issues or features you add, please file an issue or send in a PR.
Licensing
This repository is Apache-licensed.
Owner
- Name: Brandon Amos
- Login: bamos
- Kind: user
- Location: NYC
- Company: Meta AI (FAIR)
- Website: http://bamos.github.io
- Twitter: brandondamos
- Repositories: 42
- Profile: https://github.com/bamos
GitHub Events
Total
- Watch event: 12
Last Year
- Watch event: 12
Committers
Last synced: about 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Brandon Amos | b****s@c****u | 33 |
| Eric Wong | e****g@c****u | 7 |
| Brandon Amos | b****s@g****m | 2 |
| chenyuntc | c****c@1****m | 1 |
| Benoit | 6****o | 1 |
| Alankar Dutta | d****r@g****m | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 10 months ago
All Time
- Total issues: 11
- Total pull requests: 10
- Average time to close issues: about 5 hours
- Average time to close pull requests: 9 days
- Total issue authors: 9
- Total pull request authors: 5
- Average comments per issue: 0.73
- Average comments per pull request: 0.3
- Merged pull requests: 9
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: 1 minute
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 1.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- bamos (3)
- aminzheng (1)
- dutta-alankar (1)
- rychong (1)
- take98 (1)
- kyillene (1)
- kingkongkai (1)
- GeoffNN (1)
- hbgtjxzbbx (1)
Pull Request Authors
- riceric22 (6)
- BenoitDalFerro (2)
- chenyuntc (1)
- sdahdah (1)
- bamos (1)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- pypi 316 last-month
- Total dependent packages: 0
- Total dependent repositories: 29
- Total versions: 5
- Total maintainers: 1
pypi.org: block
Improved block matrix creation for numpy and PyTorch.
- Homepage: https://github.com/bamos/block
- Documentation: https://block.readthedocs.io/
- License: Apache 2.0
-
Latest release: 0.0.5
published about 9 years ago
Rankings
Maintainers (1)
Dependencies
- numpy >=1<2