Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

A small utility to compute the squarest pair of divisors for an integer.

Project description

# squarest-divisors

A small utility to compute the squarest pair of divisors for an integer.

# Installation

Install from PyPI:

```
$ pip install sqdiv
```

# Usage

The original intended usage is with `matplotlib`, to automatically figure out how many rows and columns are needed based on the number of subplots I actually need to plot.

Let's say I had a series of 11 things I needed to plot on a `matplotlib` figure, something akin to a [`seaborn.FacetGrid`](https://seaborn.pydata.org/generated/seaborn.FacetGrid.html), but with some custom things added.

```python
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from sqdiv import n_rows_cols

height = 3
nrows, ncols = n_rows_cols(len(labels)) # len(labels) == 11
fig = plt.figure(figsize=(ncols * height, nrows * height))
gs = GridSpec(nrows=nrows, ncols=ncols)

# Now, setup the axes to plot on.
axes = dict()
for i, c in enumerate(labels):
# This allows us to share axes across the plots.
if i != 0:
axes[c] = fig.add_subplot(gs[i], sharey=axes[labels[0]])
else:
axes[c] = fig.add_subplot(gs[i])
axes[c].set_title(f'{c}')
axes[c].set_xlabel('x')
axes[c].set_ylabel('y')

# Below here, plot to your heart's content on each axes object.
```

The trivial case (1 by number of items) is not provided as part of the functionality because, hey, it's trivial!

# Feature Requests

Contributions are welcome. If you'd like to submit something, let's discuss on the [GitHub Issues tracker](https://github.com/ericmjl/squarest-divisors/issues) first.

Because `sqdiv` is currently maintained by volunteers and has no fiscal support, any feature requests will be prioritized according to what maintainers encounter as a need in our day-to-day jobs. Please temper expectations accordingly.


Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for sqdiv, version 0.1
Filename, size File type Python version Upload date Hashes
Filename, size sqdiv-0.1-py3-none-any.whl (2.6 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size sqdiv-0.1.tar.gz (2.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page