Skip to content

Commit 4047843

Browse files
committed
First try to make pretty
1 parent d936866 commit 4047843

1,877 files changed

Lines changed: 179205 additions & 151865 deletions

File tree

Some content is hidden

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

.github/workflows/precommit.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
name: Precommit
2+
3+
on:
4+
pull_request:
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
test:
12+
name: Precommit
13+
runs-on: X64
14+
if: github.repository_owner == 'deepmodeling'
15+
container:
16+
image: ghcr.io/deepmodeling/abacus-gnu
17+
volumes:
18+
- /tmp/ccache:/github/home/.ccache
19+
steps:
20+
- name: Checkout repository
21+
uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
# We will handle submodules manually after fixing ownership
25+
submodules: 'false'
26+
27+
- name: Take ownership of the workspace and update submodules
28+
run: |
29+
sudo chown -R $(whoami) .
30+
git submodule update --init --recursive
31+
32+
- name: Install CI tools
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y ccache ca-certificates python-is-python3 python3-pip
36+
sudo pip install clang-format clang-tidy
37+
38+
- name: Configure
39+
run: |
40+
cmake -B build -DBUILD_TESTING=ON -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_FLOAT_FFTW=ON
41+
42+
- uses: pre-commit/action@v3.0.1
43+
with:
44+
extra_args:
45+
--from-ref ${{ github.event.pull_request.base.sha }}
46+
--to-ref ${{ github.event.pull_request.head.sha }}
47+
continue-on-error: true
48+
- uses: pre-commit-ci/lite-action@v1.0.3
49+

.github/workflows/test.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,6 @@ jobs:
3939
run: |
4040
cmake -B build -DBUILD_TESTING=ON -DENABLE_MLALGO=ON -DENABLE_LIBXC=ON -DENABLE_LIBRI=ON -DENABLE_GOOGLEBENCH=ON -DENABLE_RAPIDJSON=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=1 -DENABLE_FLOAT_FFTW=ON
4141
42-
# Temporarily removed because no one maintains this now.
43-
# And it will break the CI test workflow.
44-
45-
# - uses: pre-commit/action@v3.0.1
46-
# with:
47-
# extra_args:
48-
# --from-ref ${{ github.event.pull_request.base.sha }}
49-
# --to-ref ${{ github.event.pull_request.head.sha }}
50-
# continue-on-error: true
51-
# - uses: pre-commit-ci/lite-action@v1.0.3
52-
5342
- name: Build
5443
run: |
5544
cmake --build build -j8

python/pyabacus/src/ModuleBase/py_base_math.cpp

Lines changed: 66 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#include <pybind11/numpy.h>
2-
#include <pybind11/pybind11.h>
3-
4-
#include "source_base/math_sphbes.h"
1+
#include "../utils/pybind_utils.h"
52
#include "source_base/math_integral.h"
3+
#include "source_base/math_sphbes.h"
64
#include "source_base/spherical_bessel_transformer.h"
75

8-
#include "../utils/pybind_utils.h"
6+
#include <pybind11/numpy.h>
7+
#include <pybind11/pybind11.h>
98

109
namespace py = pybind11;
1110
using namespace pybind11::literals;
@@ -25,21 +24,13 @@ void bind_base_math(py::module& m)
2524
[](const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> jl) {
2625
check_1d_array(r, "r");
2726
check_1d_array(jl, "jl");
28-
ModuleBase::Sphbes::sphbesj(n,
29-
get_array_ptr(r),
30-
q,
31-
l,
32-
get_array_ptr(jl));
27+
ModuleBase::Sphbes::sphbesj(n, get_array_ptr(r), q, l, get_array_ptr(jl));
3328
})
3429
.def_static("dsphbesj",
3530
[](const int n, py::array_t<double> r, const double q, const int l, py::array_t<double> djl) {
3631
check_1d_array(r, "r");
3732
check_1d_array(djl, "djl");
38-
ModuleBase::Sphbes::dsphbesj(n,
39-
get_array_ptr(r),
40-
q,
41-
l,
42-
get_array_ptr(djl));
33+
ModuleBase::Sphbes::dsphbesj(n, get_array_ptr(r), q, l, get_array_ptr(djl));
4334
})
4435
.def_static("sphbes_zeros", [](const int l, const int n, py::array_t<double> zeros) {
4536
check_1d_array(zeros, "zeros");
@@ -49,76 +40,68 @@ void bind_base_math(py::module& m)
4940
// python binding for class Integral
5041
py::class_<ModuleBase::Integral>(m, "Integral")
5142
.def(py::init<>())
52-
.def_static("Simpson_Integral", [](const int mesh, py::array_t<double> func, py::array_t<double> rab, double asum) {
53-
check_1d_array(func, "func");
54-
check_1d_array(rab, "rab");
43+
.def_static("Simpson_Integral",
44+
[](const int mesh, py::array_t<double> func, py::array_t<double> rab, double asum) {
45+
check_1d_array(func, "func");
46+
check_1d_array(rab, "rab");
5547

56-
double isum = asum;
57-
ModuleBase::Integral::Simpson_Integral(mesh,
58-
get_array_ptr(func),
59-
get_array_ptr(rab),
60-
isum);
61-
return isum;
62-
})
63-
.def_static("Simpson_Integral", [](const int mesh, py::array_t<double> func, const double dr, double asum){
64-
check_1d_array(func, "func");
48+
double isum = asum;
49+
ModuleBase::Integral::Simpson_Integral(mesh, get_array_ptr(func), get_array_ptr(rab), isum);
50+
return isum;
51+
})
52+
.def_static("Simpson_Integral",
53+
[](const int mesh, py::array_t<double> func, const double dr, double asum) {
54+
check_1d_array(func, "func");
6555

66-
double isum = asum;
67-
ModuleBase::Integral::Simpson_Integral(mesh,
68-
get_array_ptr(func),
69-
dr,
70-
isum);
71-
return isum;
72-
})
73-
.def_static("Simpson_Integral_0toall", [](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum){
74-
check_1d_array(func, "func");
75-
check_1d_array(rab, "rab");
76-
check_1d_array(asum, "asum");
77-
ModuleBase::Integral::Simpson_Integral_0toall(mesh,
78-
get_array_ptr(func),
79-
get_array_ptr(rab),
80-
get_array_ptr(asum));
81-
})
82-
.def_static("Simpson_Integral_alltoinf", [](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum){
83-
check_1d_array(func, "func");
84-
check_1d_array(rab, "rab");
85-
check_1d_array(asum, "asum");
86-
ModuleBase::Integral::Simpson_Integral_alltoinf(mesh,
87-
get_array_ptr(func),
88-
get_array_ptr(rab),
89-
get_array_ptr(asum));
90-
})
91-
.def_static("simpson", [](const int n, py::array_t<double> f, const double dx){
92-
check_1d_array(f, "f");
93-
return ModuleBase::Integral::simpson(n,
94-
get_array_ptr(f),
95-
dx);
96-
})
97-
.def_static("simpson", [](const int n, py::array_t<double> f, py::array_t<double> h){
98-
check_1d_array(f, "f");
99-
check_1d_array(h, "h");
100-
return ModuleBase::Integral::simpson(n,
101-
get_array_ptr(f),
102-
get_array_ptr(h));
103-
})
104-
.def_static("Gauss_Legendre_grid_and_weight", [](const int n, py::array_t<double> x, py::array_t<double> w){
105-
check_1d_array(x, "x");
106-
check_1d_array(w, "w");
107-
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(n,
108-
get_array_ptr(x),
109-
get_array_ptr(w));
110-
})
111-
.def_static("Gauss_Legendre_grid_and_weight", [](const double xmin, const double xmax, const int n, py::array_t<double> x, py::array_t<double> w){
112-
check_1d_array(x, "x");
113-
check_1d_array(w, "w");
114-
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(xmin,
115-
xmax,
116-
n,
117-
get_array_ptr(x),
118-
get_array_ptr(w));
119-
});
120-
py::class_<ModuleBase::SphericalBesselTransformer>(m, "SphericalBesselTransformer")
121-
.def(py::init<>());
56+
double isum = asum;
57+
ModuleBase::Integral::Simpson_Integral(mesh, get_array_ptr(func), dr, isum);
58+
return isum;
59+
})
60+
.def_static("Simpson_Integral_0toall",
61+
[](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum) {
62+
check_1d_array(func, "func");
63+
check_1d_array(rab, "rab");
64+
check_1d_array(asum, "asum");
65+
ModuleBase::Integral::Simpson_Integral_0toall(mesh,
66+
get_array_ptr(func),
67+
get_array_ptr(rab),
68+
get_array_ptr(asum));
69+
})
70+
.def_static("Simpson_Integral_alltoinf",
71+
[](const int mesh, py::array_t<double> func, py::array_t<double> rab, py::array_t<double> asum) {
72+
check_1d_array(func, "func");
73+
check_1d_array(rab, "rab");
74+
check_1d_array(asum, "asum");
75+
ModuleBase::Integral::Simpson_Integral_alltoinf(mesh,
76+
get_array_ptr(func),
77+
get_array_ptr(rab),
78+
get_array_ptr(asum));
79+
})
80+
.def_static("simpson",
81+
[](const int n, py::array_t<double> f, const double dx) {
82+
check_1d_array(f, "f");
83+
return ModuleBase::Integral::simpson(n, get_array_ptr(f), dx);
84+
})
85+
.def_static("simpson",
86+
[](const int n, py::array_t<double> f, py::array_t<double> h) {
87+
check_1d_array(f, "f");
88+
check_1d_array(h, "h");
89+
return ModuleBase::Integral::simpson(n, get_array_ptr(f), get_array_ptr(h));
90+
})
91+
.def_static("Gauss_Legendre_grid_and_weight",
92+
[](const int n, py::array_t<double> x, py::array_t<double> w) {
93+
check_1d_array(x, "x");
94+
check_1d_array(w, "w");
95+
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(n, get_array_ptr(x), get_array_ptr(w));
96+
})
97+
.def_static(
98+
"Gauss_Legendre_grid_and_weight",
99+
[](const double xmin, const double xmax, const int n, py::array_t<double> x, py::array_t<double> w) {
100+
check_1d_array(x, "x");
101+
check_1d_array(w, "w");
102+
ModuleBase::Integral::Gauss_Legendre_grid_and_weight(xmin, xmax, n, get_array_ptr(x), get_array_ptr(w));
103+
});
104+
py::class_<ModuleBase::SphericalBesselTransformer>(m, "SphericalBesselTransformer").def(py::init<>());
122105
}
123106

124107
PYBIND11_MODULE(_base_pack, m)

0 commit comments

Comments
 (0)