Skip to content

Commit 340afab

Browse files
pre-commit-ci[bot]mtsokol
authored andcommitted
style: pre-commit fixes
1 parent ee40dab commit 340afab

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

include/pybind11/numpy.h

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -120,22 +120,19 @@ inline numpy_internals &get_numpy_internals() {
120120
return *ptr;
121121
}
122122

123-
module_ import_numpy_core_submodule(const char * submodule_name) {
123+
module_ import_numpy_core_submodule(const char *submodule_name) {
124124
try {
125-
return module_::import(
126-
(std::string("numpy._core.") + submodule_name).c_str()
127-
);
125+
return module_::import((std::string("numpy._core.") + submodule_name).c_str());
128126
} catch (error_already_set &ex) {
129-
if (!ex.matches(PyExc_ImportError)) throw;
127+
if (!ex.matches(PyExc_ImportError))
128+
throw;
130129
try {
131-
return module_::import(
132-
(std::string("numpy.core.") + submodule_name).c_str()
133-
);
134-
} catch(error_already_set &ex) {
135-
if (!ex.matches(PyExc_ImportError)) throw;
136-
throw import_error(
137-
std::string("pybind11 couldn't import ") + submodule_name + " from numpy."
138-
);
130+
return module_::import((std::string("numpy.core.") + submodule_name).c_str());
131+
} catch (error_already_set &ex) {
132+
if (!ex.matches(PyExc_ImportError))
133+
throw;
134+
throw import_error(std::string("pybind11 couldn't import ") + submodule_name
135+
+ " from numpy.");
139136
}
140137
}
141138
}
@@ -283,7 +280,7 @@ struct npy_api {
283280
};
284281

285282
static npy_api lookup() {
286-
module_ m = import_numpy_core_submodule("multiarray");
283+
module_ m = detail::import_numpy_core_submodule("multiarray");
287284
auto c = m.attr("_ARRAY_API");
288285
void **api_ptr = (void **) PyCapsule_GetPointer(c.ptr(), nullptr);
289286
npy_api api;
@@ -646,11 +643,8 @@ class dtype : public object {
646643

647644
private:
648645
static object _dtype_from_pep3118() {
649-
module_ m = import_numpy_core_submodule("_internal");
650-
static PyObject *obj = m.attr("_dtype_from_pep3118")
651-
.cast<object>()
652-
.release()
653-
.ptr();
646+
module_ m = detail::import_numpy_core_submodule("_internal");
647+
static PyObject *obj = m.attr("_dtype_from_pep3118").cast<object>().release().ptr();
654648
return reinterpret_borrow<object>(obj);
655649
}
656650

0 commit comments

Comments
 (0)