Skip to content

Commit

Permalink
update python tests and python module to work with new pybind11 bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
DimasfromLavoisier committed Sep 3, 2024
1 parent 802fe20 commit 9ec4318
Show file tree
Hide file tree
Showing 70 changed files with 591 additions and 7,765 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,17 @@ jobs:
env:
SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT: "120"

- name: Run tests
- name: Run unmarked tests
# Disable MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.
if: runner.os != 'macOS'
run: |
python -m pytest
- name: Run marked tests
if: runner.os != 'macOS'
run: |
python -m pytest -m exe
python -m pytest -m pyh
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ target_link_libraries(helios++ PRIVATE helios)

if(BUILD_PYTHON)
include_directories(${Python_INCLUDE_DIRS})
include_directories(${CMAKE_SOURCE_DIR}/src/binds)
include_directories(${CMAKE_SOURCE_DIR}/src/python)
pybind11_add_module(_helios MODULE python/helios/helios_python.cpp)
target_link_libraries(_helios PUBLIC helios pybind11::module)
install(TARGETS _helios DESTINATION .)
Expand All @@ -175,7 +175,7 @@ endif()
install(
TARGETS
helios++
DESTINATION helios/bin
DESTINATION pyhelios/bin
)

include(FeatureSummary)
Expand Down
8 changes: 8 additions & 0 deletions environment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,11 @@ dependencies:
- pytest
- laspy
- lazrs-python
- scipy
- polyscope
- tqdm
- pandas
- pdal
- ipywidgets
variables:
PYTHONPATH: "python"
278 changes: 60 additions & 218 deletions example_notebooks/A-arboretum_notebook.ipynb

Large diffs are not rendered by default.

106 changes: 22 additions & 84 deletions example_notebooks/I-getting-started.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,10 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "190276b5",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"2.0.0a3.dev10+g9e1844ae.d20240528\n"
]
}
],
"outputs": [],
"source": [
"import pyhelios\n",
"\n",
Expand All @@ -56,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "0d4d3428",
"metadata": {},
"outputs": [],
Expand All @@ -75,19 +67,19 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "5411a736",
"metadata": {},
"outputs": [],
"source": [
"# pyhelios.loggingQuiet()\n",
"# pyhelios.loggingSilent()\n",
"pyhelios.loggingDefault()\n",
"pyhelios.logging_default()\n",
"# pyhelios.loggingVerbose()\n",
"# pyhelios.loggingVerbose2()\n",
"\n",
"# Set seed for default random number generator.\n",
"pyhelios.setDefaultRandomnessGeneratorSeed(\"123\")"
"pyhelios.default_rand_generator_seed(\"123\")"
]
},
{
Expand All @@ -100,19 +92,10 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": null,
"id": "5e5fd46a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SimulationBuilder is building simulation ...\n",
"SimulationBuilder built simulation in 0.06853010000486393 seconds\n"
]
}
],
"outputs": [],
"source": [
"simBuilder = pyhelios.SimulationBuilder(\n",
" \"data/surveys/toyblocks/als_toyblocks.xml\", [\"assets/\"], \"output/\"\n",
Expand Down Expand Up @@ -161,27 +144,14 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": null,
"id": "b744c735",
"metadata": {
"pycharm": {
"is_executing": true
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Simulation is started!\n",
"Simulation is paused!\n",
"Simulation is not running.\n",
"Simulation is resumed!\n",
"Simulation is running since 0 min and 3 sec. Please wait.\n",
"Simulation has finished.\n"
]
}
],
"outputs": [],
"source": [
"import time\n",
"\n",
Expand Down Expand Up @@ -235,40 +205,31 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": null,
"id": "26589610",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Trajectory starting point : (-30.0, -50.0, 100.0)\n",
"Trajectory end point : (69.9, 50.0, 100.0)\n"
]
}
],
"outputs": [],
"source": [
"# Create instance of PyHeliosOutputWrapper class using sim.join().\n",
"# Contains attributes 'measurements' and 'trajectories' which are Python wrappers\n",
"# of classes that contain the output vectors.\n",
"output = sim.join()\n",
"\n",
"# Create instances of vector classes by accessing 'measurements' and 'trajectories' attributes of output wrapper.\n",
"measurements = output.measurements\n",
"trajectories = output.trajectories\n",
"measurements = output[0]\n",
"trajectories = output[1]\n",
"\n",
"# Each element of vectors contains a measurement point or point in trajectory respectively.\n",
"# Access through getPosition().\n",
"starting_point = trajectories[0].getPosition()\n",
"end_point = trajectories[len(trajectories) - 1].getPosition()\n",
"starting_point = trajectories[0].position\n",
"end_point = trajectories[len(trajectories) - 1].position\n",
"\n",
"# Access individual x, y and z vals.\n",
"print(\n",
" f\"Trajectory starting point : ({starting_point.x}, {starting_point.y}, {starting_point.z})\"\n",
" f\"Trajectory starting point : ({starting_point[0]}, {starting_point[1]}, {starting_point[2]})\"\n",
")\n",
"print(\n",
" f\"Trajectory end point : ({end_point.x:.1f}, {end_point.y:.1f}, {end_point.z:.1f})\"\n",
" f\"Trajectory end point : ({end_point[0]:.1f}, {end_point[1]:.1f}, {end_point[2]:.1f})\"\n",
")"
]
},
Expand All @@ -282,7 +243,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "cf678697",
"metadata": {},
"outputs": [],
Expand All @@ -292,33 +253,10 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"id": "41887ac9",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"First three rows of measurement array:\n",
"\n",
"[[-29.846 -13.246 0.012 -50.000 -49.915 89.871 0.001 0.342 -0.940 4.339\n",
" 0.000 1.000 1.000 1.000 0.000 0.000 -2147483648.000]\n",
" [-24.944 -13.595 0.012 -49.997 -49.915 89.871 0.047 0.339 -0.940 4.970\n",
" 0.000 1.000 1.000 33.000 0.000 0.000 -2147483648.000]\n",
" [-29.693 -13.259 0.046 -50.000 -49.915 89.871 0.003 0.342 -0.940 5.601\n",
" 0.000 1.000 1.000 2.000 0.000 0.000 -2147483648.000]]\n",
"\n",
"First three rows of trajectory array:\n",
"\n",
"[[-30.000 -50.000 100.000 -2147483648.000 0.000 0.000 4.712]\n",
" [-29.700 -50.000 100.000 -2147483648.000 0.000 0.000 4.712]\n",
" [-29.400 -50.000 100.000 -2147483648.000 0.000 0.000 4.712]]\n",
"\n"
]
}
],
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
Expand Down Expand Up @@ -373,7 +311,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.2"
"version": "3.12.5"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 9ec4318

Please sign in to comment.