Skip to content

Commit

Permalink
view
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterLuschny committed Jun 8, 2022
1 parent 8030ec6 commit 3032ba9
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 12 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
## tabl
Python implementations of integer sequences dubbed tabl in the OEIS.


## src
```python
def isTablGenerator(
Expand All @@ -22,5 +21,9 @@ def isTablGenerator(
)
```

## docs
For the [user](https://github.com/PeterLuschny/tabl/blob/main/docs/PythonIntegerTriangles.html),
for the [implementer](https://github.com/PeterLuschny/tabl/blob/main/docs/ImplementationNotes.md).

## install
python -m pip install "tabl @ git+https://github.com/PeterLuschny/tabl.git"
python -m pip install "tabl @ git+https://github.com/PeterLuschny/tabl.git"
19 changes: 19 additions & 0 deletions docs/ImplementationNotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
***Under construction***

# Design Goals

* Consistent presentation
(all triangles are (0,0)-based, no fiddling with offsets).

* Consistent representations
(by uniform use of the ``TablGenerator``).

* Implementations uniformly based on rows, not on terms.

* High performance.

* No use of external libraries.

* A simple swiss-knife user interface.

* Guides the user through the tabl jungle in the ``oeis`` to the most useful and intriguing integer triangles.
27 changes: 23 additions & 4 deletions docs/PythonIntegerTriangles.html
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,32 @@ <h2>The user interface</h2>
&nbsp;&nbsp;&nbsp;&nbsp;[1, 5, 10, 10, 5, 1]]
</p>

<p>🔶 Example: The returned format is either term, row or triangle. <br>
Note that all tabls are (0,0)-based, i.e. the index of the first row in a tabl is 0 and the index of the first term in a row is 0.</p>
<p>🔶 Note: The returned type is either term, row or triangle.
All tabls are (0,0)-based, i.e. the index of the first row in a tabl is 0 and the index of the first term in a row is 0.</p>
<lu><li style="color:darkorange">Term: binomial(0,0) = 1</li>
<li style="color:darkorange">First row:&nbsp; binomial(0) = [1]</li>
<li style="color:darkorange">Tabl with one row:&nbsp; binomial(-1) = [[1]]</li>
</lu>
<h2>The Implementation</h2>

<h2 style="margin-top: 2em; font-weight:bolder;">
Example use</h2>
<pre>
from tabl import binomial

print("binomial(1000, 500) =")
print( binomial(1000, 500))
</pre>

<p>The module also provides a number of utility functions which allow to view the triangle in different representations (as a triangular or a rectangular array).</p>
<pre>
from tabl import binomial, PrintViews

# The second parameter controls the dimension of the table.
PrintViews(binomial, 8)
</pre>


<h2>The implementation</h2>
<pre>
from functools import cache

Expand All @@ -239,7 +258,7 @@ <h2>The Implementation</h2>
return _b(n)[k]
</pre>

<h2>The type 'TablGenerator'.</h2>
<h2>The type 'TablGenerator'</h2>
<p>
A function has type 'TablGenerator' if its signature is
</p>
Expand Down
2 changes: 1 addition & 1 deletion src/tablformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def PrintColArray(F, rows, cols):
print([F(j + k, j) for k in range(rows)])


def PrintAll(T, rows, cols=None):
def PrintViews(T, rows, cols=None):
if cols == None: cols = rows
print()
PrintRows(T(-rows))
Expand Down
4 changes: 2 additions & 2 deletions src/tabltest.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from tablformat import PrintAll
from tablformat import PrintViews
from tablgenerator import isTablGenerator
from sys import setrecursionlimit


def TablTest(seq: callable, dim=7, short=False):

PrintAll(seq, dim)
PrintViews(seq, dim)

seqname = seq.__name__
print("py>", seqname, "(5) =", seq(5))
Expand Down
2 changes: 1 addition & 1 deletion tabl.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def PrintRowArray(F, rows, cols):
def PrintColArray(F, rows, cols):
for j in range(cols):
print([F(j + k, j) for k in range(rows)])
def PrintAll(T, rows, cols=None):
def PrintViews(T, rows, cols=None):
if cols == None: cols = rows
print()
PrintRows(T(-rows))
Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from tabl import motzkin, PrintAll
from tabl import motzkin, PrintViews

PrintAll(motzkin, 8)
PrintViews(motzkin, 8)

print("motzkin(1000, 500) =")
print( motzkin(1000, 500))

0 comments on commit 3032ba9

Please sign in to comment.