Rforestry icon indicating copy to clipboard operation
Rforestry copied to clipboard

`seed` same in different objects

Open petrovicboban opened this issue 1 year ago • 3 comments

Let's have

form random_forestry import RandomForest

rf_1 = RandomForest()
rf_2 = RandomForest()

Since default value for seed is random number, we expect:

assert rf_1.seed != rf_2.seed

but that's not what's happening.

although rf_1 and rf_2 are really different objects:

assert id(rf_1) != id(rf_2)

their attributes which have default value set are not:

assert id(rf_1.seed) == id(rf_2.seed)

Python does copy on write here, so if value is changed later, it will create new seed object then:

rf_1.seed = 5
assert id(rf_1.seed) != id(rf_2.seed)

The implication is that if you create different RandomForest objects with seed not explicitly set, seed will be random but all objects will have the same value. Is this acceptable to you? @edwardwliu @theo-s

petrovicboban avatar May 18 '23 13:05 petrovicboban