Figural
A tiny library for generating, evaluating, and plotting triangular and pentagonal numbers in Python.
Installation
You can install figural using pip:
pip install figural
Or from source (here I am using uv) but you can use any Python environment of your choice:
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
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
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
tr.draw_ith(5, with_label=True)
tr.draw_ith(5, with_label=True, color="red", marker_style="^", draw_contourn=False)
pn.draw_ith(5, with_label=True, color="green")
tr.draw_ith(3, with_label=True, return_tikz=True)
'% 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
tr.draw_range(1, 6, with_label=True, cols=3, draw_grid=True)
pn.draw_range(1, 8, with_label=True, cols=4, draw_grid=True, color='blue')
Contributing
Sure thing! Feel fre to open an issue or create a pull request.
Metadata
Release files for figural 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| figural-0.1.0.tar.gz | 5.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| figural-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.4 kB
Release files / figural-0.1.0.tar.gz
| Download URL | figural-0.1.0.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dc6c8950e71516cb8a60f06111796516fc6ff247c5313ddcfcc615de5a7e2126
|
|
BLAKE2b-256 checksum How to use checksums |
85e93d8c2bbf2ccb2062ae3e987f062c7139266793e330cfb1466f3097a95447
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.2 cpython/3.14.0 HTTPX/0.28.1
|
Release files / figural-0.1.0-py3-none-any.whl
| Download URL | figural-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ebbe68c0c4905c16d1950ac44c333f56682de3a304bed5c91d8a2c86069b214b
|
|
BLAKE2b-256 checksum How to use checksums |
68ea59fea7de23e53035837f06c58432a1e1d5e4aa0d17a82e091fa1244fd597
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.2 cpython/3.14.0 HTTPX/0.28.1
|