Skip to main content

A tiny Python library for generating, testing and ploting triangular and pentagonal numbers

Project description

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.

Project details


Download files

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

Source Distribution

figural-0.1.0.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

figural-0.1.0-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file figural-0.1.0.tar.gz.

File metadata

  • Download URL: figural-0.1.0.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.14.0 HTTPX/0.28.1

File hashes

Hashes for figural-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc6c8950e71516cb8a60f06111796516fc6ff247c5313ddcfcc615de5a7e2126
MD5 d24fbe28666e1b343bddd1d35d3e095f
BLAKE2b-256 85e93d8c2bbf2ccb2062ae3e987f062c7139266793e330cfb1466f3097a95447

See more details on using hashes here.

File details

Details for the file figural-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: figural-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: Hatch/1.16.2 cpython/3.14.0 HTTPX/0.28.1

File hashes

Hashes for figural-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ebbe68c0c4905c16d1950ac44c333f56682de3a304bed5c91d8a2c86069b214b
MD5 8026d97c5a16cf24cac8e45dadb2a909
BLAKE2b-256 68ea59fea7de23e53035837f06c58432a1e1d5e4aa0d17a82e091fa1244fd597

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page