{"id":15020460,"url":"https://github.com/sigma-py/npx","last_synced_at":"2026-03-14T17:36:18.426Z","repository":{"id":43318254,"uuid":"344859469","full_name":"sigma-py/npx","owner":"sigma-py","description":"Some useful extensions for NumPy","archived":false,"fork":false,"pushed_at":"2024-06-21T14:46:24.000Z","size":203,"stargazers_count":28,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T08:06:04.669Z","etag":null,"topics":["numpy","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sigma-py.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2021-03-05T15:54:11.000Z","updated_at":"2025-04-07T14:20:47.000Z","dependencies_parsed_at":"2024-10-30T02:28:30.640Z","dependency_job_id":null,"html_url":"https://github.com/sigma-py/npx","commit_stats":{"total_commits":136,"total_committers":2,"mean_commits":68.0,"dds":0.007352941176470562,"last_synced_commit":"64431cb45e45730a98c0c62075a92c630e182b74"},"previous_names":["sigma-py/npx","nschloe/npx"],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-py%2Fnpx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-py%2Fnpx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-py%2Fnpx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sigma-py%2Fnpx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sigma-py","download_url":"https://codeload.github.com/sigma-py/npx/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248843819,"owners_count":21170488,"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":["numpy","python"],"created_at":"2024-09-24T19:55:06.517Z","updated_at":"2026-03-14T17:36:13.401Z","avatar_url":"https://github.com/sigma-py.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# npx\n\n[![PyPi Version](https://img.shields.io/pypi/v/npx.svg?style=flat-square)](https://pypi.org/project/npx/)\n[![PyPI pyversions](https://img.shields.io/pypi/pyversions/npx.svg?style=flat-square)](https://pypi.org/project/npx/)\n[![GitHub stars](https://img.shields.io/github/stars/nschloe/npx.svg?style=flat-square\u0026logo=github\u0026label=Stars\u0026logoColor=white)](https://github.com/nschloe/npx)\n[![Downloads](https://pepy.tech/badge/npx/month?style=flat-square)](https://pepy.tech/project/npx)\n\n\u003c!--[![PyPi downloads](https://img.shields.io/pypi/dm/npx.svg?style=flat-square)](https://pypistats.org/packages/npx)--\u003e\n\n[![gh-actions](https://img.shields.io/github/workflow/status/nschloe/npx/ci?style=flat-square)](https://github.com/nschloe/npx/actions?query=workflow%3Aci)\n[![codecov](https://img.shields.io/codecov/c/github/nschloe/npx.svg?style=flat-square)](https://app.codecov.io/gh/nschloe/npx)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg?style=flat-square)](https://github.com/psf/black)\n\n[NumPy](https://numpy.org/) is a large library used everywhere in scientific computing.\nThat's why breaking backwards-compatibility comes at a significant cost and is almost\nalways avoided, even if the API of some methods is arguably lacking. This package\nprovides drop-in wrappers \"fixing\" those.\n\n[scipyx](https://github.com/nschloe/scipyx) does the same for\n[SciPy](https://www.scipy.org/).\n\nIf you have a fix for a NumPy method that can't go upstream for some reason, feel free\nto PR here.\n\n#### `dot`\n\n```python\nimport npx\nimport numpy as np\n\na = np.random.rand(3, 4, 5)\nb = np.random.rand(5, 2, 2)\n\nout = npx.dot(a, b)\n# out.shape == (3, 4, 2, 2)\n```\n\nForms the dot product between the last axis of `a` and the _first_ axis of `b`.\n\n(Not the second-last axis of `b` as `numpy.dot(a, b)`.)\n\n#### `np.solve`\n\n```python\nimport npx\nimport numpy as np\n\nA = np.random.rand(3, 3)\nb = np.random.rand(3, 10, 4)\n\nout = npx.solve(A, b)\n# out.shape == (3, 10, 4)\n```\n\nSolves a linear equation system with a matrix of shape `(n, n)` and an array of shape\n`(n, ...)`. The output has the same shape as the second argument.\n\n#### `sum_at`/`add_at`\n\n\u003c!--pytest.mark.skip--\u003e\n\n```python\nnpx.sum_at(a, idx, minlength=0)\nnpx.add_at(out, idx, a)\n```\n\nReturns an array with entries of `a` summed up at indices `idx` with a minimum length of\n`minlength`. `idx` can have any shape as long as it's matching `a`. The output shape is\n`(minlength,...)`.\n\nThe numpy equivalent `numpy.add.at` is _much_\nslower:\n\n\u003cimg alt=\"memory usage\" src=\"https://nschloe.github.io/npx/perf-add-at.svg\" width=\"50%\"\u003e\n\nRelevant issue reports:\n\n- [ufunc.at (and possibly other methods)\n  slow](https://github.com/numpy/numpy/issues/11156)\n\n#### `unique`\n\n```python\nimport npx\n\na = [0.1, 0.15, 0.7]\na_unique = npx.unique(a, tol=2.0e-1)\n\nassert all(a_unique == [0.1, 0.7])\n```\n\nnpx's `unique()` works just like NumPy's, except that it provides a parameter\n`tol` (default `0.0`) which allows the user to set a tolerance. The real line\nis essentially partitioned into bins of size `tol` and at most one\nrepresentative of each bin is returned.\n\n#### `unique_rows`\n\n```python\nimport npx\nimport numpy as np\n\na = np.random.randint(0, 5, size=(100, 2))\n\nnpx.unique_rows(a, return_inverse=False, return_counts=False)\n```\n\nReturns the unique rows of the integer array `a`. The numpy alternative `np.unique(a, axis=0)` is slow.\n\nRelevant issue reports:\n\n- [unique() needlessly slow](https://github.com/numpy/numpy/issues/11136)\n\n#### `isin_rows`\n\n```python\nimport npx\nimport numpy as np\n\na = [[0, 1], [0, 2]]\nb = np.random.randint(0, 5, size=(100, 2))\n\nnpx.isin_rows(a, b)\n```\n\nReturns a boolean array of length `len(a)` specifying if the rows `a[k]` appear in `b`.\nSimilar to NumPy's own `np.isin` which only works for scalars.\n\n#### `mean`\n\n```python\nimport npx\n\na = [1.0, 2.0, 5.0]\nnpx.mean(a, p=3)\n```\n\nReturns the [generalized mean](https://en.wikipedia.org/wiki/Generalized_mean) of a\ngiven list. Handles the cases `+-np.inf` (max/min) and`0` (geometric mean) correctly.\nAlso does well for large `p`.\n\nRelevant NumPy issues:\n\n- [generalized mean](https://github.com/numpy/numpy/issues/19341)\n\n### License\n\nThis software is published under the [BSD-3-Clause\nlicense](https://spdx.org/licenses/BSD-3-Clause.html).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigma-py%2Fnpx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsigma-py%2Fnpx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsigma-py%2Fnpx/lists"}