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

reseed once per fixture set #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bendavies
Copy link

Defaulting the seed to 1 causes Faker randomisation to not really work as expected.
Defaulting the seed to null is probably a better idea?

EDIT: I've just seen this is expected, to produce consistent data across runs.

Anyway, I'd like at least to be able to set seed to null in the LoadFilesCommand
What do you think?

@h4cc
Copy link
Owner

h4cc commented Jul 8, 2015

Having the seed 1 is expected, to produce consistent results.

What would seeding with null result in?
Do you want to "not seed" and use the default random behavior?

@bendavies
Copy link
Author

i noticed about 'produce consistent results' intention, sorry.
yeah, the ability to "random seed" (null) in the command would be good i guess

@bendavies
Copy link
Author

Ok, actually, I've found the actually cause of my issue.

If i load 2 files with the files command that look like this.

Cat:
  cat{1..100}:
    name: <firstName()>
Dog:
  dog{1..100}:
    name: <firstName()>

This will produce 100 cats and 100 dogs with the same names, because mt_srand is re-seeded (to the same seed) per file,

I'll edit this PR to fix that.

@h4cc
Copy link
Owner

h4cc commented Jul 8, 2015

Changing the default seed to null is not possible, because others are already depending on that.

Having 'seed' => null in your FixtureSets can be done with the effect you want, Faker does use null as it should: https://github.com/fzaninotto/Faker/blob/bcc07d0cb56cf5ec4fb6e66dda5f5fb9e39e5c27/src/Faker/Generator.php#L182

Your problems seems to be only LoadFilesCommand, where a numeric seed parameter is needed ?

@bendavies bendavies force-pushed the random-seeding branch 2 times, most recently from 90d7cc7 to fecbc8b Compare July 8, 2015 11:37
@bendavies
Copy link
Author

Ok, so the issue was that the reseeding was occurring per file.
I've changed it to per set.

This will keep the consistent results per set.

What do you think?

@bendavies bendavies changed the title default to seeding with a random number reseed once per fixture set Jul 8, 2015
@h4cc
Copy link
Owner

h4cc commented Jul 8, 2015

It was intended to have a seeding before each file. This way a single file will bring consistent results.

I cant see your remaining problem anymore. What are you trying to achieve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants