Skip to content

Commit a40eedb

Browse files
author
peng.li24
committed
test: update tests, add report scripts and csv outputs
1 parent e9fc00e commit a40eedb

6 files changed

Lines changed: 2757 additions & 2371 deletions

File tree

tests/module.cpp

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ namespace py = pybind11;
4040
PYBIND11_MODULE(numpycpp, m) {
4141
m.doc() = "C++ pixel-level alignment of Python numpy, powered by Eigen";
4242

43+
// -- 编译模式报告 ----------------------------------------------------------
44+
m.def("compile_mode", []() -> const char* {
45+
#ifdef NUMPYCPP_STD_ONLY
46+
return "std";
47+
#else
48+
return "bit_exact";
49+
#endif
50+
});
51+
4352
// -- linalg submodule --------------------------------------------------
4453
py::module_ la = m.def_submodule("linalg", "numpy.linalg equivalents");
4554
la.def("norm", static_cast<float(*)(const py::array_t<float>&)>(&numpy::linalg::norm));
@@ -83,12 +92,11 @@ PYBIND11_MODULE(numpycpp, m) {
8392
py::arg("start"), py::arg("stop"), py::arg("num")=50, py::arg("endpoint")=true);
8493

8594
// -- eye / identity / diag ---------------------------------------------
86-
// eye / identity: scalar int arguments — dtype determined by registered order;
87-
// float64 is numpy's default so register it last (wins for int args).
88-
m.def("eye", static_cast<py::array_t<float> (*)(py::ssize_t,py::ssize_t,int)>(&numpy::eye<float>),
89-
py::arg("N"), py::arg("M")=-1, py::arg("k")=0);
90-
m.def("eye", static_cast<py::array_t<double>(*)(py::ssize_t,py::ssize_t,int)>(&numpy::eye),
91-
py::arg("N"), py::arg("M")=-1, py::arg("k")=0);
95+
// eye / identity — M=None 表示方阵,严格对齐 numpy API
96+
m.def("eye", static_cast<py::array_t<float> (*)(py::ssize_t,py::object,int)>(&numpy::eye<float>),
97+
py::arg("N"), py::arg("M")=py::none(), py::arg("k")=0);
98+
m.def("eye", static_cast<py::array_t<double>(*)(py::ssize_t,py::object,int)>(&numpy::eye),
99+
py::arg("N"), py::arg("M")=py::none(), py::arg("k")=0);
92100
m.def("identity", static_cast<py::array_t<float> (*)(py::ssize_t)>(&numpy::identity<float>));
93101
m.def("identity", static_cast<py::array_t<double>(*)(py::ssize_t)>(&numpy::identity));
94102
m.def("diag", static_cast<py::array_t<float> (*)(const py::array_t<float>&, int)>(&numpy::diag<float>),
@@ -290,12 +298,12 @@ PYBIND11_MODULE(numpycpp, m) {
290298
// numpy.compress(condition, a) — boolean mask gather
291299
m.def("compress",
292300
static_cast<py::array_t<double>(*)(
293-
const py::array_t<double>&,
294-
const py::array_t<bool>&)>(&numpy::compress));
301+
const py::array_t<bool>&,
302+
const py::array_t<double>&)>(&numpy::compress));
295303
m.def("compress",
296304
static_cast<py::array_t<float>(*)(
297-
const py::array_t<float>&,
298-
const py::array_t<bool>&)>(&numpy::compress));
305+
const py::array_t<bool>&,
306+
const py::array_t<float>&)>(&numpy::compress));
299307

300308
// slice(a, starts, stops, steps) — N-D overload of existing slice()
301309
m.def("slice",

0 commit comments

Comments
 (0)