Skip to content

Commit b70efd3

Browse files
author
peng.li24
committed
fix: remove zeros_t/ones_t/full_t — inconsistent with numpy naming
The _t suffix template functions introduced non-numpy names into the public API. For dtype-flexible creation, use the native template functions in core.h directly (zeros_like<T>, full<T>) with manual py::array pointer extraction — this is the recommended path for all context builder migration.
1 parent 8745fda commit b70efd3

1 file changed

Lines changed: 0 additions & 24 deletions

File tree

pycpp/core_py.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ py::array_t<T> empty_like(const py::array_t<T>& arr) {
5454
}
5555

5656
/// numpy.zeros(shape, dtype=float, order='C', *, like=None)
57-
/// NOTE: convenient double default. For dtype flexibility, use zeros_t<T>(shape).
5857
inline py::array_t<double> zeros(const std::vector<py::ssize_t>& shape) {
5958
py::array_t<double> result(shape);
6059
zeros_like(static_cast<double*>(result.request().ptr), result.request().size);
@@ -75,29 +74,6 @@ inline py::array_t<double> full(const std::vector<py::ssize_t>& shape, double fi
7574
return result;
7675
}
7776

78-
// Template counterparts — dtype-flexible creation for pybind11 modules
79-
// that need float32 or other dtypes. Bind as e.g. m.def("zeros_f32", &numpy::zeros_t<float>);
80-
template<typename T>
81-
py::array_t<T> zeros_t(const std::vector<py::ssize_t>& shape) {
82-
py::array_t<T> result(shape);
83-
zeros_like(static_cast<T*>(result.request().ptr), result.request().size);
84-
return result;
85-
}
86-
87-
template<typename T>
88-
py::array_t<T> ones_t(const std::vector<py::ssize_t>& shape) {
89-
py::array_t<T> result(shape);
90-
ones_like(static_cast<T*>(result.request().ptr), result.request().size);
91-
return result;
92-
}
93-
94-
template<typename T>
95-
py::array_t<T> full_t(const std::vector<py::ssize_t>& shape, T fill_value) {
96-
py::array_t<T> result(shape);
97-
numpy::full(static_cast<T*>(result.request().ptr), result.request().size, fill_value);
98-
return result;
99-
}
100-
10177
// Bool specializations
10278
// NOTE: _bool suffix — dtype-specific wrappers; pybind11 cannot deduce template
10379
// argument from a Python dtype keyword, so each dtype needs its own binding.

0 commit comments

Comments
 (0)