File: pybind_wrapper_test_script.py

package info (click to toggle)
gtsam 4.2.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 46,132 kB
  • sloc: cpp: 127,191; python: 14,333; xml: 8,442; makefile: 252; sh: 156; ansic: 101
file content (62 lines) | stat: -rw-r--r-- 1,550 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import pybind_wrapper_test as pwt

p2 = pwt.sub.Point2(10, 20)
print(p2.sum())
print(p2.func_with_default_args(10))
print(p2.func_with_default_args(10, 10))
p2.print_("test print")

p22 = pwt.sub.Point2(10)
print(p22.y())

p3 = pwt.Point3(10, 20, 30)
print(p3.sum())
print(p3.x(to_add=100))

print(pwt.global_func_on_base(p2))
print(pwt.global_func_on_base(p3))

# Test template class.
# Construct with POINT
template_p2 = pwt.TemplatePoint2(p2)
print(template_p2.overload())

template_p3 = pwt.TemplatePoint3(p3)
print(template_p3.overload())
print(template_p3.overload(p3))

# Construct with This
template_p3_copy = pwt.TemplatePoint3(template_p3)
print(template_p3_copy.overload())
print(template_p3.overload(template_p3_copy))

# Function of template type.
ret_p3 = template_p3.method_on_template_type(p3)
print(ret_p3.z())

# Function of This class type.
this = template_p3.method_on_this(p3)
print(this.method_on_template_type(p3).sum())

# Static function.
another_this = pwt.TemplatePoint2.static_method(other=template_p2, dummy=0.0)

# Template function of other POINT type.
print(another_this.template_methodPoint3(p3))
print(another_this.template_methodPoint2(p2))

# Typedef template instantiation.
inst = pwt.Template2Point2Point3Instantiation(p2, p3)
inst.property_t1 = pwt.sub.Point2(100)
print("inst overload: ", inst.sum_x())
print(inst.sum_x(p2))
print(inst.sum_x(p3))
print(inst.sum_x(p2, p3))
print(inst.property_t1.sum())

# Properties
p4 = pwt.sub2.Point4(p2, 30, 40)
print(p4.p.sum())
print(p4.sum())
p4.z = 40
print(p4.sum())