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

Python helios #465

Open
wants to merge 9 commits into
base: alpha-dev
Choose a base branch
from
Open
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
18 changes: 14 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ on:
- main
- dev
- alpha-dev
- python_helios
pull_request:
branches:
- main
- dev
- alpha-dev
- python_helios
workflow_dispatch:

jobs:
Expand All @@ -21,11 +23,11 @@ jobs:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - macos-latest
# - windows-latest
python:
- "3.8"
- "3.12"
# - "3.12"

defaults:
run:
Expand Down Expand Up @@ -53,9 +55,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


1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ valgrind.xml
*.exe
libhelios.so
pyhelios.so
helios

# Output log
*.log
Expand Down
50 changes: 23 additions & 27 deletions CMakeLists.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,21 @@ else()
set(HELIOS_VERSION_FULL "1.3.0")
endif()

# Fetch pybind11
find_package(pybind11 QUIET)

if (NOT pybind11_FOUND)
message(STATUS "pybind11 not found, using FetchContent to download pybind11.")

FetchContent_Declare(
pybind11
GIT_REPOSITORY https://github.com/pybind/pybind11.git
)
FetchContent_MakeAvailable(pybind11)
else()
message(STATUS "Found pybind11: ${pybind11_DIR}")
endif()

project(Helios++
VERSION ${HELIOS_VERSION}
LANGUAGES C CXX
Expand Down Expand Up @@ -131,32 +146,21 @@ if(HELIOS_BUDDING_METRICS)
target_compile_definitions(helios PUBLIC BUDDING_METRICS=ON)
endif()

# Add the HelIOS++ executable
# # Add the HelIOS++ executable
add_executable(helios++)

target_link_libraries(helios++ PRIVATE helios)

if(BUILD_PYTHON)
find_package(Python COMPONENTS Interpreter Development)
find_package(Boost REQUIRED COMPONENTS python)

add_library(_pyhelios MODULE)

target_link_libraries(_pyhelios
PRIVATE
helios
Boost::python
Python::Module
)

# Control the output name of the produced shared library
set_target_properties(_pyhelios PROPERTIES PREFIX "")
set_target_properties(_pyhelios PROPERTIES OUTPUT_NAME "_pyhelios")
if(WIN32)
set_target_properties(_pyhelios PROPERTIES SUFFIX ".pyd")
endif()
include_directories(${Python_INCLUDE_DIRS})
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 .)
endif()



# Traverse the source tree to add all relevant sources
add_subdirectory(src)

Expand All @@ -174,13 +178,5 @@ install(
DESTINATION pyhelios/bin
)

if(BUILD_PYTHON)
install(
TARGETS
_pyhelios
DESTINATION .
)
endif()

include(FeatureSummary)
feature_summary(WHAT ALL)
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"
226 changes: 34 additions & 192 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
Loading