How to use is_dynamic method in pyresttest

Best Python code snippet using pyresttest_python

homepage_section.py

Source:homepage_section.py Github

copy

Full Screen

...94 :type: str95 """96 self._title = title97 @property98 def is_dynamic(self):99 """Gets the is_dynamic of this HomepageSection. # noqa: E501100 This section was automatically generated by Looker # noqa: E501101 :return: The is_dynamic of this HomepageSection. # noqa: E501102 :rtype: bool103 """104 return self._is_dynamic105 @is_dynamic.setter106 def is_dynamic(self, is_dynamic):107 """Sets the is_dynamic of this HomepageSection.108 This section was automatically generated by Looker # noqa: E501109 :param is_dynamic: The is_dynamic of this HomepageSection. # noqa: E501110 :type: bool111 """112 self._is_dynamic = is_dynamic113 @property114 def is_header(self):115 """Gets the is_header of this HomepageSection. # noqa: E501116 Is this a header section (has no items) # noqa: E501117 :return: The is_header of this HomepageSection. # noqa: E501118 :rtype: bool119 """120 return self._is_header...

Full Screen

Full Screen

relay_service.py

Source:relay_service.py Github

copy

Full Screen

1from flask import Response, json2#from support.connection_factory import Connection3from support.Response_Maker import IS_DEBUG, errorsToResponse, successToResponse,timeHelper4from domain.relay import Relay, RelayDynamic5import mysql.connector6from mysql.connector import errorcode7fileName = "data/relays.txt"8class RelayService():9 @classmethod10 def getRelays(cls, api_key,isArduino):11 data = cls.get_relays_datafile(isArduino)12 #relays = {"relays": data}13 code = 200 # OK14 return successToResponse.getResponseWithData(data, code)15 @classmethod16 def get_relays_datafile(cls,isArduino:bool):17 """18 Returns list of data (line by line) from the datafile.19 """20 if isArduino != True:#Could be any shit21 isArduino = False22 with open(fileName, "r") as myfile:23 lines = myfile.readlines()24 if IS_DEBUG:25 print("relayFileContents: ", lines)26 listRelays = []27 for i in range(0,3):28 if IS_DEBUG:29 print("line: ",i,", gives: ",lines[i])30 dyn=int(lines[0][-2])31 sT=int(lines[1][-2])32 eST=int(lines[2][-2])33 repeats = int(lines[3][(lines[3].find(":")+2):])34 is_dynamic = False35 hasStartTime = False36 eachHasStartTime = False37 if dyn == 1:38 is_dynamic = True39 if sT == 1:40 hasStartTime = True41 if eST == 1:42 eachHasStartTime = True43 44 if IS_DEBUG:45 print("DYN=",dyn,", ST=",sT,", EST=",eST)46 for i in range(4,len(lines)):47 line = lines[i]48 index = line.find('d')+149 indexEnd = line.find(':')-150 if IS_DEBUG:51 print("Line data on off?: ", line[-2])52 if is_dynamic: 53 temp = RelayDynamic.initFromLine(str(line))54 if isArduino:55 listRelays.append(temp.toDictNoBOOOOL())56 else:57 listRelays.append(temp.toDict())58 else:59 isOn = True60 if(line[-2] == "0"):61 isOn = False62 temp = Relay(line[index:indexEnd], isOn)#IF IS DYN!!!!!!63 listRelays.append(temp.toDict())64 65 resp = {66 "is_dynamic":is_dynamic,67 "has_start_time":hasStartTime,68 "each_has_start_time":eachHasStartTime,69 "current_time":timeHelper.get_current_timeArduino(),70 "num_repeats":repeats,71 "relays":listRelays72 } 73 """74 if isArduino:75 resp["current_time"]=timeHelper.get_current_timeArduino()76 """77 return resp78 @classmethod79 def postRelay(cls, api_key, data):80 return cls.postRelayToFile(data)81 @classmethod82 def postRelayToFile(cls, data):83 """84 Prints/replaces information in file....85 """86 #dataParsed =json.loads(data)87 #relays = json.loads(dataParsed["relays"])88 is_dynamic = False89 hasStartTime = False90 eachHasStartTime = False91 repeats=-292 if "is_dynamic" in data and (not data["is_dynamic"] is None) and data["is_dynamic"] == True:93 """94 print("SHISEEEE")95 eCode = 40096 msg = "Bad request"97 return errorsToResponse.getResponse(msg, eCode)98 """99 if IS_DEBUG:100 print("Will this work??, Lets find out!!")101 is_dynamic=True102 if "has_start_time" in data and (not data["has_start_time"] is None) and data["has_start_time"] == True:103 hasStartTime = True104 if "each_has_start_time" in data and (not data["each_has_start_time"] is None) and data["each_has_start_time"] == True:105 eachHasStartTime = True106 if is_dynamic:107 if "num_repeats" in data and (not data["num_repeats"] is None):108 repeats=data["num_repeats"]109 relays = (data["relays"])110 if IS_DEBUG:111 print("RELAYS HEYBARBARIBA type: ",112 type(relays), ", Value: ", relays)113 for i in range(len(relays)):114 if is_dynamic:115 temp = RelayDynamic(**relays[i])116 else:117 temp = Relay(**relays[i])118 relays[i] = temp119 if IS_DEBUG:120 print("TEMP type: ", type(temp), ", temp value: ", temp)121 """122 with open(fileName, "r") as myfile:123 lines = myfile.readlines()124 if IS_DEBUG:125 print("relayFileContents: ", lines)126 i = 0127 for line in lines:128 index = line.find('d')+1129 indexEnd = line.find(':')-1130 if IS_DEBUG:131 print("Relay index from file?: ", index,132 ", and its value: ", line[index:indexEnd])133 i += 1134 """135 i = 0136 dyn = 0 # DYNAMIC137 sT = 0 # StartTimes138 eST = 0 # eachStartTimes139 if is_dynamic:140 dyn = 1141 if hasStartTime:142 sT = 1143 if eachHasStartTime:144 eST = 1145 with open(fileName, "w") as myfile:146 myfile.write("dyn : "+str(dyn))147 myfile.write("\n")148 myfile.write("sT : "+str(sT))149 myfile.write("\n")150 myfile.write("eST : "+str(eST))151 myfile.write("\n")152 #if is_dynamic:153 myfile.write("repeats : "+str(repeats))154 myfile.write("\n")155 for i in range(len(relays)):156 if IS_DEBUG:157 print("RELAY NUMBER: ",158 relays[i].id, ", uses: "+str(relays[i].relay_is_on))159 myfile.write(relays[i].toString())160 myfile.write("\n")161 code = 202162 msg = "majestetic"...

Full Screen

Full Screen

dynamic_dropouts.py

Source:dynamic_dropouts.py Github

copy

Full Screen

1from uuid import uuid42import tensorflow as tf3from tensorflow.keras.layers import \4 Layer, \5 Dropout6from tensorflow.keras import backend as K7class DynamicDropout(Dropout):8 def __init__(self, rate=0.5, is_dynamic=True, **kwargs):9 super(DynamicDropout, self).__init__(rate)10 if is_dynamic:11 self.rate = K.variable(self.rate, name='rate_' + str(uuid4()))12 self.rate_value = rate13 self.is_dynamic = is_dynamic14 def set_dropout(self, rate):15 K.set_value(self.rate, rate)16 self.rate_value = rate17 def call(self, inputs, training=None):18 if not self.is_dynamic:19 return super(DynamicDropout, self).call(inputs, training)20 if 0. < self.rate_value < 1.:21 noise_shape = self._get_noise_shape(inputs)22 def dropped_inputs():23 return K.dropout(24 inputs,25 self.rate,26 noise_shape,27 seed=self.seed,28 )29 return K.in_train_phase(30 dropped_inputs,31 inputs,32 training=training,33 )34 return inputs35 def get_config(self):36 config = super(DynamicDropout, self).get_config()37 if self.is_dynamic:38 config['rate'] = K.get_value(self.rate)39 return config40class CrossmapDropBlock(Layer):41 def __init__(self, rate, block_size, scale=True):42 super(CrossmapDropBlock, self).__init__()43 self.rate = rate44 self.block_size = int(block_size)45 self.scale = scale46 def compute_output_shape(self, input_shape):47 return input_shape48 def build(self, input_shape):49 assert len(input_shape) == 450 _, self.h, self.w, self.channels = input_shape.as_list()51 # for small shapes52 if self.block_size >= self.h // 4 or self.block_size >= self.w // 4:53 self.block_size = 154 # pad the mask55 p1 = (self.block_size - 1) // 256 p0 = (self.block_size - 1) - p157 self.padding = [[0, 0], [p0, p1], [p0, p1], [0, 0]]58 super(CrossmapDropBlock, self).build(input_shape)59 def call(self, inputs, training=None, **kwargs):60 if 0. < self.rate_value < 1.:61 def drop():62 sampling_mask_shape = tf.stack([tf.shape(inputs)[0],63 self.h - self.block_size + 1,64 self.w - self.block_size + 1,65 ])66 # self.channels])67 gamma = self.rate * (self.w * self.h) / (self.block_size ** 2) / \68 ((self.w - self.block_size + 1) * (self.h - self.block_size + 1))69 self.gamma = gamma70 mask = tf.cast(gamma >= tf.random.uniform(sampling_mask_shape, minval=0, maxval=1, dtype=tf.float32),71 dtype=tf.float32)72 mask = tf.stack([mask for _ in range(self.channels)], axis=-1)73 mask = tf.pad(mask, self.padding)74 mask = tf.nn.max_pool(mask, [1, self.block_size, self.block_size, 1], [1, 1, 1, 1], 'SAME')75 mask = 1 - mask76 output = inputs * tf.cast(mask, dtype=tf.float32) / (1 - self.rate) # * tf.cast(tf.size(mask), dtype=tf.float32) / tf.reduce_sum(mask)77 return output78 if training is None:79 training = K.learning_phase()80 output = tf.cond(tf.logical_not(tf.cast(training, dtype=tf.bool)),81 true_fn=lambda: inputs,82 false_fn=drop)83 return output84 return inputs85 def get_config(self):86 config = super(CrossmapDropBlock, self).get_config()87 config = {88 **config,89 **{90 'rate': self.rate,91 'block_size': self.block_size,92 'scale': self.scale,93 },94 }95 return config96class DynamicCrossmapDropBlock(CrossmapDropBlock):97 def __init__(self, rate, block_size, is_dynamic=True, **kwargs):98 super(DynamicCrossmapDropBlock, self).__init__(rate, block_size)99 self.rate_value = self.rate100 if is_dynamic:101 self.rate = K.variable(self.rate, name='rate_' + str(uuid4()))102 self.is_dynamic = is_dynamic103 def set_rate(self, rate=None):104 if rate is not None and 0. < rate < 1.:105 if self.is_dynamic:106 K.set_value(self.rate, rate)107 else:108 self.rate = rate109 self.rate_value = rate110 def get_config(self):111 config = super(DynamicCrossmapDropBlock, self).get_config()112 if self.is_dynamic:113 config['rate'] = K.get_value(self.rate)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run pyresttest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful