Metadata-Version: 2.4
Name: figural
Version: 0.1.0
Summary: A tiny Python library for generating, testing and ploting triangular and pentagonal numbers
Project-URL: Homepage, https://github.com/twaclaw/figural
Project-URL: Documentation, https://github.com/twaclaw/figural
Project-URL: Issues, https://github.com/twaclaw/figural/issues
Author-email: Diego Sandoval <dsandovalv@gmail.com>
Maintainer-email: Diego Sandoval <dsandovalv@gmail.com>
Keywords: figural,numpy,pentagonal numbers,triangular numbers
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX
Classifier: Operating System :: Unix
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
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: Topic :: Scientific/Engineering
Requires-Python: >=3.11
Requires-Dist: matplotlib>=3.10.7
Requires-Dist: numpy>=2.3.5
Requires-Dist: tikzplotlib>=0.10.1
Provides-Extra: dev
Requires-Dist: hatch; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Description-Content-Type: text/markdown

# Figural

> A tiny library for generating, evaluating, and plotting triangular and pentagonal numbers in Python.

## Installation

You can install `figural` using pip:

```bash
pip install figural
```

Or from source (here I am using [uv](https://docs.astral.sh/uv/getting-started/installation/)) but you can use any Python environment of your choice:

```bash
git clone https://github.com/twaclaw/figural.git
cd figural
uv venv --python=3.14
source ./venv/bin/activate
uv pip install -e .
```

## Examples

### Generating the ith numbers and testing for membership

```python
import figural.triangular as tr
import figural.pentagonal as pn

tr.ith(5)
# 15

pn.ith(5)
# 35

tr.is_triangular(15)
# np.True_

pn.is_pentagonal(pn.ith(10000000))
# np.True_
```

### Generating ranges

```python
import figural.triangular as tr
import figural.pentagonal as pn
import numpy as np

tr.arange(10)
# array([ 1,  3,  6, 10, 15, 21, 28, 36, 45])

pn.arange(10)
# array([  1,   5,  12,  22,  35,  51,  70,  92, 117, 145])

np.all(pn.is_pentagonal(pn.arange(int(1e8))))
# np.True_
```

### Plotting individual numbers

```python
tr.draw_ith(5, with_label=True)
```

![](./figures/tr1.svg)

```python
tr.draw_ith(5, with_label=True, color="red", marker_style="^", draw_contourn=False)
```

![](./figures/tr2.svg)

```python
pn.draw_ith(5, with_label=True, color="green")
```

![](./figures/pn1.svg)

```python
tr.draw_ith(3, with_label=True, return_tikz=True)
```

```latex
'% This file was created with tikzplotlib v0.10.1.\n\\begin{tikzpicture}\n\n\\definecolor{darkgrey176}{RGB}{176,176,176}\n\n\\begin{axis}[\nhide x axis,\nhide y axis,\ntick align=outside,\ntick pos=left,\nx grid style={darkgrey176},\nxmin=-0.05, xmax=1.05,\nxtick style={color=black},\ny grid style={darkgrey176},\nymin=-0.05, ymax=1.05,\nytick style={color=black}\n]\n\\addplot [black]\ntable {%\n0 0\n1 0\n0.5 1\n0 0\n};\n\\addplot [semithick, black, mark=*, mark size=5, mark options={solid}, only marks]\ntable {%\n0 0\n0.5 0\n1 0\n};\n\\addplot [semithick, black, mark=*, mark size=5, mark options={solid}, only marks]\ntable {%\n0.25 0.5\n0.75 0.5\n};\n\\addplot [semithick, black, mark=*, mark size=5, mark options={solid}, only marks]\ntable {%\n0.5 1\n};\n\\draw (axis cs:0.5,-0.25) node[\n  scale=0.6,\n  anchor=north,\n  text=black,\n  rotate=0.0\n]{$T_{3}=6$};\n\\end{axis}\n\n\\end{tikzpicture}\n'
```

### Plotting ranges of numbers

```python
tr.draw_range(1, 6, with_label=True, cols=3, draw_grid=True)
```

![](./figures/tr3.svg)

```python
pn.draw_range(1, 8, with_label=True, cols=4, draw_grid=True, color='blue')
```

![](./figures/pn2.svg)

## Contributing

Sure thing! Feel fre to open an issue or create a pull request. 