Skip to content

Commit

Permalink
Fix composition tests
Browse files Browse the repository at this point in the history
  • Loading branch information
carriepl-mila committed Oct 24, 2023
1 parent c5106eb commit 80a32cf
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 5 deletions.
4 changes: 2 additions & 2 deletions gflownet/envs/crystals/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ def state2oracle(self, state: List = None) -> Tensor:
if state is None:
state = self.state
return self.statetorch2oracle(
torch.unsqueeze(tfloat(states, device=self.device), 0)
)
torch.unsqueeze(tfloat(state, device=self.device, float_type=self.float), 0)
)[0]

def statetorch2oracle(
self, states: TensorType["batch", "state_dim"]
Expand Down
30 changes: 27 additions & 3 deletions tests/gflownet/envs/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,39 @@ def test__environment__initializes_properly(elements):
[
(
[0, 0, 2, 0],
[0, 0, 2, 0],
[
# fmt: off
0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
# fmt: on
],
),
(
[3, 0, 0, 0],
[3, 0, 0, 0],
[
# fmt: off
0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,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