utils#

Submodules#

Module Contents#

Functions#

gym_socks.utils.indicator_fn(points, space)[source]

Lightweight indicator for gym.spaces.Box sets.

Provides a lightweight proxy for the contains function in gym.spaces.Box. The original function does type checking, casting, and shape checking, which is slow.

Parameters
  • points (numpy.ndarray) – Points to evaluate the indicator at.

  • space (any) – Space over which the indicator function is defined. Should be either a gym.spaces.Box or a function which returns 0 or 1 depending on whether the points are inside or outside the space.

Returns

Boolean labels of whether the points are inside or outside the space.

Return type

numpy.ndarray

gym_socks.utils.normalize(v)[source]

Normalize.

Small utility function for normalizing a matrix or a vector. Divides the matrix (vector) by the sum of the matrix rows (vector). Used primarily by the stochastic reachability algorithms.

Parameters

v (numpy.ndarray) – Matrix or vector to normalize.

Returns

Normalized matrix or vector.

Return type

numpy.ndarray