Skip to content

Commit b1b33f9

Browse files
committed
chore: update CI scripts
1 parent 4624469 commit b1b33f9

File tree

6 files changed

+29
-25
lines changed

6 files changed

+29
-25
lines changed

.github/workflows/cibuildwheel.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ jobs:
192192

193193

194194
steps:
195-
- uses: actions/checkout@v2
195+
- uses: actions/checkout@v4
196196
with:
197197
submodules: recursive
198198
- uses: actions/setup-python@v5
@@ -201,7 +201,7 @@ jobs:
201201
python-version: '3.10'
202202
- name: Set up QEMU
203203
if: runner.os == 'Linux'
204-
uses: docker/setup-qemu-action@v1
204+
uses: docker/setup-qemu-action@v3
205205
with:
206206
platforms: all
207207
- name: Build wheels
@@ -215,15 +215,16 @@ jobs:
215215
CIBW_BUILD_VERBOSITY: 1
216216
CIBW_ARCHS: ${{ matrix.arch }}
217217
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
218-
- uses: actions/upload-artifact@v2
218+
- uses: actions/upload-artifact@v4
219219
with:
220+
name: artifact
220221
path: ./wheelhouse/*.whl
221222

222223
build_sdist:
223224
name: Build source distribution
224225
runs-on: ubuntu-latest
225226
steps:
226-
- uses: actions/checkout@v2
227+
- uses: actions/checkout@v4
227228
with:
228229
submodules: recursive
229230
- uses: actions/setup-python@v5
@@ -232,8 +233,9 @@ jobs:
232233
python-version: '3.10'
233234
- name: Build sdist
234235
run: python setup.py sdist
235-
- uses: actions/upload-artifact@v2
236+
- uses: actions/upload-artifact@v4
236237
with:
238+
name: artifact
237239
path: dist/*.tar.gz
238240

239241
upload_pypi:
@@ -242,11 +244,11 @@ jobs:
242244
# upload to PyPI on every tag starting with 'v'
243245
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags/v')
244246
steps:
245-
- uses: actions/download-artifact@v2
247+
- uses: actions/download-artifact@v4
246248
with:
247249
name: artifact
248250
path: dist
249-
- uses: pypa/gh-action-pypi-publish@v1.4.2
251+
- uses: pypa/gh-action-pypi-publish@v1.8.11
250252
with:
251253
user: __token__
252254
password: ${{ secrets.PYPI_API_TOKEN }}

cpp/prtree.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ auto list_list_to_arrays(vec<vec<T>> out_ll)
7777
}
7878
vec<T> out;
7979
out.reserve(sum);
80-
for (const auto &v : out_ll)
81-
out.insert(out.end(), v.begin(), v.end());
80+
for (auto &v : out_ll)
81+
out.insert(out.end(),
82+
std::make_move_iterator(v.begin()),
83+
std::make_move_iterator(v.end()));
8284

8385
return make_tuple(
8486
std::move(as_pyarray(out_s)),
@@ -104,14 +106,14 @@ static const float REBUILD_THRE = 1.25;
104106
#define unlikely(x) (x)
105107
#endif
106108

107-
std::string compress(std::string &data)
109+
inline std::string compress(const std::string &data)
108110
{
109111
std::string output;
110112
snappy::Compress(data.data(), data.size(), &output);
111113
return output;
112114
}
113115

114-
std::string decompress(std::string &data)
116+
inline std::string decompress(const std::string &data)
115117
{
116118
std::string output;
117119
snappy::Uncompress(data.data(), data.size(), &output);
@@ -702,25 +704,22 @@ class PRTreeElement
702704
template <class T, int B = 6, int D = 2>
703705
void bfs(const std::function<void(std::unique_ptr<PRTreeLeaf<T, B, D>> &)> &func, vec<PRTreeElement<T, B, D>> &flat_tree, const BB<D> target)
704706
{
705-
queue<size_t> que;
706-
auto qpush_if_intersect = [&](const size_t &i)
707+
vec<size_t> que;
708+
que.reserve(flat_tree.size());
709+
auto qpush_if_intersect = [&](size_t i)
707710
{
708711
PRTreeElement<T, B, D> &r = flat_tree[i];
709-
// std::cout << "i " << (long int) i << " : " << (bool) r.leaf << std::endl;
710712
if (r(target))
711713
{
712-
// std::cout << " is pushed" << std::endl;
713-
que.emplace(i);
714+
que.push_back(i);
714715
}
715716
};
716717

717-
// std::cout << "size: " << flat_tree.size() << std::endl;
718718
qpush_if_intersect(0);
719-
while (!que.empty())
719+
size_t qhead = 0;
720+
while (qhead < que.size())
720721
{
721-
size_t idx = que.front();
722-
// std::cout << "idx: " << (long int) idx << std::endl;
723-
que.pop();
722+
size_t idx = que[qhead++];
724723
PRTreeElement<T, B, D> &elem = flat_tree[idx];
725724

726725
if (elem.leaf)
@@ -733,7 +732,8 @@ void bfs(const std::function<void(std::unique_ptr<PRTreeLeaf<T, B, D>> &)> &func
733732
for (size_t offset = 0; offset < B; offset++)
734733
{
735734
size_t jdx = idx * B + offset + 1;
736-
qpush_if_intersect(jdx);
735+
if (jdx < flat_tree.size())
736+
qpush_if_intersect(jdx);
737737
}
738738
}
739739
}

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pytest==7.1.2
22
pybind11==2.9.0
3-
cmake==3.22.4
3+
cmake==3.22.4

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
numpy>=1.16,<2.0
1+
numpy>=1.16,<2.0

run_profile.sh

100755100644
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
set -e
23

34
rm -rf build dist .pytest_cache
@@ -8,4 +9,4 @@ python docs/run_profile.py
89
so_path=src/python_prtree/PRTree.cpython-310-x86_64-linux-gnu.so
910
google-pprof --callgrind $so_path build.prof > cg_build.prof
1011
google-pprof --callgrind $so_path find_all.prof > cg_find_all.prof
11-
google-pprof --callgrind $so_path insert.prof > cg_insert.prof
12+
google-pprof --callgrind $so_path insert.prof > cg_insert.prof

run_test.sh

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/usr/bin/env bash
12
set -e
23

34
rm -rf build dist .pytest_cache

0 commit comments

Comments
 (0)