@@ -194,7 +194,10 @@ def spaceForScenario(scenario, ignoredProperties):
194194 assert scenario .egoObject is scenario .objects [0 ]
195195 doms = (domainForObject (obj , ignoredProperties )
196196 for obj in scenario .objects )
197- objects = Struct ({ f'object{ i } ' : dom for i , dom in enumerate (doms ) })
197+ objects = Struct ({
198+ ScenicSampler .nameForObject (i ): dom
199+ for i , dom in enumerate (doms )
200+ })
198201
199202 # create domains for global parameters
200203 paramDoms = {}
@@ -279,15 +282,30 @@ def nextSample(self, feedback=None):
279282 return self .pointForScene (self .lastScene )
280283
281284 def pointForScene (self , scene ):
282- """Convert a sampled Scenic :obj:`Scene` to a point in our feature space."""
285+ """Convert a sampled Scenic :obj:`~scenic.core.scenarios.Scene` to a point in our feature space.
286+
287+ The `FeatureSpace` used by this sampler consists of 2 features:
288+
289+ * ``objects``, which is a `Struct` consisting of attributes ``object0``,
290+ ``object1``, etc. with the properties of the corresponding objects
291+ in the Scenic program. The names of these attributes may change in a
292+ future version of VerifAI: use the `nameForObject` function to
293+ generate them.
294+ * ``params``, which is a `Struct` storing the values of the
295+ :term:`global parameters` of the Scenic program (use
296+ `paramDictForSample` to extract them).
297+ """
283298 lengths , dom = self .space .domains
284299 assert lengths is None
285300 assert scene .egoObject is scene .objects [0 ]
286301 objDomain = dom .domainNamed ['objects' ]
287302 assert len (objDomain .domains ) == len (scene .objects )
288- objects = (pointForObject (objDomain .domainNamed [f'object{ i } ' ], obj )
289- for i , obj in enumerate (scene .objects ))
290- objPoint = objDomain .makePoint (* objects )
303+ objects = {
304+ self .nameForObject (i ):
305+ pointForObject (objDomain .domainNamed [self .nameForObject (i )], obj )
306+ for i , obj in enumerate (scene .objects )
307+ }
308+ objPoint = objDomain .makePoint (** objects )
291309
292310 paramDomain = dom .domainNamed ['params' ]
293311 params = {}
@@ -298,8 +316,17 @@ def pointForScene(self, scene):
298316
299317 return self .space .makePoint (objects = objPoint , params = paramPoint )
300318
319+ @staticmethod
320+ def nameForObject (i ):
321+ """Name used in the `FeatureSpace` for the Scenic object with index i.
322+
323+ That is, if ``scene`` is a :obj:`~scenic.core.scenarios.Scene`, the object
324+ ``scene.objects[i]``.
325+ """
326+ return f'object{ i } '
327+
301328 def paramDictForSample (self , sample ):
302- """Recover the dict of global parameters from a `ScenicSampler` sample."""
329+ """Recover the dict of :term:` global parameters` from a `ScenicSampler` sample."""
303330 params = sample .params ._asdict ()
304331 corrected = {}
305332 for newName , quotedParam in self .quotedParams .items ():
0 commit comments