{"id":19338549,"url":"https://github.com/bionumpy/npstructures","last_synced_at":"2025-07-24T15:38:51.660Z","repository":{"id":39582604,"uuid":"444434988","full_name":"bionumpy/npstructures","owner":"bionumpy","description":null,"archived":false,"fork":false,"pushed_at":"2025-03-24T10:40:29.000Z","size":3516,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-05-16T03:47:52.273Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/bionumpy.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","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":"AUTHORS.rst","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-04T13:45:49.000Z","updated_at":"2025-02-26T08:34:52.000Z","dependencies_parsed_at":"2024-04-12T12:42:34.845Z","dependency_job_id":"9b8d7c6c-4f51-46a3-8fd6-2baec447f9e4","html_url":"https://github.com/bionumpy/npstructures","commit_stats":{"total_commits":400,"total_committers":6,"mean_commits":66.66666666666667,"dds":0.235,"last_synced_commit":"791c7211ca810183bed68fd4c7fe17be7e64ed1c"},"previous_names":["knutdrand/npstructures"],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/bionumpy/npstructures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bionumpy%2Fnpstructures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bionumpy%2Fnpstructures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bionumpy%2Fnpstructures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bionumpy%2Fnpstructures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bionumpy","download_url":"https://codeload.github.com/bionumpy/npstructures/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bionumpy%2Fnpstructures/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261462731,"owners_count":23162021,"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":[],"created_at":"2024-11-10T03:17:48.693Z","updated_at":"2025-07-02T23:35:27.612Z","avatar_url":"https://github.com/bionumpy.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"================\nNumpy Structures\n================\n\n\n.. image:: https://img.shields.io/pypi/v/npstructures.svg\n        :target: https://pypi.python.org/pypi/npstructures\n\n.. image:: https://github.com/knutdrand/npstructures/actions/workflows/python-install-and-test.yml/badge.svg\n        :target: https://github.com/knutdrand/npstructures/actions/workflows/python-install-and-test.yml\n\n.. image:: https://readthedocs.org/projects/npstructures/badge/?version=latest\n        :target: https://npstructures.readthedocs.io/en/latest/?version=latest\n        :alt: Documentation Status\n\nSimple data structures that augments the numpy library\n\n\n* Free software: MIT license\n* Documentation: https://npstructures.readthedocs.io.\n\n\nFeatures\n--------\nThe main feature is the `RaggedArray` class which enables `numpy`-like behaviour and performance for arrays where\nthe length of the rows differ.\n\n`RaggedArray` is meant as a drop-in replacement for `numpy` when you have arrays with differing row lengths.\nAs such, familiarity with `numpy` is assumed. The simplest way to construct a `RaggedArray` is from a list of lists::\n\n    \u003e\u003e\u003e from npstructures import RaggedArray\n    \u003e\u003e\u003e ra = RaggedArray([[1, 2], [4, 1, 3, 7], [9], [8, 7, 3, 4]])\n\nA `RaggedArray` can be indexed much like a `numpy` array::\n\n    \u003e\u003e\u003e ra[1]\n    array([4, 1, 3, 7])\n    \u003e\u003e\u003e ra[1, 3]\n    7\n    \u003e\u003e\u003e ra[1:3]\n    RaggedArray([[4, 1, 3, 7], [9]])\n    \u003e\u003e\u003e ra[[0, 3]]\n    RaggedArray([[1, 2], [8, 7, 3, 4]])\n    \u003e\u003e\u003e ra[0] = [0, 0]\n    \u003e\u003e\u003e ra\n    RaggedArray([[0, 0], [4, 1, 3, 7], [9], [8, 7, 3, 4]])\n    \u003e\u003e\u003e ra[1:3] = [[10], [20]]\n    \u003e\u003e\u003e ra\n    RaggedArray([[0, 0], [10, 10, 10, 10], [20], [8, 7, 3, 4]])\n    \u003e\u003e\u003e ra[[0, 2, 3]] = RaggedArray([[2, 2], [3], [5, 5, 5, 5]])\n    \u003e\u003e\u003e ra\n    RaggedArray([[2, 2], [10, 10, 10, 10], [3], [5, 5, 5, 5]])\n\n`numpy ufuncs` can be applied to `RaggedArray` objects::\n\n    \u003e\u003e\u003e ra + 1\n    RaggedArray([[2, 3], [5, 2, 4, 8], [10], [9, 8, 4, 5]])\n    \u003e\u003e\u003e ra*2\n    RaggedArray([[2, 4], [8, 2, 6, 14], [18], [16, 14, 6, 8]])\n    \u003e\u003e\u003e ra + [[1], [10], [100], [1000]]\n    RaggedArray([[2, 3], [14, 11, 13, 17], [109], [1008, 1007, 1003, 1004]])\n    \u003e\u003e\u003e ra - (ra*2)\n    RaggedArray([[-1, -2], [-4, -1, -3, -7], [-9], [-8, -7, -3, -4]])\n\nSome `numpy` functions can be applied to `RaggedArray` objects::\n\n    \u003e\u003e\u003e import numpy as np\n    \u003e\u003e\u003e ra = RaggedArray([[1, 2], [4, 1, 3, 7], [9], [8, 7, 3, 4]])\n    \u003e\u003e\u003e np.concatenate((ra, ra*10))\n    RaggedArray([[1, 2], [4, 1, 3, 7], [9], [8, 7, 3, 4], [10, 20], [40, 10, 30, 70], [90], [80, 70, 30, 40]])\n    \u003e\u003e\u003e np.nonzero(ra\u003e3)\n    (array([1, 1, 2, 3, 3, 3]), array([0, 3, 0, 0, 1, 3]))\n    \u003e\u003e\u003e np.ones_like(ra)\n    RaggedArray([[1, 1], [1, 1, 1, 1], [1], [1, 1, 1, 1]])\n\n\nIn addition to this. `HashTable` and `Counter` provides simple `dict`-like behaviour for `numpy` arrays:\n\n`HashTable` can be used for `dict`-like functionality of `numpy` arrays. The simplest way to construct a `HashTable` is from an array of keys and an array of values (note that the set of keys cannot be modified after the initialization of the object)::\n\n    \u003e\u003e\u003e table = HashTable([11, 113, 1191, 11199], [2, 3, 5, 7])\n    \u003e\u003e\u003e table[11]\n    array([2])\n    \u003e\u003e\u003e table[[113, 11199]]\n    array([3, 7])\n    \u003e\u003e\u003e table[11]=1000\n    \u003e\u003e\u003e table\n    HashTable([  113  1191    11 11199], [   3    5 1000    7])\n    \u003e\u003e\u003e table[[113, 1191]]=2000\n    \u003e\u003e\u003e table\n    HashTable([  113  1191    11 11199], [2000 2000 1000    7])\n    \u003e\u003e\u003e table[[113, 1191, 11, 11191]] = [1, 2, 3, 4]\n    \u003e\u003e\u003e table[[113, 1191, 11, 11199]] = [1, 2, 3, 4]\n    \u003e\u003e\u003e table\n    HashTable([  113  1191    11 11199], [1 2 3 4])\n\n`Counter` objects supports counting the occurances of a predefined set of keys in a set of samples. For instance, to count the occurances of `3` and `1` in the list ``[3, 2, 1, 3, 4, 1, 1]``::\n\n    \u003e\u003e\u003e from npstructures import Counter\n    \u003e\u003e\u003e counter = Counter([3, 1])\n    \u003e\u003e\u003e counter.count([3, 2, 1, 3, 4, 1, 1])\n    \u003e\u003e\u003e counter\n    Counter([3 1], [2 3])\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbionumpy%2Fnpstructures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbionumpy%2Fnpstructures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbionumpy%2Fnpstructures/lists"}