Remove camelCase properties#1440
Conversation
| PyErr_WarnEx( | ||
| PyExc_DeprecationWarning, | ||
| "'v0' is deprecated, use 'desired_speed' instead.", | ||
| 1); |
There was a problem hiding this comment.
just rename the property, this is an internal only interface, this can be changed freely.
There was a problem hiding this comment.
Same is true for all changes in this PR affecting the bindings.
There was a problem hiding this comment.
I added in test_desired_speed another test:
- test deprecated params when adding agents (works)
- test deprecated params after adding agents (does not work, unless I touch the internal cpp interface)
| """Init dataclass to handle deprecated argument.""" | ||
| if v0 is not None: | ||
| warnings.warn( | ||
| "'v0' is deprecated, use 'desired_speed' instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| self.desired_speed = v0 | ||
|
|
||
| self.__dict__.update(kwargs) | ||
|
|
There was a problem hiding this comment.
The AVM model has not yet been released, you can freely modify the names still. No need to release with any deprecation.
There was a problem hiding this comment.
True. I remove v0 from avm.
| def __init__( | ||
| self, | ||
| v0=None, | ||
| **kwargs, |
There was a problem hiding this comment.
Nope we cannot do it like this, now unknown parameters are silently ignored, e.g.
CollisionFreeSpeedModelAgentParameters(foo=True) was an error and is now silently ignored.
| import warnings | ||
| from dataclasses import dataclass | ||
|
|
||
| from deprecated import deprecated |
There was a problem hiding this comment.
| from deprecated import deprecated | |
| import sys | |
| if sys.version_info < (3, 13): | |
| from deprecated import deprecated | |
| else: | |
| from warnings import deprecated |
@deprecated decorators got added with 3.13, see https://docs.python.org/3/library/warnings.html#warnings.deprecated
There was a problem hiding this comment.
Apply the same in all places where you imported deprecated
| @@ -0,0 +1,74 @@ | |||
| # Copyright © 2012-2024 Forschungszentrum Jülich GmbH | |||
There was a problem hiding this comment.
| # Copyright © 2012-2024 Forschungszentrum Jülich GmbH |
9e88a28 to
4a89844
Compare
| # if v0 is not None: | ||
| # warnings.warn( | ||
| # "'v0' is deprecated, use 'desired_speed' instead.", | ||
| # DeprecationWarning, | ||
| # stacklevel=2, | ||
| # ) | ||
| # self.desired_speed = v0 | ||
| # else: |
There was a problem hiding this comment.
Need to check if v0 and desired_speed are set by the user
| deprecated_map = { | ||
| "desiredSpeed": "desired_speed", | ||
| "reactionTime": "reaction_time", | ||
| "agentScale": "agent_scale", | ||
| "obstacleScale": "obstacle_scale", | ||
| "forceDistance": "force_distance", | ||
| } | ||
| for old_name, new_name in deprecated_map.items(): | ||
| if old_name in locals() and locals()[old_name] is not None: | ||
| warnings.warn( | ||
| f"'{old_name}' is deprecated, use '{new_name}' instead.", | ||
| DeprecationWarning, | ||
| stacklevel=2, | ||
| ) | ||
| setattr(self, new_name, locals()[old_name]) | ||
|
|
||
| self.desired_speed = desired_speed | ||
| self.reaction_time = reaction_time | ||
| self.agent_scale = agent_scale | ||
| self.obstacle_scale = obstacle_scale | ||
| self.force_distance = force_distance |
There was a problem hiding this comment.
Need to check if new_name and old_name are set by the user
bfbf257 to
94e3a67
Compare
Co-authored-by: Ozaq <ozaq@posteo.de> Co-authored-by: schroedtert <t.schroedter@posteo.de>
94e3a67 to
df640fc
Compare
This PR addresses issue #1415.
v0in all models todesired_speed