Skip to content

Commit afef285

Browse files
committed
clang-formatting
1 parent bdfcb31 commit afef285

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2288
-2281
lines changed

.pre-commit-config.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,4 @@ repos:
2929
rev: v14.0.6
3030
hooks:
3131
- id: clang-format
32+

onedal/basic_statistics/basic_statistics.cpp

+44-40
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ auto get_onedal_result_options(const py::dict& params) {
114114
struct params2desc {
115115
template <typename Float, typename Method, typename Task>
116116
auto operator()(const py::dict& params) {
117-
auto desc = dal::basic_statistics::descriptor<Float,
118-
Method, dal::basic_statistics::task::compute>()
119-
.set_result_options(get_onedal_result_options(params));
117+
auto desc =
118+
dal::basic_statistics::descriptor<Float, Method, dal::basic_statistics::task::compute>()
119+
.set_result_options(get_onedal_result_options(params));
120120
return desc;
121121
}
122122
};
@@ -126,54 +126,53 @@ struct params2desc_incremental {
126126
template <typename Float, typename Method, typename Task>
127127
auto operator()(const py::dict& params) {
128128
auto desc = dal::basic_statistics::descriptor<Float,
129-
dal::basic_statistics::method::dense, dal::basic_statistics::task::compute>()
130-
.set_result_options(get_onedal_result_options(params));
129+
dal::basic_statistics::method::dense,
130+
dal::basic_statistics::task::compute>()
131+
.set_result_options(get_onedal_result_options(params));
131132
return desc;
132133
}
133134
};
134135

135136
template <typename Policy, typename Task>
136137
void init_compute_ops(py::module& m) {
137-
m.def("compute", [](
138-
const Policy& policy,
139-
const py::dict& params,
140-
const table& data,
141-
const table& weights) {
138+
m.def(
139+
"compute",
140+
[](const Policy& policy, const py::dict& params, const table& data, const table& weights) {
142141
using namespace dal::basic_statistics;
143142
using input_t = compute_input<Task>;
144143

145144
compute_ops ops(policy, input_t{ data, weights }, params2desc{});
146145
return fptype2t{ method2t{ Task{}, ops } }(params);
147-
}
148-
);
146+
});
149147
}
150148

151-
152149
template <typename Policy, typename Task>
153150
void init_partial_compute_ops(py::module& m) {
154151
using prev_result_t = dal::basic_statistics::partial_compute_result<Task>;
155-
m.def("partial_compute", [](
156-
const Policy& policy,
157-
const py::dict& params,
158-
const prev_result_t& prev,
159-
const table& data,
160-
const table& weights) {
161-
using namespace dal::basic_statistics;
162-
using input_t = partial_compute_input<Task>;
163-
partial_compute_ops ops(policy, input_t{ prev, data, weights }, params2desc_incremental{});
164-
return fptype2t{ method2t{ Task{}, ops } }(params);
165-
}
166-
);
152+
m.def("partial_compute",
153+
[](const Policy& policy,
154+
const py::dict& params,
155+
const prev_result_t& prev,
156+
const table& data,
157+
const table& weights) {
158+
using namespace dal::basic_statistics;
159+
using input_t = partial_compute_input<Task>;
160+
partial_compute_ops ops(policy,
161+
input_t{ prev, data, weights },
162+
params2desc_incremental{});
163+
return fptype2t{ method2t{ Task{}, ops } }(params);
164+
});
167165
}
168166

169167
template <typename Policy, typename Task>
170168
void init_finalize_compute_ops(pybind11::module_& m) {
171169
using namespace dal::basic_statistics;
172170
using input_t = partial_compute_result<Task>;
173-
m.def("finalize_compute", [](const Policy& policy, const pybind11::dict& params, const input_t& data) {
174-
finalize_compute_ops ops(policy, data, params2desc_incremental{});
175-
return fptype2t{ method2t{ Task{}, ops } }(params);
176-
});
171+
m.def("finalize_compute",
172+
[](const Policy& policy, const pybind11::dict& params, const input_t& data) {
173+
finalize_compute_ops ops(policy, data, params2desc_incremental{});
174+
return fptype2t{ method2t{ Task{}, ops } }(params);
175+
});
177176
}
178177

179178
template <typename Task>
@@ -216,23 +215,28 @@ void init_partial_compute_result(py::module_& m) {
216215
py::cast<py::object>(convert_to_pyobject(res.get_partial_max())),
217216
py::cast<py::object>(convert_to_pyobject(res.get_partial_sum())),
218217
py::cast<py::object>(convert_to_pyobject(res.get_partial_sum_squares())),
219-
py::cast<py::object>(convert_to_pyobject(res.get_partial_sum_squares_centered()))
220-
);
218+
py::cast<py::object>(
219+
convert_to_pyobject(res.get_partial_sum_squares_centered())));
221220
},
222221
[](py::tuple t) {
223222
if (t.size() != 6)
224223
throw std::runtime_error("Invalid state!");
225224
result_t res;
226-
if (py::cast<int>(t[0].attr("size")) != 0) res.set_partial_n_rows(convert_to_table(t[0]));
227-
if (py::cast<int>(t[1].attr("size")) != 0) res.set_partial_min(convert_to_table(t[1]));
228-
if (py::cast<int>(t[2].attr("size")) != 0) res.set_partial_max(convert_to_table(t[2]));
229-
if (py::cast<int>(t[3].attr("size")) != 0) res.set_partial_sum(convert_to_table(t[3]));
230-
if (py::cast<int>(t[4].attr("size")) != 0) res.set_partial_sum_squares(convert_to_table(t[4]));
231-
if (py::cast<int>(t[5].attr("size")) != 0) res.set_partial_sum_squares_centered(convert_to_table(t[5]));
232-
225+
if (py::cast<int>(t[0].attr("size")) != 0)
226+
res.set_partial_n_rows(convert_to_table(t[0]));
227+
if (py::cast<int>(t[1].attr("size")) != 0)
228+
res.set_partial_min(convert_to_table(t[1]));
229+
if (py::cast<int>(t[2].attr("size")) != 0)
230+
res.set_partial_max(convert_to_table(t[2]));
231+
if (py::cast<int>(t[3].attr("size")) != 0)
232+
res.set_partial_sum(convert_to_table(t[3]));
233+
if (py::cast<int>(t[4].attr("size")) != 0)
234+
res.set_partial_sum_squares(convert_to_table(t[4]));
235+
if (py::cast<int>(t[5].attr("size")) != 0)
236+
res.set_partial_sum_squares_centered(convert_to_table(t[5]));
237+
233238
return res;
234-
}
235-
));
239+
}));
236240
}
237241

238242
ONEDAL_PY_DECLARE_INSTANTIATOR(init_compute_result);

onedal/cluster/dbscan.cpp

+9-11
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,15 @@ struct params2desc {
100100

101101
template <typename Policy, typename Task>
102102
void init_compute_ops(py::module_& m) {
103-
m.def("compute",
104-
[](const Policy& policy,
105-
const py::dict& params,
106-
const table& data,
107-
const table& weights) {
108-
using namespace dbscan;
109-
using input_t = compute_input<Task>;
110-
111-
compute_ops ops(policy, input_t{ data, weights }, params2desc{});
112-
return fptype2t{ method2t{ Task{}, ops } }(params);
113-
});
103+
m.def(
104+
"compute",
105+
[](const Policy& policy, const py::dict& params, const table& data, const table& weights) {
106+
using namespace dbscan;
107+
using input_t = compute_input<Task>;
108+
109+
compute_ops ops(policy, input_t{ data, weights }, params2desc{});
110+
return fptype2t{ method2t{ Task{}, ops } }(params);
111+
});
114112
}
115113

116114
template <typename Task>

onedal/cluster/kmeans_common.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,11 @@
2323

2424
#include "onedal/common/pybind11_helpers.hpp"
2525

26-
namespace oneapi::dal::python{
26+
namespace oneapi::dal::python {
2727

2828
namespace kmeans {
2929

30-
bool is_same_clustering(const dal::table& left,
31-
const dal::table& right,
32-
std::int64_t n_clusters) {
30+
bool is_same_clustering(const dal::table& left, const dal::table& right, std::int64_t n_clusters) {
3331
if (!left.has_data() || !right.has_data())
3432
throw std::invalid_argument("Empty input table");
3533

@@ -39,15 +37,16 @@ bool is_same_clustering(const dal::table& left,
3937
if (left.get_column_count() > 1 || right.get_column_count() > 1)
4038
throw std::length_error("Too many columns in input table");
4139

42-
const auto l_arr = l_acc.pull({0, -1});
43-
const auto r_arr = r_acc.pull({0, -1});
40+
const auto l_arr = l_acc.pull({ 0, -1 });
41+
const auto r_arr = r_acc.pull({ 0, -1 });
4442

4543
if (n_clusters < 1)
4644
throw std::invalid_argument("Invalid number of clusters");
4745

4846
constexpr std::int32_t minus_one = -1;
4947
auto map = dal::array<std::int32_t>::full( //
50-
n_clusters, minus_one);
48+
n_clusters,
49+
minus_one);
5150

5251
auto* const m_ptr = map.get_mutable_data();
5352

@@ -85,4 +84,4 @@ ONEDAL_PY_INIT_MODULE(kmeans_common) {
8584
sub.def("_is_same_clustering", &kmeans::is_same_clustering);
8685
} // ONEDAL_PY_INIT_MODULE(kmeans_common)
8786

88-
} // namespace oneapi::dal::python::kmeans
87+
} // namespace oneapi::dal::python

onedal/common.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616

1717
#pragma once
1818

19-
#define OVERFLOW_CHECK_BY_ADDING(type, op1, op2) \
20-
{ \
21-
volatile type r = (op1) + (op2); \
22-
r -= (op1); \
23-
if (!(r == (op2))) \
24-
throw std::runtime_error("Integer overflow by adding"); \
19+
#define OVERFLOW_CHECK_BY_ADDING(type, op1, op2) \
20+
{ \
21+
volatile type r = (op1) + (op2); \
22+
r -= (op1); \
23+
if (!(r == (op2))) \
24+
throw std::runtime_error("Integer overflow by adding"); \
2525
}
2626

2727
#define OVERFLOW_CHECK_BY_MULTIPLICATION(type, op1, op2) \

0 commit comments

Comments
 (0)