@@ -419,19 +419,6 @@ def _prepare_terms(self):
419419 # call function the first time to fill up dimensions
420420 obs_dims = tuple (term_cfg .func (self ._env , ** term_cfg .params ).shape )
421421
422- # create history buffers and calculate history term dimensions
423- if term_cfg .history_length > 0 :
424- group_entry_history_buffer [term_name ] = CircularBuffer (
425- max_len = term_cfg .history_length , batch_size = self ._env .num_envs , device = self ._env .device
426- )
427- old_dims = list (obs_dims )
428- old_dims .insert (1 , term_cfg .history_length )
429- obs_dims = tuple (old_dims )
430- if term_cfg .flatten_history_dim :
431- obs_dims = (obs_dims [0 ], np .prod (obs_dims [1 :]))
432-
433- self ._group_obs_term_dim [group_name ].append (obs_dims [1 :])
434-
435422 # if scale is set, check if single float or tuple
436423 if term_cfg .scale is not None :
437424 if not isinstance (term_cfg .scale , (float , int , tuple )):
@@ -495,6 +482,19 @@ def _prepare_terms(self):
495482 f" and optional parameters: { args_with_defaults } , but received: { term_params } ."
496483 )
497484
485+ # create history buffers and calculate history term dimensions
486+ if term_cfg .history_length > 0 :
487+ group_entry_history_buffer [term_name ] = CircularBuffer (
488+ max_len = term_cfg .history_length , batch_size = self ._env .num_envs , device = self ._env .device
489+ )
490+ old_dims = list (obs_dims )
491+ old_dims .insert (1 , term_cfg .history_length )
492+ obs_dims = tuple (old_dims )
493+ if term_cfg .flatten_history_dim :
494+ obs_dims = (obs_dims [0 ], np .prod (obs_dims [1 :]))
495+
496+ self ._group_obs_term_dim [group_name ].append (obs_dims [1 :])
497+
498498 # add term in a separate list if term is a class
499499 if isinstance (term_cfg .func , ManagerTermBase ):
500500 self ._group_obs_class_term_cfgs [group_name ].append (term_cfg )
0 commit comments