unilab.base.entity.SceneTensorReadPlan

class unilab.base.entity.SceneTensorReadPlan[source]

Bases: object

Phase-scoped packed tensor reads for one EntityScene.

The plan is the Manager read boundary. A phase calls refresh() (or refresh_selected() after a mask reset) once and then slices entity views from the resulting packet. Host-bridge execution therefore performs one packed H2D transfer per read phase regardless of the number of terms, entities, sensors, or bodies.

Parameters:

Methods

__init__(*, scene, device, entities, ...)

body_tensor_view(entity[, body_names])

Return entity-local body state from canonical phase sensors.

close()

Release the backend-owned packed read plan.

invalidate()

Drop phase values after an in-phase simulation mutation.

joint_tensor_view(entity)

Return one entity's validated joint state from the phase packet.

refresh()

Publish one full-batch packet for the current read phase.

refresh_selected()

Publish the post-selected-reset packet for the current read phase.

sensor_tensor_views(entity, names)

Return explicit named sensors from the phase packet.

Attributes

body_names

device

entities

host_plan

last_timing

packet_names

Return the immutable backend sensor names compiled into this plan.

ready

Return whether the current packet is available to phase readers.

scene

sensor_names

transfer_stats

__init__(*, scene, device, entities, sensor_names, body_names, host_plan)[source]
Parameters:
property scene: EntityScene
property device: device
property entities: Mapping[str, Entity]
property sensor_names: Mapping[str, tuple[str, ...]]
property body_names: Mapping[str, tuple[str, ...]]
property host_plan: HostBridgeTransferPlan | None
property ready: bool

Return whether the current packet is available to phase readers.

property packet_names: tuple[str, ...]

Return the immutable backend sensor names compiled into this plan.

refresh()[source]

Publish one full-batch packet for the current read phase.

Return type:

None

refresh_selected()[source]

Publish the post-selected-reset packet for the current read phase.

Host bridges use the backend’s selected-row boundary so reset rebuild does not trigger a second full read. Device-resident backends refresh their stable public views through the same normal read path.

Return type:

None

invalidate()[source]

Drop phase values after an in-phase simulation mutation.

Return type:

None

joint_tensor_view(entity)[source]

Return one entity’s validated joint state from the phase packet.

Parameters:

entity (str | Entity)

Return type:

EntityTensorStateView

sensor_tensor_views(entity, names)[source]

Return explicit named sensors from the phase packet.

Parameters:
Return type:

EntityTensorSensorViews

body_tensor_view(entity, body_names=None)[source]

Return entity-local body state from canonical phase sensors.

Parameters:
Return type:

EntityTensorBodyStateView

property transfer_stats: dict[str, int]
property last_timing: dict[str, float]
close()[source]

Release the backend-owned packed read plan.

Return type:

None