rpy2 converters
Type aliases for R↔Python conversion functions.
brmspy performs most conversion inside the worker process (where embedded R
lives). Converters may optionally use shared memory
(ShmPool) to avoid extra copies when moving large
numeric data across the main↔worker boundary.
This module only defines type aliases used by converter registries and helper
code under [brmspy.helpers._rpy2][].
Notes
- The main process must not import
rpy2.robjects. These aliases only refer to the lower-levelrpy2.rinterface_lib.sexp.Sexphandle type.
Attributes¶
PyObject = Union[dict, list, str, float, int, np.dtype, None, Any, pd.DataFrame, pd.Series, np.ndarray, az.InferenceData, xr.DataArray, xr.Dataset]
module-attribute
¶
Union of common Python-side objects produced by R→Python conversion.
This is intentionally broad: brmspy frequently returns standard scientific Python types (NumPy/pandas/xarray/ArviZ), plus plain dict/list primitives.
Note
Avoid adding Any here unless absolutely necessary; it defeats the purpose of
having this alias.
R2pyConverter = Callable[[Any, ShmPool | None], PyObject]
module-attribute
¶
Py2rConverter = Callable[[Any], Sexp]
module-attribute
¶
Callable signature for a Python→R converter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Any
|
Python object to convert. |
required |
Returns:
| Type | Description |
|---|---|
Sexp
|
Low-level R object handle. |