warp-lang 1.0.0b5__py3-none-manylinux2014_x86_64.whl → 1.0.0b6__py3-none-manylinux2014_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- docs/conf.py +3 -4
- examples/env/env_ant.py +1 -1
- examples/env/env_cartpole.py +1 -1
- examples/env/env_humanoid.py +1 -1
- examples/example_dem.py +28 -26
- examples/example_diffray.py +37 -30
- examples/example_fluid.py +7 -3
- examples/example_jacobian_ik.py +1 -1
- examples/example_mesh_intersect.py +10 -7
- examples/example_nvdb.py +3 -3
- examples/example_render_opengl.py +19 -10
- examples/example_sim_cartpole.py +9 -5
- examples/example_sim_cloth.py +29 -25
- examples/example_sim_fk_grad.py +2 -2
- examples/example_sim_fk_grad_torch.py +3 -3
- examples/example_sim_grad_bounce.py +11 -8
- examples/example_sim_grad_cloth.py +12 -9
- examples/example_sim_granular.py +2 -2
- examples/example_sim_granular_collision_sdf.py +13 -13
- examples/example_sim_neo_hookean.py +3 -3
- examples/example_sim_particle_chain.py +2 -2
- examples/example_sim_quadruped.py +8 -5
- examples/example_sim_rigid_chain.py +8 -5
- examples/example_sim_rigid_contact.py +13 -10
- examples/example_sim_rigid_fem.py +2 -2
- examples/example_sim_rigid_gyroscopic.py +2 -2
- examples/example_sim_rigid_kinematics.py +1 -1
- examples/example_sim_trajopt.py +3 -2
- examples/fem/example_apic_fluid.py +5 -7
- examples/fem/example_diffusion_mgpu.py +18 -16
- warp/__init__.py +3 -2
- warp/bin/warp.so +0 -0
- warp/build_dll.py +29 -9
- warp/builtins.py +206 -7
- warp/codegen.py +58 -38
- warp/config.py +3 -1
- warp/context.py +234 -128
- warp/fem/__init__.py +2 -2
- warp/fem/cache.py +2 -1
- warp/fem/field/nodal_field.py +18 -17
- warp/fem/geometry/hexmesh.py +11 -6
- warp/fem/geometry/quadmesh_2d.py +16 -12
- warp/fem/geometry/tetmesh.py +19 -8
- warp/fem/geometry/trimesh_2d.py +18 -7
- warp/fem/integrate.py +341 -196
- warp/fem/quadrature/__init__.py +1 -1
- warp/fem/quadrature/pic_quadrature.py +138 -53
- warp/fem/quadrature/quadrature.py +81 -9
- warp/fem/space/__init__.py +1 -1
- warp/fem/space/basis_space.py +169 -51
- warp/fem/space/grid_2d_function_space.py +2 -2
- warp/fem/space/grid_3d_function_space.py +2 -2
- warp/fem/space/hexmesh_function_space.py +2 -2
- warp/fem/space/partition.py +9 -6
- warp/fem/space/quadmesh_2d_function_space.py +2 -2
- warp/fem/space/shape/cube_shape_function.py +27 -15
- warp/fem/space/shape/square_shape_function.py +29 -18
- warp/fem/space/tetmesh_function_space.py +2 -2
- warp/fem/space/topology.py +10 -0
- warp/fem/space/trimesh_2d_function_space.py +2 -2
- warp/fem/utils.py +10 -5
- warp/native/array.h +49 -8
- warp/native/builtin.h +31 -14
- warp/native/cuda_util.cpp +8 -3
- warp/native/cuda_util.h +1 -0
- warp/native/exports.h +1177 -1108
- warp/native/intersect.h +4 -4
- warp/native/intersect_adj.h +8 -8
- warp/native/mat.h +65 -6
- warp/native/mesh.h +126 -5
- warp/native/quat.h +28 -4
- warp/native/vec.h +76 -14
- warp/native/warp.cu +1 -6
- warp/render/render_opengl.py +261 -109
- warp/sim/import_mjcf.py +13 -7
- warp/sim/import_urdf.py +14 -14
- warp/sim/inertia.py +17 -18
- warp/sim/model.py +67 -67
- warp/sim/render.py +1 -1
- warp/sparse.py +6 -6
- warp/stubs.py +19 -81
- warp/tape.py +1 -1
- warp/tests/__main__.py +3 -6
- warp/tests/{test_class_kernel.py → aux_test_class_kernel.py} +9 -1
- warp/tests/aux_test_conditional_unequal_types_kernels.py +21 -0
- warp/tests/{test_dependent.py → aux_test_dependent.py} +2 -2
- warp/tests/{test_reference.py → aux_test_reference.py} +1 -1
- warp/tests/aux_test_unresolved_func.py +14 -0
- warp/tests/aux_test_unresolved_symbol.py +14 -0
- warp/tests/{test_kinematics.py → disabled_kinematics.py} +10 -12
- warp/tests/run_coverage_serial.py +31 -0
- warp/tests/test_adam.py +102 -106
- warp/tests/test_arithmetic.py +39 -40
- warp/tests/test_array.py +46 -48
- warp/tests/test_array_reduce.py +25 -19
- warp/tests/test_atomic.py +62 -26
- warp/tests/test_bool.py +16 -11
- warp/tests/test_builtins_resolution.py +1292 -0
- warp/tests/test_bvh.py +9 -12
- warp/tests/test_closest_point_edge_edge.py +53 -57
- warp/tests/test_codegen.py +164 -134
- warp/tests/test_compile_consts.py +13 -19
- warp/tests/test_conditional.py +30 -32
- warp/tests/test_copy.py +9 -12
- warp/tests/test_ctypes.py +90 -98
- warp/tests/test_dense.py +20 -14
- warp/tests/test_devices.py +34 -35
- warp/tests/test_dlpack.py +74 -75
- warp/tests/test_examples.py +215 -97
- warp/tests/test_fabricarray.py +15 -21
- warp/tests/test_fast_math.py +14 -11
- warp/tests/test_fem.py +280 -97
- warp/tests/test_fp16.py +19 -15
- warp/tests/test_func.py +177 -194
- warp/tests/test_generics.py +71 -77
- warp/tests/test_grad.py +83 -32
- warp/tests/test_grad_customs.py +7 -9
- warp/tests/test_hash_grid.py +6 -10
- warp/tests/test_import.py +9 -23
- warp/tests/test_indexedarray.py +19 -21
- warp/tests/test_intersect.py +15 -9
- warp/tests/test_large.py +17 -19
- warp/tests/test_launch.py +14 -17
- warp/tests/test_lerp.py +63 -63
- warp/tests/test_lvalue.py +84 -35
- warp/tests/test_marching_cubes.py +9 -13
- warp/tests/test_mat.py +388 -3004
- warp/tests/test_mat_lite.py +9 -12
- warp/tests/test_mat_scalar_ops.py +2889 -0
- warp/tests/test_math.py +10 -11
- warp/tests/test_matmul.py +104 -100
- warp/tests/test_matmul_lite.py +72 -98
- warp/tests/test_mesh.py +35 -32
- warp/tests/test_mesh_query_aabb.py +18 -25
- warp/tests/test_mesh_query_point.py +39 -23
- warp/tests/test_mesh_query_ray.py +9 -21
- warp/tests/test_mlp.py +8 -9
- warp/tests/test_model.py +89 -93
- warp/tests/test_modules_lite.py +15 -25
- warp/tests/test_multigpu.py +87 -114
- warp/tests/test_noise.py +10 -12
- warp/tests/test_operators.py +14 -21
- warp/tests/test_options.py +10 -11
- warp/tests/test_pinned.py +16 -18
- warp/tests/test_print.py +16 -20
- warp/tests/test_quat.py +121 -88
- warp/tests/test_rand.py +12 -13
- warp/tests/test_reload.py +27 -32
- warp/tests/test_rounding.py +7 -10
- warp/tests/test_runlength_encode.py +105 -106
- warp/tests/test_smoothstep.py +8 -9
- warp/tests/test_snippet.py +13 -22
- warp/tests/test_sparse.py +30 -29
- warp/tests/test_spatial.py +179 -174
- warp/tests/test_streams.py +100 -107
- warp/tests/test_struct.py +98 -67
- warp/tests/test_tape.py +11 -17
- warp/tests/test_torch.py +89 -86
- warp/tests/test_transient_module.py +9 -12
- warp/tests/test_types.py +328 -50
- warp/tests/test_utils.py +217 -218
- warp/tests/test_vec.py +133 -2133
- warp/tests/test_vec_lite.py +8 -11
- warp/tests/test_vec_scalar_ops.py +2099 -0
- warp/tests/test_volume.py +391 -382
- warp/tests/test_volume_write.py +122 -135
- warp/tests/unittest_serial.py +35 -0
- warp/tests/unittest_suites.py +291 -0
- warp/tests/{test_base.py → unittest_utils.py} +138 -25
- warp/tests/{test_misc.py → unused_test_misc.py} +13 -5
- warp/tests/{test_debug.py → walkthough_debug.py} +2 -15
- warp/thirdparty/unittest_parallel.py +257 -54
- warp/types.py +119 -98
- warp/utils.py +14 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/METADATA +2 -1
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/RECORD +182 -178
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/WHEEL +1 -1
- warp/tests/test_all.py +0 -239
- warp/tests/test_conditional_unequal_types_kernels.py +0 -14
- warp/tests/test_coverage.py +0 -38
- warp/tests/test_unresolved_func.py +0 -7
- warp/tests/test_unresolved_symbol.py +0 -7
- /warp/tests/{test_compile_consts_dummy.py → aux_test_compile_consts_dummy.py} +0 -0
- /warp/tests/{test_reference_reference.py → aux_test_reference_reference.py} +0 -0
- /warp/tests/{test_square.py → aux_test_square.py} +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/LICENSE.md +0 -0
- {warp_lang-1.0.0b5.dist-info → warp_lang-1.0.0b6.dist-info}/top_level.txt +0 -0
warp/tests/test_quat.py
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
# Copyright (c) 2022 NVIDIA CORPORATION. All rights reserved.
|
|
2
|
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
|
3
|
+
# and proprietary rights in and to this software, related documentation
|
|
4
|
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
|
5
|
+
# distribution of this software and related documentation without an express
|
|
6
|
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
|
+
|
|
1
8
|
import unittest
|
|
2
9
|
|
|
3
10
|
import numpy as np
|
|
4
11
|
|
|
5
12
|
import warp as wp
|
|
6
|
-
from warp.tests.
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
7
14
|
|
|
8
15
|
wp.init()
|
|
9
16
|
|
|
@@ -1932,99 +1939,125 @@ def test_constructor_default():
|
|
|
1932
1939
|
wp.expect_eq(qeye[3], 1.0)
|
|
1933
1940
|
|
|
1934
1941
|
|
|
1935
|
-
def
|
|
1936
|
-
|
|
1942
|
+
def test_py_arithmetic_ops(test, device, dtype):
|
|
1943
|
+
wptype = wp.types.np_dtype_to_warp_type[np.dtype(dtype)]
|
|
1937
1944
|
|
|
1938
|
-
|
|
1939
|
-
|
|
1945
|
+
def make_quat(*args):
|
|
1946
|
+
if wptype in wp.types.int_types:
|
|
1947
|
+
# Cast to the correct integer type to simulate wrapping.
|
|
1948
|
+
return tuple(wptype._type_(x).value for x in args)
|
|
1940
1949
|
|
|
1941
|
-
|
|
1950
|
+
return args
|
|
1942
1951
|
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
)
|
|
1960
|
-
add_function_test_register_kernel(
|
|
1961
|
-
TestQuat, f"test_quat_identity_{dtype.__name__}", test_quat_identity, devices=devices, dtype=dtype
|
|
1962
|
-
)
|
|
1963
|
-
add_function_test_register_kernel(
|
|
1964
|
-
TestQuat, f"test_dotproduct_{dtype.__name__}", test_dotproduct, devices=devices, dtype=dtype
|
|
1965
|
-
)
|
|
1966
|
-
add_function_test_register_kernel(
|
|
1967
|
-
TestQuat, f"test_length_{dtype.__name__}", test_length, devices=devices, dtype=dtype
|
|
1968
|
-
)
|
|
1969
|
-
add_function_test_register_kernel(
|
|
1970
|
-
TestQuat, f"test_normalize_{dtype.__name__}", test_normalize, devices=devices, dtype=dtype
|
|
1971
|
-
)
|
|
1972
|
-
add_function_test_register_kernel(
|
|
1973
|
-
TestQuat, f"test_addition_{dtype.__name__}", test_addition, devices=devices, dtype=dtype
|
|
1974
|
-
)
|
|
1975
|
-
add_function_test_register_kernel(
|
|
1976
|
-
TestQuat, f"test_subtraction_{dtype.__name__}", test_subtraction, devices=devices, dtype=dtype
|
|
1977
|
-
)
|
|
1978
|
-
add_function_test_register_kernel(
|
|
1979
|
-
TestQuat,
|
|
1980
|
-
f"test_scalar_multiplication_{dtype.__name__}",
|
|
1981
|
-
test_scalar_multiplication,
|
|
1982
|
-
devices=devices,
|
|
1983
|
-
dtype=dtype,
|
|
1984
|
-
)
|
|
1985
|
-
add_function_test_register_kernel(
|
|
1986
|
-
TestQuat, f"test_scalar_division_{dtype.__name__}", test_scalar_division, devices=devices, dtype=dtype
|
|
1987
|
-
)
|
|
1988
|
-
add_function_test_register_kernel(
|
|
1989
|
-
TestQuat,
|
|
1990
|
-
f"test_quat_multiplication_{dtype.__name__}",
|
|
1991
|
-
test_quat_multiplication,
|
|
1992
|
-
devices=devices,
|
|
1993
|
-
dtype=dtype,
|
|
1994
|
-
)
|
|
1995
|
-
add_function_test_register_kernel(
|
|
1996
|
-
TestQuat, f"test_indexing_{dtype.__name__}", test_indexing, devices=devices, dtype=dtype
|
|
1997
|
-
)
|
|
1998
|
-
add_function_test_register_kernel(
|
|
1999
|
-
TestQuat, f"test_quat_lerp_{dtype.__name__}", test_quat_lerp, devices=devices, dtype=dtype
|
|
2000
|
-
)
|
|
2001
|
-
add_function_test_register_kernel(
|
|
2002
|
-
TestQuat,
|
|
2003
|
-
f"test_quat_to_axis_angle_grad_{dtype.__name__}",
|
|
2004
|
-
test_quat_to_axis_angle_grad,
|
|
2005
|
-
devices=devices,
|
|
2006
|
-
dtype=dtype,
|
|
2007
|
-
)
|
|
2008
|
-
add_function_test_register_kernel(
|
|
2009
|
-
TestQuat, f"test_slerp_grad_{dtype.__name__}", test_slerp_grad, devices=devices, dtype=dtype
|
|
2010
|
-
)
|
|
2011
|
-
add_function_test_register_kernel(
|
|
2012
|
-
TestQuat, f"test_quat_rpy_grad_{dtype.__name__}", test_quat_rpy_grad, devices=devices, dtype=dtype
|
|
2013
|
-
)
|
|
2014
|
-
add_function_test_register_kernel(
|
|
2015
|
-
TestQuat, f"test_quat_from_matrix_{dtype.__name__}", test_quat_from_matrix, devices=devices, dtype=dtype
|
|
2016
|
-
)
|
|
2017
|
-
add_function_test_register_kernel(
|
|
2018
|
-
TestQuat, f"test_quat_rotate_{dtype.__name__}", test_quat_rotate, devices=devices, dtype=dtype
|
|
2019
|
-
)
|
|
2020
|
-
add_function_test_register_kernel(
|
|
2021
|
-
TestQuat, f"test_quat_to_matrix_{dtype.__name__}", test_quat_to_matrix, devices=devices, dtype=dtype
|
|
2022
|
-
)
|
|
1952
|
+
quat_cls = wp.types.quaternion(wptype)
|
|
1953
|
+
|
|
1954
|
+
v = quat_cls(1, -2, 3, -4)
|
|
1955
|
+
test.assertSequenceEqual(+v, make_quat(1, -2, 3, -4))
|
|
1956
|
+
test.assertSequenceEqual(-v, make_quat(-1, 2, -3, 4))
|
|
1957
|
+
test.assertSequenceEqual(v + quat_cls(5, 5, 5, 5), make_quat(6, 3, 8, 1))
|
|
1958
|
+
test.assertSequenceEqual(v - quat_cls(5, 5, 5, 5), make_quat(-4, -7, -2, -9))
|
|
1959
|
+
|
|
1960
|
+
v = quat_cls(2, 4, 6, 8)
|
|
1961
|
+
test.assertSequenceEqual(v * wptype(2), make_quat(4, 8, 12, 16))
|
|
1962
|
+
test.assertSequenceEqual(wptype(2) * v, make_quat(4, 8, 12, 16))
|
|
1963
|
+
test.assertSequenceEqual(v / wptype(2), make_quat(1, 2, 3, 4))
|
|
1964
|
+
test.assertSequenceEqual(wptype(24) / v, make_quat(12, 6, 4, 3))
|
|
1965
|
+
|
|
1966
|
+
|
|
1967
|
+
devices = get_test_devices()
|
|
2023
1968
|
|
|
2024
|
-
|
|
1969
|
+
|
|
1970
|
+
class TestQuat(unittest.TestCase):
|
|
1971
|
+
pass
|
|
1972
|
+
|
|
1973
|
+
|
|
1974
|
+
add_kernel_test(TestQuat, test_constructor_default, dim=1, devices=devices)
|
|
1975
|
+
|
|
1976
|
+
for dtype in np_float_types:
|
|
1977
|
+
add_function_test_register_kernel(
|
|
1978
|
+
TestQuat, f"test_constructors_{dtype.__name__}", test_constructors, devices=devices, dtype=dtype
|
|
1979
|
+
)
|
|
1980
|
+
add_function_test_register_kernel(
|
|
1981
|
+
TestQuat,
|
|
1982
|
+
f"test_casting_constructors_{dtype.__name__}",
|
|
1983
|
+
test_casting_constructors,
|
|
1984
|
+
devices=devices,
|
|
1985
|
+
dtype=dtype,
|
|
1986
|
+
)
|
|
1987
|
+
add_function_test_register_kernel(
|
|
1988
|
+
TestQuat, f"test_anon_type_instance_{dtype.__name__}", test_anon_type_instance, devices=devices, dtype=dtype
|
|
1989
|
+
)
|
|
1990
|
+
add_function_test_register_kernel(
|
|
1991
|
+
TestQuat, f"test_inverse_{dtype.__name__}", test_inverse, devices=devices, dtype=dtype
|
|
1992
|
+
)
|
|
1993
|
+
add_function_test_register_kernel(
|
|
1994
|
+
TestQuat, f"test_quat_identity_{dtype.__name__}", test_quat_identity, devices=devices, dtype=dtype
|
|
1995
|
+
)
|
|
1996
|
+
add_function_test_register_kernel(
|
|
1997
|
+
TestQuat, f"test_dotproduct_{dtype.__name__}", test_dotproduct, devices=devices, dtype=dtype
|
|
1998
|
+
)
|
|
1999
|
+
add_function_test_register_kernel(
|
|
2000
|
+
TestQuat, f"test_length_{dtype.__name__}", test_length, devices=devices, dtype=dtype
|
|
2001
|
+
)
|
|
2002
|
+
add_function_test_register_kernel(
|
|
2003
|
+
TestQuat, f"test_normalize_{dtype.__name__}", test_normalize, devices=devices, dtype=dtype
|
|
2004
|
+
)
|
|
2005
|
+
add_function_test_register_kernel(
|
|
2006
|
+
TestQuat, f"test_addition_{dtype.__name__}", test_addition, devices=devices, dtype=dtype
|
|
2007
|
+
)
|
|
2008
|
+
add_function_test_register_kernel(
|
|
2009
|
+
TestQuat, f"test_subtraction_{dtype.__name__}", test_subtraction, devices=devices, dtype=dtype
|
|
2010
|
+
)
|
|
2011
|
+
add_function_test_register_kernel(
|
|
2012
|
+
TestQuat,
|
|
2013
|
+
f"test_scalar_multiplication_{dtype.__name__}",
|
|
2014
|
+
test_scalar_multiplication,
|
|
2015
|
+
devices=devices,
|
|
2016
|
+
dtype=dtype,
|
|
2017
|
+
)
|
|
2018
|
+
add_function_test_register_kernel(
|
|
2019
|
+
TestQuat, f"test_scalar_division_{dtype.__name__}", test_scalar_division, devices=devices, dtype=dtype
|
|
2020
|
+
)
|
|
2021
|
+
add_function_test_register_kernel(
|
|
2022
|
+
TestQuat,
|
|
2023
|
+
f"test_quat_multiplication_{dtype.__name__}",
|
|
2024
|
+
test_quat_multiplication,
|
|
2025
|
+
devices=devices,
|
|
2026
|
+
dtype=dtype,
|
|
2027
|
+
)
|
|
2028
|
+
add_function_test_register_kernel(
|
|
2029
|
+
TestQuat, f"test_indexing_{dtype.__name__}", test_indexing, devices=devices, dtype=dtype
|
|
2030
|
+
)
|
|
2031
|
+
add_function_test_register_kernel(
|
|
2032
|
+
TestQuat, f"test_quat_lerp_{dtype.__name__}", test_quat_lerp, devices=devices, dtype=dtype
|
|
2033
|
+
)
|
|
2034
|
+
add_function_test_register_kernel(
|
|
2035
|
+
TestQuat,
|
|
2036
|
+
f"test_quat_to_axis_angle_grad_{dtype.__name__}",
|
|
2037
|
+
test_quat_to_axis_angle_grad,
|
|
2038
|
+
devices=devices,
|
|
2039
|
+
dtype=dtype,
|
|
2040
|
+
)
|
|
2041
|
+
add_function_test_register_kernel(
|
|
2042
|
+
TestQuat, f"test_slerp_grad_{dtype.__name__}", test_slerp_grad, devices=devices, dtype=dtype
|
|
2043
|
+
)
|
|
2044
|
+
add_function_test_register_kernel(
|
|
2045
|
+
TestQuat, f"test_quat_rpy_grad_{dtype.__name__}", test_quat_rpy_grad, devices=devices, dtype=dtype
|
|
2046
|
+
)
|
|
2047
|
+
add_function_test_register_kernel(
|
|
2048
|
+
TestQuat, f"test_quat_from_matrix_{dtype.__name__}", test_quat_from_matrix, devices=devices, dtype=dtype
|
|
2049
|
+
)
|
|
2050
|
+
add_function_test_register_kernel(
|
|
2051
|
+
TestQuat, f"test_quat_rotate_{dtype.__name__}", test_quat_rotate, devices=devices, dtype=dtype
|
|
2052
|
+
)
|
|
2053
|
+
add_function_test_register_kernel(
|
|
2054
|
+
TestQuat, f"test_quat_to_matrix_{dtype.__name__}", test_quat_to_matrix, devices=devices, dtype=dtype
|
|
2055
|
+
)
|
|
2056
|
+
add_function_test(
|
|
2057
|
+
TestQuat, f"test_py_arithmetic_ops_{dtype.__name__}", test_py_arithmetic_ops, devices=None, dtype=dtype
|
|
2058
|
+
)
|
|
2025
2059
|
|
|
2026
2060
|
|
|
2027
2061
|
if __name__ == "__main__":
|
|
2028
2062
|
wp.build.clear_kernel_cache()
|
|
2029
|
-
_ = register(unittest.TestCase)
|
|
2030
2063
|
unittest.main(verbosity=2)
|
warp/tests/test_rand.py
CHANGED
|
@@ -9,10 +9,11 @@ import unittest
|
|
|
9
9
|
|
|
10
10
|
import numpy as np
|
|
11
11
|
|
|
12
|
+
import warp as wp
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
14
|
+
|
|
12
15
|
# import matplotlib.pyplot as plt
|
|
13
16
|
|
|
14
|
-
import warp as wp
|
|
15
|
-
from warp.tests.test_base import *
|
|
16
17
|
|
|
17
18
|
wp.init()
|
|
18
19
|
|
|
@@ -62,7 +63,7 @@ def test_rand(test, device):
|
|
|
62
63
|
wp.copy(int_ab_host, int_ab_device)
|
|
63
64
|
wp.copy(float_01_host, float_01_device)
|
|
64
65
|
wp.copy(float_ab_host, float_ab_device)
|
|
65
|
-
wp.
|
|
66
|
+
wp.synchronize_device(device)
|
|
66
67
|
|
|
67
68
|
int_a = int_a_host.numpy()
|
|
68
69
|
int_ab = int_ab_host.numpy()
|
|
@@ -269,21 +270,19 @@ def test_poisson(test, device):
|
|
|
269
270
|
test.assertTrue(np.abs(poisson_high_std - np_poisson_high_std) <= 2e-1)
|
|
270
271
|
|
|
271
272
|
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
devices = get_test_devices()
|
|
274
|
+
|
|
274
275
|
|
|
275
|
-
|
|
276
|
-
|
|
276
|
+
class TestRand(unittest.TestCase):
|
|
277
|
+
pass
|
|
277
278
|
|
|
278
|
-
add_function_test(TestNoise, "test_rand", test_rand, devices=devices)
|
|
279
|
-
add_function_test(TestNoise, "test_sample_cdf", test_sample_cdf, devices=devices)
|
|
280
|
-
add_function_test(TestNoise, "test_sampling_methods", test_sampling_methods, devices=devices)
|
|
281
|
-
add_function_test(TestNoise, "test_poisson", test_poisson, devices=devices)
|
|
282
279
|
|
|
283
|
-
|
|
280
|
+
add_function_test(TestRand, "test_rand", test_rand, devices=devices)
|
|
281
|
+
add_function_test(TestRand, "test_sample_cdf", test_sample_cdf, devices=devices)
|
|
282
|
+
add_function_test(TestRand, "test_sampling_methods", test_sampling_methods, devices=devices)
|
|
283
|
+
add_function_test(TestRand, "test_poisson", test_poisson, devices=devices)
|
|
284
284
|
|
|
285
285
|
|
|
286
286
|
if __name__ == "__main__":
|
|
287
287
|
wp.build.clear_kernel_cache()
|
|
288
|
-
_ = register(unittest.TestCase)
|
|
289
288
|
unittest.main(verbosity=2)
|
warp/tests/test_reload.py
CHANGED
|
@@ -5,25 +5,22 @@
|
|
|
5
5
|
# distribution of this software and related documentation without an express
|
|
6
6
|
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import
|
|
8
|
+
import importlib
|
|
9
|
+
import os
|
|
10
|
+
import unittest
|
|
10
11
|
|
|
11
|
-
import
|
|
12
|
+
import numpy as np
|
|
12
13
|
|
|
13
14
|
import warp as wp
|
|
14
|
-
from warp.tests.test_base import *
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
import
|
|
16
|
+
# dummy modules used for testing reload with dependencies
|
|
17
|
+
import warp.tests.aux_test_dependent as test_dependent
|
|
18
|
+
import warp.tests.aux_test_reference as test_reference
|
|
19
|
+
import warp.tests.aux_test_reference_reference as test_reference_reference
|
|
19
20
|
|
|
20
21
|
# dummy module used for testing reload
|
|
21
|
-
import warp.tests.
|
|
22
|
-
|
|
23
|
-
# dummy modules used for testing reload with dependencies
|
|
24
|
-
import warp.tests.test_dependent as test_dependent
|
|
25
|
-
import warp.tests.test_reference as test_reference
|
|
26
|
-
import warp.tests.test_reference_reference as test_reference_reference
|
|
22
|
+
import warp.tests.aux_test_square as test_square
|
|
23
|
+
from warp.tests.unittest_utils import *
|
|
27
24
|
|
|
28
25
|
wp.init()
|
|
29
26
|
|
|
@@ -110,7 +107,7 @@ def run(expect, device):
|
|
|
110
107
|
|
|
111
108
|
def test_reload(test, device):
|
|
112
109
|
# write out the module python and import it
|
|
113
|
-
f = open(os.path.abspath(os.path.join(os.path.dirname(__file__), "
|
|
110
|
+
f = open(os.path.abspath(os.path.join(os.path.dirname(__file__), "aux_test_square.py")), "w")
|
|
114
111
|
f.writelines(square_two)
|
|
115
112
|
f.flush()
|
|
116
113
|
f.close()
|
|
@@ -118,7 +115,7 @@ def test_reload(test, device):
|
|
|
118
115
|
reload_module(test_square)
|
|
119
116
|
test_square.run(expect=4.0, device=device) # 2*2=4
|
|
120
117
|
|
|
121
|
-
f = open(os.path.abspath(os.path.join(os.path.dirname(__file__), "
|
|
118
|
+
f = open(os.path.abspath(os.path.join(os.path.dirname(__file__), "aux_test_square.py")), "w")
|
|
122
119
|
f.writelines(square_four)
|
|
123
120
|
f.flush()
|
|
124
121
|
f.close()
|
|
@@ -130,12 +127,12 @@ def test_reload(test, device):
|
|
|
130
127
|
|
|
131
128
|
def test_reload_class(test, device):
|
|
132
129
|
def test_func():
|
|
133
|
-
import warp.tests.test_class_kernel
|
|
134
|
-
from warp.tests.test_class_kernel import ClassKernelTest
|
|
135
|
-
|
|
136
130
|
import importlib as imp
|
|
137
131
|
|
|
138
|
-
|
|
132
|
+
import warp.tests.aux_test_class_kernel
|
|
133
|
+
from warp.tests.aux_test_class_kernel import ClassKernelTest
|
|
134
|
+
|
|
135
|
+
imp.reload(warp.tests.aux_test_class_kernel)
|
|
139
136
|
|
|
140
137
|
ctest = ClassKernelTest(device)
|
|
141
138
|
expected = np.zeros((10, 3, 3), dtype=np.float32)
|
|
@@ -149,7 +146,7 @@ def test_reload_class(test, device):
|
|
|
149
146
|
template_ref = """# This file is used to test reloading module references.
|
|
150
147
|
|
|
151
148
|
import warp as wp
|
|
152
|
-
import warp.tests.
|
|
149
|
+
import warp.tests.aux_test_reference_reference as refref
|
|
153
150
|
|
|
154
151
|
wp.init()
|
|
155
152
|
|
|
@@ -173,8 +170,8 @@ def more_magic():
|
|
|
173
170
|
|
|
174
171
|
|
|
175
172
|
def test_reload_references(test, device):
|
|
176
|
-
path_ref = os.path.abspath(os.path.join(os.path.dirname(__file__), "
|
|
177
|
-
path_refref = os.path.abspath(os.path.join(os.path.dirname(__file__), "
|
|
173
|
+
path_ref = os.path.abspath(os.path.join(os.path.dirname(__file__), "aux_test_reference.py"))
|
|
174
|
+
path_refref = os.path.abspath(os.path.join(os.path.dirname(__file__), "aux_test_reference_reference.py"))
|
|
178
175
|
|
|
179
176
|
# rewrite both dependency modules and reload them
|
|
180
177
|
with open(path_ref, "w") as f:
|
|
@@ -202,21 +199,19 @@ def test_reload_references(test, device):
|
|
|
202
199
|
test_dependent.run(expect=4.0, device=device) # 2 * 2 = 4
|
|
203
200
|
|
|
204
201
|
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
devices = get_test_devices()
|
|
203
|
+
|
|
207
204
|
|
|
208
|
-
|
|
209
|
-
|
|
205
|
+
class TestReload(unittest.TestCase):
|
|
206
|
+
pass
|
|
210
207
|
|
|
211
|
-
add_function_test(TestReload, "test_redefine", test_redefine, devices=devices)
|
|
212
|
-
add_function_test(TestReload, "test_reload", test_reload, devices=devices)
|
|
213
|
-
add_function_test(TestReload, "test_reload_class", test_reload_class, devices=devices)
|
|
214
|
-
add_function_test(TestReload, "test_reload_references", test_reload_references, devices=devices)
|
|
215
208
|
|
|
216
|
-
|
|
209
|
+
add_function_test(TestReload, "test_redefine", test_redefine, devices=devices)
|
|
210
|
+
add_function_test(TestReload, "test_reload", test_reload, devices=devices)
|
|
211
|
+
add_function_test(TestReload, "test_reload_class", test_reload_class, devices=devices)
|
|
212
|
+
add_function_test(TestReload, "test_reload_references", test_reload_references, devices=devices)
|
|
217
213
|
|
|
218
214
|
|
|
219
215
|
if __name__ == "__main__":
|
|
220
216
|
wp.build.clear_kernel_cache()
|
|
221
|
-
_ = register(unittest.TestCase)
|
|
222
217
|
unittest.main(verbosity=2, failfast=False)
|
warp/tests/test_rounding.py
CHANGED
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
|
|
8
8
|
import unittest
|
|
9
9
|
|
|
10
|
-
import warp as wp
|
|
11
|
-
from warp.tests.test_base import *
|
|
12
|
-
|
|
13
10
|
import numpy as np
|
|
14
11
|
|
|
12
|
+
import warp as wp
|
|
13
|
+
from warp.tests.unittest_utils import *
|
|
14
|
+
|
|
15
15
|
compare_to_numpy = False
|
|
16
16
|
print_results = False
|
|
17
17
|
|
|
@@ -165,18 +165,15 @@ def test_rounding(test, device):
|
|
|
165
165
|
print("----------------------------------------------")
|
|
166
166
|
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
pass
|
|
168
|
+
class TestRounding(unittest.TestCase):
|
|
169
|
+
pass
|
|
171
170
|
|
|
172
|
-
devices = get_test_devices()
|
|
173
171
|
|
|
174
|
-
|
|
172
|
+
devices = get_test_devices()
|
|
175
173
|
|
|
176
|
-
|
|
174
|
+
add_function_test(TestRounding, "test_rounding", test_rounding, devices=devices)
|
|
177
175
|
|
|
178
176
|
|
|
179
177
|
if __name__ == "__main__":
|
|
180
178
|
wp.build.clear_kernel_cache()
|
|
181
|
-
_ = register(unittest.TestCase)
|
|
182
179
|
unittest.main(verbosity=2)
|