
    h                       S r SSKJr  SSKrSSKrSSKrSSKJ	r	J
r
  SSKJr  SSKJrJrJr   SSKJr  / SQr\R*                  " \\" \5      S	9r\R*                  " \\" \5      S	9r " S
 S\5      rg! \ a	    \" S5      ef = f)zHHelper functions and wrapper class for converting between numpy and Jax.    )annotationsN)ActTypeObsType)DependencyNotInstalled)ArrayConversionarray_conversionmodule_namespacez]Jax is not installed therefore cannot call `numpy_to_jax`, run `pip install "gymnasium[jax]"`)
JaxToNumpyjax_to_numpynumpy_to_jax)xpc                  0   ^  \ rS rSrSrSU 4S jjrSrU =r$ )r
   "   aT  Wraps a Jax-based environment such that it can be interacted with NumPy arrays.

Actions must be provided as numpy arrays and observations will be returned as numpy arrays.
A vector version of the wrapper exists, :class:`gymnasium.wrappers.vector.JaxToNumpy`.

Notes:
    The Jax To Numpy and Numpy to Jax conversion does not guarantee a roundtrip (jax -> numpy -> jax) and vice versa.
    The reason for this is jax does not support non-array values, therefore numpy ``int_32(5) -> DeviceArray([5], dtype=jnp.int23)``

Example:
    >>> import gymnasium as gym                                     # doctest: +SKIP
    >>> env = gym.make("JaxEnv-vx")                                 # doctest: +SKIP
    >>> env = JaxToNumpy(env)                                       # doctest: +SKIP
    >>> obs, _ = env.reset(seed=123)                                # doctest: +SKIP
    >>> type(obs)                                                   # doctest: +SKIP
    <class 'numpy.ndarray'>
    >>> action = env.action_space.sample()                          # doctest: +SKIP
    >>> obs, reward, terminated, truncated, info = env.step(action) # doctest: +SKIP
    >>> type(obs)                                                   # doctest: +SKIP
    <class 'numpy.ndarray'>
    >>> type(reward)                                                # doctest: +SKIP
    <class 'float'>
    >>> type(terminated)                                            # doctest: +SKIP
    <class 'bool'>
    >>> type(truncated)                                             # doctest: +SKIP
    <class 'bool'>

Change logs:
 * v1.0.0 - Initially added
c                X   > [         c  [        S5      e[        TU ]  U[         [        S9  g)zvWraps a jax environment such that the input and outputs are numpy arrays.

Args:
    env: the jax environment to wrap
Nz8Jax is not installed, run `pip install "gymnasium[jax]"`)envenv_xp	target_xp)jnpr   super__init__np)selfr   	__class__s     Y/home/james-whalen/.local/lib/python3.13/site-packages/gymnasium/wrappers/jax_to_numpy.pyr   JaxToNumpy.__init__B   s0     ;(J  	S;     )r   zgym.Env[ObsType, ActType])__name__
__module____qualname____firstlineno____doc__r   __static_attributes____classcell__)r   s   @r   r
   r
   "   s    >
< 
<r   r
   )r"   
__future__r   	functoolsnumpyr   	gymnasiumgymgymnasium.corer   r   gymnasium.errorr   #gymnasium.wrappers.array_conversionr   r   r	   	jax.numpyr   ImportError__all__partialr   r   r
   r   r   r   <module>r1      s    N "    + 2  9   !16Fr6JK  !16Fs6KL*< *<  
 g s   A2 2B