rsnumpy 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,140 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main, master]
6
+ pull_request:
7
+ branches: [main, master]
8
+
9
+ jobs:
10
+ test:
11
+ strategy:
12
+ matrix:
13
+ os: [ubuntu-latest, macos-latest, windows-latest]
14
+ python-version: ["3.9", "3.13"]
15
+ fail-fast: false
16
+
17
+ runs-on: ${{ matrix.os }}
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python ${{ matrix.python-version }}
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ matrix.python-version }}
25
+
26
+ - name: Build wheel and install
27
+ uses: PyO3/maturin-action@v1
28
+ with:
29
+ args: --release -o dist
30
+ pip: uv
31
+
32
+ - name: Install test dependencies
33
+ run: uv pip install numpy xlrd --system
34
+
35
+ - name: Run basic tests
36
+ run: python -c "
37
+ import rsnum;
38
+ a = rsnum.array([[1, 2, 3], [4, 5, 6]]);
39
+ assert a.shape == (2, 3);
40
+ assert a.ndim == 2;
41
+ assert a.size == 6;
42
+ b = rsnum.zeros((2, 3));
43
+ assert b.shape == (2, 3);
44
+ c = rsnum.ones((2, 3));
45
+ assert c.shape == (2, 3);
46
+ d = rsnum.eye(3);
47
+ assert d.shape == (3, 3);
48
+ e = rsnum.arange(5);
49
+ assert e.shape == (5,);
50
+ f = rsnum.linspace(0, 1, 5);
51
+ assert f.shape == (5,);
52
+ g = rsnum.sin(rsnum.array([0.0]));
53
+ assert g.shape == (1,);
54
+ h = rsnum.concatenate([rsnum.array([1, 2]), rsnum.array([3, 4])]);
55
+ assert h.shape == (4,);
56
+ i = rsnum.std(rsnum.array([1.0, 2.0, 3.0]));
57
+ print('All basic tests passed!');
58
+ "
59
+
60
+ - name: Run math function tests
61
+ run: python -c "
62
+ import rsnum;
63
+ a = rsnum.array([0.0, 1.0, -1.0]);
64
+ rsnum.sin(a);
65
+ rsnum.cos(a);
66
+ rsnum.tan(a);
67
+ rsnum.exp(a);
68
+ rsnum.log(rsnum.array([1.0, 2.0]));
69
+ rsnum.sqrt(rsnum.array([4.0, 9.0]));
70
+ rsnum.abs(rsnum.array([-1.0, -2.0]));
71
+ rsnum.around(rsnum.array([1.234]), 2);
72
+ print('Math tests passed!');
73
+ "
74
+
75
+ - name: Run LAPACK / linalg tests
76
+ run: python -c "
77
+ import rsnum;
78
+ a = rsnum.array([[1.0, 2.0], [3.0, 4.0]]);
79
+ rsnum.dot(a, a);
80
+ rsnum.matmul(a, a);
81
+ rsnum.linalg.det(a);
82
+ rsnum.linalg.inv(a);
83
+ rsnum.linalg.norm(a);
84
+ rsnum.linalg.eig(a);
85
+ print('Linalg tests passed!');
86
+ "
87
+
88
+ - name: Run statistics tests
89
+ run: python -c "
90
+ import rsnum;
91
+ a = rsnum.array([1.0, 2.0, 3.0, 4.0, 5.0]);
92
+ rsnum.mean(a);
93
+ rsnum.std(a);
94
+ rsnum.var(a);
95
+ rsnum.sum(a);
96
+ rsnum.median(a);
97
+ print('Statistics tests passed!');
98
+ "
99
+
100
+ - name: Run polynomial tests
101
+ run: python -c "
102
+ import rsnum;
103
+ p = rsnum.Poly([1, -3, 2]);
104
+ r = p.roots;
105
+ print('Polynomial tests passed!');
106
+ "
107
+
108
+ - name: Run random tests
109
+ run: python -c "
110
+ import rsnum;
111
+ rng = rsnum.random.default_rng(42);
112
+ rng.random(10);
113
+ rng.normal(0, 1, 10);
114
+ rng.integers(0, 100, 10);
115
+ print('Random tests passed!');
116
+ "
117
+
118
+ - name: Run FFT tests
119
+ run: python -c "
120
+ import rsnum;
121
+ a = rsnum.array([1.0, 2.0, 1.0, -1.0]);
122
+ rsnum.fft(a);
123
+ rsnum.rfft(a);
124
+ print('FFT tests passed!');
125
+ "
126
+
127
+ lint:
128
+ runs-on: ubuntu-latest
129
+ steps:
130
+ - uses: actions/checkout@v4
131
+
132
+ - name: Check Rust formatting
133
+ uses: actions-rust-lang/rustfmt@v1
134
+ with:
135
+ args: --check
136
+
137
+ - name: Run clippy
138
+ uses: actions-rust-lang/clippy@v1
139
+ with:
140
+ args: -- -D warnings
@@ -0,0 +1,84 @@
1
+ name: Build and Publish Wheels
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ workflow_dispatch: # 允许手动触发
7
+
8
+ jobs:
9
+ linux:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout code
13
+ uses: actions/checkout@v4
14
+
15
+ - name: Build Linux Wheels
16
+ uses: PyO3/maturin-action@v1
17
+ with:
18
+ args: --release --sdist -o dist --find-interpreter
19
+
20
+ - name: Upload Linux artifacts
21
+ uses: actions/upload-artifact@v4
22
+ with:
23
+ name: wheels-linux
24
+ path: dist
25
+
26
+ windows:
27
+ runs-on: windows-latest
28
+ steps:
29
+ - name: Checkout code
30
+ uses: actions/checkout@v4
31
+
32
+ - name: Build Windows Wheels
33
+ uses: PyO3/maturin-action@v1
34
+ with:
35
+ args: --release -o dist --find-interpreter
36
+
37
+ - name: Upload Windows artifacts
38
+ uses: actions/upload-artifact@v4
39
+ with:
40
+ name: wheels-windows
41
+ path: dist
42
+
43
+ macos:
44
+ runs-on: macos-latest
45
+ steps:
46
+ - name: Checkout code
47
+ uses: actions/checkout@v4
48
+
49
+ - name: Build macOS (universal2) Wheels
50
+ uses: PyO3/maturin-action@v1
51
+ with:
52
+ # `--universal2` 生成同时支持 x86_64 和 arm64 的单一 Wheel
53
+ args: --release -o dist --universal2 --find-interpreter
54
+
55
+ - name: Upload macOS artifacts
56
+ uses: actions/upload-artifact@v4
57
+ with:
58
+ name: wheels-macos
59
+ path: dist
60
+
61
+ pypi-publish:
62
+ name: Upload release to PyPI
63
+ runs-on: ubuntu-latest
64
+ needs: [linux, windows, macos]
65
+ # 推荐使用 Trusted Publishing (OIDC) — 在 PyPI 项目设置中配置受信发布方
66
+ # 也可使用传统 Token 方式: 在 GitHub Secrets 中设置 PYPI_API_TOKEN
67
+ environment: release
68
+ permissions:
69
+ id-token: write # Trusted Publishing 需要
70
+ steps:
71
+ - name: Download all artifacts
72
+ uses: actions/download-artifact@v4
73
+ with:
74
+ pattern: wheels-*
75
+ path: dist
76
+ merge-multiple: true
77
+
78
+ - name: Publish to PyPI
79
+ uses: PyO3/maturin-action@v1
80
+ env:
81
+ MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
82
+ with:
83
+ command: upload
84
+ args: --skip-existing dist/*
@@ -0,0 +1,41 @@
1
+ # Rust
2
+ target/
3
+ wheelhouse/
4
+ Cargo.lock
5
+ rsnum*.whl
6
+
7
+ # Python
8
+ __pycache__/
9
+ *.py[cod]
10
+ *$py.class
11
+ *.so
12
+ *.egg-info/
13
+ dist/
14
+ build/
15
+ *.egg
16
+ .venv/
17
+ venv/
18
+ uv.lock
19
+
20
+ # IDE
21
+ .vscode/
22
+ .idea/
23
+ *.swp
24
+ *.swo
25
+ *~
26
+
27
+ # OS
28
+ .DS_Store
29
+ Thumbs.db
30
+
31
+ # Data / plots
32
+ push*.sh
33
+ main*.py
34
+ test*.py
35
+ debug*.py
36
+ check*.py
37
+
38
+ # Environment
39
+ .venv
40
+ .env
41
+ .env.local