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:
4848 {
4949 std::string clsNameCopy = clsName;
5050
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+
5158 cls_State
5259 .def(
5360 py::init<Distance_t, Velocity_t>(),
@@ -71,23 +78,10 @@ classes:
7178 ignore : true
7279 Velocity_t, Acceleration_t :
7380 param_override :
74- maxVelocity_ :
75- name : maxVelocity
81+ maxVelocity :
7682 default : ' 0'
77- maxAcceleration_ :
78- name : maxAcceleration
83+ maxAcceleration :
7984 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- }
9185 frc::TrapezoidProfile::State :
9286 force_no_default_constructor : true
9387 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