Skip to main content

WWU

CI PyPI License: MIT

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.

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

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

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:

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:

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

Metadata

Release files for wwu 0.1.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 wwu 0.1.0
File Size Uploaded Provenance Actions
wwu-0.1.0.tar.gz 11.0 kB With provenance Details for wwu-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wwu 0.1.0
File Interpreter ABI Platform Actions
wwu-0.1.0-py3-none-any.whl Python 3 none any Details for wwu-0.1.0-py3-none-any.whl

Total release size: 17.7 kB

Release files / wwu-0.1.0.tar.gz

Download URL wwu-0.1.0.tar.gz
Size 11.0 kB
Tags Source
SHA-256 checksum
How to use checksums
fdd472cd1188f90b9461c634c923c84807454c6cec04a53cf5e576a2d4c9006e
BLAKE2b-256 checksum
How to use checksums
4c7ab70e301f6a3ed739612e56f312cbdcb32e4093e153ac210a35fc2960662e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Release files / wwu-0.1.0-py3-none-any.whl

Download URL wwu-0.1.0-py3-none-any.whl
Size 6.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd2bbbf4f834db6c87b531b26c2bf58a3c691c6ea1b896b9e48b739d327551ef
BLAKE2b-256 checksum
How to use checksums
8b29b460070c85f3d0048a2251329591b45b9eaddbe334f8985c1920756efa49
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

Security for wwu 0.1.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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for wwu-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.

Transparency log

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.

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