How to use is_periodic method in localstack

Best Python code snippet using localstack_python

trajectory.py

Source:trajectory.py Github

copy

Full Screen

1import numpy as np2from scipy.interpolate import UnivariateSpline3from wzk.math2 import angle2minuspi_pluspi4def full2inner(x):5 return x[..., 1:-1, :].copy()6def inner2full(inner, start=None, end=None):7 n_samples = inner.shape[0]8 def __repeat(x):9 x = np.atleast_2d(x)10 if inner.ndim != 3:11 return x12 else:13 if x.ndim == 2:14 x = x[:, np.newaxis, :]15 return x.repeat(n_samples // x.shape[0], axis=0)16 if start is not None:17 start = __repeat(start)18 inner = np.concatenate((start, inner), axis=-2)19 if end is not None:20 end = __repeat(end)21 inner = np.concatenate((inner, end), axis=-2)22 return inner23def full2start_end(x, mode=''):24 if mode == '1':25 return x[..., [0, -1], :].copy()26 if mode == '20':27 return x[..., 0, :].copy(), x[..., -1, :].copy()28 elif mode == '21':29 return x[..., :1, :].copy(), x[..., -1:, :].copy()30 else:31 raise NotImplementedError32def path_mode(x, mode=None):33 if mode is None or mode == 'full':34 return x35 elif mode == 'inner':36 return x[..., 1:-1, :]37 elif mode == 'wo_start':38 return x[..., 1:, :]39 elif mode == 'wo_end':40 return x[..., :-1, :]41 else:42 raise ValueError43def flat2full(flat, n_dof):44 if flat.ndim == 1:45 flat = flat.reshape(-1, n_dof)46 elif flat.ndim == 2:47 flat = flat.reshape(len(flat), -1, n_dof)48 return flat49def full2flat(x):50 if x.ndim == 2:51 x = x.reshape(-1)52 elif x.ndim == 3:53 x = x.reshape(len(x), -1)54 return x55def periodic_dof_wrapper(x,56 is_periodic=None):57 if is_periodic is not None and any(is_periodic):58 x[..., is_periodic] = angle2minuspi_pluspi(x[..., is_periodic])59 return x60def get_steps(q,61 is_periodic=None):62 return periodic_dof_wrapper(np.diff(q, axis=-2), is_periodic=is_periodic)63def get_steps_norm(q,64 is_periodic=None):65 return np.linalg.norm(get_steps(q=q, is_periodic=is_periodic), axis=-1)66def get_substeps(x, n,67 is_periodic=None, include_start=True):68 *shape, m, d = x.shape69 # only fill in substeps if the number is greater 1,70 if n <= 1 or m <= 1:71 if include_start:72 return x73 else: # How often does this happen? once?: fill_linear_connection74 return x[..., 1:, :]75 steps = get_steps(q=x, is_periodic=is_periodic)76 delta = (np.arange(n-1, -1, -1)/n) * steps[..., np.newaxis]77 x_ss = x[..., 1:, :, np.newaxis] - delta78 x_ss = np.swapaxes(x_ss, -2, -1)79 x_ss = x_ss.reshape(shape + [(m-1) * n, d])80 if include_start:81 x_ss = np.concatenate((x[..., :1, :], x_ss), axis=-2)82 x_ss = periodic_dof_wrapper(x_ss, is_periodic=is_periodic)83 return x_ss84def get_steps_between(start, end, n, is_periodic=None):85 q = np.concatenate((start[..., np.newaxis, :], end[..., np.newaxis, :]), axis=-2)86 q = get_substeps(q, n=n-1, is_periodic=is_periodic)87 return q88def get_substeps_adjusted(x, n,89 is_periodic=None, weighting=None):90 *shape, m, d = x.shape91 if shape:92 shape = tuple(shape)93 x_n = np.zeros(shape+(n, d))94 for i in np.ndindex(*shape):95 x_n[i] = get_substeps_adjusted(x=x[i], n=n, is_periodic=is_periodic, weighting=weighting)96 return x_n97 m1 = m - 198 steps = get_steps(q=x, is_periodic=is_periodic)99 if weighting is not None:100 steps *= weighting101 # Distribute the waypoints equally along the linear sequences of the initial path102 steps_length = np.linalg.norm(steps, axis=-1)103 if np.sum(steps_length) == 0:104 relative_steps_length = np.full(m1, fill_value=1 / m1)105 else:106 relative_steps_length = steps_length / np.sum(steps_length)107 # Adjust the number of waypoints for each step to make the initial guess as equally spaced as possible108 n_sub_exact = relative_steps_length * (n - 1)109 n_sub = np.round(n_sub_exact).astype(int)110 # If the number of points do not match, change the substeps where the rounding was worst111 n_diff = (n-1) - np.sum(n_sub)112 if n_diff != 0:113 n_sub_acc = n_sub_exact - n_sub114 n_sub_acc = 0.5 + np.sign(n_diff) * n_sub_acc115 idx = np.argsort(n_sub_acc)[-np.abs(n_diff):]116 n_sub[idx] += np.sign(n_diff)117 n_sub_cs = np.hstack((0, n_sub.cumsum())) + 1118 # Add the linear interpolation between the waypoints - step by step for each dimension119 x_n = np.empty((n, d))120 x_n[0, :] = x[0, :].copy()121 for i in range(m1):122 x_n[n_sub_cs[i]:n_sub_cs[i + 1], :] = \123 get_substeps(x=x[i:i + 2, :], n=n_sub[i], is_periodic=is_periodic, include_start=False)124 x_n = periodic_dof_wrapper(x=x_n, is_periodic=is_periodic)125 return x_n126def x2bee(x, n_wp=None):127 x_se = x[..., [0, -1], :]128 if n_wp is None:129 n_wp = x.shape[-2]130 bee = get_substeps(x_se, n=n_wp-1, include_start=True)131 return bee132def x2beerel(x, n_wp=None, eps=1e-4):133 bee = x2bee(x, n_wp=n_wp)134 beerel = x - bee135 d = np.linalg.norm(x[..., -1, :] - x[..., 0, :], axis=-1, keepdims=True)[..., np.newaxis] + eps136 beerel = beerel / d137 return beerel138def beerel2x(beerel, se, eps=1e-4):139 n_wp = beerel.shape[-2]140 assert np.all(beerel[..., [0, -1], :] == 0)141 bee = x2bee(x=se, n_wp=n_wp)142 d = np.linalg.norm(se[..., -1, :] - se[..., 0, :], axis=-1, keepdims=True)[..., np.newaxis] + eps143 x = bee + beerel * d144 return x145def get_path_adjusted(x, n=None, is_periodic=None, weighting=None, __m=5):146 n0 = x.shape[-2]147 if n is None:148 n = n0149 else:150 pass151 return get_substeps_adjusted(x=x, n=(n - 1) * (n0*__m) + 1,152 is_periodic=is_periodic, weighting=weighting)[..., ::(n0*__m), :]153def order_path(x, start=None, end=None, is_periodic=None, weights=1.):154 """155 Order the points given by 'x' [2d: (n, d)] according to a weighted euclidean distance156 so that always the nearest point comes next.157 Start with the first point in the array and end with the last if 'x_start' or 'x_end' aren't given.158 """159 # Handle different input combinations160 d = None161 if start is None:162 start = x[..., 0, :]163 x = np.delete(x, 0, axis=-2)164 else:165 d = np.size(start)166 if x is None:167 n = 0168 else:169 n, d = x.shape170 if end is None:171 x_o = np.zeros((n + 1, d))172 else:173 x_o = np.zeros((n + 2, d))174 x_o[-1, :] = end.ravel()175 # Order the points, so that always the nearest is visited next, according to the euclidean distance176 x_o[0, :] = start.ravel()177 for i in range(n):178 x_diff = np.linalg.norm(periodic_dof_wrapper(x - start, is_periodic=is_periodic) * weights, axis=-1)179 i_min = np.argmin(x_diff)180 x_o[1 + i, :] = x[i_min, :]181 start = x[i_min, :]182 x = np.delete(x, i_min, axis=-2)183 return x_o184#185# DERIVATIVES186def d_substeps__dx(n, order=0):187 """188 Get the dependence of substeps ' on the outer way points (x).189 The substeps are placed linear between the waypoints.190 To prevent counting points double one step includes only one of the two endpoints191 This gives a symmetric number of steps but ignores either the start or the end in192 the following calculations.193 x--'--'--'--x---'---'---'---x---'---'---'---x--'--'--'--x--'--'--'--x194 0: {> }{> } {> } {> }{> }195 1: { <} { <} { <}{ <}{ <}196 Ordering of the waypoints into a matrix:197 0:198 s00 s01 s02 s03 -> step 0 (with start)199 s10 s11 s12 s13200 s20 s21 s22 s23201 s30 s31 s32 s33202 s40 s41 s42 s43 -> step 4 (without end)203 1: (shifting by one, and reordering)204 s01 s02 s03 s10 -> step 0 (without start)205 s11 s12 s13 s20206 s21 s22 s23 s30207 s31 s32 s33 s40208 s41 s42 s43 s50 -> step 4 (with end)209 n # way points210 n-1 # steps211 n_s # intermediate points per step212 (n-1)*n_s # substeps (total)213 n_s = 5214 jac0 = ([[1., 0.8, 0.6, 0.4, 0.2], # following step (including way point (1.))215 [0., 0.2, 0.4, 0.6, 0.8]]) # previous step (excluding way point (1.))216 jac1 = ([[0.2, 0.4, 0.6, 0.8, 1.], # previous step (including way point (2.))217 [0.8, 0.6, 0.4, 0.2, 0.]]) # following step (excluding way point (2.))218 """219 if order == 0:220 jac = (np.arange(n) / n)[np.newaxis, :].repeat(2, axis=0)221 jac[0, :] = 1 - jac[0, :]222 else:223 jac = (np.arange(start=n - 1, stop=-1, step=-1) / n)[np.newaxis, :].repeat(2, axis=0)224 jac[0, :] = 1 - jac[0, :]225 return jac226def combine_d_substeps__dx(d_dxs, n):227 # Combine the jacobians of the sub-way-points (joints) to the jacobian for the optimization variables228 if n <= 1:229 return d_dxs230 if d_dxs.ndim == 3:231 n_samples, n_wp_ss, n_dof = d_dxs.shape232 d_dxs = d_dxs.reshape(n_samples, n_wp_ss//n, n, n_dof)233 ss_jac = d_substeps__dx(n=n, order=1)[np.newaxis, np.newaxis, ..., np.newaxis]234 d_dx = np.einsum('ijkl, ijkl -> ijl', d_dxs, ss_jac[:, :, 0, :, :])235 d_dx[:, :-1, :] += np.einsum('ijkl, ijkl -> ijl', d_dxs[:, 1:, :, :], ss_jac[:, :, 1, :, :])236 return d_dx237 else:238 raise ValueError(f"{d_dxs.ndim}")239def to_spline(x, n_c=4, start_end0=False):240 n_wp, n_dof = x.shape[-2:]241 xx = np.linspace(0, 1, n_wp)242 if np.ndim(x) == 2:243 c = np.zeros((n_c, n_dof))244 for i_d in range(n_dof):245 spl = UnivariateSpline(x=xx, y=x[:, i_d])246 c[..., i_d] = spl.get_coeffs()247 elif np.ndim(x) == 3:248 n = x.shape[0]249 c = np.zeros((n, n_c, n_dof))250 for i_n in range(n):251 for i_d in range(n_dof):252 spl = UnivariateSpline(x=xx, y=x[i_n, :, i_d])253 c[i_n, :, i_d] = spl.get_coeffs()254 else:255 raise ValueError256 if start_end0:257 c = c[..., 1:-1, :]258 return c259def set_spline_coeffs(spl, coeffs):260 data = spl._data # noqa261 k, n = data[5], data[7]262 data[9][:n - k - 1] = np.ravel(coeffs)263 spl._data = data264def from_spline(c, n_wp, start_end0=False):265 xx = np.linspace(0, 1, n_wp)266 spl = UnivariateSpline(x=xx, y=xx, )267 if start_end0:268 z = np.zeros_like(c[..., :1, :])269 c = np.concatenate((z, c, z), axis=-2)270 n_c, n_dof = c.shape[-2:]271 if np.ndim(c) == 2:272 x = np.zeros((n_wp, n_dof))273 for i_d in range(n_dof):274 set_spline_coeffs(spl, coeffs=c[:, i_d])275 x[:, i_d] = spl(xx)276 elif np.ndim(c) == 3:277 n = c.shape[0]278 x = np.zeros((n, n_wp, n_dof))279 for i_n in range(n):280 for i_d in range(n_dof):281 spl = UnivariateSpline(x=xx, y=x[i_n, :, i_d])282 set_spline_coeffs(spl, coeffs=c[i_n, :, i_d])283 x[i_n, :, i_d] = spl(xx)284 else:285 raise ValueError286 return x287# TODO which way is the best? Start and end MUST match288def fromto_spline(x, n_c=4, start_end0=False):289 return from_spline(c=to_spline(x=x, n_c=n_c, start_end0=start_end0), n_wp=x.shape[-2])290def fromto_spline2(x, n_c=4, start_end0=False):291 n_wp = x.shape[-2]292 x2 = get_steps_between(start=x[..., 0, :], end=x[..., -1, :], n=n_wp)293 dx = x - x2294 c = to_spline(dx, n_c=n_c, start_end0=start_end0)295 dx_spline = from_spline(c=c, n_wp=n_wp)296 x_spline = x2 + dx_spline297 x_spline = get_path_adjusted(x=x_spline)...

Full Screen

Full Screen

test_geometry.py

Source:test_geometry.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import numpy as np3import pytest4import amrex5from amrex import Geometry as Gm6# TODO: return coord?7@pytest.fixture8def box():9 return amrex.Box(amrex.IntVect(0, 0, 0), amrex.IntVect(127, 127, 127))10@pytest.fixture11def real_box():12 return amrex.RealBox([0, 0, 0], [1, 2, 5])13@pytest.fixture14def geometry(box, real_box):15 coord = 116 is_periodic = [0, 0, 1]17 return amrex.Geometry(box, real_box, coord, is_periodic)18def test_geometry_data(box, real_box):19 gd = amrex.GeometryData()20 print(gd.coord)21 assert gd.coord == 022 print(gd.domain)23 print(gd.domain.small_end)24 assert gd.domain.small_end == amrex.IntVect(1, 1, 1)25 print(gd.domain.big_end)26 assert gd.domain.big_end == amrex.IntVect(0, 0, 0)27 print(gd.prob_domain)28 assert amrex.AlmostEqual(gd.prob_domain, amrex.RealBox(0, 0, 0, -1, -1, -1))29 print(gd.isPeriodic())30 print(gd.is_periodic)31 assert gd.is_periodic == gd.isPeriodic() == [0, 0, 0]32 with pytest.raises(AttributeError):33 gd.coord = 134 with pytest.raises(AttributeError):35 gd.domain = box36 with pytest.raises(AttributeError):37 gd.prob_domain = real_box38 with pytest.raises(AttributeError):39 gd.is_periodic = [1, 0, 1]40 with pytest.raises(AttributeError):41 gd.dx = [0.1, 0.2, 0.3]42@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")43def test_geometry_define(box, real_box):44 gm = Gm()45 coord = 146 is_periodic = [0, 0, 1]47 gm.define(box, real_box, coord, is_periodic)48 assert gm.ProbLength(0) == 1 and gm.ProbLength(1) == 2 and gm.ProbLength(2) == 549 assert gm.isPeriodic() == is_periodic50@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")51def test_probDomain(box, real_box):52 gm = Gm()53 coord = 154 is_periodic = [0, 0, 1]55 gm.define(box, real_box, coord, is_periodic)56 assert gm.ok()57 lo = [0, -1, 1]58 hi = [1, 0, 2]59 rb = amrex.RealBox(lo, hi)60 gm.ProbDomain(rb)61 assert (62 np.isclose(gm.ProbLo(0), lo[0])63 and np.isclose(gm.ProbLo(1), lo[1])64 and np.isclose(gm.ProbLo(2), lo[2])65 and np.isclose(gm.ProbHi(0), hi[0])66 and np.isclose(gm.ProbHi(1), hi[1])67 and np.isclose(gm.ProbHi(2), hi[2])68 )69@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")70def test_size(geometry):71 gm = geometry72 assert np.isclose(gm.ProbSize(), 10)73 assert np.isclose(gm.ProbLength(0), 1)74 assert np.isclose(gm.ProbLength(1), 2)75 assert np.isclose(gm.ProbLength(2), 5)76@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")77def test_domain(box, real_box):78 bx = amrex.Box(amrex.IntVect(0, 0, 0), amrex.IntVect(127, 127, 127))79 gm = Gm()80 coord = 181 is_periodic = [0, 0, 1]82 gm.define(box, real_box, coord, is_periodic)83 assert gm.ok()84 gm.Domain(bx)85 assert gm.Domain().small_end == bx.small_end and gm.Domain().big_end == bx.big_end86@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")87def test_periodic_queries(box, real_box):88 coord = 189 is_periodic = [0, 0, 1]90 gm = Gm(box, real_box, coord, is_periodic)91 pdcity = gm.periodicity()92 assert gm.isAnyPeriodic()93 assert not gm.isPeriodic(0) and not gm.isPeriodic(1) and gm.isPeriodic(2)94 assert not gm.isAllPeriodic()95 assert gm.isPeriodic() == is_periodic96 gm.setPeriodicity([0, 0, 0])97 assert not gm.isAnyPeriodic()98 gm.setPeriodicity([1, 1, 1])99 assert gm.isAllPeriodic()100@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")101def test_periodicity(geometry):102 gm = geometry103 bx = gm.Domain()104 for non_periodic_coord in [0, 1]:105 error_thrown = False106 try:107 gm.period(0)108 except RuntimeError:109 error_thrown = True110 assert error_thrown111 assert gm.period(2) == bx.length(2)112 pdcity = amrex.Periodicity(bx.length() * amrex.IntVect(gm.isPeriodic()))113 assert gm.periodicity() == pdcity114 iv1 = amrex.IntVect(0, 0, 0)115 iv2 = amrex.IntVect(9, 19, 29)116 pdcity = amrex.Periodicity(amrex.IntVect(0, 0, 30))117 bx = amrex.Box(iv1, iv2)118 assert gm.periodicity(bx) == pdcity119@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")120def test_grow(geometry):121 gm = geometry122 gm_grow_pd = gm.growPeriodicDomain(2)123 assert gm_grow_pd.small_end == amrex.IntVect(0, 0, -2)124 assert gm_grow_pd.big_end == amrex.IntVect(127, 127, 129)125 gm_grow_npd = gm.growNonPeriodicDomain(3)126 assert gm_grow_npd.small_end == amrex.IntVect(-3, -3, 0)127 assert gm_grow_npd.big_end == amrex.IntVect(130, 130, 127)128def test_data(geometry, box, real_box):129 geometry_data = geometry.data()130 gd = geometry_data131 assert gd.domain.small_end == box.small_end == gd.Domain().small_end132 assert gd.domain.big_end == box.big_end == gd.Domain().big_end133 assert amrex.AlmostEqual(gd.prob_domain, real_box)134 assert np.allclose(real_box.lo(), gd.prob_domain.lo())135 assert np.allclose(real_box.hi(), gd.prob_domain.hi())136 assert (137 np.isclose(real_box.lo(0), gd.prob_domain.lo(0))138 and np.isclose(real_box.lo(1), gd.prob_domain.lo(1))139 and np.isclose(real_box.lo(2), gd.prob_domain.lo(2))140 )141 assert (142 np.isclose(real_box.hi(0), gd.prob_domain.hi(0))143 and np.isclose(real_box.hi(1), gd.prob_domain.hi(1))144 and np.isclose(real_box.hi(2), gd.prob_domain.hi(2))145 )146 assert np.allclose(real_box.lo(), gd.ProbLo())147 assert np.allclose(real_box.hi(), gd.ProbHi())148 assert (149 np.isclose(real_box.lo(0), gd.ProbLo(0))150 and np.isclose(real_box.lo(1), gd.ProbLo(1))151 and np.isclose(real_box.lo(2), gd.ProbLo(2))152 )153 assert (154 np.isclose(real_box.hi(0), gd.ProbHi(0))155 and np.isclose(real_box.hi(1), gd.ProbHi(1))156 and np.isclose(real_box.hi(2), gd.ProbHi(2))157 )158 assert gd.coord == gd.Coord() == 1159 assert gd.is_periodic == [0, 0, 1]160 assert gd.is_periodic[0] == gd.isPeriodic(0) == 0161 assert gd.is_periodic[1] == gd.isPeriodic(1) == 0162 assert gd.is_periodic[2] == gd.isPeriodic(2) == 1163 print(gd.CellSize())164 assert np.allclose(gd.CellSize(), [0.0078125, 0.015625, 0.0390625])165 assert np.isclose(gd.CellSize(0), 0.0078125)166 assert np.isclose(gd.CellSize(1), 0.015625)167 assert np.isclose(gd.CellSize(2), 0.0390625)168@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")169def test_coarsen_refine(geometry):170 iv1 = amrex.IntVect(-1, -2, -3)171 iv2 = amrex.IntVect(4, 5, 6)172 bx = amrex.Box(iv1, iv2)173 rb = amrex.RealBox(-1, -2, -3, 2, 4, 6)174 gmc = amrex.Geometry(bx, rb, 1, [0, 0, 1])175 cv = amrex.IntVect(2, 2, 1)176 gmc.coarsen(cv)177 assert gmc.Domain().small_end == amrex.IntVect(-1, -1, -3)178 assert gmc.Domain().big_end == amrex.IntVect(2, 2, 6)179 gmr = amrex.Geometry(bx, rb, 1, [0, 0, 1])180 rv = amrex.IntVect(2, 2, 3)181 gmr.refine(rv)182 assert gmr.Domain().small_end == amrex.IntVect(-2, -4, -9)183 assert gmr.Domain().big_end == amrex.IntVect(9, 11, 20)184@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")185def test_roundoff_domain():186 iv1 = amrex.IntVect(-1, -2, -3)187 iv2 = amrex.IntVect(4, 5, 6)188 bx = amrex.Box(iv1, iv2)189 rb = amrex.RealBox(0, 1.0002, 0.00105, 2, 4.2, 5)190 gm = Gm(bx, rb, 1, [0, 0, 1])191 assert gm.outsideRoundOffDomain(-1.0, 1, 2)192 assert not gm.outsideRoundOffDomain(1.00, 2.0, 2)193 assert not gm.insideRoundOffDomain(-1.0, 1, 2)194 assert gm.insideRoundOffDomain(1.00, 2.0, 2)195@pytest.mark.skipif(amrex.Config.spacedim != 3, reason="Requires AMREX_SPACEDIM = 3")196def test_Resets():197 rb = amrex.RealBox(0, 0, 0, 1, 2, 6)198 amrex.Geometry.ResetDefaultProbDomain(rb)199 Gm.ResetDefaultProbDomain(rb)200 is_periodic = [1, 0, 1]201 Gm.ResetDefaultPeriodicity(is_periodic)202 Gm.ResetDefaultCoord(1)203 gm = Gm()204 assert (205 np.isclose(gm.ProbLength(0), 1)206 and np.isclose(gm.ProbLength(1), 2)207 and np.isclose(gm.ProbLength(2), 6)208 )209 assert gm.isPeriodic() == is_periodic210 print(gm.Coord())211 CType = amrex.CoordSys.CoordType...

Full Screen

Full Screen

verify.py

Source:verify.py Github

copy

Full Screen

1from printer import print_line2def set_verification(app_data, is_periodic):3 print_line()4 print("[verify]: Setting the verification values ...")5 verify_data = {}6 verify_data['verified'] = False7 verify_data['epsilon'] = 1.0e-88 verify_value = 0.09 Class = app_data['prob_class']10 if Class == 'S':11 if is_periodic == True:12 verify_value = 0.530770700573e-0413 else:14 verify_value = 0.115028215110e-0115 elif Class == 'W':16 if is_periodic == True:17 verify_value = 0.646732937534e-0518 else:19 verify_value = 0.731581264884e-0120 elif Class == 'A':21 if is_periodic == True:22 verify_value = 0.243336530907e-0523 else:24 verify_value = 0.979991065870e-0125 elif Class == 'B':26 if is_periodic == True:27 verify_value = 0.180056440136e-0528 else:29 verify_value = 0.184378110108e+1930 elif Class == 'C':31 if is_periodic == True:32 verify_value = 0.570673228574e-0633 else:34 verify_value = 0.474623829181e+2435 elif Class == 'D':36 if is_periodic == True:37 verify_value = 0.158327506043e-0938 else:39 verify_value = 0.183242406095e+8440 #fi41 verify_data['verify_value'] = verify_value42 app_data['verify_data'] = verify_data43 return44def verify_norm(app_data):45 print_line()46 print("[verify]: Verifying the results ...")47 verify_data = app_data['verify_data']48 rnm2 = app_data['rnm2']49 verify_value = verify_data['verify_value']50 epsilon = verify_data['epsilon']51 err = abs(rnm2 - verify_value) / verify_value52 if err <= epsilon:53 print("[verify]: VERIFICATION SUCCESSFUL")54 print("[verify]: L2 norm =", rnm2)55 print("[verify]: Error =", err)56 else:57 print("[verify]: VERIFICATION FAILED")58 print("[verify]: L2 norm =", rnm2)59 print("[verify]: Correct L2 norm =", verify_value)60 #fi61 verify_data['verified'] = True...

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