{"id":28896018,"url":"https://github.com/34j/types-array-api","last_synced_at":"2026-04-07T04:31:38.695Z","repository":{"id":299332169,"uuid":"997732299","full_name":"34j/types-array-api","owner":"34j","description":"Autogenerated types for array-api-compat and array API - IDE friendly. `pip install types-array-api` and ready to go!","archived":false,"fork":false,"pushed_at":"2026-04-01T14:55:11.000Z","size":1141,"stargazers_count":6,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-01T16:32:37.581Z","etag":null,"topics":["array-api","array-api-typing","jax","mypy","mypy-stubs","numpy","python","pytorch","type-stubs","typing"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/34j.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["34j"]}},"created_at":"2025-06-07T04:11:19.000Z","updated_at":"2026-04-01T14:55:16.000Z","dependencies_parsed_at":"2025-06-16T02:23:44.819Z","dependency_job_id":"7355d014-d4d1-48de-941f-6b2b6ea9c562","html_url":"https://github.com/34j/types-array-api","commit_stats":null,"previous_names":["34j/types-array-api"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/34j/types-array-api","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Ftypes-array-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Ftypes-array-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Ftypes-array-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Ftypes-array-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/34j","download_url":"https://codeload.github.com/34j/types-array-api/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/34j%2Ftypes-array-api/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31500397,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["array-api","array-api-typing","jax","mypy","mypy-stubs","numpy","python","pytorch","type-stubs","typing"],"created_at":"2025-06-21T05:10:26.337Z","updated_at":"2026-04-07T04:31:38.678Z","avatar_url":"https://github.com/34j.png","language":"Python","readme":"# Python array API standard typing\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/34j/types-array-api/actions/workflows/ci.yml?query=branch%3Amain\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/actions/workflow/status/34j/types-array-api/ci.yml?branch=main\u0026label=CI\u0026logo=github\u0026style=flat-square\" alt=\"CI Status\" \u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://array-api.readthedocs.io\"\u003e\n    \u003cimg src=\"https://img.shields.io/readthedocs/types-array-api.svg?logo=read-the-docs\u0026logoColor=fff\u0026style=flat-square\" alt=\"Documentation Status\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://codecov.io/gh/34j/types-array-api\"\u003e\n    \u003cimg src=\"https://img.shields.io/codecov/c/github/34j/types-array-api.svg?logo=codecov\u0026logoColor=fff\u0026style=flat-square\" alt=\"Test coverage percentage\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/astral-sh/uv\"\u003e\n    \u003cimg src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/uv/main/assets/badge/v0.json\" alt=\"uv\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/astral-sh/ruff\"\u003e\n    \u003cimg src=\"https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json\" alt=\"Ruff\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://github.com/pre-commit/pre-commit\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white\u0026style=flat-square\" alt=\"pre-commit\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://pypi.org/project/types-array-api/\"\u003e\n    \u003cimg src=\"https://img.shields.io/pypi/v/types-array-api.svg?logo=python\u0026logoColor=fff\u0026style=flat-square\" alt=\"PyPI Version\"\u003e\n  \u003c/a\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/pyversions/types-array-api.svg?style=flat-square\u0026logo=python\u0026amp;logoColor=fff\" alt=\"Supported Python versions\"\u003e\n  \u003cimg src=\"https://img.shields.io/pypi/l/types-array-api.svg?style=flat-square\" alt=\"License\"\u003e\n\u003c/p\u003e\n\n---\n\n**Documentation**: \u003ca href=\"https://array-api.readthedocs.io\" target=\"_blank\"\u003ehttps://array-api.readthedocs.io \u003c/a\u003e\n\n**Source Code**: \u003ca href=\"https://github.com/34j/types-array-api\" target=\"_blank\"\u003ehttps://github.com/34j/types-array-api \u003c/a\u003e\n\n---\n\nTyping for array API and array-api-compat\n\n## Installation\n\nInstall this via pip (or your favourite package manager):\n\n```shell\npip install types-array-api\n```\n\n## Usage\n\n### Type stubs\n\nAutocompletion for [`array-api-compat`](https://data-apis.org/array-api-compat/) is available in your IDE **just by installing** this package.\n\n```python\nimport array_api_compat\n\nxp = array_api_compat.array_namespace(x)\n```\n\n![Screenshot 1](https://raw.githubusercontent.com/34j/array-api/main/docs/_static/screenshot1.png)\n![Screenshot 2](https://raw.githubusercontent.com/34j/array-api/main/docs/_static/screenshot2.png)\n\n### Typing functions using `Array`\n\nThere are multiple ways to type functions:\n\n- ```python\n  from array_api.latest import Array\n\n  def simple(x: Array) -\u003e Array:\n      return x + 1\n  ```\n\n  The simplest way to enjoy autocompletion for `Array`. This should be enough for most use cases.\n\n- To make sure that the same type of array is returned (`ndarray`→`ndarray`, `Tensor`→`Tensor`), a `TypeVar` bound to `Array` can be used:\n\n  ```python\n  def generic[TArray: Array](x: TArray) -\u003e TArray:\n      return x + 1\n  ```\n\n## Advanced Usage\n\n### Namespace Type\n\nYou can test if an object matches the Protocol as they are [`runtime-checkable`](https://docs.python.org/3/library/typing.html#typing.runtime_checkable):\n\n```python\nimport array_api_strict\n\nfrom array_api.latest import ArrayNamespace, ArrayNamespaceFull\n\n\nassert isinstance(array_api_strict, ArrayNamespace)\n# Full version contains fft and linalg\n# fft and linalg are not included by default in array_api_strict\nassert not isinstance(array_api_strict, ArrayNamespaceFull)\n```\n\n### Shape Typing\n\n- To clarify the input and output shapes, `ShapedArray` and `ShapedAnyArray` can be used:\n\n  ```python\n  from array_api.latest import ShapedAnyArray as Array\n\n  def sum_last_axis[*TShape](x: Array[*TShape, Any]) -\u003e Array[*TShape]:\n      return xp.sum(x, axis=-1)\n  ```\n\n  More complex example using [NewType](https://docs.python.org/3/library/typing.html#newtype) or [type aliases](https://docs.python.org/3/library/typing.html#type-aliases):\n\n  ```python\n  RTheta = NewType(\"RTheta\", int)\n  XY = NewType(\"XY\", int)\n  def polar_coordinates[*TShape](randtheta: Array[*TShape, RTheta]) -\u003e Array[*TShape, XY]:\n      \"\"\"Convert polar coordinates to Cartesian coordinates.\"\"\"\n      r = randtheta[..., 0]\n      theta = randtheta[..., 1]\n      x = r * xp.cos(theta)\n      y = r * xp.sin(theta)\n      return xp.stack((x, y), axis=-1)\n  ```\n\n  Note that `ShapedAnyArray` exists only for **documentation purposes** and internally it is treated as `Array`.\n  Using both generic and shaped are impossible due to [python/typing#548](https://github.com/python/typing/issues/548).\n\n- Note that the below example is ideal but impossible due to Python specification.\n\n  ```python\n  def impossible[\n      TDtype,\n      TDevice,\n      *TShapeFormer: int,\n      *TShapeLatter: int,\n      TArray: Array\n  ](x: TArray[*TShapeFormer, *TShapeLatter | Literal[1], TDtype, TDevice], y: TArray[*TShapeLatter | Literal[1], TDtype, TDevice]) -\u003e TArray[*TShapeFormer, *TShapeLatter, TDtype, TDevice]:\n      return x + y # broadcasting\n  ```\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003c!-- markdownlint-enable --\u003e\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Credits\n\n[![Copier](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/copier-org/copier/master/img/badge/badge-grayscale-inverted-border-orange.json)](https://github.com/copier-org/copier)\n\nThis package was created with\n[Copier](https://copier.readthedocs.io/) and the\n[browniebroke/pypackage-template](https://github.com/browniebroke/pypackage-template)\nproject template.\n","funding_links":["https://github.com/sponsors/34j"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F34j%2Ftypes-array-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F34j%2Ftypes-array-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F34j%2Ftypes-array-api/lists"}