Skip to content

Commit

Permalink
fix(RandomForest): Always cast seed to int
Browse files Browse the repository at this point in the history
In cases where seeds were generated from some numpy objects, sometimes
you'd get back an `np.integer`, which causes the program to crash when
communicating with `pyrfr` through `swig`. It seems that swig doesn't
know that it's an _int-like_ and so we explicitly cast it to `int`.
  • Loading branch information
eddiebergman committed Nov 16, 2023
1 parent 06d584f commit 2591549
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion smac/model/random_forest/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ def __init__(
self._rf_opts.compute_law_of_total_variance = False
self._rf: BinaryForest | None = None
self._log_y = log_y
self._rng = regression.default_random_engine(seed)

# Case to `int` incase we get an `np.integer` type
self._rng = regression.default_random_engine(int(seed))

self._n_trees = n_trees
self._n_points_per_tree = n_points_per_tree
Expand Down

0 comments on commit 2591549

Please sign in to comment.