-
Notifications
You must be signed in to change notification settings - Fork 767
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
Clean up the __init__ #893
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,8 +65,10 @@ set(interface_headers | |
${PROJECT_SOURCE_DIR}/gtsam/basis/basis.i | ||
) | ||
|
||
set(GTSAM_TARGET gtsam_py) | ||
set(GTSAM_UNSTABLE_TARGET gtsam_unstable_py) | ||
|
||
pybind_wrap(gtsam_py # target | ||
pybind_wrap(${GTSAM_TARGET} # target | ||
"${interface_headers}" # interface_headers | ||
"gtsam.cpp" # generated_cpp | ||
"gtsam" # module_name | ||
|
@@ -78,7 +80,7 @@ pybind_wrap(gtsam_py # target | |
ON # use_boost | ||
) | ||
|
||
set_target_properties(gtsam_py PROPERTIES | ||
set_target_properties(${GTSAM_TARGET} PROPERTIES | ||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" | ||
INSTALL_RPATH_USE_LINK_PATH TRUE | ||
OUTPUT_NAME "gtsam" | ||
|
@@ -98,7 +100,7 @@ create_symlinks("${CMAKE_CURRENT_SOURCE_DIR}/gtsam" | |
file(COPY "${GTSAM_SOURCE_DIR}/examples/Data" DESTINATION "${GTSAM_MODULE_PATH}") | ||
|
||
# Add gtsam as a dependency to the install target | ||
set(GTSAM_PYTHON_DEPENDENCIES gtsam_py) | ||
set(GTSAM_PYTHON_DEPENDENCIES ${GTSAM_TARGET}) | ||
|
||
|
||
if(GTSAM_UNSTABLE_BUILD_PYTHON) | ||
|
@@ -122,7 +124,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) | |
gtsam::CameraSetCal3Fisheye | ||
gtsam::KeyPairDoubleMap) | ||
|
||
pybind_wrap(gtsam_unstable_py # target | ||
pybind_wrap(${GTSAM_UNSTABLE_TARGET} # target | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same |
||
${PROJECT_SOURCE_DIR}/gtsam_unstable/gtsam_unstable.i # interface_header | ||
"gtsam_unstable.cpp" # generated_cpp | ||
"gtsam_unstable" # module_name | ||
|
@@ -134,7 +136,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) | |
ON # use_boost | ||
) | ||
|
||
set_target_properties(gtsam_unstable_py PROPERTIES | ||
set_target_properties(${GTSAM_UNSTABLE_TARGET} PROPERTIES | ||
INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" | ||
INSTALL_RPATH_USE_LINK_PATH TRUE | ||
OUTPUT_NAME "gtsam_unstable" | ||
|
@@ -150,7 +152,7 @@ if(GTSAM_UNSTABLE_BUILD_PYTHON) | |
"${GTSAM_UNSTABLE_MODULE_PATH}") | ||
|
||
# Add gtsam_unstable to the install target | ||
list(APPEND GTSAM_PYTHON_DEPENDENCIES gtsam_unstable_py) | ||
list(APPEND GTSAM_PYTHON_DEPENDENCIES ${GTSAM_UNSTABLE_TARGET}) | ||
|
||
endif() | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
from . import utils | ||
from .gtsam import * | ||
from .utils import findExampleDataFile | ||
"""Module definition file for GTSAM""" | ||
|
||
# pylint: disable=import-outside-toplevel, global-variable-not-assigned, possibly-unused-variable, import-error, import-self | ||
|
||
import sys | ||
|
||
from gtsam import gtsam, utils | ||
from gtsam.gtsam import * | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thanks for the PR @varunagrawal. While we're updating this, we probably want to remove this wildcard import too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is needed, and I think is generally OK for pybind11 modules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup this is needed for proper functioning of the module. |
||
from gtsam.utils import findExampleDataFile | ||
|
||
|
||
def _init(): | ||
|
@@ -13,7 +19,7 @@ def _init(): | |
def Point2(x=np.nan, y=np.nan): | ||
"""Shim for the deleted Point2 type.""" | ||
if isinstance(x, np.ndarray): | ||
assert x.shape == (2,), "Point2 takes 2-vector" | ||
assert x.shape == (2, ), "Point2 takes 2-vector" | ||
return x # "copy constructor" | ||
return np.array([x, y], dtype=float) | ||
|
||
|
@@ -22,7 +28,7 @@ def Point2(x=np.nan, y=np.nan): | |
def Point3(x=np.nan, y=np.nan, z=np.nan): | ||
"""Shim for the deleted Point3 type.""" | ||
if isinstance(x, np.ndarray): | ||
assert x.shape == (3,), "Point3 takes 3-vector" | ||
assert x.shape == (3, ), "Point3 takes 3-vector" | ||
return x # "copy constructor" | ||
return np.array([x, y, z], dtype=float) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GTSAM_PYTHON_TARGET
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah great point!