test.generative

binding *seed* does not change the basis

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None

Description

This is what I'm observing:

user=> (binding [gen/*seed* 7] (gen/uniform))
-6880819372607069048
user=> (binding [gen/*seed* 7] (gen/uniform))
5065957067589062886

This is what I'm expecting:

user=> (binding [gen/*seed* 7] (gen/uniform))
-4967725919621401576
user=> (binding [gen/*seed* 7] (gen/uniform))
-4967725919621401576

The work-around is to bind *rnd* to a new java.util.Random constructed appropriately:

(binding [gen/*rnd* (java.util.Random. 7)] (gen/uniform))

I'm not sure: Is this is a bug in the doc string of *seed*? Is the bug the very existence of *seed*? (*seed* is never used.) Should the doc-string for *rnd* suggest something like the code above as a way to get a consistent basis? Should generators provide a with-seed macro to do this for us?

Activity

Stuart Halloway made changes -
Field Original Value New Value
Resolution Completed [ 1 ]
Status Open [ 1 ] Closed [ 6 ]

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: