Skip to content

Time plans with no delay and indeterminate length #156

@tlambert03

Description

@tlambert03

It should be possible to specify a time plan with no delay but some known duration of number of loops (e.g. time_plan=TIntervalDuration(interval=0, duration=3)) ... and it is possible to instantiate it... but when you iterate over it in an MDASequence, you'll get an error:

File ~/dev/self/useq-schema/src/useq/_time.py:72, in TimePlan.deltas(self)
     70 def deltas(self) -> Iterator[datetime.timedelta]:
     71     current = timedelta(0)
---> 72     for _ in range(self.loops):  # type: ignore  # TODO
     73         yield current
     74         current += self.interval

File ~/dev/self/useq-schema/src/useq/_time.py:145, in TIntervalDuration.loops(self)
    143 @property
    144 def loops(self) -> int:
--> 145     return self.duration // self.interval + 1

ZeroDivisionError: integer division or modulo by zero

For this to work, I think the consumer (such as MDARunner.run) might actually need to special case an MDASequence with a TIntervalDuration plan of interval 0... or we should add something to MDAEvent like a kill_time: a total duration after which the experiment should be stopped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions