How to use calculate method in localstack

Best Python code snippet using localstack_python

_stop_criterion.py

Source:_stop_criterion.py Github

copy

Full Screen

1"""2..3 Copyright (c) 2015-2017, Magni developers.4 All rights reserved.5 See LICENSE.rst for further information.6Module providing functions for calculating stop criteria used in Iterative7Threholding (IT) algorithms.8Routine listings9----------------10calculate_using_mse_convergence(var)11 Calculate stop criterion based on mse convergence.12calculate_using_normalised_mse_convergence(var)13 Calculate stop criterion based on normalised mse convergence.14calculate_using_residual(var)15 Calculate stop criterion based on residual.16calculate_using_residual_measurments_ratio(var)17 Calculate stop criterion based on the residual to measurements ratio.18get_function_handle(method)19 Return a function handle to a given calculation method.20"""21from __future__ import division22import numpy as np23def wrap_calculate_using_mse_convergence(var):24 """25 Arguments wrapper for `calculate_using_mse_convergence`.26 Calculate stop criterion based on mse convergence.27 """28 n = var['A'].shape[1]29 tolerance = var['tolerance']30 def calculate_using_mse_convergence(var):31 """32 Calculate stop criterion based on mse convergence.33 Parameters34 ----------35 var : dict36 Dictionary of variables used in calculating the stop criterion.37 Returns38 -------39 stop : bool40 The indicator of whether or not the stop criterion is satisfied.41 mse : float42 The current convergence mean squared error.43 Notes44 -----45 The IT algorithm should converge to a fixed point. This criterion46 is based on the mean squared error of the difference between the47 proposed solution in this iteration and the proposed solution in the48 previous solution.49 """50 mse = 1/n * np.linalg.norm(var['alpha_prev'] - var['alpha'])**251 stop = mse < tolerance52 return stop, mse53 return calculate_using_mse_convergence54def wrap_calculate_using_normalised_mse_convergence(var):55 """56 Arguments wrapper for `calculate_using_normalised_mse_convergence`.57 Calculate stop criterion based on normalised mse convergence.58 """59 tolerance = var['tolerance']60 def calculate_using_normalised_mse_convergence(var):61 """62 Calculate stop criterion based on normalised mse convergence.63 Parameters64 ----------65 var : dict66 Dictionary of variables used in calculating the stop criterion.67 Returns68 -------69 stop : bool70 The indicator of whether or not the stop criterion is satisfied.71 mse : float72 The current convergence normalised mean squared error.73 Notes74 -----75 The IT algorithm should converge to a fixed point. This criterion76 is based on the normalised mean squared error of the difference77 between the proposed solution in this iteration and the proposed78 solution in the previous solution normalised by the mean squared error79 of the proposed solution in the previous iteration80 """81 se = np.linalg.norm(var['alpha_prev'] - var['alpha'])**282 norm = np.linalg.norm(var['alpha_prev'])**283 if norm > 0:84 nmse = se / norm85 stop = se < tolerance * norm86 else:87 # Previous solution was zero-vector (most likely first iteration)88 nmse = se89 stop = False90 return stop, nmse91 return calculate_using_normalised_mse_convergence92def wrap_calculate_using_residual(var):93 """94 Arguments wrapper for `calculate_using_residual`.95 Calculate stop criterion based on residual.96 """97 tolerance = var['tolerance']98 m = var['A'].shape[0]99 def calculate_using_residual(var):100 """101 Calculate stop criterion based on residual.102 Parameters103 ----------104 var : dict105 Dictionary of variables used in calculating the stop criterion.106 Returns107 -------108 stop : bool109 The indicator of whether or not the stop criterion is satisfied.110 r_mse : float111 The current mean squared error of the residual.112 Notes113 -----114 This stopping criterion is based on the mean sqaured error of the115 residual.116 """117 r_mse = 1/m * np.linalg.norm(var['r'])**2118 stop = r_mse < tolerance119 return stop, r_mse120 return calculate_using_residual121def wrap_calculate_using_residual_measurements_ratio(var):122 """123 Arguments wrapper for `calculate_using_residual_measurements_ratio`.124 Calculate stop criterion based on the residual to measurements ratio.125 """126 tolerance = var['tolerance']127 y = var['y']128 def calculate_using_residual_measurements_ratio(var):129 """130 Calculate stop criterion based on the residual to measurements ratio.131 Parameters132 ----------133 var : dict134 Dictionary of variables used in calculating of the stop criterion.135 Returns136 -------137 stop : bool138 The indicator of whether or not the stop criterion is satisfied.139 r_norm : float140 The current 2-norm of the residual.141 Notes142 -----143 This stop criterion is based on the ratio of the 2-norm of the current144 residual to the 2-norm of the measurments.145 """146 r_norm = np.linalg.norm(var['r'])147 stop = r_norm < tolerance * np.linalg.norm(y)148 return stop, r_norm149 return calculate_using_residual_measurements_ratio150def get_function_handle(method, var):151 """152 Return a function handle to a given calculation method.153 Parameters154 ----------155 method : str156 Identifier of the calculation method to return a handle to.157 var : dict158 Local variables needed in the calculation method.159 Returns160 -------161 f_handle : function162 Handle to calculation `method` defined in this globals scope.163 """...

Full Screen

Full Screen

test_near_wake_length.py

Source:test_near_wake_length.py Github

copy

Full Screen

1import pytest2from miniwake.near_wake_length import calculate_ambient_turbulence_wake_erosion_rate3from miniwake.near_wake_length import calculate_angular_velocity4from miniwake.near_wake_length import calculate_flow_field_ratio5from miniwake.near_wake_length import calculate_mechanical_turbulence_wake_erosion_rate6from miniwake.near_wake_length import calculate_n7from miniwake.near_wake_length import calculate_radius_of_inviscid_expanded_rotor_disk8from miniwake.near_wake_length import calculate_near_wake_length9def test_calculate_ambient_turbulence_wake_erosion_rate():10 ambientTurbuluence = 0.111 assert calculate_ambient_turbulence_wake_erosion_rate(ambientTurbuluence) == (2.5 * ambientTurbuluence + 0.05)12def test_calculate_angular_velocity():13 assert calculate_angular_velocity(0.0) == 0.014def test_calculate_flow_field_ratio():15 assert calculate_flow_field_ratio(1.0) == 3.016def test_calculate_mechanical_turbulence_wake_erosion_rate():17 assert calculate_mechanical_turbulence_wake_erosion_rate(3, 0.0) == 0.018def test_calculate_n():19 pass #todo20def test_calculate_radius_of_inviscid_expanded_rotor_disk():21 pass #todo22def test_calculate_shear_generated_turbulence_wake_erosion_rate():23 pass #todo24def test_calculate_tip_speed_ratio():25 pass #todo26def test_calculate_total_wake_erosion_rate():27 pass #todo28def testcalculate__near_wake_length():...

Full Screen

Full Screen

__init__.py

Source:__init__.py Github

copy

Full Screen

1# ------------------------------------------------------------------------2# Copyright (c) 2022 megvii-model. All Rights Reserved.3# ------------------------------------------------------------------------4# Modified from BasicSR (https://github.com/xinntao/BasicSR)5# Copyright 2018-2020 BasicSR Authors6# ------------------------------------------------------------------------7from .niqe import calculate_niqe8from .psnr_ssim import calculate_psnr, calculate_ssim, calculate_ssim_left, calculate_psnr_left, calculate_skimage_ssim, calculate_skimage_ssim_left...

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 localstack 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