Skip to content

Commit 11250dc

Browse files
fix latent warnings
1 parent 5dabe61 commit 11250dc

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

include/pybind11/numpy_ufunc.h

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ class ufunc : public object {
127127
entries.reset(new entries_t(name));
128128
}
129129

130-
ufunc(const ufunc& other) {
131-
}
132-
133130
~ufunc() {
134131
if (entries)
135132
finalize();
@@ -230,12 +227,12 @@ class ufunc : public object {
230227
// Store core functionn.
231228
core_funcs_.push_back(func);
232229
core_data_.push_back(data);
233-
int ncore = core_funcs_.size();
234-
int t_index = core_type_args_.size();
230+
size_t ncore = core_funcs_.size();
231+
size_t t_index = core_type_args_.size();
235232
int nargs = nin_ + nout_;
236233
core_type_args_.resize(ncore * nargs);
237-
for (int i = 0; i < dtype_args.size(); ++i) {
238-
core_type_args_.at(t_index++) = dtype_args[i];
234+
for (size_t i = 0; i < dtype_args.size(); ++i) {
235+
core_type_args_.at(t_index++) = (char)dtype_args[i];
239236
}
240237
}
241238

@@ -249,16 +246,16 @@ class ufunc : public object {
249246
}
250247

251248
detail::PyUFuncObject* create_core() {
252-
int ncore = core_funcs_.size();
253-
char* name_raw = (char*)name();
249+
int ncore = (int)core_funcs_.size();
250+
char* name_raw = const_cast<char*>(name());
254251
return (detail::PyUFuncObject*)detail::npy_api::get().PyUFunc_FromFuncAndData_(
255252
core_funcs_.data(), core_data_.data(), core_type_args_.data(), ncore,
256253
nin_, nout_, detail::npy_api::constants::PyUFunc_None_, name_raw, nullptr, 0);
257254
}
258255

259256
void create_user(detail::PyUFuncObject* h) {
260-
int nuser = user_funcs_.size();
261-
for (int i = 0; i < nuser; ++i) {
257+
size_t nuser = user_funcs_.size();
258+
for (size_t i = 0; i < nuser; ++i) {
262259
if (detail::npy_api::get().PyUFunc_RegisterLoopForType_(
263260
h, user_types_[i], user_funcs_[i], user_type_args_[i].data(), user_data_[i]) < 0)
264261
pybind11_fail("ufunc: Failed to register custom ufunc");

tests/test_numpy_dtypes_user.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -238,18 +238,14 @@ TEST_SUBMODULE(numpy_dtype_user, m) {
238238
.def_loop("cos", [](const Custom& self) {
239239
return Custom(cos(self.value()));
240240
})
241-
.def_loop("logical_and", [](const Custom& self, const Custom& other) -> double {
241+
.def_loop("logical_and", [](const Custom&, const Custom&) -> double {
242242
return 10;
243243
});
244244
// Somewhat more expressive.
245245

246246
// N.B. We should not define a boolean operator for `equal`, as NumPy will
247247
// use this, even if we define it "afterwards", due to how it is stored.
248248

249-
// // Define other stuff.
250-
// py::ufunc::get_builtin("power").def_loop<Custom>(
251-
// ;
252-
253249
// `py::vectorize` does not seem to allow custom types due to sfinae constraints :(
254250
py::ufunc x(m, "same");
255251
x

0 commit comments

Comments
 (0)