{"id":31041047,"url":"https://github.com/byte-sourcerer/array_contract","last_synced_at":"2025-09-14T09:03:03.019Z","repository":{"id":57411586,"uuid":"286058996","full_name":"byte-sourcerer/array_contract","owner":"byte-sourcerer","description":"Contract programming for Pytorch, Numpy","archived":false,"fork":false,"pushed_at":"2020-08-14T06:53:09.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-14T09:02:19.013Z","etag":null,"topics":["contracts","ndarray","numpy","python","python3","pytorch","tensor"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/arraycontract/","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/byte-sourcerer.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}},"created_at":"2020-08-08T14:30:52.000Z","updated_at":"2021-02-13T09:14:12.000Z","dependencies_parsed_at":"2022-08-27T17:11:11.898Z","dependency_job_id":null,"html_url":"https://github.com/byte-sourcerer/array_contract","commit_stats":null,"previous_names":["cjwcommuny/array_contract"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/byte-sourcerer/array_contract","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byte-sourcerer%2Farray_contract","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byte-sourcerer%2Farray_contract/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byte-sourcerer%2Farray_contract/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byte-sourcerer%2Farray_contract/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byte-sourcerer","download_url":"https://codeload.github.com/byte-sourcerer/array_contract/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byte-sourcerer%2Farray_contract/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275082396,"owners_count":25402339,"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","status":"online","status_checked_at":"2025-09-14T02:00:10.474Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["contracts","ndarray","numpy","python","python3","pytorch","tensor"],"created_at":"2025-09-14T09:01:59.416Z","updated_at":"2025-09-14T09:03:02.992Z","avatar_url":"https://github.com/byte-sourcerer.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ArrayContract\n\n```python\nfrom arraycontract import shape, _\nimport torch\n\n@shape(x=(_, 'N'), y=('N', _))\ndef matrix_dot(x, y):\n    return x @ y\n\nmatrix_dot(torch.rand(3,4), torch.rand(4,5)) # OK\nmatrix_dot(torch.rand(3,4), torch.rand(3,5)) # raise AssertionError\n```\n\n```python\nfrom arraycontract import shape, _\nimport torch\nfrom torch import nn\n\nlinear = nn.Linear(3, 4)\n\n@shape((..., 3))\ndef forward_linear(x):\n    \"\"\"\n    requires x.shape[-1] == 3\n    \"\"\"\n    return linear(x)\n\nforward_linear(torch.rand(4,5,3)) # OK\nforward_linear(torch.rand(4,4)) # raise AssertionError\n```\n\n```python\nfrom arraycontract import dtype\nfrom arraycontract import ndim\nimport torch\n\n@ndim(x=3, y=4)\ndef ndim_contract(x, y):\n    print(\"requires x.ndim == 3 and y.ndim == 4\")\n\n@dtype(x=torch.long)\ndef dtype_contract(x):\n    print(\"requires x.dtype == torch.long\")\n```\n\n```python\nfrom arraycontract import Trigger\nfrom arraycontract import dtype\nimport torch\n\nTrigger.dtype_check_trigger = False\n\n@dtype(x=torch.long)\ndef dtype_contract(x):\n    print(\"not requires x.dtype == torch.long\")\n\ndtype_contract(torch.rand(3, 4).float()) # OK\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyte-sourcerer%2Farray_contract","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyte-sourcerer%2Farray_contract","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyte-sourcerer%2Farray_contract/lists"}