@@ -78,10 +78,11 @@ static pybind11::array_t<double> _get_transform_mesh(const pybind11::object& tra
7878 auto output_mesh_array =
7979 pybind11::array_t <double , pybind11::array::c_style | pybind11::array::forcecast>(output_mesh);
8080
81- if (output_mesh_array.ndim () != 2 )
81+ if (output_mesh_array.ndim () != 2 ) {
8282 throw std::runtime_error (
8383 " Inverse transformed mesh array should be 2D not " +
8484 std::to_string (output_mesh_array.ndim ()) + " D" );
85+ }
8586
8687 return output_mesh_array;
8788}
@@ -102,38 +103,45 @@ static void image_resample(pybind11::array input_array,
102103 auto dtype = input_array.dtype (); // Validated when determine resampler below
103104 auto ndim = input_array.ndim ();
104105
105- if (ndim != 2 && ndim != 3 )
106+ if (ndim != 2 && ndim != 3 ) {
106107 throw std::invalid_argument (" Input array must be a 2D or 3D array" );
108+ }
107109
108- if (ndim == 3 && input_array.shape (2 ) != 4 )
110+ if (ndim == 3 && input_array.shape (2 ) != 4 ) {
109111 throw std::invalid_argument (
110112 " 3D input array must be RGBA with shape (M, N, 4), has trailing dimension of " +
111113 std::to_string (ndim));
114+ }
112115
113116 // Ensure input array is contiguous, regardless of dtype
114117 input_array = pybind11::array::ensure (input_array, pybind11::array::c_style);
115118
116119 // Validate output array
117120 auto out_ndim = output_array.ndim ();
118121
119- if (out_ndim != ndim)
122+ if (out_ndim != ndim) {
120123 throw std::invalid_argument (
121124 " Input (" + std::to_string (ndim) + " D) and output (" + std::to_string (out_ndim) +
122125 " D) arrays have different dimensionalities" );
126+ }
123127
124- if (out_ndim == 3 && output_array.shape (2 ) != 4 )
128+ if (out_ndim == 3 && output_array.shape (2 ) != 4 ) {
125129 throw std::invalid_argument (
126130 " 3D output array must be RGBA with shape (M, N, 4), has trailing dimension of " +
127131 std::to_string (out_ndim));
132+ }
128133
129- if (!output_array.dtype ().is (dtype))
134+ if (!output_array.dtype ().is (dtype)) {
130135 throw std::invalid_argument (" Input and output arrays have mismatched types" );
136+ }
131137
132- if ((output_array.flags () & pybind11::array::c_style) == 0 )
138+ if ((output_array.flags () & pybind11::array::c_style) == 0 ) {
133139 throw std::invalid_argument (" Output array must be C-contiguous" );
140+ }
134141
135- if (!output_array.writeable ())
142+ if (!output_array.writeable ()) {
136143 throw std::invalid_argument (" Output array must be writeable" );
144+ }
137145
138146 resample_params_t params;
139147 params.interpolation = interpolation;
@@ -187,8 +195,9 @@ static void image_resample(pybind11::array input_array,
187195 output_array.mutable_data (), output_array.shape (1 ), output_array.shape (0 ),
188196 params);
189197 Py_END_ALLOW_THREADS
190- } else
198+ } else {
191199 throw std::invalid_argument (" arrays must be of dtype byte, short, float32 or float64" );
200+ }
192201}
193202
194203
0 commit comments