Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,314 changes: 1,299 additions & 15 deletions src/gfn/gym/hypergrid.py

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions testing/test_environments.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_HyperGrid_preprocessors(
ND_BATCH_SHAPE = (4, 2)
SEED = 1234

env = HyperGrid(ndim=NDIM, height=ENV_HEIGHT)
env = HyperGrid(ndim=NDIM, height=ENV_HEIGHT, validate_modes=False)

if preprocessor_name == "Identity":
preprocessor = IdentityPreprocessor(output_dim=NDIM)
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_HyperGrid_fwd_step():
NDIM = 2
ENV_HEIGHT = BATCH_SIZE = 3

env = HyperGrid(ndim=NDIM, height=ENV_HEIGHT)
env = HyperGrid(ndim=NDIM, height=ENV_HEIGHT, validate_modes=False)
states = env.reset(batch_shape=BATCH_SIZE) # Instantiate a batch of initial states
assert (states.batch_shape[0], states.state_shape[0]) == (BATCH_SIZE, NDIM)

Expand Down Expand Up @@ -104,7 +104,7 @@ def test_HyperGrid_bwd_step():
SEED = 1234

# Testing the backward method from a batch of random (seeded) state.
env = HyperGrid(ndim=NDIM, height=ENV_HEIGHT)
env = HyperGrid(ndim=NDIM, height=ENV_HEIGHT, validate_modes=False)
states = env.reset(batch_shape=(NDIM, ENV_HEIGHT), random=True, seed=SEED)

passing_actions_lists = [
Expand Down Expand Up @@ -261,7 +261,7 @@ def test_states_getitem(ndim: int, env_name: str):
ND_BATCH_SHAPE = (2, 3)

if env_name == "HyperGrid":
env = HyperGrid(ndim=ndim, height=8)
env = HyperGrid(ndim=ndim, height=8, validate_modes=False)
elif env_name == "DiscreteEBM":
env = DiscreteEBM(ndim=ndim)
elif env_name == "Box":
Expand Down Expand Up @@ -298,7 +298,11 @@ def test_get_grid():
NDIM = 2

env = HyperGrid(
height=HEIGHT, ndim=NDIM, store_all_states=True, calculate_partition=True
height=HEIGHT,
ndim=NDIM,
store_all_states=True,
calculate_partition=True,
validate_modes=False,
)
all_states = env.all_states
assert all_states is not None
Expand Down
2 changes: 1 addition & 1 deletion testing/test_estimators.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def test_numerical_stability_different_dtypes(dtype):
def test_discrete_policy_estimator_integration():
"""Test integration with DiscretePolicyEstimator."""
# Create a simple environment and estimator
env = HyperGrid(ndim=2, height=4)
env = HyperGrid(ndim=2, height=4, validate_modes=False)
preprocessor = KHotPreprocessor(env.height, env.ndim)
module = MLP(input_dim=preprocessor.output_dim, output_dim=env.n_actions)

Expand Down
2 changes: 1 addition & 1 deletion testing/test_gflownet.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_trajectory_based_gflownet_generic():


def test_flow_matching_gflownet_generic():
env = HyperGrid(ndim=2)
env = HyperGrid(ndim=2, validate_modes=False)
preprocessor = KHotPreprocessor(ndim=env.ndim, height=env.height)
module = MLP(input_dim=preprocessor.output_dim, output_dim=env.n_actions)
estimator = DiscretePolicyEstimator(
Expand Down
Loading
Loading