Metadata-Version: 2.4
Name: matrix-dict
Version: 1.0.0
Summary: A 100x100 dictionary-based matrix with 10,000 accessible indexes
Author-email: amphibiar <amphibiar@example.com>
License: MIT
Project-URL: Homepage, https://github.com/amphibiar/matrix-dict
Project-URL: Repository, https://github.com/amphibiar/matrix-dict
Project-URL: Issues, https://github.com/amphibiar/matrix-dict/issues
Keywords: matrix,dictionary,data-structure,100x100,grid
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Scientific/Engineering :: Mathematics
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"

# 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

```bash
pip install matrix-dict
```

Or from source:
```bash
git clone https://github.com/amphibiar/matrix-dict
cd matrix-dict
pip install -e .
```

## Quick Start

```python
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
