Skip to content

Commit

Permalink
modify following clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
icfaust committed Jan 7, 2025
1 parent a471809 commit 58def5e
Show file tree
Hide file tree
Showing 55 changed files with 2,455 additions and 2,446 deletions.
158 changes: 3 additions & 155 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,155 +1,3 @@
---
Language: Cpp
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveMacros: true
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AllowAllConstructorInitializersOnNextLine: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Inline
AllowShortLambdasOnASingleLine: All
AllowShortIfStatementsOnASingleLine: WithoutElse
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: true
BinPackParameters: true
BraceWrapping:
AfterCaseLabel: true
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterFunction: true
AfterNamespace: true
AfterObjCDeclaration: false
AfterStruct: true
AfterUnion: true
AfterExternBlock: true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: NonAssignment
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakInheritanceList: BeforeColon
BreakBeforeTernaryOperators: false
BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: BeforeColon
BreakAfterJavaFieldAnnotations: false
BreakStringLiterals: true
ColumnLimit: 1500
CommentPragmas: '^ IWYU pragma:'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros:
- foreach
- Q_FOREACH
- BOOST_FOREACH
IncludeBlocks: Preserve
IncludeCategories:
- Regex: '^<ext/.*\.h>'
Priority: 2
- Regex: '^<.*\.h>'
Priority: 1
- Regex: '^<.*'
Priority: 2
- Regex: '.*'
Priority: 3
IncludeIsMainRegex: '([-_](test|unittest))?$'
IndentCaseLabels: false
IndentPPDirectives: BeforeHash
IndentWidth: 4
IndentWrappedFunctionNames: true
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
ObjCBinPackProtocolList: Never
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 1
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 200
PointerAlignment: Middle
RawStringFormats:
- Language: Cpp
Delimiters:
- cc
- CC
- cpp
- Cpp
- CPP
- 'c++'
- 'C++'
CanonicalDelimiter: ''
BasedOnStyle: google
- Language: TextProto
Delimiters:
- pb
- PB
- proto
- PROTO
EnclosingFunctions:
- EqualsProto
- EquivToProto
- PARSE_PARTIAL_TEXT_PROTO
- PARSE_TEST_PROTO
- PARSE_TEXT_PROTO
- ParseTextOrDie
- ParseTextProtoOrDie
CanonicalDelimiter: ''
BasedOnStyle: google
ReflowComments: false
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: true
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 1
SpacesInAngles: false
SpacesInContainerLiterals: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
TabWidth: 4
UseTab: Never
...
---
DisableFormat: true
...
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
#===============================================================================

repos:
- repo: https://github.com/psf/black
rev: 24.1.1
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/PyCQA/isort
rev: 5.13.2
hooks:
- id: isort
language_version: python3.10
# - repo: https://github.com/psf/black
# rev: 24.1.1
# hooks:
# - id: black
# language_version: python3.10
# - repo: https://github.com/PyCQA/isort
# rev: 5.13.2
# hooks:
# - id: isort
# language_version: python3.10
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v14.0.6
hooks:
Expand Down
84 changes: 44 additions & 40 deletions onedal/basic_statistics/basic_statistics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ auto get_onedal_result_options(const py::dict& params) {
struct params2desc {
template <typename Float, typename Method, typename Task>
auto operator()(const py::dict& params) {
auto desc = dal::basic_statistics::descriptor<Float,
Method, dal::basic_statistics::task::compute>()
.set_result_options(get_onedal_result_options(params));
auto desc =
dal::basic_statistics::descriptor<Float, Method, dal::basic_statistics::task::compute>()
.set_result_options(get_onedal_result_options(params));
return desc;
}
};
Expand All @@ -126,54 +126,53 @@ struct params2desc_incremental {
template <typename Float, typename Method, typename Task>
auto operator()(const py::dict& params) {
auto desc = dal::basic_statistics::descriptor<Float,
dal::basic_statistics::method::dense, dal::basic_statistics::task::compute>()
.set_result_options(get_onedal_result_options(params));
dal::basic_statistics::method::dense,
dal::basic_statistics::task::compute>()
.set_result_options(get_onedal_result_options(params));
return desc;
}
};

template <typename Policy, typename Task>
void init_compute_ops(py::module& m) {
m.def("compute", [](
const Policy& policy,
const py::dict& params,
const table& data,
const table& weights) {
m.def(
"compute",
[](const Policy& policy, const py::dict& params, const table& data, const table& weights) {
using namespace dal::basic_statistics;
using input_t = compute_input<Task>;

compute_ops ops(policy, input_t{ data, weights }, params2desc{});
return fptype2t{ method2t{ Task{}, ops } }(params);
}
);
});
}


template <typename Policy, typename Task>
void init_partial_compute_ops(py::module& m) {
using prev_result_t = dal::basic_statistics::partial_compute_result<Task>;
m.def("partial_compute", [](
const Policy& policy,
const py::dict& params,
const prev_result_t& prev,
const table& data,
const table& weights) {
using namespace dal::basic_statistics;
using input_t = partial_compute_input<Task>;
partial_compute_ops ops(policy, input_t{ prev, data, weights }, params2desc_incremental{});
return fptype2t{ method2t{ Task{}, ops } }(params);
}
);
m.def("partial_compute",
[](const Policy& policy,
const py::dict& params,
const prev_result_t& prev,
const table& data,
const table& weights) {
using namespace dal::basic_statistics;
using input_t = partial_compute_input<Task>;
partial_compute_ops ops(policy,
input_t{ prev, data, weights },
params2desc_incremental{});
return fptype2t{ method2t{ Task{}, ops } }(params);
});
}

template <typename Policy, typename Task>
void init_finalize_compute_ops(pybind11::module_& m) {
using namespace dal::basic_statistics;
using input_t = partial_compute_result<Task>;
m.def("finalize_compute", [](const Policy& policy, const pybind11::dict& params, const input_t& data) {
finalize_compute_ops ops(policy, data, params2desc_incremental{});
return fptype2t{ method2t{ Task{}, ops } }(params);
});
m.def("finalize_compute",
[](const Policy& policy, const pybind11::dict& params, const input_t& data) {
finalize_compute_ops ops(policy, data, params2desc_incremental{});
return fptype2t{ method2t{ Task{}, ops } }(params);
});
}

template <typename Task>
Expand Down Expand Up @@ -216,23 +215,28 @@ void init_partial_compute_result(py::module_& m) {
py::cast<py::object>(convert_to_pyobject(res.get_partial_max())),
py::cast<py::object>(convert_to_pyobject(res.get_partial_sum())),
py::cast<py::object>(convert_to_pyobject(res.get_partial_sum_squares())),
py::cast<py::object>(convert_to_pyobject(res.get_partial_sum_squares_centered()))
);
py::cast<py::object>(
convert_to_pyobject(res.get_partial_sum_squares_centered())));
},
[](py::tuple t) {
if (t.size() != 6)
throw std::runtime_error("Invalid state!");
result_t res;
if (py::cast<int>(t[0].attr("size")) != 0) res.set_partial_n_rows(convert_to_table(t[0]));
if (py::cast<int>(t[1].attr("size")) != 0) res.set_partial_min(convert_to_table(t[1]));
if (py::cast<int>(t[2].attr("size")) != 0) res.set_partial_max(convert_to_table(t[2]));
if (py::cast<int>(t[3].attr("size")) != 0) res.set_partial_sum(convert_to_table(t[3]));
if (py::cast<int>(t[4].attr("size")) != 0) res.set_partial_sum_squares(convert_to_table(t[4]));
if (py::cast<int>(t[5].attr("size")) != 0) res.set_partial_sum_squares_centered(convert_to_table(t[5]));

if (py::cast<int>(t[0].attr("size")) != 0)
res.set_partial_n_rows(convert_to_table(t[0]));
if (py::cast<int>(t[1].attr("size")) != 0)
res.set_partial_min(convert_to_table(t[1]));
if (py::cast<int>(t[2].attr("size")) != 0)
res.set_partial_max(convert_to_table(t[2]));
if (py::cast<int>(t[3].attr("size")) != 0)
res.set_partial_sum(convert_to_table(t[3]));
if (py::cast<int>(t[4].attr("size")) != 0)
res.set_partial_sum_squares(convert_to_table(t[4]));
if (py::cast<int>(t[5].attr("size")) != 0)
res.set_partial_sum_squares_centered(convert_to_table(t[5]));

return res;
}
));
}));
}

ONEDAL_PY_DECLARE_INSTANTIATOR(init_compute_result);
Expand Down
20 changes: 9 additions & 11 deletions onedal/cluster/dbscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,15 @@ struct params2desc {

template <typename Policy, typename Task>
void init_compute_ops(py::module_& m) {
m.def("compute",
[](const Policy& policy,
const py::dict& params,
const table& data,
const table& weights) {
using namespace dbscan;
using input_t = compute_input<Task>;

compute_ops ops(policy, input_t{ data, weights }, params2desc{});
return fptype2t{ method2t{ Task{}, ops } }(params);
});
m.def(
"compute",
[](const Policy& policy, const py::dict& params, const table& data, const table& weights) {
using namespace dbscan;
using input_t = compute_input<Task>;

compute_ops ops(policy, input_t{ data, weights }, params2desc{});
return fptype2t{ method2t{ Task{}, ops } }(params);
});
}

template <typename Task>
Expand Down
15 changes: 7 additions & 8 deletions onedal/cluster/kmeans_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@

#include "onedal/common/pybind11_helpers.hpp"

namespace oneapi::dal::python{
namespace oneapi::dal::python {

namespace kmeans {

bool is_same_clustering(const dal::table& left,
const dal::table& right,
std::int64_t n_clusters) {
bool is_same_clustering(const dal::table& left, const dal::table& right, std::int64_t n_clusters) {
if (!left.has_data() || !right.has_data())
throw std::invalid_argument("Empty input table");

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

const auto l_arr = l_acc.pull({0, -1});
const auto r_arr = r_acc.pull({0, -1});
const auto l_arr = l_acc.pull({ 0, -1 });
const auto r_arr = r_acc.pull({ 0, -1 });

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

constexpr std::int32_t minus_one = -1;
auto map = dal::array<std::int32_t>::full( //
n_clusters, minus_one);
n_clusters,
minus_one);

auto* const m_ptr = map.get_mutable_data();

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

} // namespace oneapi::dal::python::kmeans
} // namespace oneapi::dal::python
Loading

0 comments on commit 58def5e

Please sign in to comment.