Skip to content

Commit 5843e77

Browse files
jeongseok-metafacebook-github-bot
authored andcommitted
Merge geometry test helper into geometry (#153)
Summary: Pull Request resolved: #153 Now that `geometry_test_helper` no longer has a gtest dependency, it can be merged into geometry for simplicity. Reviewed By: cdtwigg Differential Revision: D66790295 fbshipit-source-id: bbfc739a642b95a140a14780fd5f60a0205d32b9
1 parent cbb0254 commit 5843e77

File tree

8 files changed

+34
-69
lines changed

8 files changed

+34
-69
lines changed

pymomentum/CMakeLists.txt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ mt_python_binding(
111111
${TORCH_LIBRARIES}
112112
LINK_LIBRARIES
113113
character
114+
character_test_helpers
114115
io_fbx
115116
io_gltf
116117
io_marker
@@ -169,15 +170,6 @@ if(MOMENTUM_BUILD_TESTING)
169170
enable_testing()
170171
mt_setup_gtest()
171172

172-
mt_python_binding(
173-
NAME geometry_test_helper
174-
PYMOMENTUM_HEADERS_VARS geometry_test_helper_public_headers
175-
PYMOMENTUM_SOURCES_VARS geometry_test_helper_sources
176-
INCLUDE_DIRECTORIES
177-
LINK_LIBRARIES
178-
character_test_helpers
179-
)
180-
181173
mt_test(
182174
NAME tensor_utility_test
183175
PYMOMENTUM_SOURCES_VARS tensor_utility_test_sources

pymomentum/cmake/build_variables.bzl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,6 @@ geometry_sources = [
6161
"geometry/momentum_io.cpp",
6262
]
6363

64-
geometry_test_helper_public_headers = [
65-
]
66-
67-
geometry_test_helper_sources = [
68-
"geometry/geometry_test_helper_pybind.cpp",
69-
]
70-
7164
quaternion_public_headers = [
7265
]
7366

pymomentum/geometry/geometry_pybind.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include <momentum/io/shape/blend_shape_io.h>
3030
#include <momentum/math/mesh.h>
3131
#include <momentum/math/mppca.h>
32+
#include <momentum/test/character/character_helpers.h>
3233

3334
#include <pybind11/eigen.h>
3435
#include <pybind11/numpy.h>
@@ -2134,4 +2135,29 @@ Computes vertex normals for a triangle mesh given its positions.
21342135
)",
21352136
py::arg("vertex_positions"),
21362137
py::arg("triangles"));
2138+
2139+
// createTestCharacter()
2140+
m.def(
2141+
"test_character",
2142+
&momentum::createTestCharacter<float>,
2143+
R"(Create a simple 3-joint test character. This is useful for writing confidence tests that
2144+
execute quickly and don't rely on outside files.
2145+
2146+
The mesh is made by a few vertices on the line segment from (1,0,0) to (1,1,0) and a few dummy
2147+
faces. The skeleton has three joints: root at (0,0,0), joint1 parented by root, at world-space
2148+
(0,1,0), and joint2 parented by joint1, at world-space (0,2,0).
2149+
The character has only one parameter limit: min-max type [-0.1, 0.1] for root.
2150+
2151+
:parameter numJoints: The number of joints in the resulting character.
2152+
:return: A simple character with 3 joints and 10 model parameters.
2153+
)",
2154+
py::arg("num_joints") = 3);
2155+
2156+
// createTestPosePrior()
2157+
m.def(
2158+
"create_test_mppca",
2159+
&momentum::createDefaultPosePrior<float>,
2160+
R"(Create a pose prior that acts on the simple 3-joint test character.
2161+
2162+
:return: A simple pose prior.)");
21372163
}

pymomentum/geometry/geometry_test_helper_pybind.cpp

Lines changed: 0 additions & 46 deletions
This file was deleted.

pymomentum/test/test_parameter_transform.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
import unittest
99

1010
import torch
11-
from pymomentum.geometry import Character, uniform_random_to_model_parameters
12-
from pymomentum.geometry_test_helper import test_character
11+
from pymomentum.geometry import (
12+
Character,
13+
test_character,
14+
uniform_random_to_model_parameters,
15+
)
1316

1417

1518
class TestParameterTransform(unittest.TestCase):

pymomentum/test/test_skel_state.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
import unittest
99

1010
import pymomentum.geometry as pym_geometry
11-
import pymomentum.geometry_test_helper as pym_geometry_test_helper
1211
import pymomentum.quaternion as pym_quaternion
1312
import pymomentum.skel_state as pym_skel_state
1413
import torch
@@ -44,7 +43,7 @@ def generate_random_skel_state(sz):
4443

4544
class TestSkelState(unittest.TestCase):
4645
def test_skel_state_to_transforms(self) -> None:
47-
character = pym_geometry_test_helper.test_character()
46+
character = pym_geometry.test_character()
4847
nBatch = 2
4948
modelParams = 0.2 * torch.ones(
5049
nBatch,

pymomentum/test/test_skeleton.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77

88
import unittest
99

10-
from pymomentum.geometry import Character
11-
from pymomentum.geometry_test_helper import test_character
10+
from pymomentum.geometry import Character, test_character
1211

1312

1413
class TestSkeleton(unittest.TestCase):

setup.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,6 @@ def main():
115115
ext_modules=[
116116
CMakeExtension("geometry", sourcedir=ROOT_DIR),
117117
CMakeExtension("quaternion", sourcedir=ROOT_DIR),
118-
CMakeExtension("geometry_test_helper", sourcedir=ROOT_DIR),
119118
CMakeExtension("skel_state", sourcedir=ROOT_DIR),
120119
],
121120
cmdclass={

0 commit comments

Comments
 (0)