Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrapper bug when no state variable is used #80

Open
musslick opened this issue Aug 2, 2024 · 1 comment
Open

Wrapper bug when no state variable is used #80

musslick opened this issue Aug 2, 2024 · 1 comment
Labels
bug Something isn't working.

Comments

@musslick
Copy link
Contributor

musslick commented Aug 2, 2024

This is will throw an error (since none of the standard state fields are used).

@on_state()
def random_sample_on_state(all_conditions, num_samples, random_state=None):
  return Delta(conditions=random_sample(all_conditions, num_samples, random_state))

and currently requires this workaround:

@on_state()
def random_sample_on_state(conditions, all_conditions, num_samples, random_state=None):
  return Delta(conditions=random_sample(all_conditions, num_samples, random_state))
@musslick musslick added the bug Something isn't working. label Aug 2, 2024
@younesStrittmatter
Copy link
Contributor

Could not reproduce the error. Maybe you forgot the keyword argument or to pass in the state. This works:

import pandas as pd

from autora.experimentalist.random import random_sample
from autora.state import StandardState, on_state, Delta


@on_state
def random_sample_on_state(all_conditions):
    return Delta(conditions=random_sample(all_conditions, 1, 42))


all_conditions = pd.DataFrame({'x': [0, 1, 2]})
s = StandardState()
s = random_sample_on_state(s, all_conditions=all_conditions)
print(s.conditions)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working.
Projects
None yet
Development

No branches or pull requests

2 participants