Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
156 changes: 5 additions & 151 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ jobs:
with:
python-version: ${{ matrix.python-version }}

- name: Install native dependencies
run: |
sudo apt-get update
sudo apt-get install -y libeigen3-dev libqhull-dev

Comment thread
AkshayThiru marked this conversation as resolved.
- name: Install build dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
Expand All @@ -39,101 +44,6 @@ jobs:
cd python
pytest tests/ -v

build-wheel:
runs-on: ubuntu-latest
name: Build wheel distribution
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install build tools
run: |
python -m pip install --upgrade pip
pip install build

- name: Build wheel and sdist
run: |
cd python
python -m build

- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: python-packages
path: python/dist/
retention-days: 1

test-wheel:
runs-on: ubuntu-latest
needs: build-wheel
name: Test wheel installation
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Download wheel artifact
uses: actions/download-artifact@v3
with:
name: python-packages
path: dist/

- name: List downloaded files
run: ls -lh dist/

- name: Install from wheel in clean environment
run: |
# Create a temporary directory for the clean install
mkdir -p /tmp/wheel-test
cd /tmp/wheel-test
python -m venv test_env
source test_env/bin/activate
pip install --upgrade pip
WHEEL=$(ls "${{ github.workspace }}"/dist/dgd-*.whl)
pip install "$WHEEL"

- name: Test wheel imports all symbols
run: |
source /tmp/wheel-test/test_env/bin/activate
python <<'PY'
import dgd
import inspect

# Check all public exports declared by the package are present.
expected_symbols = getattr(dgd, '__all__', None)
if not isinstance(expected_symbols, list):
print('ERROR: dgd.__all__ is missing or not a list')
raise SystemExit(1)

missing = [s for s in expected_symbols if not hasattr(dgd, s)]
if missing:
print(f'ERROR: Missing symbols: {missing}')
raise SystemExit(1)

print(f' All {len(expected_symbols)} expected symbols found in dgd package')

# Verify stub file is accessible
stub_path = inspect.getfile(dgd._dgd_core)
print(f' Module loaded from: {stub_path}')
PY

- name: Run basic functionality test
run: |
source /tmp/wheel-test/test_env/bin/activate
cd /tmp/wheel-test
python -m pytest "${{ github.workspace }}/python/tests/test_types.py" -v --tb=short

cpp-build-test:
runs-on: ubuntu-latest
name: Build and test C++ library
Expand All @@ -159,62 +69,6 @@ jobs:
run: |
ctest --test-dir build-ci --output-on-failure

Comment thread
AkshayThiru marked this conversation as resolved.
cpp-coverage:
runs-on: ubuntu-latest
name: C++ code coverage (core library)
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Install native dependencies and coverage tools
run: |
sudo apt-get update
sudo apt-get install -y libeigen3-dev libqhull-dev gcovr

- name: Configure CMake (Debug + coverage)
run: |
cmake -S . -B build-cov -DCMAKE_BUILD_TYPE=Debug -DDGD_BUILD_TESTS=ON -DDGD_ENABLE_COVERAGE=ON

- name: Build C++ targets
run: |
cmake --build build-cov --parallel

- name: Run C++ unit tests
run: |
ctest --test-dir build-cov --output-on-failure

- name: Generate coverage reports
run: |
gcovr \
--root "${{ github.workspace }}" \
--object-directory build-cov \
--filter "${{ github.workspace }}/src" \
--filter "${{ github.workspace }}/include" \
--exclude ".*/tests/.*" \
--exclude ".*/benchmarks/.*" \
--exclude ".*/external/.*" \
--exclude ".*/build.*/.*" \
--cobertura build-cov/coverage.xml \
--txt build-cov/coverage.txt

- name: Upload coverage artifact
uses: actions/upload-artifact@v3
with:
name: cpp-coverage-report
path: |
build-cov/coverage.xml
build-cov/coverage.txt
retention-days: 1

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: build-cov/coverage.xml
flags: cpp
name: cpp-core-coverage
fail_ci_if_error: false

lint:
runs-on: ubuntu-latest
name: Lint and code quality
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ option(DGD_INSTALL_LIBS "Install library" ON)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

find_package(Eigen3 5.0 REQUIRED)
find_package(Eigen3 REQUIRED NO_MODULE)
message(STATUS "Found Eigen version ${Eigen3_VERSION}")
Comment thread
AkshayThiru marked this conversation as resolved.
Outdated

# Prefer shared Qhull to avoid non-PIC static archive link failures for
# Python extension modules.
if(NOT DEFINED PCL_QHULL_REQUIRED_TYPE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ The codebase is modular, extensible, and leverages modern C++17 features, as wel
## Requirements

- C++17 compiler (tested with GCC)
- [Eigen](https://eigen.tuxfamily.org/) (version 5.0 or later)
- [Eigen](https://eigen.tuxfamily.org/) (version 3.4 or later)
Comment thread
AkshayThiru marked this conversation as resolved.
Outdated
- [Qhull](http://www.qhull.org/) (for convex hull operations and adjacency graph computation)
- CMake (version 3.15 or later)

Expand Down
13 changes: 1 addition & 12 deletions python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,7 @@ export PYTHONPATH=/path/to/repo/python:$PYTHONPATH
```

Use `PYTHONPATH` only with this manual workflow. It is not needed after an editable
install or wheel install.

### Building a wheel

From the repository root, run:

```bash
pip install build
python -m build python/ --wheel
```

The generated wheel can then be installed with `pip install dist/dgd-*.whl`.
install.


## Running the tests
Expand Down
3 changes: 1 addition & 2 deletions src/graham_scan.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

#include "dgd/graham_scan.h"

#include <Eigen/Dense>
#include <algorithm>
#include <cassert>
#include <cmath>
Expand All @@ -32,7 +31,7 @@ namespace dgd {
namespace {

inline Real Ccw(const Vec2r& u, const Vec2r& v, const Vec2r& w) {
return (v - u).cross(w - u);
return (v(0) - u(0)) * (w(1) - u(1)) - (v(1) - u(1)) * (w(0) - u(0));
}

} // namespace
Expand Down
3 changes: 1 addition & 2 deletions tests/graham_scan_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <gtest/gtest.h>

#include <Eigen/Dense>
#include <cmath>
#include <vector>

Expand Down Expand Up @@ -121,7 +120,7 @@ TEST(GrahamScanTest, CcwOrientation) {
const Real side_len = 10.0;

auto ccw = [](const Vec2r& u, const Vec2r& v, const Vec2r& w) -> Real {
return (v - u).cross(w - u);
return (v(0) - u(0)) * (w(1) - u(1)) - (v(1) - u(1)) * (w(0) - u(0));
};

std::vector<Vec2r> pts(npts), vert;
Expand Down
3 changes: 3 additions & 0 deletions tests/local_geometry_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1716,6 +1716,9 @@ void CapsuleImplLocalGeometryTest() {
for (int i = 0; i < static_cast<int>(normals.size()); ++i) {
test_cases[i].base_pt = base_pts[i];
test_cases[i].ncs_true.span_dim = (i < 4) ? dim : dim - 1;
if constexpr (dim == 3) {
if (i >= 4) test_cases[i].ncs_true.basis = Vecr<dim>::UnitY();
}
}

// Run test cases.
Expand Down
18 changes: 0 additions & 18 deletions tests/solution_derivative_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -469,24 +469,6 @@ TEST(GdSolutionDerivativeTest, ConeEllipsoid) {
ConvexSetSolutionDerivativeTest(&set1, &set2, Real(1e-4), nsamples, 55);
}

Comment thread
AkshayThiru marked this conversation as resolved.
TEST(GdSolutionDerivativeTest, EllipsoidMesh) {
if (typeid(Real) == typeid(float)) GTEST_SKIP();

ConvexSetPtr<3> set1, set2;
// The numerical derivatives can be inaccurate for large number of polygon
// vertices.
MakeConvexSetPair<3>(set1, set2, Real(0.1), Real(0.1), 9);
set1 =
std::make_unique<Ellipsoid>(Real(2.0), Real(1.0), Real(0.7), Real(0.05));
// The epsilon quantities are set large only for testing purposes.
set2->set_eps_p(Real(1e-3));
set2->set_eps_d(Real(1e-3));

const int nsamples = 10;
ConvexSetSolutionDerivativeTest(set1.get(), set2.get(), Real(1e-4), nsamples,
73);
}

TEST(GdSolutionDerivativeTest, FrustumHalfspace) {
constexpr int tw_dim = SeDim<3>();
const int nsamples = 50;
Comment thread
AkshayThiru marked this conversation as resolved.
Expand Down
Loading