File tree Expand file tree Collapse file tree 2 files changed +33
-15
lines changed
subprojects/robotpy-wpimath Expand file tree Collapse file tree 2 files changed +33
-15
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,13 @@ classes:
48
48
{
49
49
std::string clsNameCopy = clsName;
50
50
51
+ cls_Constraints
52
+ .def("__repr__", [clsNameCopy](const Constraints &self) {
53
+ return clsNameCopy + ".Constraints("
54
+ "maxVelocity=" + std::to_string(self.maxVelocity()) + ", "
55
+ "maxAcceleration=" + std::to_string(self.maxAcceleration()) + ")";
56
+ });
57
+
51
58
cls_State
52
59
.def(
53
60
py::init<Distance_t, Velocity_t>(),
@@ -71,23 +78,10 @@ classes:
71
78
ignore : true
72
79
Velocity_t, Acceleration_t :
73
80
param_override :
74
- maxVelocity_ :
75
- name : maxVelocity
81
+ maxVelocity :
76
82
default : ' 0'
77
- maxAcceleration_ :
78
- name : maxAcceleration
83
+ maxAcceleration :
79
84
default : ' 0'
80
- template_inline_code : |
81
- {
82
- std::string clsNameCopy = clsName;
83
-
84
- cls_Constraints
85
- .def("__repr__", [clsNameCopy](const Constraints &self) {
86
- return clsNameCopy + ".Constraints("
87
- "maxVelocity=" + std::to_string(self.maxVelocity()) + ", "
88
- "maxAcceleration=" + std::to_string(self.maxAcceleration()) + ")";
89
- });
90
- }
91
85
frc::TrapezoidProfile::State :
92
86
force_no_default_constructor : true
93
87
attributes :
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from wpimath import trajectory
4
+
5
+ trapezoid_profile_types = [
6
+ trajectory .TrapezoidProfile ,
7
+ trajectory .TrapezoidProfileRadians ,
8
+ ]
9
+
10
+
11
+ @pytest .mark .parametrize ("TrapezoidProfile" , trapezoid_profile_types )
12
+ def test_constraints_repr (TrapezoidProfile ):
13
+ expected_qualname = f"{ TrapezoidProfile .__name__ } .Constraints"
14
+ constraints = TrapezoidProfile .Constraints ()
15
+
16
+ assert repr (constraints ).startswith (f"{ expected_qualname } (maxVelocity=0." )
17
+
18
+
19
+ @pytest .mark .parametrize ("TrapezoidProfile" , trapezoid_profile_types )
20
+ def test_state_repr (TrapezoidProfile ):
21
+ expected_qualname = f"{ TrapezoidProfile .__name__ } .State"
22
+ constraints = TrapezoidProfile .State ()
23
+
24
+ assert repr (constraints ).startswith (f"{ expected_qualname } (position=0." )
You can’t perform that action at this time.
0 commit comments