Skip to content

Commit cbcb910

Browse files
authored
Merge 141c7b7 into 3f63e1f
2 parents 3f63e1f + 141c7b7 commit cbcb910

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+184
-201
lines changed

Migration.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ release will remove the deprecated code.
1919
* CMake `-config` files
2020
* Paths that depend on the project name
2121

22+
1. Python library imports such `import ignition.math` and `from ignition import math` should be replaced with `import gz.math7` and `from gz import math7`. Note the change from `ignition` to `gz` and the addition of the major version number as a suffix to the package name.
23+
2224
### Deprecations
2325

2426
1. **Angle.hh**
@@ -89,7 +91,6 @@ release will remove the deprecated code.
8991
1. `IGN_MASSMATRIX3_DEFAULT_TOLERANCE`
9092
1. All `IGN_*_SIZE_T` variables are deprecated and will be removed in future versions.
9193
Please use `GZ_*_SIZE_T` instead.
92-
1. Python library `ignition` namespaces should be replaced with `gz`.
9394

9495

9596
### Modifications

examples/angle_example.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
# $ export PYTHONPATH=/usr/lib/python:$PYTHONPATH
2222
#
2323

24-
import gz.math
24+
import gz.math7
2525

26-
print("PI in degrees = {}\n".format(gz.math.Angle.PI.degree()))
26+
print("PI in degrees = {}\n".format(gz.math7.Angle.PI.degree()))
2727

28-
a1 = gz.math.Angle(1.5707)
29-
a2 = gz.math.Angle(0.7854)
28+
a1 = gz.math7.Angle(1.5707)
29+
a2 = gz.math7.Angle(0.7854)
3030
print("a1 = {} radians, {} degrees\n".format(a1.radian(), a1.degree()))
3131
print("a2 = {} radians, {} degrees\n".format(a2.radian(), a2.degree()))
3232
print("a1 * a2 = {} radians, {} degrees\n".format((a1 * a2).radian(),
@@ -36,7 +36,7 @@
3636
print("a1 - a2 = {} radians, {} degrees\n".format((a1 - a2).radian(),
3737
(a1 - a2).degree()))
3838

39-
a3 = gz.math.Angle(15.707)
39+
a3 = gz.math7.Angle(15.707)
4040
print("a3 = {} radians, {} degrees\n".format(a3.radian(), a3.degree()))
4141
a3.normalize()
4242
print("a3.Normalize = {} radians, {} degrees\n".format(a3.radian(),

examples/diff_drive_odometry.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import datetime
2424
import math
2525

26-
from gz.math import Angle, DiffDriveOdometry
26+
from gz.math7 import Angle, DiffDriveOdometry
2727

2828
odom = DiffDriveOdometry()
2929

examples/gauss_markov_process_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
# 2. Use gnuplot to create a plot:
2727
# gnuplot -e 'set terminal jpeg; plot "plot.data" with lines' > out.jpg
2828
import datetime
29-
from gz.math import GaussMarkovProcess
29+
from gz.math7 import GaussMarkovProcess
3030

3131
# Create the process with:
3232
# * Start value of 20.2

examples/kmeans.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
# limitations under the License.
1414

1515

16-
from gz.math import Kmeans, Vector3d
16+
from gz.math7 import Kmeans, Vector3d
1717

1818
# Create some observations.
1919
obs = list([])

examples/rand_example.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# 2. Use gnuplot to create a plot:
2323
# gnuplot -c rand_view_normal.gp > normal.jpg
2424
# gnuplot -c rand_view_uniform.gp > uniform.jpg
25-
from gz.math import Rand
25+
from gz.math7 import Rand
2626
import sys
2727

2828
if (len(sys.argv) < 2):

examples/vector2_example.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@
2020
#
2121
# $ export PYTHONPATH=/usr/lib/python:$PYTHONPATH
2222
#
23-
import gz.math
23+
import gz.math7
2424

25-
va = gz.math.Vector2d(1, 2)
26-
vb = gz.math.Vector2d(3, 4)
27-
vc = gz.math.Vector2d(vb)
25+
va = gz.math7.Vector2d(1, 2)
26+
vb = gz.math7.Vector2d(3, 4)
27+
vc = gz.math7.Vector2d(vb)
2828

2929
print("va = {} {}\n".format(va.x(), va.y()))
3030
print("vb = {} {}\n".format(vb.x(), vb.y()))

examples/vector3_example.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
#
2121
# $ export PYTHONPATH=/usr/lib/python:$PYTHONPATH
2222
#
23-
import gz.math
23+
import gz.math7
2424

25-
v1 = gz.math.Vector3d(0, 0, 3)
25+
v1 = gz.math7.Vector3d(0, 0, 3)
2626
print("v =: {} {} {}\n".format(v1.x(), v1.y(), v1.z()))
2727

28-
v2 = gz.math.Vector3d(4, 0, 0)
28+
v2 = gz.math7.Vector3d(4, 0, 0)
2929
print("v2 = {} {} {}\n".format(v2.x(), v2.y(), v2.z()))
3030

3131
v3 = v1 + v2

src/python_pybind11/CMakeLists.txt

+9-27
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug")
66
endif()
77

88
message(STATUS "Building pybind11 interfaces")
9+
set(BINDINGS_MODULE_NAME "math${PROJECT_VERSION_MAJOR}")
910
# Split from main extension and converted to pybind11
10-
pybind11_add_module(math MODULE
11+
pybind11_add_module(${BINDINGS_MODULE_NAME} MODULE
1112
src/_gz_math_pybind11.cc
1213
src/Angle.cc
1314
src/AxisAlignedBox.cc
@@ -51,21 +52,24 @@ pybind11_add_module(math MODULE
5152
src/Vector3Stats.cc
5253
)
5354

54-
target_link_libraries(math PRIVATE
55+
target_link_libraries(${BINDINGS_MODULE_NAME} PRIVATE
5556
${PROJECT_LIBRARY_TARGET_NAME}
5657
)
5758

59+
target_compile_definitions(${BINDINGS_MODULE_NAME} PRIVATE
60+
BINDINGS_MODULE_NAME=${BINDINGS_MODULE_NAME})
61+
5862
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
5963
# Workaround for Clang and pybind11 on Focal
6064
# https://github.com/pybind/pybind11/issues/1604
6165
# Resolved by newer versions of pybind11
6266
if(${pybind11_VERSION} VERSION_LESS "2.4.4")
63-
target_compile_options(math PRIVATE -fsized-deallocation)
67+
target_compile_options(${BINDINGS_MODULE_NAME} PRIVATE -fsized-deallocation)
6468
endif()
6569

6670
# Suppress warnings that clang misidentifies:
6771
# https://github.com/pybind/pybind11/issues/1893
68-
target_compile_options(math PRIVATE -Wno-self-assign-overloaded)
72+
target_compile_options(${BINDINGS_MODULE_NAME} PRIVATE -Wno-self-assign-overloaded)
6973
endif()
7074

7175
if(USE_SYSTEM_PATHS_FOR_PYTHON_INSTALLATION)
@@ -107,31 +111,9 @@ function(configure_build_install_location _library_name)
107111
install(TARGETS ${_library_name}
108112
DESTINATION "${GZ_PYTHON_INSTALL_PATH}/"
109113
)
110-
111-
# TODO(CH3): Deprecated. Remove on tock.
112-
# Install Python library symlinks
113-
if(${GZ_PYTHON_INSTALL_PATH} MATCHES "gz$")
114-
cmake_policy(SET CMP0087 NEW) # Allow evaluation of generator expressions in install(CODE )
115-
file(MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/ignition")
116-
117-
string(REGEX REPLACE "gz$" "ignition" IGN_PYTHON_INSTALL_PATH ${GZ_PYTHON_INSTALL_PATH})
118-
if (WIN32) # Windows requires copy instead of symlink
119-
install(TARGETS ${_library_name}
120-
DESTINATION "${IGN_PYTHON_INSTALL_PATH}/"
121-
)
122-
else()
123-
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink \
124-
../gz/$<TARGET_FILE_NAME:${_library_name}> \
125-
${PROJECT_BINARY_DIR}\/ignition/$<TARGET_FILE_NAME:${_library_name}>)")
126-
install(FILES ${PROJECT_BINARY_DIR}\/ignition/$<TARGET_FILE_NAME:${_library_name}>
127-
DESTINATION "${IGN_PYTHON_INSTALL_PATH}/"
128-
)
129-
endif()
130-
endif()
131-
132114
endfunction()
133115

134-
configure_build_install_location(math)
116+
configure_build_install_location(${BINDINGS_MODULE_NAME})
135117

136118
if (BUILD_TESTING)
137119
# Add the Python tests

src/python_pybind11/src/_gz_math_pybind11.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363

6464
namespace py = pybind11;
6565

66-
PYBIND11_MODULE(math, m)
66+
PYBIND11_MODULE(BINDINGS_MODULE_NAME, m)
6767
{
6868
m.doc() = "Gazebo Math Python Library.";
6969

src/python_pybind11/test/Angle_TEST.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
import unittest
1616
import math
17-
from gz.math import Angle
17+
from gz.math7 import Angle
1818

1919

2020
class TestAngle(unittest.TestCase):

src/python_pybind11/test/AxisAlignedBox_TEST.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import math
1616
import unittest
1717

18-
from gz.math import AxisAlignedBox, Helpers, Line3d, Vector3d
18+
from gz.math7 import AxisAlignedBox, Helpers, Line3d, Vector3d
1919

2020

2121
class TestAxisAlignedBox(unittest.TestCase):

src/python_pybind11/test/Box_TEST.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import unittest
1616

1717
import gz
18-
from gz.math import Boxd, MassMatrix3d, Material, Planed, Vector3d
18+
from gz.math7 import Boxd, MassMatrix3d, Material, Planed, Vector3d
1919

2020

2121
class TestBox(unittest.TestCase):
@@ -46,30 +46,30 @@ def test_constructor(self):
4646
self.assertEqual(box, box2)
4747

4848
# Dimension and mat constructor
49-
box = Boxd(1.0, 2.0, 5.0, Material(gz.math.MaterialType.WOOD))
49+
box = Boxd(1.0, 2.0, 5.0, Material(gz.math7.MaterialType.WOOD))
5050
self.assertEqual(Vector3d(1.0, 2.0, 5.0), box.size())
51-
self.assertEqual(Material(gz.math.MaterialType.WOOD), box.material())
51+
self.assertEqual(Material(gz.math7.MaterialType.WOOD), box.material())
5252

53-
box2 = Boxd(1.0, 2.0, 5.0, Material(gz.math.MaterialType.WOOD))
53+
box2 = Boxd(1.0, 2.0, 5.0, Material(gz.math7.MaterialType.WOOD))
5454
self.assertEqual(box, box2)
5555

5656
# Vector Dimension and mat constructor
57-
box = Boxd(Vector3d(2.2, 2.0, 10.0), Material(gz.math.MaterialType.WOOD))
57+
box = Boxd(Vector3d(2.2, 2.0, 10.0), Material(gz.math7.MaterialType.WOOD))
5858
self.assertEqual(Vector3d(2.2, 2.0, 10.0), box.size())
59-
self.assertEqual(Material(gz.math.MaterialType.WOOD), box.material())
59+
self.assertEqual(Material(gz.math7.MaterialType.WOOD), box.material())
6060

61-
box2 = Boxd(Vector3d(2.2, 2.0, 10.0), Material(gz.math.MaterialType.WOOD))
61+
box2 = Boxd(Vector3d(2.2, 2.0, 10.0), Material(gz.math7.MaterialType.WOOD))
6262
self.assertEqual(box, box2)
6363

6464
def test_mutators(self):
6565
box = Boxd()
6666
box.set_size(100.1, 2.3, 5.6)
67-
box.set_material(Material(gz.math.MaterialType.PINE))
67+
box.set_material(Material(gz.math7.MaterialType.PINE))
6868

6969
self.assertEqual(100.1, box.size().x())
7070
self.assertEqual(2.3, box.size().y())
7171
self.assertEqual(5.6, box.size().z())
72-
self.assertEqual(Material(gz.math.MaterialType.PINE), box.material())
72+
self.assertEqual(Material(gz.math7.MaterialType.PINE), box.material())
7373

7474
box.set_size(Vector3d(3.4, 1.2, 0.5))
7575
self.assertEqual(3.4, box.size().x())

src/python_pybind11/test/Capsule_TEST.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import unittest
1616

1717
import gz
18-
from gz.math import Capsuled, Material, MassMatrix3d
18+
from gz.math7 import Capsuled, Material, MassMatrix3d
1919

2020
import math
2121

@@ -41,14 +41,14 @@ def test_constructor(self):
4141

4242
# Length, radius, mat
4343
capsule = Capsuled(1.0, 2.0,
44-
Material(gz.math.MaterialType.WOOD));
44+
Material(gz.math7.MaterialType.WOOD));
4545
self.assertEqual(1.0, capsule.length());
4646
self.assertEqual(2.0, capsule.radius());
47-
self.assertEqual(Material(gz.math.MaterialType.WOOD),
47+
self.assertEqual(Material(gz.math7.MaterialType.WOOD),
4848
capsule.material());
4949

5050
capsule2 = Capsuled(1.0, 2.0,
51-
Material(gz.math.MaterialType.WOOD));
51+
Material(gz.math7.MaterialType.WOOD));
5252
self.assertEqual(capsule, capsule2);
5353

5454

@@ -60,11 +60,11 @@ def test_mutators(self):
6060

6161
capsule.set_length(100.1);
6262
capsule.set_radius(.123);
63-
capsule.set_material(Material(gz.math.MaterialType.PINE));
63+
capsule.set_material(Material(gz.math7.MaterialType.PINE));
6464

6565
self.assertEqual(100.1, capsule.length());
6666
self.assertEqual(.123, capsule.radius());
67-
self.assertEqual(Material(gz.math.MaterialType.PINE),
67+
self.assertEqual(Material(gz.math7.MaterialType.PINE),
6868
capsule.material());
6969

7070

src/python_pybind11/test/Color_TEST.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
import math
1616
import unittest
17-
from gz.math import Color
18-
from gz.math import Vector3f
17+
from gz.math7 import Color
18+
from gz.math7 import Vector3f
1919

2020

2121
class TestColor(unittest.TestCase):

src/python_pybind11/test/Cylinder_TEST.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import unittest
1717

1818
import gz
19-
from gz.math import Cylinderd, MassMatrix3d, Material, Quaterniond
19+
from gz.math7 import Cylinderd, MassMatrix3d, Material, Quaterniond
2020

2121

2222
class TestCylinder(unittest.TestCase):
@@ -54,14 +54,14 @@ def test_constructor(self):
5454
self.assertEqual(cylinder, cylinder2)
5555

5656
# Length, radius, mat and rot constructor
57-
cylinder = Cylinderd(1.0, 2.0, Material(gz.math.MaterialType.WOOD),
57+
cylinder = Cylinderd(1.0, 2.0, Material(gz.math7.MaterialType.WOOD),
5858
Quaterniond(0.1, 0.2, 0.3))
5959
self.assertEqual(1.0, cylinder.length())
6060
self.assertEqual(2.0, cylinder.radius())
6161
self.assertEqual(Quaterniond(0.1, 0.2, 0.3), cylinder.rotational_offset())
62-
self.assertEqual(Material(gz.math.MaterialType.WOOD), cylinder.mat())
62+
self.assertEqual(Material(gz.math7.MaterialType.WOOD), cylinder.mat())
6363

64-
cylinder2 = Cylinderd(1.0, 2.0, Material(gz.math.MaterialType.WOOD),
64+
cylinder2 = Cylinderd(1.0, 2.0, Material(gz.math7.MaterialType.WOOD),
6565
Quaterniond(0.1, 0.2, 0.3))
6666
self.assertEqual(cylinder, cylinder2)
6767

@@ -75,12 +75,12 @@ def test_mutators(self):
7575
cylinder.set_length(100.1)
7676
cylinder.set_radius(.123)
7777
cylinder.set_rotational_offset(Quaterniond(1.2, 2.3, 3.4))
78-
cylinder.set_mat(Material(gz.math.MaterialType.PINE))
78+
cylinder.set_mat(Material(gz.math7.MaterialType.PINE))
7979

8080
self.assertEqual(100.1, cylinder.length())
8181
self.assertEqual(.123, cylinder.radius())
8282
self.assertEqual(Quaterniond(1.2, 2.3, 3.4), cylinder.rotational_offset())
83-
self.assertEqual(Material(gz.math.MaterialType.PINE), cylinder.mat())
83+
self.assertEqual(Material(gz.math7.MaterialType.PINE), cylinder.mat())
8484

8585
def test_volume_and_density(self):
8686
mass = 1.0

src/python_pybind11/test/DiffDriveOdometry_TEST.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import math
1717
import unittest
1818

19-
from gz.math import Angle, DiffDriveOdometry
19+
from gz.math7 import Angle, DiffDriveOdometry
2020

2121

2222
class TestDiffDriveOdometry(unittest.TestCase):

src/python_pybind11/test/Ellipsoid_TEST.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import unittest
1616

1717
import gz
18-
from gz.math import Ellipsoidd, Material, MassMatrix3d, Vector3d
18+
from gz.math7 import Ellipsoidd, Material, MassMatrix3d, Vector3d
1919

2020
import math
2121

@@ -40,7 +40,7 @@ def test_constructor(self):
4040

4141
# Vector3 of radii and material
4242
expectedRadii = Vector3d(1.0, 2.0, 3.0)
43-
expectedMaterial = Material(gz.math.MaterialType.WOOD)
43+
expectedMaterial = Material(gz.math7.MaterialType.WOOD)
4444
ellipsoid = Ellipsoidd(expectedRadii, expectedMaterial)
4545
self.assertEqual(expectedRadii, ellipsoid.radii())
4646
self.assertEqual(expectedMaterial, ellipsoid.material())
@@ -57,7 +57,7 @@ def test_mutators(self):
5757
expectedRadii = Vector3d(1.0, 2.0, 3.0)
5858
ellipsoid.set_radii(expectedRadii)
5959

60-
expectedMaterial = Material(gz.math.MaterialType.PINE)
60+
expectedMaterial = Material(gz.math7.MaterialType.PINE)
6161
ellipsoid.set_material(expectedMaterial)
6262

6363
self.assertEqual(expectedRadii, ellipsoid.radii())

0 commit comments

Comments
 (0)