Skip to content

Commit 3604571

Browse files
authored
feat: add main feat (#1)
1 parent 7d79f73 commit 3604571

File tree

17 files changed

+35140
-30
lines changed

17 files changed

+35140
-30
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ jobs:
3636
fail-fast: false
3737
matrix:
3838
python-version:
39-
- "3.9"
40-
- "3.10"
41-
- "3.11"
39+
# - "3.9"
40+
# - "3.10"
41+
# - "3.11"
4242
- "3.12"
4343
- "3.13"
4444
os:

.pre-commit-config.yaml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ repos:
1313
hooks:
1414
- id: commitizen
1515
stages: [commit-msg]
16+
# run .pre-commit/update_array_namespace.py
17+
# - repo: local
18+
# hooks:
19+
# - id: update-array-namespace
20+
# name: Update array namespace
21+
# entry: python -m src.array_api
22+
# language: python
23+
# additional_dependencies: ["attrs", "typer", "ssort", "ruff"]
24+
# require_serial: true
25+
# pass_filenames: false
1626
- repo: https://github.com/pre-commit/pre-commit-hooks
1727
rev: v5.0.0
1828
hooks:
@@ -44,14 +54,14 @@ repos:
4454
rev: v0.11.5
4555
hooks:
4656
- id: ruff
47-
args: [--fix, --exit-non-zero-on-fix]
57+
args: [--fix, --unsafe-fixes, --exit-non-zero-on-fix]
4858
- id: ruff-format
49-
- repo: https://github.com/codespell-project/codespell
50-
rev: v2.4.1
51-
hooks:
52-
- id: codespell
59+
# - repo: https://github.com/codespell-project/codespell
60+
# rev: v2.4.1
61+
# hooks:
62+
# - id: codespell
5363
- repo: https://github.com/pre-commit/mirrors-mypy
5464
rev: v1.15.0
5565
hooks:
5666
- id: mypy
57-
additional_dependencies: []
67+
additional_dependencies: [attrs]

LICENSE-MIT

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020-2025 Consortium for Python Data API Standards contributors
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,47 @@ Typing for array API and array-api-compat
4444

4545
Install this via pip (or your favourite package manager):
4646

47-
`pip install array-api`
47+
```shell
48+
pip install array-api
49+
```
50+
51+
## Usage
52+
53+
### Type stubs
54+
55+
Provices type stubs for [`array-api-compat`](https://data-apis.org/array-api-compat/).
56+
57+
```python
58+
import array_api_compat
59+
60+
xp = array_api_compat.array_namespace(x)
61+
```
62+
63+
### Array Type
64+
65+
```python
66+
from array_api._2024_12 import Array
67+
68+
69+
def my_function[TArray: Array](x: TArray) -> TArray:
70+
return x + 1
71+
```
72+
73+
### Namespace Type
74+
75+
You can test if an object matches the Protocol by:
76+
77+
```python
78+
import array_api_strict
79+
80+
from array_api._2024_12 import ArrayNamespace, ArrayNamespaceFull
81+
82+
83+
assert isinstance(array_api_strict, ArrayNamespace)
84+
# Full version contains fft and linalg
85+
# fft and linalg are not included by default in array_api_strict
86+
assert not isinstance(array_api_strict, ArrayNamespaceFull)
87+
```
4888

4989
## Contributors ✨
5090

pyproject.toml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "array-api"
77
version = "0.0.0"
88
description = "Typing for array API and array-api-compat"
99
readme = "README.md"
10-
license = { text = "Apache Software License 2.0" }
10+
license = "MIT AND Apache-2.0"
1111
authors = [
1212
{ name = "34j", email = "[email protected]" },
1313
]
@@ -26,6 +26,7 @@ classifiers = [
2626
]
2727

2828
dependencies = [
29+
"attrs>=25.3.0",
2930
"rich>=10",
3031
"typer>=0.15,<1",
3132
]
@@ -37,8 +38,11 @@ scripts.array-api = "array_api.cli:app"
3738

3839
[dependency-groups]
3940
dev = [
41+
"array-api-compat>=1.11.2",
42+
"array-api-strict>=2.3.1",
4043
"pytest>=8,<9",
4144
"pytest-cov>=6,<7",
45+
"ruff>=0.11.13",
4246
]
4347
docs = [
4448
"furo>=2023.5.20; python_version>='3.11'",
@@ -48,7 +52,7 @@ docs = [
4852
]
4953

5054
[tool.ruff]
51-
line-length = 88
55+
line-length = 320
5256
lint.select = [
5357
"B", # flake8-bugbear
5458
"D", # flake8-docstrings
@@ -68,6 +72,9 @@ lint.ignore = [
6872
"D104", # Missing docstring in public package
6973
"D107", # Missing docstring in `__init__`
7074
"D401", # First line of docstring should be in imperative mood
75+
"S603",
76+
"S607",
77+
"E501"
7178
]
7279
lint.per-file-ignores."conftest.py" = [ "D100" ]
7380
lint.per-file-ignores."docs/conf.py" = [ "D100" ]
@@ -106,7 +113,7 @@ exclude_lines = [
106113

107114
[tool.mypy]
108115
check_untyped_defs = true
109-
disallow_any_generics = true
116+
disallow_any_generics = false
110117
disallow_incomplete_defs = true
111118
disallow_untyped_defs = true
112119
mypy_path = "src/"

0 commit comments

Comments
 (0)