Skip to content

Commit e95aed3

Browse files
author
peng.li24
committed
Resolve issues 002 & 003: add 100-batch tests for linalg.solve and Rotation
Issue 002: linalg.solve - Promote float32 inputs to float64 in module.cpp (Eigen3 float32 LU differs from LAPACK sgesv; double-precision ensures bit-alignment) - Add test_solve_batch (100 random matrices n=4..8) - Add test_solve_large (10x10, 20x20) - Add test_solve_ill_conditioned (cond ~1e6 boundary tests) - Add assert_linalg_close helper (tolerates ULP-level Eigen3 vs LAPACK diffs) Issue 003: Rotation - Expand random tests from 10 to 100 iterations per Euler sequence - Cover all 6 Tait-Bryan sequences: xyz, xzy, yxz, yzx, zxy, zyx - Add gimbal lock boundary tests (beta ≈ ±pi/2) - Add test_random_matrices (scipy.random round-trip) - Add test_XYZ_intrinsic (uppercase intrinsic sequence) Doc: rename 开发标准.txt → development_standards.txt (English)
1 parent a017881 commit e95aed3

3 files changed

Lines changed: 728 additions & 311 deletions

File tree

doc/development_standards.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# scipycpp Development Standards
2+
3+
## 1. Bit-level Alignment
4+
- All C++ APIs must produce output identical to the corresponding scipy Python API
5+
- Acceptance criterion: np.array_equal(cpp_result, scipy_result) must be True
6+
- Zero differences for both float64 and float32 inputs (0 differences)
7+
- Tests cover 100-batch random data, from extremely small to extremely large values
8+
9+
## 2. Dependency Restrictions
10+
- Production code (pycpp/ headers) MUST NOT call py::module_::import()
11+
- py::module_::import() is ONLY permitted in test code (tests/module.cpp)
12+
- No direct use of numpy's SVML internal functions; only indirect via numpy/core.h (numpycpp)
13+
- No calls to numpcpp's detail internal interfaces
14+
15+
## 3. Floating-Point Precision
16+
- Both float64 and float32 inputs must be covered
17+
- scipy float32 inputs are internally promoted to float64 for computation; C++ implementations must match this behavior
18+
- C++ compilation must use floating-point flags matching scipy's (e.g., -ffp-contract=off -ffloat-store)
19+
20+
## 4. Code Structure
21+
- scipy/ directory: pure C++ algorithm implementations (header-only), no Python dependencies
22+
- pycpp/ directory: pybind11 wrappers (production code), py::module_::import() prohibited
23+
- tests/ directory: test module and test cases, py::module_::import() allowed
24+
25+
## 5. Test Requirements
26+
- Each API must cover at least: default parameters, boundary values, random batch (100 samples)
27+
- Covered API list:
28+
- scipy.stats.norm — pdf / cdf / ppf
29+
- scipy.integrate — trapezoid / simpson
30+
- scipy.linalg — solve
31+
- scipy.spatial.distance — cdist
32+
- scipy.spatial — KDTree
33+
- scipy.ndimage — gaussian_filter1d
34+
- scipy.signal — medfilt
35+
- scipy.spatial.transform — Rotation (from_matrix / as_euler)

0 commit comments

Comments
 (0)