Skip to content

Commit

Permalink
Update python from list logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruishenl committed Jan 19, 2024
1 parent b73efec commit 3bca4c2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions invertedai/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,22 +171,22 @@ class AgentAttributes(BaseModel):
def fromlist(cls, l):
if len(l) == 5:
length, width, rear_axis_offset, agent_type, waypoints = l
return cls(length=length, width=width, rear_axis_offset=rear_axis_offset, agent_type=agent_type, waypoints=waypoints)
return cls(length=length, width=width, rear_axis_offset=rear_axis_offset, agent_type=agent_type, waypoints=Point(x=waypoints[0], y=waypoints[1]))
if len(l) == 4:
if type(l[3]) == list:
if type(l[2]) == str:
length, width, agent_type, waypoints = l
return cls(length=length, width=width, agent_type=agent_type, waypoints=waypoints)
return cls(length=length, width=width, agent_type=agent_type, waypoints=Point(x=waypoints[0], y=waypoints[1]))
else:
length, width, rear_axis_offset, waypoints = l
return cls(length=length, width=width, rear_axis_offset=rear_axis_offset, waypoints=waypoints)
return cls(length=length, width=width, rear_axis_offset=rear_axis_offset, waypoints=Point(x=waypoints[0], y=waypoints[1]))
else:
length, width, rear_axis_offset, agent_type = l
return cls(length=length, width=width, rear_axis_offset=rear_axis_offset, agent_type=agent_type)
elif len(l) == 3:
if type(l[2]) == list:
length, width, waypoints = l
return cls(length=length, width=width, waypoints=waypoints)
return cls(length=length, width=width, waypoints=Point(x=waypoints[0], y=waypoints[1]))
elif type(l[2]) == str:
length, width, agent_type = l
return cls(length=length, width=width, agent_type=agent_type)
Expand Down

0 comments on commit 3bca4c2

Please sign in to comment.