Skip to content

Commit c90091c

Browse files
authored
Windows (#15)
1 parent 9e3f173 commit c90091c

File tree

4 files changed

+86
-43
lines changed

4 files changed

+86
-43
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
matrix:
15-
os: [ubuntu-20.04, macos-latest]
15+
os: [ubuntu-20.04, macos-11, windows-2019]
1616

1717
steps:
1818
- uses: actions/checkout@v3

.github/workflows/ci.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
test_pygram11:
1010
strategy:
1111
matrix:
12-
platform: [ubuntu-latest, macos-latest]
12+
platform: [ubuntu-latest, macos-latest, windows-latest]
1313
python-version: ["3.8", "3.9", "3.10", "3.11-dev"]
1414
runs-on: ${{matrix.platform}}
1515
steps:
@@ -21,15 +21,20 @@ jobs:
2121
with:
2222
python-version: ${{matrix.python-version}}
2323
- name: install libomp on macOS
24-
if: startsWith(matrix.platform, 'macOS')
24+
shell: bash
2525
run: |
26-
brew install libomp
26+
if [ "$RUNNER_OS" == "macOS" ]; then
27+
brew install libomp
28+
fi
2729
- name: install
30+
shell: bash
2831
run: |
32+
python -m pip install pip wheel -U
2933
python -m pip install build
34+
python -m pip install pytest
3035
python -m build
31-
pip install dist/*.whl pytest
32-
pip list
36+
python -m pip install dist/*.whl
37+
python -m pip list
3338
- name: test
3439
run: |
3540
python -m pytest --ignore=extern

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ else()
2727
pybind11_add_module(_backend MODULE src/_backend.cpp)
2828
set_target_properties(_backend PROPERTIES CXX_STANDARD 14)
2929
target_link_libraries(_backend PUBLIC OpenMP::OpenMP_CXX)
30-
target_compile_options(_backend PRIVATE -Wall -Wextra -pedantic)
30+
if (NOT WIN32)
31+
target_compile_options(_backend PRIVATE -Wall -Wextra -pedantic)
32+
endif()
3133
target_include_directories(_backend PRIVATE extern/mp11/include)
3234
install(TARGETS _backend DESTINATION .)
3335
endif()

src/_backend.cpp

Lines changed: 72 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,20 @@ py::array_t<py::ssize_t> f1d(py::array_t<Tx, py::array::c_style> x, py::ssize_t
11411141
pg11::faxis_t<double> ax{nbins, xmin, xmax};
11421142
auto nx = x.shape(0);
11431143
if (nx < pg11::config_threshold("thresholds.fix1d")) { // serial
1144-
if (flow)
1144+
if (flow) {
11451145
pg11::one::s_loop_incf(x.data(), nx, ax, values.mutable_data());
1146-
else
1146+
}
1147+
else {
11471148
pg11::one::s_loop_excf(x.data(), nx, ax, values.mutable_data());
1149+
}
11481150
}
11491151
else { // parallel
1150-
if (flow)
1152+
if (flow) {
11511153
pg11::one::p_loop_incf(x.data(), nx, ax, values.mutable_data());
1152-
else
1154+
}
1155+
else {
11531156
pg11::one::p_loop_excf(x.data(), nx, ax, values.mutable_data());
1157+
}
11541158
}
11551159
return values;
11561160
}
@@ -1163,20 +1167,24 @@ py::tuple f1dw(py::array_t<Tx, py::array::c_style> x, py::array_t<Tw, py::array:
11631167
auto nx = x.shape(0);
11641168
pg11::faxis_t<double> ax{nbins, xmin, xmax};
11651169
if (nx < pg11::config_threshold("thresholds.fix1d")) { // serial
1166-
if (flow)
1170+
if (flow) {
11671171
pg11::one::s_loop_incf(x.data(), w.data(), nx, ax, values.mutable_data(),
11681172
variances.mutable_data());
1169-
else
1173+
}
1174+
else {
11701175
pg11::one::s_loop_excf(x.data(), w.data(), nx, ax, values.mutable_data(),
11711176
variances.mutable_data());
1177+
}
11721178
}
11731179
else { // parallel
1174-
if (flow)
1180+
if (flow) {
11751181
pg11::one::p_loop_incf(x.data(), w.data(), nx, ax, values.mutable_data(),
11761182
variances.mutable_data());
1177-
else
1183+
}
1184+
else {
11781185
pg11::one::p_loop_excf(x.data(), w.data(), nx, ax, values.mutable_data(),
11791186
variances.mutable_data());
1187+
}
11801188
}
11811189
return py::make_tuple(values, variances);
11821190
}
@@ -1188,10 +1196,12 @@ py::tuple f1dmw(py::array_t<Tx> x, py::array_t<Tw> w, py::ssize_t nbins, double
11881196
auto variances = pg11::zeros<Tw>(nbins, w.shape(1));
11891197
pg11::faxis_t<double> ax{nbins, xmin, xmax};
11901198
if (x.shape(0) < pg11::config_threshold("thresholds.fix1dmw")) { // serial
1191-
if (flow)
1199+
if (flow) {
11921200
pg11::one::s_loop_incf(x, w, ax, values, variances);
1193-
else
1201+
}
1202+
else {
11941203
pg11::one::s_loop_excf(x, w, ax, values, variances);
1204+
}
11951205
}
11961206
else { // parallel
11971207
if (flow)
@@ -1210,16 +1220,20 @@ py::array_t<py::ssize_t> v1d(py::array_t<Tx, py::array::c_style> x,
12101220
auto values = pg11::zeros<py::ssize_t>(nedges - 1);
12111221
auto nx = x.shape(0);
12121222
if (nx < pg11::config_threshold("thresholds.var1d")) { // serial
1213-
if (flow)
1223+
if (flow) {
12141224
pg11::one::s_loop_incf(x.data(), nx, edges_v, values.mutable_data());
1215-
else
1225+
}
1226+
else {
12161227
pg11::one::s_loop_excf(x.data(), nx, edges_v, values.mutable_data());
1228+
}
12171229
}
12181230
else { // parallel
1219-
if (flow)
1231+
if (flow) {
12201232
pg11::one::p_loop_incf(x.data(), nx, edges_v, values.mutable_data());
1221-
else
1233+
}
1234+
else {
12221235
pg11::one::p_loop_excf(x.data(), nx, edges_v, values.mutable_data());
1236+
}
12231237
}
12241238
return values;
12251239
}
@@ -1234,20 +1248,24 @@ py::tuple v1dw(py::array_t<Tx, py::array::c_style> x, py::array_t<Tw, py::array:
12341248
auto variances = pg11::zeros<Tw>(nbins);
12351249
auto nx = x.shape(0);
12361250
if (nx < pg11::config_threshold("thresholds.var1d")) { // serial
1237-
if (flow)
1251+
if (flow) {
12381252
pg11::one::s_loop_incf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
12391253
variances.mutable_data());
1240-
else
1254+
}
1255+
else {
12411256
pg11::one::s_loop_excf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
12421257
variances.mutable_data());
1258+
}
12431259
}
12441260
else { // parallel
1245-
if (flow)
1261+
if (flow) {
12461262
pg11::one::p_loop_incf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
12471263
variances.mutable_data());
1248-
else
1264+
}
1265+
else {
12491266
pg11::one::p_loop_excf(x.data(), w.data(), nx, edges_v, values.mutable_data(),
12501267
variances.mutable_data());
1268+
}
12511269
}
12521270
return py::make_tuple(values, variances);
12531271
}
@@ -1261,10 +1279,12 @@ py::tuple v1dmw(py::array_t<Tx> x, py::array_t<Tw> w, py::array_t<double> edges,
12611279
auto values = pg11::zeros<Tw>(nbins, w.shape(1));
12621280
auto variances = pg11::zeros<Tw>(nbins, w.shape(1));
12631281
if (x.shape(0) < pg11::config_threshold("thresholds.var1dmw")) { // serial
1264-
if (flow)
1282+
if (flow) {
12651283
pg11::one::s_loop_incf(x, w, edges_v, values, variances);
1266-
else
1284+
}
1285+
else {
12671286
pg11::one::s_loop_excf(x, w, edges_v, values, variances);
1287+
}
12681288
}
12691289
else { // parallel
12701290
if (flow)
@@ -1283,16 +1303,20 @@ py::array_t<py::ssize_t> f2d(py::array_t<Tx> x, py::array_t<Ty> y, py::ssize_t n
12831303
pg11::faxis_t<double> axx{nbinsx, xmin, xmax};
12841304
pg11::faxis_t<double> axy{nbinsy, ymin, ymax};
12851305
if (x.shape(0) < pg11::config_threshold("thresholds.fix2d")) { // serial
1286-
if (flow)
1306+
if (flow) {
12871307
pg11::two::s_loop_incf(x.data(), y.data(), x.shape(0), axx, axy, values);
1288-
else
1308+
}
1309+
else {
12891310
pg11::two::s_loop_excf(x.data(), y.data(), x.shape(0), axx, axy, values);
1311+
}
12901312
}
12911313
else {
1292-
if (flow)
1314+
if (flow) {
12931315
pg11::two::p_loop_incf(x.data(), y.data(), x.shape(0), axx, axy, values);
1294-
else
1316+
}
1317+
else {
12951318
pg11::two::p_loop_excf(x.data(), y.data(), x.shape(0), axx, axy, values);
1319+
}
12961320
}
12971321
return values;
12981322
}
@@ -1306,20 +1330,24 @@ py::tuple f2dw(py::array_t<Tx> x, py::array_t<Ty> y, py::array_t<Tw> w, py::ssiz
13061330
pg11::faxis_t<double> axx{nbinsx, xmin, xmax};
13071331
pg11::faxis_t<double> axy{nbinsy, ymin, ymax};
13081332
if (x.shape(0) < pg11::config_threshold("thresholds.fix2d")) { // serial
1309-
if (flow)
1333+
if (flow) {
13101334
pg11::two::s_loop_incf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
13111335
variances);
1312-
else
1336+
}
1337+
else {
13131338
pg11::two::s_loop_excf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
13141339
variances);
1340+
}
13151341
}
13161342
else {
1317-
if (flow)
1343+
if (flow) {
13181344
pg11::two::p_loop_incf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
13191345
variances);
1320-
else
1346+
}
1347+
else {
13211348
pg11::two::p_loop_excf(x.data(), y.data(), w.data(), x.shape(0), axx, axy, values,
13221349
variances);
1350+
}
13231351
}
13241352
return py::make_tuple(values, variances);
13251353
}
@@ -1336,16 +1364,20 @@ py::array_t<py::ssize_t> v2d(py::array_t<Tx> x, py::array_t<Ty> y,
13361364
std::vector<double> edgesx_v(xbins.data(), xbins.data() + nedgesx);
13371365
std::vector<double> edgesy_v(ybins.data(), ybins.data() + nedgesy);
13381366
if (x.shape(0) < pg11::config_threshold("thresholds.var2d")) {
1339-
if (flow)
1367+
if (flow) {
13401368
pg11::two::s_loop_incf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
1341-
else
1369+
}
1370+
else {
13421371
pg11::two::s_loop_excf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
1372+
}
13431373
}
13441374
else {
1345-
if (flow)
1375+
if (flow) {
13461376
pg11::two::p_loop_incf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
1347-
else
1377+
}
1378+
else {
13481379
pg11::two::p_loop_excf(x.data(), y.data(), x.shape(0), edgesx_v, edgesy_v, values);
1380+
}
13491381
}
13501382
return values;
13511383
}
@@ -1362,20 +1394,24 @@ py::tuple v2dw(py::array_t<Tx> x, py::array_t<Ty> y, py::array_t<Tw> w,
13621394
std::vector<double> edgesx_v(xbins.data(), xbins.data() + nedgesx);
13631395
std::vector<double> edgesy_v(ybins.data(), ybins.data() + nedgesy);
13641396
if (x.shape(0) < pg11::config_threshold("thresholds.var2d")) {
1365-
if (flow)
1397+
if (flow) {
13661398
pg11::two::s_loop_incf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
13671399
values, variances);
1368-
else
1400+
}
1401+
else {
13691402
pg11::two::s_loop_excf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
13701403
values, variances);
1404+
}
13711405
}
13721406
else {
1373-
if (flow)
1407+
if (flow) {
13741408
pg11::two::p_loop_incf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
13751409
values, variances);
1376-
else
1410+
}
1411+
else {
13771412
pg11::two::p_loop_excf(x.data(), y.data(), w.data(), x.shape(0), edgesx_v, edgesy_v,
13781413
values, variances);
1414+
}
13791415
}
13801416
return py::make_tuple(values, variances);
13811417
}

0 commit comments

Comments
 (0)