99import numpy as np
1010import pandas as pd
1111
12- from activitysim .core .util import reindex
1312from activitysim .core .exceptions import DuplicateLoadableObjectError , TableIndexError
13+ from activitysim .core .util import reindex
1414
1515from .tracing import print_elapsed_time
1616
@@ -445,11 +445,9 @@ def get_channel_for_df(self, df):
445445 raise TableIndexError ("No channel with index name '%s'" % df .index .name )
446446 return self .channels [channel_name ]
447447
448- # step handling
449-
450448 def reset_offsets_for_step (self , step_name ):
451449 """
452- Reset offsets for all channels for a new step
450+ Reset offsets for all channels for a step
453451
454452 Parameters
455453 ----------
@@ -462,6 +460,24 @@ def reset_offsets_for_step(self, step_name):
462460 for c in self .channels :
463461 self .channels [c ].row_states ["offset" ] = 0
464462
463+ def reset_offsets_for_df (self , df ):
464+ """
465+ Reset offsets for all choosers in df if the channel for a step
466+
467+ Parameters
468+ ----------
469+ step_name : str
470+ pipeline step name for this step
471+ df : pandas.DataFrame
472+ df with index name and values corresponding to a registered channel
473+ """
474+ channel = self .get_channel_for_df (df )
475+ channel .row_states .loc [df .index , "offset" ] = 0
476+ logger .info (
477+ f"RNG: resetting random number generator offsets for channel '{ channel .channel_name } ' for { len (df )} rows"
478+ + f" with index name '{ df .index .name } '. Total lenght df: { len (channel .row_states )} "
479+ )
480+
465481 def begin_step (self , step_name ):
466482 """
467483 Register that the pipeline has entered a new step and that global and channel streams
0 commit comments