block

An intelligent block matrix library for numpy, PyTorch, and beyond.

https://github.com/bamos/block

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

deep-learning linear-algebra numpy pytorch
Last synced: 9 months ago · JSON representation

Repository

An intelligent block matrix library for numpy, PyTorch, and beyond.

Basic Info
  • Host: GitHub
  • Owner: bamos
  • License: apache-2.0
  • Language: Python
  • Default Branch: master
  • Homepage:
  • Size: 188 KB
Statistics
  • Stars: 310
  • Watchers: 13
  • Forks: 32
  • Open Issues: 5
  • Releases: 0
Topics
deep-learning linear-algebra numpy pytorch
Created over 9 years ago · Last pushed almost 2 years ago
Metadata Files
Readme License

README.md

Block • License PyPi

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)

GitHub Events

Total
  • Watch event: 12
Last Year
  • Watch event: 12

Committers

Last synced: about 1 year ago

All Time
  • Total Commits: 45
  • Total Committers: 6
  • Avg Commits per committer: 7.5
  • Development Distribution Score (DDS): 0.267
Past Year
  • Commits: 1
  • Committers: 1
  • Avg Commits per committer: 1.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email 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.

  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 29
  • Downloads: 316 Last month
Rankings
Dependent repos count: 2.7%
Stargazers count: 3.7%
Average: 6.2%
Forks count: 6.8%
Downloads: 8.0%
Dependent packages count: 10.0%
Maintainers (1)
Last synced: 9 months ago

Dependencies

setup.py pypi
  • numpy >=1<2