How to use _get_value method in Robotframework-anywherelibrary

Best Python code snippet using robotframework-anywherelibrary

Naive Bayes.py

Source:Naive Bayes.py Github

copy

Full Screen

...136 p = input.iloc[row]['persons']137 l = input.iloc[row]['lug_boot']138 s = input.iloc[row]['safety']139 if smoothing == 0 :140 probability[0] = buying._get_value(b,'acc') * maint._get_value(m,'acc') * doors._get_value(d,'acc')\141 * persons._get_value(p,'acc') * lug_boot._get_value(l,'acc')\142 * safety._get_value(s,'acc')/(pow(acc,5) * 1208)143 probability[1] = buying._get_value(b, 'unacc') * maint._get_value(m, 'unacc') * doors._get_value(d, 'unacc') \144 * persons._get_value(p, 'unacc') * lug_boot._get_value(l, 'unacc') \145 * safety._get_value(s, 'unacc') / (pow(unacc, 5) * 1208)146 probability[2] = buying._get_value(b, 'good') * maint._get_value(m, 'good') * doors._get_value(d, 'good') \147 * persons._get_value(p, 'good') * lug_boot._get_value(l, 'good') \148 * safety._get_value(s, 'good') / (pow(good, 5) * 1208)149 probability[3] = buying._get_value(b, 'vgood') * maint._get_value(m, 'vgood') * doors._get_value(d, 'vgood') \150 * persons._get_value(p, 'vgood') * lug_boot._get_value(l, 'vgood') \151 * safety._get_value(s, 'vgood') / (pow(vgood, 5) * 1208)152 elif smoothing == 1:153 probability[0] = math.log((buying._get_value(b, 'acc') +1)* (maint._get_value(m, 'acc') + 1) * (doors._get_value(d, 'acc') + 1) \154 * (persons._get_value(p, 'acc')+1) * (lug_boot._get_value(l, 'acc')+1) \155 * (safety._get_value(s, 'acc')+1) * acc / (pow(acc + 3, 3) * 1208 * pow(acc + 4, 3)))156 probability[1] = math.log((buying._get_value(b, 'unacc') + 1) * (maint._get_value(m, 'unacc') + 1)\157 * (doors._get_value(d, 'unacc')+1) * (persons._get_value(p, 'unacc')+1)\158 * (lug_boot._get_value(l, 'unacc') + 1) * (safety._get_value(s, 'unacc') +1)\159 * unacc / (pow(unacc + 3, 3) * 1208 * pow(unacc + 4, 3)))160 probability[2] = math.log((buying._get_value(b, 'good')+1) * (maint._get_value(m, 'good')+1) *(doors._get_value(d, 'good')+1) \161 * (persons._get_value(p, 'good')+1) * (lug_boot._get_value(l, 'good')+1) \162 * (safety._get_value(s, 'good')+1) * good / (pow(good + 3, 3) * 1208 * pow(good + 4, 3)))163 probability[3] = math.log((buying._get_value(b, 'vgood')+1) * (maint._get_value(m, 'vgood')+1) * (doors._get_value(d, 'vgood')+1) \164 * (persons._get_value(p, 'vgood')+1) * (lug_boot._get_value(l, 'vgood')+1) \165 * (safety._get_value(s, 'vgood')+1) * vgood/ (pow(vgood + 3, 3) * 1208 * pow(vgood + 4, 3)))166 if max(probability) == probability[0]:167 labels.append('acc')168 ac.append(probability[0])169 elif max(probability) == probability[1]:170 labels.append('unacc')171 unac.append(probability[1])172 elif max(probability) == probability[2]:173 labels.append('good')174 god.append(probability[2])175 elif max(probability) == probability[3]:176 labels.append('vgood')177 vgo.append(probability[3])178 else:179 labels.append("error")180 acc_vs_all = []181 unacc_vs_all = []182 good_vs_all = []183 vgood_vs_all = []184 for i in np.arange(1.5,10 , 0.2):185 if probability[0]*10000>= i :186 acc_vs_all.append("acc")187 else:188 acc_vs_all.append("not acc")189 if probability[1]*10000>= i :190 unacc_vs_all.append("unacc")191 else:192 unacc_vs_all.append("not unacc")193 if probability[2]*10000>= i :194 good_vs_all.append("good")195 else:196 good_vs_all.append("not good")197 if probability[3]*10000>= i :198 vgood_vs_all.append("vgood")199 else:200 vgood_vs_all.append("not vgood")201 acc_all.append(acc_vs_all)202 unacc_all.append(unacc_vs_all)203 good_all.append(good_vs_all)204 vgood_all.append(vgood_vs_all)205 acc_all = np.array(acc_all).T206 unacc_all = np.array(unacc_all).T207 good_all = np.array(good_all).T208 vgood_all = np.array(vgood_all).T209 return labels,acc_all,unacc_all,good_all,vgood_all210def calculate_measures(real,label):211 confusion_matrix.fillna(0, inplace=True)212 for i in range(len(real)):213 confusion_matrix.loc[real.iloc[i]['class'], label[i]] += 1214 # confusion matrix for acc class vs other classes215 TP_acc = confusion_matrix._get_value('acc','acc')216 TN_acc = confusion_matrix._get_value('unacc','unacc') + confusion_matrix._get_value('good','good')\217 + confusion_matrix._get_value('vgood', 'vgood') + confusion_matrix._get_value('unacc','good')\218 + confusion_matrix._get_value('unacc','vgood') + confusion_matrix._get_value('good','vgood')\219 + confusion_matrix._get_value('good','unacc') + confusion_matrix._get_value('vgood','unacc')\220 + confusion_matrix._get_value('vgood','good')221 FP_acc = confusion_matrix._get_value('unacc','acc') + confusion_matrix._get_value('good','acc')\222 + confusion_matrix._get_value('vgood', 'acc')223 FN_acc = confusion_matrix._get_value('acc','unacc') + confusion_matrix._get_value('acc','good')\224 + confusion_matrix._get_value('acc', 'vgood')225 # confusion matrix for unacc class vs other classes226 TP_unacc = confusion_matrix._get_value('unacc', 'unacc')227 TN_unacc = confusion_matrix._get_value('acc', 'acc') + confusion_matrix._get_value('good', 'good') \228 + confusion_matrix._get_value('vgood', 'vgood') + confusion_matrix._get_value('acc', 'good') \229 + confusion_matrix._get_value('acc', 'vgood') + confusion_matrix._get_value('good', 'vgood') \230 + confusion_matrix._get_value('good', 'acc') + confusion_matrix._get_value('vgood', 'acc') \231 + confusion_matrix._get_value('vgood', 'good')232 FP_unacc = confusion_matrix._get_value('acc', 'unacc') + confusion_matrix._get_value('good', 'unacc') \233 + confusion_matrix._get_value('vgood', 'unacc')234 FN_unacc = confusion_matrix._get_value('unacc', 'acc') + confusion_matrix._get_value('unacc', 'good') \235 + confusion_matrix._get_value('unacc', 'vgood')236 # confusion matrix for good class vs other classes237 TP_good = confusion_matrix._get_value('good', 'good')238 TN_good = confusion_matrix._get_value('unacc', 'unacc') + confusion_matrix._get_value('acc', 'acc') \239 + confusion_matrix._get_value('vgood', 'vgood') + confusion_matrix._get_value('unacc', 'acc') \240 + confusion_matrix._get_value('unacc', 'vgood') + confusion_matrix._get_value('acc', 'vgood') \241 + confusion_matrix._get_value('acc', 'unacc') + confusion_matrix._get_value('vgood', 'unacc') \242 + confusion_matrix._get_value('vgood', 'acc')243 FP_good = confusion_matrix._get_value('acc', 'good') + confusion_matrix._get_value('unacc', 'good') \244 + confusion_matrix._get_value('vgood', 'good')245 FN_good = confusion_matrix._get_value('good', 'unacc') + confusion_matrix._get_value('good', 'acc') \246 + confusion_matrix._get_value('good', 'vgood')247 # confusion matrix for vgood class vs other classes248 TP_vgood = confusion_matrix._get_value('vgood', 'vgood')249 TN_vgood = confusion_matrix._get_value('unacc', 'unacc') + confusion_matrix._get_value('good', 'good') \250 + confusion_matrix._get_value('acc', 'acc') + confusion_matrix._get_value('unacc', 'good') \251 + confusion_matrix._get_value('unacc', 'acc') + confusion_matrix._get_value('good', 'acc') \252 + confusion_matrix._get_value('good', 'unacc') + confusion_matrix._get_value('acc', 'unacc') \253 + confusion_matrix._get_value('acc', 'good')254 FP_vgood = confusion_matrix._get_value('unacc', 'vgood') + confusion_matrix._get_value('good', 'vgood') \255 + confusion_matrix._get_value('acc', 'vgood')256 FN_vgood = confusion_matrix._get_value('vgood', 'unacc') + confusion_matrix._get_value('vgood', 'good') \257 + confusion_matrix._get_value('vgood', 'acc')258 TPR = (TP_acc + TP_good + TP_unacc + TP_vgood) / (TP_acc + TP_good + TP_unacc + TP_vgood + FN_acc + FN_good + FN_unacc + FN_vgood)259 print("sensivity : ")260 print(TPR)261 specificity = (TN_acc + TN_good + TN_unacc + TN_vgood) / (TN_acc + TN_good + TN_unacc + TN_vgood + FP_acc + FP_good + FP_unacc + FP_vgood)262 print("specificity :")263 print(specificity)264 FPR = (FP_acc + FP_good + FP_unacc + FP_vgood) / (TN_acc + TN_good + TN_unacc + TN_vgood + FP_acc + FP_good + FP_unacc + FP_vgood)265 print("False Positive Rate : ")266 print(FPR)267 FNR = (FN_acc + FN_good + FN_unacc + FN_vgood) / (TP_acc + TP_good + TP_unacc + TP_vgood + FN_acc + FN_good + FN_unacc + FN_vgood)268 print("False Negative Rate : ")269 print(FNR)270 print("confusion matrix : ")271 print(confusion_matrix)...

Full Screen

Full Screen

_format.py

Source:_format.py Github

copy

Full Screen

...46def endpoints_output_format(result):47 info = []48 for e in result['dataEndpoints']:49 info.append(OrderedDict([50 ('loginServer', _get_value(result, 'loginServer')),51 ('region', _get_value(e, 'region')),52 ('endpoint', _get_value(e, 'endpoint'))53 ]))54 return info55def agentpool_output_format(result):56 return _output_format(result, _agentpool_format_group)57def connected_registry_output_format(result):58 return _output_format(result, _connected_registry_format_group)59def connected_registry_list_output_format(result):60 family_tree = {}61 for reg in result:62 parent_id = _get_value(reg, 'parent', 'id')63 parent_name = '' if parent_id.isspace() else parent_id.split('/connectedRegistries/')[1]64 family_tree[_get_value(reg, 'id')] = {65 "name": _get_value(reg, 'name'),66 "id": _get_value(reg, 'id'),67 "connectionState": _get_value(reg, 'connectionState'),68 "parent_name": parent_name,69 "parent_id": parent_id,70 "loginServer_host": _get_value(reg, 'loginServer', 'host'),71 "parent_syncProperties_lastSyncTime": _get_value(reg, 'parent', 'syncProperties', 'lastSyncTime'),72 "mode": _get_value(reg, 'mode'),73 "childs": []74 }75 roots = []76 for reg in result:77 parent_id = _get_value(reg, 'parent', 'id')78 if parent_id.isspace() or parent_id not in family_tree:79 roots.append(_get_value(reg, 'id'))80 else:81 family_tree[parent_id]["childs"].append(_get_value(reg, 'id'))82 result_list_format = []83 for connected_registry_id in roots:84 result_list_format.extend(_recursive_format_list_acr_childs(family_tree, connected_registry_id))85 return _output_format(result_list_format, _connected_registry_list_format_group)86def list_referrers_output_format(result):87 manifests = []88 for manifest in result[REF_KEY]:89 manifests.append(OrderedDict([90 ('Digest', _get_value(manifest, 'digest')),91 ('ArtifactType', _get_value(manifest, 'artifactType')),92 ('MediaType', _get_value(manifest, 'mediaType')),93 ('Size', _get_value(manifest, 'size'))94 ]))95 return manifests96def manifest_output_format(result):97 manifests = []98 for manifest in result:99 manifests.append(OrderedDict([100 ('MediaType', _get_value(manifest, 'mediaType')),101 ('ArtifactType', _get_value(manifest, 'artifactType')),102 ('SubjectDigest', _get_value(manifest, 'subject', 'digest'))103 ]))104 return manifests105def _recursive_format_list_acr_childs(family_tree, connected_registry_id):106 connected_registry = family_tree[connected_registry_id]107 childs = connected_registry['childs']108 result = [connected_registry]109 for child_id in childs:110 result.extend(_recursive_format_list_acr_childs(family_tree, child_id))111 return result112def helm_list_output_format(result):113 if isinstance(result, dict):114 obj_list = []115 for _, item in result.items():116 obj_list += item117 return _output_format(obj_list, _helm_format_group)118 logger.debug("Unexpected output %s", result)119 return _output_format(result, _helm_format_group)120def helm_show_output_format(result):121 return _output_format(result, _helm_format_group)122def _output_format(result, format_group):123 if 'value' in result and isinstance(result['value'], list):124 result = result['value']125 obj_list = result if isinstance(result, list) else [result]126 return [format_group(item) for item in obj_list]127def _registry_format_group(item):128 return OrderedDict([129 ('NAME', _get_value(item, 'name')),130 ('RESOURCE GROUP', _get_value(item, 'resourceGroup')),131 ('LOCATION', _get_value(item, 'location')),132 ('SKU', _get_value(item, 'sku', 'name')),133 ('LOGIN SERVER', _get_value(item, 'loginServer')),134 ('CREATION DATE', _format_datetime(_get_value(item, 'creationDate'))),135 ('ADMIN ENABLED', _get_value(item, 'adminUserEnabled'))136 ])137def _usage_format_group(item):138 return OrderedDict([139 ('NAME', _get_value(item, 'name')),140 ('LIMIT', _get_value(item, 'limit')),141 ('CURRENT VALUE', _get_value(item, 'currentValue')),142 ('UNIT', _get_value(item, 'unit'))143 ])144def _policy_format_group(item):145 return OrderedDict([146 ('STATUS', _get_value(item, 'status')),147 ('TYPE', _get_value(item, 'type'))148 ])149def _credential_format_group(item):150 return OrderedDict([151 ('USERNAME', _get_value(item, 'username')),152 ('PASSWORD', _get_value(item, 'passwords', 0, 'value')),153 ('PASSWORD2', _get_value(item, 'passwords', 1, 'value'))154 ])155def _webhook_format_group(item):156 return OrderedDict([157 ('NAME', _get_value(item, 'name')),158 ('LOCATION', _get_value(item, 'location')),159 ('ACTIONS', _get_value(item, 'actions')),160 ('SCOPE', _get_value(item, 'scope')),161 ('STATUS', _get_value(item, 'status'))162 ])163def _webhook_get_config_format_group(item):164 return OrderedDict([165 ('SERVICE URI', _get_value(item, 'serviceUri')),166 ('HEADERS', _get_value(item, 'customHeaders'))167 ])168def _webhook_list_events_format_group(item):169 repository = _get_value(item, 'eventRequestMessage', 'content', 'target', 'repository').strip()170 tag = _get_value(item, 'eventRequestMessage', 'content', 'target', 'tag').strip()171 status = _get_value(item, 'eventResponseMessage', 'statusCode').strip()172 reason = _get_value(item, 'eventResponseMessage', 'reasonPhrase').strip()173 return OrderedDict([174 ('ID', _get_value(item, 'id')),175 ('ACTION', _get_value(item, 'eventRequestMessage', 'content', 'action')),176 ('IMAGE', '{}:{}'.format(repository, tag) if repository and tag else repository or ' '),177 ('HTTP STATUS', '{} {}'.format(status, reason) if status and reason else status or reason or ' '),178 ('TIMESTAMP', _format_datetime(_get_value(item, 'eventRequestMessage', 'content', 'timestamp')))179 ])180def _webhook_ping_format_group(item):181 return OrderedDict([182 ('ID', _get_value(item, 'id'))183 ])184def _replication_format_group(item):185 return OrderedDict([186 ('NAME', _get_value(item, 'name')),187 ('LOCATION', _get_value(item, 'location')),188 ('PROVISIONING STATE', _get_value(item, 'provisioningState')),189 ('STATUS', _get_value(item, 'status', 'displayStatus')),190 ('REGION ENDPOINT ENABLED', _get_value(item, 'regionEndpointEnabled'))191 ])192def _task_format_group(item):193 return OrderedDict([194 ('NAME', _get_value(item, 'name')),195 ('PLATFORM', _get_value(item, 'platform', 'os')),196 ('STATUS', _get_value(item, 'status')),197 ('SOURCE REPOSITORY', _get_value(item, 'step', 'contextPath')),198 ('TRIGGERS', _get_triggers(item))199 ])200def _task_identity_format_group(item):201 identities = _get_array_value(item, 'userAssignedIdentities')202 identities_by_line = str('\n'.join(identities)) if identities else ' '203 return OrderedDict([204 ('PRINCIPAL ID', _get_value(item, 'principalId')),205 ('TENANT ID', _get_value(item, 'tenantId')),206 ('TYPE', _get_value(item, 'type')),207 ('USER ASSIGNED IDENTITIES', identities_by_line)208 ])209def _taskrun_format_group(item):210 return OrderedDict([211 ('NAME', _get_value(item, 'name')),212 ('RUN ID', _get_value(item, 'runResult', 'runId')),213 ('TASK', _get_value(item, 'runResult', 'task')),214 ('PLATFORM', _get_value(item, 'runResult', 'platform', 'os')),215 ('STATUS', _get_value(item, 'runResult', 'status')),216 ('STARTED', _format_datetime(_get_value(item, 'runResult', 'startTime'))),217 ('DURATION', _get_duration(_get_value(item, 'runResult', 'startTime'),218 _get_value(item, 'runResult', 'finishTime')))219 ])220def _agentpool_format_group(item):221 return OrderedDict([222 ('NAME', _get_value(item, 'name')),223 ('COUNT', _get_value(item, 'count')),224 ('TIER', _get_value(item, 'tier')),225 ('STATE', _get_value(item, 'provisioningState')),226 ('VNET', _get_value(item, 'virtualNetworkSubnetResourceId')),227 ('OS', _get_value(item, 'os'))228 ])229def _connected_registry_format_group(item):230 parent_id = _get_value(item, 'parent', 'id')231 parent_name = '' if parent_id.isspace() else parent_id.split('/connectedRegistries/')[1]232 return OrderedDict([233 ('NAME', _get_value(item, 'name')),234 ('MODE', _get_value(item, 'mode')),235 ('CONNECTION STATE', _get_value(item, 'connectionState')),236 ('PARENT', parent_name),237 ('LOGIN SERVER', _get_value(item, 'loginServer', 'host')),238 ('LAST SYNC (UTC)', _get_value(item, 'parent', 'syncProperties', 'lastSyncTime')),239 ('SYNC SCHEDULE', _get_value(item, 'parent', 'syncProperties', 'schedule')),240 ('SYNC WINDOW', _get_value(item, 'parent', 'syncProperties', 'syncWindow'))241 ])242def _connected_registry_list_format_group(item):243 return OrderedDict([244 ('NAME', _get_value(item, 'name')),245 ('MODE', _get_value(item, 'mode')),246 ('CONNECTION STATE', _get_value(item, 'connectionState')),247 ('PARENT', _get_value(item, 'parent_name')),248 ('LOGIN SERVER', _get_value(item, 'loginServer_host')),249 ('LAST SYNC (UTC)', _get_value(item, 'parent_syncProperties_lastSyncTime'))250 ])251def _build_format_group(item):252 return OrderedDict([253 ('BUILD ID', _get_value(item, 'buildId')),254 ('TASK', _get_value(item, 'buildTask')),255 ('PLATFORM', _get_value(item, 'platform', 'osType')),256 ('STATUS', _get_value(item, 'status')),257 ("TRIGGER", _get_build_trigger(_get_value(item, 'imageUpdateTrigger'),258 _get_value(item, 'sourceTrigger', 'eventType'))),259 ('STARTED', _format_datetime(_get_value(item, 'startTime'))),260 ('DURATION', _get_duration(_get_value(item, 'startTime'),261 _get_value(item, 'finishTime')))262 ])263def _run_format_group(item):264 return OrderedDict([265 ('RUN ID', _get_value(item, 'runId')),266 ('TASK', _get_value(item, 'task')),267 ('PLATFORM', _get_value(item, 'platform', 'os')),268 ('STATUS', _get_value(item, 'status')),269 ("TRIGGER", _get_build_trigger(_get_value(item, 'imageUpdateTrigger'),270 _get_value(item, 'sourceTrigger', 'eventType'),271 _get_value(item, 'timerTrigger'))),272 ('STARTED', _format_datetime(_get_value(item, 'startTime'))),273 ('DURATION', _get_duration(_get_value(item, 'startTime'), _get_value(item, 'finishTime')))274 ])275def _helm_format_group(item):276 description = _get_value(item, 'description')277 if len(description) > 57: # Similar to helm client278 description = description[:57] + '...'279 return OrderedDict([280 ('NAME', _get_value(item, 'name')),281 ('CHART VERSION', _get_value(item, 'version')),282 ('APP VERSION', _get_value(item, 'appVersion')),283 ('DESCRIPTION', description)284 ])285def _scope_map_format_group(item):286 description = _get_value(item, 'description')287 if len(description) > 57:288 description = description[:57] + '...'289 return OrderedDict([290 ('NAME', _get_value(item, 'name')),291 ('TYPE', _get_value(item, 'scopeMapType')),292 ('CREATION DATE', _format_datetime(_get_value(item, 'creationDate'))),293 ('DESCRIPTION', description),294 ])295def _token_format_group(item):296 scope_map_id = _get_value(item, 'scopeMapId')297 output = OrderedDict([298 ('NAME', _get_value(item, 'name')),299 ('SCOPE MAP', scope_map_id.split('/')[-1]),300 ('PASSWORD1 EXPIRY', ''),301 ('PASSWORD2 EXPIRY', ''),302 ('STATUS', _get_value(item, 'status').title()),303 ('PROVISIONING STATE', _get_value(item, 'provisioningState')),304 ('CREATION DATE', _format_datetime(_get_value(item, 'creationDate')))305 ])306 passwords = _get_array_value(item, 'credentials', 'passwords')307 for password in passwords:308 password_name = _get_value(password, 'name').upper()309 # _get_value returns ' ' if item is none.310 expiry_value = _get_value(password, 'expiry')311 expiry_value = 'Never' if expiry_value == ' ' else _format_datetime(expiry_value)312 output_password_column = '{} EXPIRY'.format(password_name)313 if output_password_column in output:314 output[output_password_column] = expiry_value315 return output316def _token_password_format_group(item):317 username = _get_value(item, 'username')318 passwords = _get_array_value(item, 'passwords')319 output = [('USERNAME', username)]320 for password in passwords:321 password_name = _get_value(password, 'name').upper()322 password_value = _get_value(password, 'value')323 expiry_value = _get_value(password, 'expiry')324 # _get_value returns ' ' if item is none.325 expiry_value = 'Never' if expiry_value == ' ' else _format_datetime(expiry_value)326 output.append((password_name, password_value))327 output.append(('{} EXPIRY'.format(password_name), expiry_value))328 return OrderedDict(output)329def _get_triggers(item):330 """Get a nested value from a dict.331 :param dict item: The dict object332 """333 triggers = []334 if _get_value(item, 'trigger', 'sourceTriggers', 0, 'status').lower() == 'enabled':335 triggers.append('SOURCE')336 if _get_trigger_status(item, 'trigger', 'timerTriggers'):337 triggers.append('TIMER')338 if _get_value(item, 'trigger', 'baseImageTrigger', 'status').lower() == 'enabled':339 triggers.append('BASE_IMAGE')340 triggers.sort()341 return ' ' if not triggers else str(', '.join(triggers))342def _get_value(item, *args):343 """Get a nested value from a dict.344 :param dict item: The dict object345 """346 try:347 for arg in args:348 item = item[arg]349 return str(item) if item or item == 0 else ' '350 except (KeyError, TypeError, IndexError):351 return ' '352def _get_array_value(item, *args):353 """Get a nested array value from a dict.354 :param dict item: The dict object355 """356 try:...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1from browser import html, document, window2import javascript3#memorize/cache?4def _get_value(other):5 if isinstance(other, LongInt):6 return other.value7 return other8class BigInt:9 def __init__(self):10 pass11 def __abs__(self):12 return LongInt(self.value.abs())13 def __add__(self, other):14 return LongInt(self.value.plus(_get_value(other)))15 def __and__(self, other):16 pass17 def __divmod__(self, other):18 _value=_get_value(other)19 return LongInt(self.value.div(_value)), LongInt(self.value.mod(_value))20 def __div__(self, other):21 return LongInt(self.value.div(_get_value(other)))22 def __eq__(self, other):23 return bool(self.value.eq(_get_value(other)))24 def __floordiv__(self, other):25 return LongInt(self.value.div(_get_value(other)).floor())26 def __ge__(self, other):27 return bool(self.value.gte(_get_value(other)))28 def __gt__(self, other):29 return bool(self.value.gt(_get_value(other)))30 def __index__(self):31 if self.value.isInt():32 return int(self.value.toNumber())33 raise TypeError("This is not an integer")34 def __le__(self, other):35 return bool(self.value.lte(_get_value(other)))36 def __lt__(self, other):37 return bool(self.value.lt(_get_value(other)))38 def __lshift__(self, shift):39 if isinstance(shift, int):40 _v=LongInt(2)**shift41 return LongInt(self.value.times(_v.value))42 def __mod__(self, other):43 return LongInt(self.value.mod(_get_value(other)))44 def __mul__(self, other):45 return LongInt(self.value.times(_get_value(other)))46 def __neg__(self, other):47 return LongInt(self.value.neg(_get_value(other)))48 def __or__(self, other):49 pass50 def __pow__(self, other):51 return LongInt(self.value.pow(_get_value(other)))52 def __rshift__(self, other):53 pass54 def __sub__(self, other):55 return LongInt(self.value.minus(_get_value(other)))56 57 def __repr__(self):58 return "%s(%s)" % (self.__name__, self.value.toString(10))59 def __str__(self):60 return "%s(%s)" % (self.__name__, self.value.toString(10))61 def __xor__(self, other):62 pass63_precision=2064def get_precision(value):65 if isinstance(value, LongInt):66 return len(str(value.value.toString(10)))67 return len(str(value))68class DecimalJS(BigInt):69 def __init__(self, value=0, base=10):70 global _precision71 _prec=get_precision(value)72 if _prec > _precision:73 _precision=_prec74 window.eval('Decimal.precision=%s' % _precision)75 self.value=javascript.JSConstructor(window.Decimal)(value, base)76class BigNumberJS(BigInt):77 def __init__(self, value=0, base=10):78 self.value=javascript.JSConstructor(window.BigNumber)(value, base)79class BigJS(BigInt):80 def __init__(self, value=0, base=10):81 self.value=javascript.JSConstructor(window.Big)(value, base)82 def __floordiv__(self, other):83 _v=LongInt(self.value.div(_get_value(other)))84 if _v >= 0:85 return LongInt(_v.value.round(0, 0)) #round down86 return LongInt(_v.value.round(0, 3)) #round up87 def __pow__(self, other):88 if isinstance(other, LongInt):89 _value=int(other.value.toString(10))90 elif isinstance(other, str):91 _value=int(other)92 return LongInt(self.value.pow(_value))93#_path = __file__[:__file__.rfind('/')]+'/'94_path = __BRYTHON__.brython_path + 'Lib/long_int1/'95#to use decimal.js library uncomment these 2 lines96#javascript.load(_path+'decimal.min.js', ['Decimal'])97#LongInt=DecimalJS...

Full Screen

Full Screen

calculation.py

Source:calculation.py Github

copy

Full Screen

...14def calculate(lines,conditions,mc_hc,container_type,days,df):15 cost = 016 number_count = 017 for line in df.index :18 if df._get_value(number_count,'line') == lines:19 if df._get_value(number_count,'condition') == conditions:20 if df._get_value(number_count,'MC/CH') == mc_hc :21 if df._get_value(number_count,'container') == container_type:22 days_in_stay = df._get_value(number_count,'days in')23 days_out_stay = df._get_value(number_count,'days out')24 if days_in_stay <= days <=days_out_stay:25 price = df._get_value(number_count,'price')26 days_red = df._get_value(number_count,'days red')27 first_period = df._get_value(number_count,'first period')28 first_price = df._get_value(number_count,'first price')29 g2nd_period = df._get_value(number_count,'2nd period')30 g2nd_price = df._get_value(number_count,'2nd price')31 g3rd_period = df._get_value(number_count,'3rd period')32 g3rd_price = df._get_value(number_count,'3rd price')33 g4th_period = df._get_value(number_count,'4th period')34 g4th_price = df._get_value(number_count,'4th price')35 g5th_period = df._get_value(number_count,'5th period')36 g5th_price = df._get_value(number_count,'5th price')37 38 cost += (((days - days_red) * price) + (first_period * first_price) + (g2nd_period * g2nd_price) + (g3rd_period * g3rd_price) + (g4th_period * g4th_price) + (g5th_period * g5th_price)) 39 number_count += 140 return cost 41 ...

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 Robotframework-anywherelibrary 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