Skip to content

Commit 27a266b

Browse files
committed
fix a bug in reset + seed + reset for MultiFolderWithCache
1 parent 8f093b2 commit 27a266b

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

grid2op/Chronics/multifolderWithCache.py

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,11 @@ def reset(self):
170170
Rebuilt the cache as if it were built from scratch.
171171
This call might take a while to process.
172172
173+
This means that current data in cache will be discarded and that new data will
174+
most likely be read from the hard drive.
175+
176+
This might take a while.
177+
173178
.. danger::
174179
You NEED to call this function (with `env.chronics_handler.reset()`)
175180
if you use the `MultiFolderWithCache` class in your experiments.
@@ -189,25 +194,9 @@ def reset(self):
189194
# everything in "_order" need to be put in cache
190195
path = self.subpaths[i]
191196
data = self._get_nex_data(path)
192-
# if issubclass(self.gridvalueClass, GridStateFromFile):
193-
# data = self.gridvalueClass(
194-
# time_interval=self.time_interval,
195-
# sep=self.sep,
196-
# path=path,
197-
# max_iter=self.max_iter,
198-
# chunk_size=None,
199-
# )
200-
# elif issubclass(self.gridvalueClass, FromHandlers):
201-
# data = self.gridvalueClass(
202-
# time_interval=self.time_interval,
203-
# else:
204-
# raise ChronicsError("Can only use MultiFolderWithCache with GridStateFromFile "
205-
# f"or FromHandlers and not {self.gridvalueClass}")
206-
if self.seed_used is not None:
207-
# seed_chronics = self.space_prng.randint(max_int)
208-
# self._cached_seeds[i] = seed_chronics
197+
198+
if self._cached_seeds is not None:
209199
data.seed(self._cached_seeds[i])
210-
data.regenerate_with_new_seed()
211200

212201
data.initialize(
213202
self._order_backend_loads,
@@ -216,6 +205,10 @@ def reset(self):
216205
self._order_backend_subs,
217206
self._names_chronics_to_backend,
218207
)
208+
209+
if self._cached_seeds is not None:
210+
data.regenerate_with_new_seed()
211+
219212
self._cached_data[i] = data
220213
self.cache_size += 1
221214
if self.action_space is not None:

0 commit comments

Comments
 (0)