99from useq ._channel import Channel # noqa: TC001 # noqa: TCH001
1010from useq ._enums import AXES , Axis
1111from useq ._mda_event import Channel as EventChannel
12- from useq ._mda_event import MDAEvent , ReadOnlyDict
12+ from useq ._mda_event import MDAEvent , PropertyTuple , ReadOnlyDict
1313from useq ._utils import _has_axes
1414from useq ._z import AnyZPlan # noqa: TC001 # noqa: TCH001
1515
@@ -30,7 +30,7 @@ class MDAEventDict(TypedDict, total=False):
3030 y_pos : float | None
3131 z_pos : float | None
3232 sequence : MDASequence | None
33- # properties: list[tuple ] | None
33+ properties : list [PropertyTuple ] | None
3434 metadata : dict
3535 reset_event_timer : bool
3636
@@ -113,6 +113,7 @@ def _iter_sequence(
113113 event_kwarg_overrides : MDAEventDict | None = None ,
114114 position_offsets : PositionDict | None = None ,
115115 _last_t_idx : int = - 1 ,
116+ _last_p_idx : int = - 1 ,
116117) -> Iterator [MDAEvent ]:
117118 """Helper function for `iter_sequence`.
118119
@@ -174,6 +175,11 @@ def _iter_sequence(
174175 event_kwargs .update (_xyzpos (position , channel , sequence .z_plan , grid , z_pos ))
175176 if position and position .name :
176177 event_kwargs ["pos_name" ] = position .name
178+ # include position properties only when p-index changes
179+ p_idx = index .get (Axis .POSITION , - 1 )
180+ if position and position .properties and p_idx != _last_p_idx :
181+ event_kwargs ["properties" ] = list (position .properties )
182+ _last_p_idx = p_idx
177183 if channel :
178184 event_kwargs ["channel" ] = EventChannel .model_construct (
179185 config = channel .config , group = channel .group
@@ -223,6 +229,7 @@ def _iter_sequence(
223229 event_kwarg_overrides = pos_overrides ,
224230 position_offsets = _offsets ,
225231 _last_t_idx = _last_t_idx ,
232+ _last_p_idx = _last_p_idx ,
226233 )
227234 continue
228235 # note that position.sequence may be Falsey even if not None, for example
0 commit comments