{"id":17044386,"url":"https://github.com/srush/anynp","last_synced_at":"2025-04-12T15:13:27.286Z","repository":{"id":244977530,"uuid":"816889317","full_name":"srush/anynp","owner":"srush","description":"Proof-of-concept of global switching between numpy/jax/pytorch in a library. ","archived":false,"fork":false,"pushed_at":"2024-06-18T15:54:53.000Z","size":8,"stargazers_count":18,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-12T15:13:23.536Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/srush.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-06-18T15:35:51.000Z","updated_at":"2024-09-04T17:35:06.000Z","dependencies_parsed_at":"2024-06-18T20:00:07.138Z","dependency_job_id":null,"html_url":"https://github.com/srush/anynp","commit_stats":null,"previous_names":["srush/anynp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srush%2Fanynp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srush%2Fanynp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srush%2Fanynp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/srush%2Fanynp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/srush","download_url":"https://codeload.github.com/srush/anynp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248586244,"owners_count":21128998,"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-10-14T09:34:13.779Z","updated_at":"2025-04-12T15:13:27.265Z","avatar_url":"https://github.com/srush.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# anynp\nProof-of-concept of global switching between numpy/jax/pytorch in a library. \n\nThis is a wrapper around the Array API and the `array_api_compat` lib. It adds a stub for the `np` type so that mypy doesn't complain and a context handler. \n\n\n```python\nfrom switcher import switch, XP\nfrom numpy.typing import ArrayLike \n\ndef my_fun(x) -\u003e ArrayLike:\n    array = switch.xp.asarray(x)\n    print(type(array))\n    return array\n\nx = my_fun([10])\n\nwith switch.set_context(XP.Jax):\n    x = my_fun([10])\n    print(x.at[0].set(0))\n\nwith switch.set_context(XP.Torch):\n    my_fun([10])\n\nmy_fun([20])\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrush%2Fanynp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsrush%2Fanynp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsrush%2Fanynp/lists"}