gym_gridverse.utils package#
Submodules#
gym_gridverse.utils.custom module#
- is_custom(name)[source]#
Checks if input name indicates a custom function/object
A custom name is expressed as <module_name>:<stripped_name>.
- import_custom(name)[source]#
Imports custom module and returns stripped name.
A custom name is expressed as <module_name>:<stripped_name>.
- import_if_custom(name)[source]#
Conditionally imports custom module and returns stripped name.
Combines
is_custom()
andimport_custom()
.
gym_gridverse.utils.fast_copy module#
- T#
generic type
alias of TypeVar(‘T’)
gym_gridverse.utils.functions module#
gym_gridverse.utils.protocols module#
gym_gridverse.utils.raytracing module#
- compute_ray(position, area, *, radians, step_size, unique=True)[source]#
Returns a ray from a given position.
A ray is a list of positions which are hit by a direct line starting at the center of the given position and moving along the given direction (in radians) until the area is left.
- Parameters
- Returns
ray from the given position until the area boundary
- Return type
Ray
- compute_rays(position, area)[source]#
Returns rays obtained at 1° granularity.
A ray is a list of positions which are hit by a direct line starting at the center of the given position and moving along a direction until the area is left. This method will search for the ingeter directions between 0° and 359°.
- compute_rays_fancy(position, area)[source]#
Returns rays obtained by targeting edge points.
A ray is a list of positions which are hit by a direct line starting at the center of the given position and moving along a direction until the area is left. This method will search in the directions towards all other cell edges.
- cached_compute_rays(position, area)#
Returns rays obtained at 1° granularity.
A ray is a list of positions which are hit by a direct line starting at the center of the given position and moving along a direction until the area is left. This method will search for the ingeter directions between 0° and 359°.
- cached_compute_rays_fancy(position, area)#
Returns rays obtained by targeting edge points.
A ray is a list of positions which are hit by a direct line starting at the center of the given position and moving along a direction until the area is left. This method will search in the directions towards all other cell edges.
gym_gridverse.utils.registry module#
- class FunctionRegistry(dict=None, /, **kwargs)[source]#
Bases:
UserDict
- register(function=None, *, name=None)[source]#
Register a function in this registry.
This method can be either called directly or used as a decorator. Before registration, the function signature is checked to make sure it matches the appropriate protocol, and the name is checked to avoid conflicts. If name is not given, function.__name__ is used.
Usage:
>>> @registry.register >>> def function_1(...): ...
>>> @registry.register(name='alt_name_2') >>> def function_2(...): ...
>>> def function_3(...): ... >>> registry.register(function_3)
>>> def function_4(...): ... >>> registry.register(function_4, name='alt_name_4')