Skip to content

Conversation

@Eric-Vin
Copy link
Collaborator

Adds dynamic sampling to VerifAI.

Merge with BerkeleyLearnVerify/Scenic#417

@Eric-Vin Eric-Vin requested a review from dfremont December 16, 2025 16:10
Comment on lines 1121 to 1130
if length is None:
domain.flattenOnto(value, flattened)
else:
fixedDomain = feature.fixedDomains(self.timeBound)[length]
fixedDomain.flattenOnto(value, flattened)
if fixedDimension:
sizePerElt = domain.flattenedDimension
needed = (feature.maxLength - length) * sizePerElt
for i in range(needed):
flattened.append(None)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we pull this code out into a helper function (can be local, doesn't need to be a method on the class) and use it in the loop for static features too? Most of the code is identical.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(We can leave this to later, it's not that important)

dim += 1 # Timesteps
for feature in self.features:
domain = feature.domain
timeMult = self.timeBound if isinstance(feature, TimeSeriesFeature) else 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A thought probably best left for later: maybe we should move all the flattening logic into new Feature._flatten and Feature._flattenedDimension methods. Then this kind of case split could be handled by overrides in TimeSeriesFeature instead of needing to have special cases here.

Copy link
Collaborator

@dfremont dfremont left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall. Details are in comments above, but my main suggestion is to try to preserve the simple way to access features from the sampled point (point.myFeature instead of point.staticSample.myFeature). If we can do that, then most of the changes you had to make to the existing tests shouldn't be necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants