Esempio n. 1
0
class PatientAddForm(forms.ModelForm):
    p_ids = DataPatinet.objects.values_list('id')
    new_pid = rand_num(0, 100)
    while new_pid in p_ids:
        new_pid = rand_num(0, 100)

    first_name = forms.CharField(label='First Name', max_length=100)
    last_name = forms.CharField(label='Last Name', max_length=100)
    # p_id = str(first_name) +
    patient_id = forms.CharField(max_length=50,
                                 required=False,
                                 initial=str(new_pid))
    patient_id.disabled = True
    email = forms.EmailField()
    phone = forms.CharField(label='Phone', max_length=12, required=False)
    age = forms.IntegerField(label='Age', required=False)
    image = forms.ImageField(required=True)

    class Meta:
        model = DataPatinet
        fields = [
            'first_name',
            'last_name',
            'patient_id',
            'email',
            'phone',
            'age',
            'image',
        ]


# class PatientRetinaImages(forms.Form):
#     class Meta:
#         model = PatientImage
#         fields = ['image']
Esempio n. 2
0
def _hash_builder(num_bits):
    'Returns a simple hash function that uses num_bits as the modulo'
    assert num_bits > 1, 'Hash functions with <2 modulo are just silly'
    c = rand_num(0, num_bits - 1)
    while not _is_coprime(c, num_bits):
        c = rand_num(0, num_bits - 1)
    # multiplicand
    a = rand_num(1, num_bits - 1)
    while not _is_coprime(a, num_bits):
        a = rand_num(1, num_bits - 1)

    def __chunks(n):
        'Breaks n up into smaller ints, so each one is smaller than num_bits'
        ns = []
        while n != 0:
            ns.append(n % num_bits)
            n = n / num_bits
        return ns

    def __hash(n):
        # does this work for strings or other types as well?
        ns = __chunks(n)
        x = (a * ns[0] + c) % num_bits
        for i in range(1, len(ns)):
            # this doesnt quite smell right, b/c x is reused
            x = (a * x + ns[i]) % num_bits
        return x

    return __hash
Esempio n. 3
0
 def _visit_NullaryFunc(self, node):
     if node.op.type == GETKEY:
         return self._getkey()
     elif node.op.type == RANDNUM:
         return float(rand_num())
     else:
         raise Exception('Unknown NullaryFunc op type: {}'.format(
             node.op.type))
Esempio n. 4
0
    def __init__(self, block_type):
        self.coins_burned = 10000 * rand_num()

        global total_coins_burned
        total_coins_burned += self.coins_burned

        self.type = block_type
        
        self.diff = calc_PoB_difficulty(self.coins_burned)
Esempio n. 5
0
    def __init__(self, block_type):
        self.coins_burned = 10000 * rand_num()

        global total_coins_burned
        total_coins_burned += self.coins_burned

        self.type = block_type

        self.diff = calc_PoB_difficulty(self.coins_burned)
Esempio n. 6
0
def gen_fake_blocks(nBlocks):
    #generate psuedo blocks randomly to fill the blocks list

    #genesis block
    blocks.append(CBlock(POW))

    for n in range(nBlocks):
        multi = blocks[-1].diff / blocks[0].diff

        if rand_num() < multi * PoW or blocks[-1].type == POB:         #make a PoW block
            blocks.append(CBlock(POW))
        else:                        #make a PoB block
            blocks.append(CBlock(POB))
Esempio n. 7
0
def gen_fake_blocks(nBlocks):
    #generate psuedo blocks randomly to fill the blocks list

    #genesis block
    blocks.append(CBlock(POW))

    for n in range(nBlocks):
        multi = blocks[-1].diff / blocks[0].diff

        if rand_num(
        ) < multi * PoW or blocks[-1].type == POB:  #make a PoW block
            blocks.append(CBlock(POW))
        else:  #make a PoB block
            blocks.append(CBlock(POB))
Esempio n. 8
0
class UserCreationForm(forms.ModelForm):

    first_name = forms.CharField(label='First Name', max_length=100)
    last_name = forms.CharField(label='Last Name', max_length=100)
    username = forms.CharField(label='Username', max_length=100)
    dept_name = forms.CharField(label='Department',
                                max_length=50,
                                required=False)
    doctor_id = forms.IntegerField(initial=str(rand_num(0, 100)))
    doctor_id.disabled = True
    # hospital = forms.CharField(label='Hospital', max_length=12, required=False)

    # age = forms.IntegerField(label='Age', required=False)
    # image = forms.ImageField(required=True)
    password = forms.CharField(widget=forms.PasswordInput())

    class Meta:
        model = StaffDataModel
        fields = [
            'doctor_id', 'first_name', 'last_name', 'username', 'password'
        ]
Esempio n. 9
0
            newx = pose.residue(r).atom(a).xyz()[0] + t[0]
            newy = pose.residue(r).atom(a).xyz()[1] + t[1]
            newz = pose.residue(r).atom(a).xyz()[2] + t[2]
            pose.residue(r).atom(a).xyz(
                numeric.xyzVector_double_t(newx, newy, newz))

    return pose


add_chain(first_pdb, 'A')
add_chain(second_pdb, 'B')

initial_start = append_pdbs(first_pdb, second_pdb)
pose = pyrosetta.pose_from_pdb(initial_start)

pose = translatePose(pose, [rand_num(1, 60), 0, 0]).clone()

for i in range(40):
    R_X = get_rotation_matrix('x', rand_num(1, 360))
    R_Y = get_rotation_matrix('y', rand_num(1, 360))
    R_Z = get_rotation_matrix('z', rand_num(1, 360))

    pose = rotatePose(pose, R_X).clone()
    pose = rotatePose(pose, R_Y).clone()
    pose = rotatePose(pose, R_Z).clone()

pose = translatePose(pose, [0, rand_num(1, 60), 0]).clone()
pose = translatePose(pose, [0, 0, rand_num(1, 60)]).clone()

pose.dump_pdb(initial_start)