{"id":19110984,"url":"https://github.com/peterluschny/table","last_synced_at":"2025-06-14T03:38:11.753Z","repository":{"id":252972575,"uuid":"841492438","full_name":"PeterLuschny/table","owner":"PeterLuschny","description":"The 100 most interesting integer triangles from the OEIS implemented in Python and providing a dozen methods for manipulating them.","archived":false,"fork":false,"pushed_at":"2025-01-02T18:50:51.000Z","size":2388,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-02T19:37:25.561Z","etag":null,"topics":["oeis","sequences","triangles"],"latest_commit_sha":null,"homepage":"https://peterluschny.github.io/table/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PeterLuschny.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-12T14:11:45.000Z","updated_at":"2025-01-02T18:50:55.000Z","dependencies_parsed_at":"2024-12-30T04:05:19.451Z","dependency_job_id":null,"html_url":"https://github.com/PeterLuschny/table","commit_stats":null,"previous_names":["peterluschny/tabels","peterluschny/table"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterLuschny%2Ftable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterLuschny%2Ftable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterLuschny%2Ftable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PeterLuschny%2Ftable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PeterLuschny","download_url":"https://codeload.github.com/PeterLuschny/table/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240165135,"owners_count":19758314,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oeis","sequences","triangles"],"created_at":"2024-11-09T04:26:41.422Z","updated_at":"2025-02-22T11:21:25.402Z","avatar_url":"https://github.com/PeterLuschny.png","language":"Python","readme":"![Tables](imag/IntegerTrianglesPy.png)\n\n# The objectives of this library\n\n* The library aims to provide the ~100 most interesting integer triangles listed in the OEIS. If you are new to this subject look into the [ranking](https://github.com/PeterLuschny/table/blob/main/data/Ranking.txt) of the triangles to see where to begin your studies.\n\n* In addition, it provides a dozen methods for manipulating the triangles.\n\n* Further, the library serves as the basis for a project in which the triangles are analyzed in more detail and connections to other sequences are investigated. You can take a look here: [TriangleAnalyser](https://peterluschny.github.io/tabl/Abel.html).\n\n# Installation\n\nCurrently there is only one dependency. Make sure your Python has the \"more_itertools\" package installed.\n\n* If you want to use the package only in one project just copy the file \"Tables.py\" (only this file!) into the root directory of your project.\n\n* If you want to install it globaly into your Python environment do this: Following the advice from [stackoverflow](https://stackoverflow.com/a/16196400) query the Python user directory in your shell:\n\n      python -m site --user-site\n\n  If the returned directory does not yet exist create it with:\n\n      mkdir -p \"the answer from the query\"\n\n  On Windows this creates the directory:\n\n      C:\\Users\\UserName\\AppData\\Roaming\\Python\\Python312\\site-packages\n\n  Then move the file Tables.py (only this file!) to this directory.\n\n* If you want to use it in a SageMath Jupyter notebook, then put on top of the file\n\n      load(\"Tables.py\")\n\n  Again you might have to put the file Tables.py in the same directory where the notebook is.\n\n* If you want to contribute to the development fork it on GitHub.\n\n\n# Example use\n\nFirst test the installation.\n\n ### Example 1\n    from Tables import QuickView\n\n    QuickView()\n\nThis shows the list of the sequences implemented.\n\nUse a Table from the library:\n\n ### Example 2\n    from Tables import PreView, StirlingSet\n\n    PreView(StirlingSet)\n\n### Example 3\n\nDifferent ways to display a Table:\n\n    Abel.show(7)\n    print(Abel.tab(7))\n    print(list(flatten(Abel.itr(7))))\n\n    # Use the Table as an iterable:\n    rows = Abel.itr(7)\n    for r in rows:\n        print(r, sum(r))\n\nNext define your own Table:\n\n ### Example 4\n    from Tables import Table, PreView\n    from functools import cache\n    from math import comb as binomial\n\n    @cache\n    def abel(n: int) -\u003e list[int]:\n        if n == 0: return [1]\n        return [binomial(n - 1, k - 1) * n ** (n - k) if k \u003e 0 else 0\n                for k in range(n + 1)]\n\n    Abel = Table(abel, \"Abel\", [\"A137452\", \"A061356\", \"A139526\"], True)\n\n    PreView(Abel)\n\n\n# The methods\n\nThere is only one constructor: Table(...). The parameters are:\n\n    row:  gen                 # The row generator, gen(n:int) -\u003e list[int].\n    id:   str                 # The name of the triangle.\n    sim:  list[str] = ['']    # References to similar OEIS-sequences.\n    invQ: bool | None = None  # Is the triangle invertible?\n                              # Default 'None' means 'I do not know'.\n\nThe row generator is a function of type: g(n: int) -\u003e list[int] defined for all nonnegative n.\nThis function should be decorated with '@cache' and return a list of integers of length n + 1.\n\nA Table T provides the following methods:\n\n    off (N: int, K: int) -\u003e rgen | new offset (N, K)\n    val (n:int, k:int)   -\u003e int  | T(n, k)\n    poly(n: int, x: int) -\u003e int  | sum(T(n, k) * x^j for j=0..n)\n    flat (size: int)     -\u003e list[int] | flattened form of the first size rows\n    diag(n, size: int)   -\u003e list[int] | diagonal starting at the left side\n    col (k, size: int)   -\u003e list[int] | k-th column starting at the main diagonal\n    sum (size: int)      -\u003e list[int] | sums of the first size rows\n    antidiag (size: int) -\u003e list[int] | upward anti-diagonals\n    row (n: int)         -\u003e trow | n-th row of table\n    rev (size: int)      -\u003e trow | reversed rows\n    acc (size: int)      -\u003e trow | accumulated row \n    alt (size: int)      -\u003e trow | alternating signs \n    diff (size: int)     -\u003e trow | first difference of row\n    der (size: int)      -\u003e trow | derivative of row\n    tab (size: int)      -\u003e tabl | table with size rows\n    mat (size: int)      -\u003e tabl | matrix form of lower triangular array\n    inv (size: int)      -\u003e tabl | inverse table\n    revinv (size: int)   -\u003e tabl | row reversed inverse\n    invrev (size: int)   -\u003e tabl | inverse of row reversed\n    revinv11 (size: int) -\u003e tabl | revinv from offset (1, 1)\n    invrev11 (size: int) -\u003e tabl | invrev from offset (1, 1)\n    trans(s: seq, size)  -\u003e list[int] | linear transformation induced by T\n    invtrans(s: seq, size) -\u003e list[int] | inverse transformation induced by T\n    show (size: int)     -\u003e None | prints the first 'size' rows with row-numbers\n    itr (size: int)      -\u003e Iterator[list[int]] | traverse the first 'size' rows\n\nThe type 'tabl' is a triangular array that is a list of lists of the form\n[[0] * (n + 1) for n in range(size)] representing the first 'size' rows of\nthe triangle.\n\n\n# For developers\n\nYou are invited to share your code and add it to the library. Only sequences already in the OEIS will be considered. Please send a pull request!\n\nObserve the design constraints:\n\n  1) No use of extern modules like SymPy or NumPy; only use standard modules, but the use of the package [more-itertools](https://pypi.org/project/more-itertools/) is OK.\n\n  2) All tables are (0,0)-based. If the table in the OEIS is (1,1)-based, adapt it. Often the best way to do this is to prepend a column (1, 0, 0, ...) to the left of the table.\n\n  3) Keep the design philosophy you see in the code: base the implementations on the rows of a triangle, not on the individual T(n, k), whenever possible. In other words, we regard a triangle as a 1-dim sequence of lists, not as a 2-dim matrix of terms.\n\n  4) We do not aim for one-liners. Readability is important.\n\nWorkflow:\n\n  1) Copy the Template.py file, rename the copy \"Myseq.py\", and replace in the file the function \"template\" with your sequence function \"myseq\" and the class \"Template\" by \"Myseq\". Note the case sensitivity and that \"@cache\" for \"myseq\" is mandatory.\n\n  2) In the file _tablmake insert the names \"Myseq.py\" and \"Myseq\" in the list of files and classes.\n\n  3) Execute the file _tablmake (producing a new Tables.py). Done.\n\n\n# Contributing\n\nContributions are what make the open source community such an amazing place to be learn, inspire, and create. We greatly appreciated any contributions that follow the above guidelines.\n\n  1) Fork the Project\n  2) Create your Feature Branch (`git checkout -b branch/AmazingTriangle`)\n  3) Commit your Changes (`git commit -m 'Add some AmazingTriangle'`)\n  4) Push to the Branch (`git push origin branch/AmazingTriangle`)\n  5) Open a Pull Request\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterluschny%2Ftable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterluschny%2Ftable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterluschny%2Ftable/lists"}