Skip to content

Commit

Permalink
update notebooks and some docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaMorsali committed Oct 7, 2022
1 parent 4600214 commit 3186993
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ response = iai.initialize(
> _response["states"]_ is a list of agent states, by default the first on the list is always the ego vehicle.
## DRIVE
{py:func}`invertedai.api_resources.drive` **DRIVE** is Inverted AI's cutting-edge realistic driving model trained on millions of miles of traffic data.
**DRIVE** is Inverted AI's cutting-edge realistic driving model trained on millions of miles of traffic data.
This model can drive all the agents with only the current state of the environment, i.e., one step observations (which could be obtained from **INITIALIZE**) or with multiple past observations.
```python
response = iai.drive(
Expand Down
1 change: 1 addition & 0 deletions docs/source/sdk.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Python SDK

```{eval-rst}
.. autofunction:: invertedai.api_resources.initialize
.. autofunction:: invertedai.api_resources.drive
Expand Down
49 changes: 43 additions & 6 deletions invertedai/api_resources.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
"""
Python SDK for
Functions
---------
.. autosummary::
:toctree: generated/
available_maps
drive
get_map
initialize
"""
from invertedai.error import TryAgain
import math
from typing import List, Optional
Expand All @@ -9,6 +21,32 @@


def available_maps(*args):
"""
Searching the available maps using the provided keywords as *args
Parameters
----------
*args: str
Variable length argument list of keywords.
Returns
-------
out : List[str]
A list of "availalbe maps" to your account (api-key)
See Also
--------
invertedai.get_map
Notes
-----
Providing more than three keywords is uncessary
Examples
--------
>>> iai.available_maps("carla", "roundabout")
["CARLA:Town03:Roundabout"]
"""
start = time.time()
timeout = TIMEOUT
keywords = "+".join(list(args))
Expand Down Expand Up @@ -83,18 +121,17 @@ def initialize(


def drive(
location="CARLA:Town03:Roundabout",
states: dict,
agent_attributes: dict,
location: str = "CARLA:Town03:Roundabout",
states: dict = {},
agent_attributes: dict = {},
recurrent_states: Optional[List] = None,
get_birdviews: bool = False,
steps: int = 1,
get_infractions: bool = False,
traffic_states_id: str = "000:0",
exclude_ego_agent: bool = True,
present_mask: Optional[List] = None
present_mask: Optional[List] = None,
) -> dict:

def _tolist(input_data: List):
if not isinstance(input_data, list):
return input_data.tolist()
Expand All @@ -118,7 +155,7 @@ def _tolist(input_data: List):
get_infractions=get_infractions,
traffic_states_id=traffic_states_id,
exclude_ego_agent=exclude_ego_agent,
present_mask=present_mask
present_mask=present_mask,
)

start = time.time()
Expand Down

0 comments on commit 3186993

Please sign in to comment.