<commit_before># rectpack

Rectpack is a collection of algorithms for solving the 2D knapsack problem,
or packing as much rectangles as possible into another one.

![alt tag](docs/maxrects.png)


Installation
============

Just dowload the package or clone the repository, Then install with:

```bash
python setup.py install
```

Basic Usage
===========

Packing rectangles in a number of bins is very simple:

```python
from rectpack import newPacker

rectangles = [(100, 30), (40, 60), (30, 30), .....]
bins = [(300, 450), (80, 40), ...]

packer = newPacker()

# Add all the rectangles to be packed
for r in rectangles:
	packer.add_rect(*r)

# Add bins where the rectangles will be placed
for b in bins:
	packer.add_bin(*b)

# Do packing
packer.pack()

# Iterate through each bin and obtain a list of rectangle positions
# format [(x0, y0, w0, h0, rid0), (x1, y1, w1, h1, rid1), ...]<commit_msg>Added pip to installation instruction<commit_after># rectpack

Rectpack is a collection of algorithms for solving the 2D knapsack problem,
or packing as much rectangles as possible into another one.

![alt tag](docs/maxrects.png)


Installation
============

Just dowload the package or clone the repository, Then install with:

```bash
python setup.py install
```

or using pypi

```bash
pip install rectpack
```

Basic Usage
===========

Packing rectangles in a number of bins is very simple:

```python
from rectpack import newPacker

rectangles = [(100, 30), (40, 60), (30, 30), .....]
bins = [(300, 450), (80, 40), ...]

packer = newPacker()

# Add all the rectangles to be packed
for r in rectangles:
	packer.add_rect(*r)

# Add bins where the rectangles will be placed
for b in bins:
	packer.add_bin(*b)

# Do packing
packer.pack()

# Iterate through each bin and obtain a list of rectangle positions
# format [(x0, y0, w0, h0, rid0), (x1, y1, w1, h1, rid1), ...]
{'fraction_non_alphanumeric': 0.13497589716122121, 'fraction_numerical': 0.03642206748794858, 'mean_word_length': 4.23249299719888, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1102233', 'n_tokens_mistral': 676, 'n_tokens_neox': 602, 'n_words': 257}