How to use random2 - 4 common examples

To help you get started, we’ve selected a few random2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joke2k / faker / tests / providers / test_ssn.py View on Github external
def test_invalid_ssn(self):
        self.fake.random = random2.Random()
        # Magic Numbers below generate '666-92-7944', '000-54-2963', '956-GG-9478', '436-00-1386',
        # and 134-76-0000 respectively. The "group" (GG) returned for '956-GG-9478 will be a random
        # number, and that random number is not in the "itin_group_numbers" List. The random GG occurs
        # even when using the same seed_instance() due to using random.choice() for GG to avoid valid
        # ITINs being returned as an invalid SSN:
        #
        # Ensure that generated SSNs are 11 characters long
        # including dashes, consist of dashes and digits only, and the tested number
        # violates the requirements below, ensuring an INVALID SSN is returned:
        #
        # A United States Social Security Number
        # (SSN) is a tax processing number issued by the Internal
        # Revenue Service with the format "AAA-GG-SSSS".  The
        # number is divided into three parts: the first three
        # digits, known as the area number because they were
        # formerly assigned by geographical region; the middle two
github joke2k / faker / tests / providers / test_ssn.py View on Github external
def test_ssn(self):
        self.fake.random = random2.Random()

        self.fake.seed_instance(0)
        value = self.fake.ssn()
        assert re.search(r'^\d{11}$', value)
        assert not value.endswith('0')

        self.fake.seed_instance(5)
        value = self.fake.ssn()

        assert re.search(r'^\d{11}$', value)
        assert value.endswith('0')
github shlomif / fc-solve / fc-solve / source / board_gen / make_board_fc_solve.py View on Github external
return self._randp() + 1

    def _randp(self):
        self.seedx = ((self.seedx) * 214013 + 2531011) & self.MAX_SEED
        return (self.seedx >> 16) & 0xffff

    def _rand(self):
        self.seedx = ((self.seedx) * 214013 + 2531011) & self.MAX_SEED
        return (self.seedx >> 16) & 0x7fff

    def randint(self, a, b):
        return a + self.random() % (b+1-a)


# * Mersenne Twister random number generator
class MTRandom(RandomBase, random2.Random):
    MAX_SEED = 100000000000000000000  # 20 digits

    def setSeed(self, seed):
        random2.Random.__init__(self, seed)
        self.initial_state = self.getstate()


def ms_rearrange(cards):
    if len(cards) != 52:
        return cards
    c = []
    for i in range(13):
        for j in (0, 39, 26, 13):
            c.append(cards[i + j])
    return c
github shlomif / fc-solve / fc-solve / source / board_gen / make_board_fc_solve.py View on Github external
def setSeed(self, seed):
        random2.Random.__init__(self, seed)
        self.initial_state = self.getstate()

random2

Python 3 compatible Python 2 `random` Module.

Python-2.0
Latest version published 1 year ago

Package Health Score

50 / 100
Full package analysis

Popular random2 functions

Similar packages