Skip to main content

matrix-dict

A 100x100 dictionary-based matrix with 10,000 accessible indexes for Python.

Features

  • Fixed 100x100 size - Exactly 10,000 cells
  • Dictionary-like access - Use (row, col) tuple keys
  • Default values - Initialize all cells with a default
  • Bulk operations - Set/get entire rows, columns, or submatrices
  • Iteration - Iterate over all 10,000 positions efficiently
  • Slicing - Extract rectangular submatrices
  • List conversion - Convert to/from nested lists
  • Type hints - Full typing support

Installation

pip install matrix-dict

Or from source:

git clone https://github.com/amphibiar/matrix-dict
cd matrix-dict
pip install -e .

Quick Start

from matrix_dict import create_matrix

# Create a 100x100 matrix with default value 0
matrix = create_matrix(default_value=0)

# Set individual cells
matrix[(0, 0)] = 100
matrix[(50, 50)] = 2500

# Access cells
value = matrix[(0, 0)]  # 100

# Fill with a loop
for row in range(100):
    for col in range(100):
        matrix[(row, col)] = row * 100 + col

# Or iterate directly
for (row, col), _ in matrix:
    matrix[(row, col)] = row * 100 + col

# Get entire row/column
row_5 = matrix.get_row(5)   # [500, 501, ..., 599]
col_3 = matrix.get_col(3)   # [3, 103, 203, ..., 9903]

# Set entire row/column
matrix.set_row(0, [i * 2 for i in range(100)])
matrix.set_col(5, [i * 3 for i in range(100)])

# Submatrix operations
sub = matrix.get_submatrix(0, 10, 0, 10)  # 10x10 top-left
matrix.set_submatrix(20, 20, [[1, 2], [3, 4]])

# Check if explicitly set
if (50, 50) in matrix:
    print("Cell was set")

# Convert to/from list
data = matrix.to_list()           # 100x100 list of lists
new_matrix = MatrixDict.from_list(data)

API Reference

create_matrix(default_value=None) -> MatrixDict

Factory function to create a new matrix.

MatrixDict(default_value=None)

Main class. Initialize with optional default value for all 10,000 cells.

Item Access

  • matrix[(row, col)] = value - Set cell
  • value = matrix[(row, col)] - Get cell (returns default if not set)
  • (row, col) in matrix - Check if explicitly set

Bulk Operations

  • matrix.fill(value) - Fill all 10,000 cells
  • matrix.clear() - Clear all explicitly set values
  • matrix.set_row(row, values) - Set row from list of 100
  • matrix.set_col(col, values) - Set column from list of 100
  • matrix.get_row(row) -> List - Get row as list
  • matrix.get_col(col) -> List - Get column as list

Submatrix

  • matrix.get_submatrix(r_start, r_end, c_start, c_end) -> List[List]
  • matrix.set_submatrix(row_start, col_start, values)

Iteration

  • for (row, col), value in matrix: - All 10,000 positions
  • matrix.iterate_row(row) - Iterate (col, value) in row
  • matrix.iterate_col(col) - Iterate (row, value) in column
  • matrix.items() - Explicitly set (key, value) pairs
  • matrix.keys() - Explicitly set keys
  • matrix.values() - Explicitly set values

Conversion

  • matrix.to_list() - Convert to 100x100 list of lists
  • MatrixDict.from_list(data, default_value) - Create from list

Requirements

  • Python 3.8+

License

MIT

Metadata

Release files for matrix-dict 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for matrix-dict 1.0.0
File Size Uploaded Provenance Actions
matrix_dict-1.0.0.tar.gz 4.0 kB Without provenance Details for matrix_dict-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for matrix-dict 1.0.0
File Interpreter ABI Platform Actions
matrix_dict-1.0.0-py3-none-any.whl Python 3 none any Details for matrix_dict-1.0.0-py3-none-any.whl

Total release size: 6.6 kB

Release files / matrix_dict-1.0.0.tar.gz

Download URL matrix_dict-1.0.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b7df812b3004d0f44644b714194816c55fc0f74c20c1d5771b20cbef663ffd34
BLAKE2b-256 checksum
How to use checksums
f2745024e03d1dc1b151003553c720d9437bfb550e4b04fe0aba20b43e74e7bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / matrix_dict-1.0.0-py3-none-any.whl

Download URL matrix_dict-1.0.0-py3-none-any.whl
Size 2.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be4643ae517eecc9e5a141a162c759ea5ba9597620b47454a2654a2678a382d8
BLAKE2b-256 checksum
How to use checksums
da3080d263e8e4f210b1d8dd6bb1931463bb5816a2765525587609c5329e3f9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for matrix-dict 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page