lmacken / quantumrandom

Tools for utilizing the ANU Quantum Random Number Generator
https://pypi.python.org/pypi/quantumrandom
146 stars 36 forks source link

is there randint wrapper that can return multiple ints on one call #21

Open catchmonster opened 5 years ago

catchmonster commented 5 years ago

ii = int(round(quantumrandom.randint(1, upperLimit))) would be nice to return list or array of ints, something like this: ii = int(round(quantumrandom.randint(1, upperLimit, 10)))

Saves, calling with request and url libs over and over again ...

breadbored commented 4 years ago

You can put it through a for-loop and pass the generator back. Basically like so:


import quantumrandom

upperLimit = 10
generator = quantumrandom.cached_generator()
nums = []

for x in range(10):
    nums.append(quantumrandom.randint(1, upperLimit, generator=generator))

print(nums)
breadbored commented 4 years ago

I'm maintaining a version of this @ identex/quantumrand (quantumrand on PyPi) that has this standard. My quick_dice and dice_roll functions do this already if you're looking for a whole number, along with randint returning a whole number and renaming the old randint to randfloat. I'm adding more to it to make it comparable to the random library, and if you have any suggestions for features I will be maintaining it.

catchthemonster commented 4 years ago

Hi, thanks for response, I am using generator now and converting floats to ints so I am good for now! thanks