Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/v0.1.0 #40

Merged
merged 8 commits into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
python-version: "3.10"

- name: build napf linux
run: pip install -e.
run: pip install .

- name: test
run: python3 tests/test_init_and_query.py
Expand Down
67 changes: 30 additions & 37 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,33 @@ on:
pull_request:

jobs:
macos_wheel:
runs-on: macos-latest
strategy:
matrix:
arch: [x86_64, arm64]
cw_build: ["pp*", "cp*"]
exclude:
- arch: arm64
cw_build: "pp*"
macos_wheel_m:
runs-on: macos-14

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: build wheels
uses: pypa/cibuildwheel@v2.18
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.cw_build }}
CIBW_TEST_SKIP: "*-macosx_x86_64"
CIBW_ARCHS: "arm64"

- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl

macos_wheel_intel:
runs-on: macos-13

steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: build wheels
uses: pypa/[email protected]
env:
CIBW_ARCHS: "x86_64"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -34,22 +41,16 @@ jobs:

linux_wheel:
runs-on: ubuntu-latest
strategy:
matrix:
arch: [x86_64]
cw_build: ["cp*manylinux*", "pp*manylinux*", "*musllinux*"]


steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: build wheels
uses: pypa/cibuildwheel@v2.18
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.cw_build }}
CIBW_SKIP: "pp39-many*"
CIBW_ARCHS: x86_64
CIBW_BUILD: "cp*manylinux*"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -60,14 +61,7 @@ jobs:
strategy:
matrix:
arch: [aarch64, ppc64le]
cw_build: ["cp36*many*", "cp37*many*", "cp38*many*", "cp39*many*", "cp310*many*", "cp311*many*", "cp312*many*", "pp37*many*", "pp38*many*", "pp39*many*"]
exclude:
- arch: ppc64le
cw_build: "pp37*many*"
- arch: ppc64le
cw_build: "pp38*many*"
- arch: ppc64le
cw_build: "pp39*many*"
cw_build: ["cp37*many*", "cp38*many*", "cp39*many*", "cp310*many*", "cp311*many*", "cp312*many*"]

steps:
- uses: actions/checkout@v3
Expand All @@ -81,11 +75,11 @@ jobs:
platforms: arm64, ppc64le

- name: build wheels
uses: pypa/cibuildwheel@v2.18
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_BUILD: ${{ matrix.cw_build }}
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le,s390x}"
CIBW_TEST_SKIP: "*-*linux_{aarch64,ppc64le}"

- uses: actions/upload-artifact@v3
with:
Expand All @@ -104,9 +98,10 @@ jobs:
with:
submodules: recursive
- name: build wheels
uses: pypa/cibuildwheel@v2.18
uses: pypa/cibuildwheel@v2.19
env:
CIBW_ARCHS: ${{ matrix.arch }}
CIBW_SKIP: "pp*"


- uses: actions/upload-artifact@v3
Expand All @@ -129,10 +124,8 @@ jobs:
path: ./dist/*

upload_pypi:
needs: [macos_wheel, linux_wheel, windows_wheel, source_dist]
needs: [macos_wheel_m, macos_wheel_intel, linux_wheel, windows_wheel, source_dist]
runs-on: ubuntu-latest
permissions:
id-token: write
# try to publish only if this is a push to stable branch
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
steps:
Expand All @@ -143,4 +136,4 @@ jobs:

- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
skip_existing: true
38 changes: 18 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@

# use default options for ci
ci:
autoupdate_schedule: "monthly"
autoupdate_schedule: "weekly"
submodules: false

exclude: "third_party/nanoflann.hpp"

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: "v4.6.0"
Expand All @@ -28,31 +26,31 @@ repos:
- id: requirements-txt-fixer
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: "v3.15.2"
hooks:
- id: pyupgrade
args: [--py36-plus]

- repo: https://github.com/PyCQA/isort
rev: "5.13.2"
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: "24.4.2"
hooks:
- id: black
args: [--line-length=79]
additional_dependencies: [tomli]

- repo: https://github.com/PyCQA/flake8
rev: 7.0.0
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.4
hooks:
- id: flake8
args: [--extend-ignore=E203]
- id: ruff
args: [--fix, --exit-non-zero-on-fix]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.4
rev: v18.1.8
hooks:
- id: clang-format
types_or: [c++]

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: "v0.6.13"
hooks:
- id: cmake-format

- repo: https://github.com/keewis/blackdoc
rev: v0.3.9
hooks:
- id: blackdoc
additional_dependencies: [tomli]
82 changes: 30 additions & 52 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
cmake_minimum_required(VERSION 3.12)
project(napf VERSION 0.0.0 LANGUAGES CXX)
project(
napf
VERSION 0.1.0
LANGUAGES CXX)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)

endif()

# options
option(BUILD_EXAMPLES "build examples" ON)
option(BUILD_FORTRAN_MODULE "build fortran module" ON)
option(SPLINEPY_EXT "add splinepy extension" ON)
option(NAPF_BUILD_PYTHON "build python module" ON)

# config
set(exe_dest "bin")
Expand All @@ -29,68 +31,44 @@ add_library(napf INTERFACE)
add_library(napf::napf ALIAS napf)

# basic path
target_include_directories(napf
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${incl_dest}>)
target_include_directories(
napf INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<INSTALL_INTERFACE:${incl_dest}>)

# try to use installed nanoflann.
# else, include the one in the third_party
# try to use installed nanoflann. else, include the one in the third_party
find_package(nanoflann QUIET)
if(nanoflann_FOUND AND nanoflann_VERSION VERSION_GREATER_EQUAL "1.5.0")
message("nanoflann found - napf will link to nanoflann found in system.")
target_link_libraries(napf INTERFACE nanoflann::nanoflann)
else()
set(CXX_HEADERS ${CXX_HEADERS} third_party/nanoflann.hpp)
target_include_directories(napf
INTERFACE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party>)
target_include_directories(
napf INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party>)
endif()
target_compile_features(napf INTERFACE cxx_std_11)

if(BUILD_FORTRAN_MODULE)
message("*** building additional fortran module ***")
message("*** ------ NOT IMPLEMENTED ----------- ***")
endif(BUILD_FORTRAN_MODULE)

if(BUILD_EXAMPLES)
message("*** building examples ***")
message("*** ------ NOT IMPLEMENTED ----------- ***")
endif(BUILD_EXAMPLES)

if(SPLINEPY_EXT)
target_compile_definitions(napf INTERFACE -DSPLINEPYEXT)
endif(SPLINEPY_EXT)
if(NAPF_BUILD_PYTHON)
add_subdirectory(src/python)
endif()

# configure config files
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${version_config}" COMPATIBILITY SameMajorVersion
)
configure_package_config_file(
"cmake/config.cmake.in"
"${project_config}"
INSTALL_DESTINATION "${cfg_dest}"
)
write_basic_package_version_file("${version_config}"
COMPATIBILITY SameMajorVersion)
configure_package_config_file("cmake/config.cmake.in" "${project_config}"
INSTALL_DESTINATION "${cfg_dest}")

install(
TARGETS napf
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${lib_dest}
ARCHIVE DESTINATION ${lib_dest}
INCLUDES DESTINATION "${incl_dest}"
)
install(
FILES "${project_config}" "${version_config}"
DESTINATION "${cfg_dest}"
)
TARGETS napf
EXPORT "${TARGETS_EXPORT_NAME}"
LIBRARY DESTINATION ${lib_dest}
ARCHIVE DESTINATION ${lib_dest}
INCLUDES
DESTINATION "${incl_dest}")
install(FILES "${project_config}" "${version_config}" DESTINATION "${cfg_dest}")

install(
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${cfg_dest}"
)
install(
FILES ${CXX_HEADERS}
DESTINATION ${incl_dest}
)
EXPORT "${TARGETS_EXPORT_NAME}"
NAMESPACE "${namespace}"
DESTINATION "${cfg_dest}")
install(FILES ${CXX_HEADERS} DESTINATION ${incl_dest})
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# napf
<p align="center"><img src="https://github.com/tataratat/napf/raw/main/docs/source/_static/napf.png" width="50%" title="nurbs"></p>

**napf - [nanoflann](https://github.com/jlblancoc/nanoflann) wrappers for python and maybe fortran**

[![main](https://github.com/tataratat/napf/actions/workflows/main.yml/badge.svg)](https://github.com/tataratat/napf/actions/workflows/main.yml)
[![PyPI version](https://badge.fury.io/py/napf.svg)](https://badge.fury.io/py/napf)

[nanoflann](https://github.com/jlblancoc/nanoflann) wrappers for python and maybe fortran.

## python
As `nanoflann` offers template classes, separate classes are implemented in `napf` for each ___{datatype, distance metric}___. All the search functions are equipped with multi-thread execution. Uses [numpy.ndarray](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.html) for data input and output.
Expand Down
2 changes: 1 addition & 1 deletion napf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version = "0.0.8"
version = "0.1.0"
6 changes: 3 additions & 3 deletions napf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def knn_search(self, queries, kneighbors, nthread=None):

Parameters
-----------
queires: (m, d) np.ndarray
queries: (m, d) np.ndarray
Data type will be casted to the same type as `tree_data`.
kneighbors: int
nthread: int
Expand Down Expand Up @@ -405,7 +405,7 @@ def radii_search(self, queries, radii, return_sorted, nthread=None):
# input size check
if len(queries) != len(radii):
raise ValueError(
f"Input size mismatch between queires ({len(queries)}) "
f"Input size mismatch between queries ({len(queries)}) "
f" and radii ({len(radii)})."
"They should be the same."
)
Expand Down Expand Up @@ -447,7 +447,7 @@ def unique_data_and_inverse(
Same as kdt.tree_data[unique_ids].
unique_ids: np.ndarray
Indices of unique entries from tree data.
First occurance is considered unique.
First occurrence is considered unique.
inverse_ids: np.ndarray
Indices to reconstruct original tree_data with
unique_data. kdt.tree_data == unique_data[inverse_ids]
Expand Down
Loading
Loading