Metadata-Version: 2.4
Name: wwu
Version: 0.1.0
Summary: Find the optimal way up to store your boxes.
Author-email: Rob Horton <vulgarmessiah@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/Um9i/wwu
Project-URL: Download, https://pypi.org/project/wwu/#files
Keywords: boxes,containers,inventory,permutation,combinatorics
Classifier: Development Status :: 3 - Alpha
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: Operating System :: OS Independent
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Utilities
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest; extra == "test"
Provides-Extra: lint
Requires-Dist: ruff; extra == "lint"
Dynamic: license-file

# WWU

[![CI](https://github.com/Um9i/wwu/actions/workflows/ci.yml/badge.svg)](https://github.com/Um9i/wwu/actions/workflows/ci.yml)
[![PyPI](https://img.shields.io/pypi/v/wwu.svg)](https://pypi.org/project/wwu/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)

**Which Way Up?** — Pack more boxes into less space.

WWU finds the optimal orientation for storing a box in a given storage space, maximising how many fit. Just pass in your box size and storage dimensions, and WWU tells you which way to turn it.

On a shelf 100 cm wide and 60 cm deep, with 20 cm of clearance, a 30 × 20 × 20 cm carton fits three across and three deep. Turn every carton a quarter turn and five across by two deep gives **10 cartons instead of 9**.

```python
from wwu import Box

carton = Box(20, 30, 20)  # height, width, depth in cm
layout = carton.best_orientation(20, 100, 60)
print(layout.box_count)  # 10
```

The calculation compares uniform layouts of identical boxes. Use the usable internal dimensions after allowing for clearance.

## Contents

- [Permutation Index](#permutation-index)
- [Examples](#examples)
- [How It Works](#how-it-works)
- [Limitations](#limitations)
- [Installation](#installation)
- [Requirements](#requirements)
- [Contributing](#contributing)

## Permutation Index

The returned index (0–5) maps to orientation as follows for a box with dimensions `(H, W, D)`:

| Index | Orientation |
|-------|-------------|
| 0     | (H, W, D)  |
| 1     | (H, D, W)  |
| 2     | (W, H, D)  |
| 3     | (W, D, H)  |
| 4     | (D, H, W)  |
| 5     | (D, W, H)  |

## Examples

```py
from wwu import Box

b = Box(10, 10, 20)  # Create a box with 10 x 10 x 20 dimensions.
b.wwu(10, 10, 20)  # Find the optimal permutation in storage of 10 x 10 x 20
# >>> 0

b.wwu(20, 10, 10)  # Different storage shape picks a different orientation
# >>> 4
```

For more detail, use `best_orientation()` which returns the index, the dimension
ordering, and how many boxes fit:

```py
from wwu import Box

b = Box(10, 10, 20)
result = b.best_orientation(40, 20, 20)
print(result.perm_index)  # Orientation index
print(result.dimensions)  # The dimension ordering used
print(result.box_count)  # Number of boxes that fit
```

Dimensions are validated — zero, negative, or non-numeric values raise an error:

```py
Box(-1, 10, 20)  # ValueError: Box height must be positive
b.wwu(10, 10, "ten")  # TypeError: Storage depth must be a number
```

## How It Works

Use the same unit for all six dimensions. WWU takes integers exactly and interprets
each float as the decimal value shown by Python’s `str()`. For example, three
`0.1` m cartons fit along a `0.3` m shelf. A computed dimension such as
`0.1 + 0.2` is treated as `0.30000000000000004` m and exceeds that shelf.

For each of the 6 permutations of the box's `(height, width, depth)`, WWU computes
how many boxes fit along each storage axis independently (`floor(storage_axis / box_axis)`)
and multiplies them together to get a total box count for that orientation. It returns
whichever permutation yields the highest count.

## Limitations

WWU answers "how many identical boxes fit, axis-aligned, in a grid?" — it is not a
general bin-packing or mixed-carton solver. In particular:

- All boxes are assumed to be the same size (one `Box` per call).
- Boxes are placed on a uniform grid along each axis; it does not try irregular or
  interlocking arrangements that could fit more boxes into leftover space.
- Rotations are limited to the 6 axis-aligned permutations of height/width/depth —
  no diagonal or off-axis placement.

## Installation

```
pip install wwu
```

## Requirements

Python 3.11+. No runtime dependencies.

## Contributing

```
git clone https://github.com/Um9i/wwu.git
cd wwu
pip install -e ".[test,lint]"

pytest        # run tests
ruff check .  # lint
```
