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

Add global random seed for deterministic tests #95

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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 change: 1 addition & 0 deletions tests/models/test_keras_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
except ImportError:
pass

random.seed(42)

# def assert_variables_updated(
# input_value: float,
Expand Down
4 changes: 4 additions & 0 deletions tests/models/test_torch_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
from botorch.models.transforms.input import AffineInputTransform
from lume_model.models import TorchModel
from lume_model.variables import InputVariable, OutputVariable, ScalarOutputVariable

torch.manual_seed(42)
except ImportError:
pass

random.seed(42)


# def assert_variables_updated(
# input_value: float,
Expand Down
3 changes: 3 additions & 0 deletions tests/models/test_torch_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
import torch
from botorch.models import SingleTaskGP
from lume_model.models import TorchModel, TorchModule

torch.manual_seed(42)
except ImportError:
pass

random.seed(42)

def assert_california_module_result(result: torch.Tensor, idx=None):
target = torch.tensor([4.0636503726, 2.7774916915, 2.7928111793], dtype=result.dtype)
Expand Down