How to use len_is method in Sure

Best Python code snippet using sure_python

shape_creator.py

Source:shape_creator.py Github

copy

Full Screen

1# Copyright (c) 2022. Eva Schnider2import numpy as np3class ShapeCreator:4 def __init__(self, canvas_size_lr, canvas_size_is, canvas_size_ap):5 self.canvas_size_ap = canvas_size_ap6 self.canvas_size_is = canvas_size_is7 self.canvas_size_lr = canvas_size_lr8 # create a meshgrid with coordinates in all three dimentions9 self.xx, self.yy, self.zz = np.mgrid[:canvas_size_lr, :canvas_size_ap, :canvas_size_is]10 def sphere(self, center_lr, center_ap, center_is, radius):11 # sphere contains the squared distance to the center point12 sphere_equation = (self.xx - center_lr) ** 2 + \13 (self.yy - center_ap) ** 2 + \14 (self.zz - center_is) ** 2 - radius ** 215 sphere_mask = sphere_equation < 016 return sphere_mask17 def half_sphere_lower(self, center_lr, center_ap, center_is, radius):18 sphere_mask = self.sphere(center_lr=center_lr, center_ap=center_ap, center_is=center_is, radius=radius)19 half_sphere_mask = np.logical_and(sphere_mask, self.zz < center_is)20 return half_sphere_mask21 def half_sphere_upper(self, center_lr, center_ap, center_is, radius):22 sphere_mask = self.sphere(center_lr=center_lr, center_ap=center_ap, center_is=center_is, radius=radius)23 half_sphere_mask = np.logical_and(sphere_mask, self.zz > center_is)24 return half_sphere_mask25 def brick(self, center_lr, center_ap, center_is, len_lr, len_ap, len_is):26 slice_lr = np.logical_and(center_lr - len_lr / 2 < self.xx, self.xx <= center_lr + len_lr / 2)27 slice_ap = np.logical_and(center_ap - len_ap / 2 < self.yy, self.yy <= center_ap + len_ap / 2)28 slice_is = np.logical_and(center_is - len_is / 2 < self.zz, self.zz <= center_is + len_is / 2)29 brick_mask = np.logical_and(slice_lr, np.logical_and(slice_ap, slice_is))30 return brick_mask31 def pyramid_on_tip(self, center_base_lr, center_base_ap, center_base_is, base_len, height):32 slope = height / base_len33 lr_equation = -slope * np.abs(self.xx - center_base_lr) + height >= np.abs(self.zz - center_base_is)34 ap_equation = -slope * np.abs(self.yy - center_base_ap) + height >= np.abs(self.zz - center_base_is)35 pyramid_mask = np.logical_and(self.zz <= center_base_is, np.logical_and(lr_equation, ap_equation))36 return pyramid_mask37 def tube_vertical(self, center_lr, center_ap, center_is, len_is, radius):38 # circle in x and y dimension contains the squared distance to the center point39 sphere_equation = (self.xx - center_lr) ** 2 + \40 (self.yy - center_ap) ** 2 - radius ** 241 tube_mask = np.logical_and(sphere_equation < 0,42 np.logical_and(center_is - len_is / 2 < self.zz, self.zz <= center_is + len_is / 2))43 return tube_mask44 def tube_horizontal(self, center_lr, center_ap, center_is, len_lr, radius):45 # circle in x and y dimension contains the squared distance to the center point46 sphere_equation = (self.yy - center_ap) ** 2 + \47 (self.zz - center_is) ** 2 - radius ** 248 tube_mask = np.logical_and(sphere_equation < 0,49 np.logical_and(center_lr - len_lr / 2 < self.xx, self.xx <= center_lr + len_lr / 2))50 return tube_mask51 def u_horizontal_open_right(self, center_lr, center_ap, center_is, breadth, height, thickness):52 """ Create a U shape that lies on the horizontal plane, opening towards the right.53 :param center_lr: left/right center on the U shape, i.e. were the . is placed in |_._|54 :param center_ap: anterior/posterior center on the U shape, i.e. were the . is placed in |_._|55 :param center_is: inferior/superior center on the U shape, i.e. were the . is placed in |_._|56 :param breadth: The distance between the poles | and | in |__|.57 :param height: The length of the pole | in |__|.58 :param thickness: If you turn the U from 2D to 3D, how much depth you add.59 """60 pole_p = self.brick(center_lr=center_lr + height / 2 - thickness / 2, center_ap=center_ap - breadth / 2,61 center_is=center_is, len_lr=height, len_ap=thickness, len_is=thickness)62 pole_a = self.brick(center_lr=center_lr + height / 2 - thickness / 2, center_ap=center_ap + breadth / 2,63 center_is=center_is, len_lr=height, len_ap=thickness, len_is=thickness)64 bar = self.brick(center_lr=center_lr, center_ap=center_ap, center_is=center_is, len_lr=thickness,65 len_ap=breadth, len_is=thickness)66 u_mask = np.logical_or(bar, np.logical_or(pole_a, pole_p))67 return u_mask68 def u_horizontal_open_left(self, center_lr, center_ap, center_is, breadth, height, thickness):69 """ Create a U shape that lies on the horizontal plane, opening towards the left.70 :param center_lr: left/right center on the U shape, i.e. were the . is placed in |_._|71 :param center_ap: anterior/posterior center on the U shape, i.e. were the . is placed in |_._|72 :param center_is: inferior/superior center on the U shape, i.e. were the . is placed in |_._|73 :param breadth: The distance between the poles | and | in |__|.74 :param height: The length of the pole | in |__|.75 :param thickness: If you turn the U from 2D to 3D, how much depth you add.76 """77 pole_p = self.brick(center_lr=center_lr - height / 2 + thickness / 2, center_ap=center_ap - breadth / 2,78 center_is=center_is, len_lr=height, len_ap=thickness, len_is=thickness)79 pole_a = self.brick(center_lr=center_lr - height / 2 + thickness / 2, center_ap=center_ap + breadth / 2,80 center_is=center_is, len_lr=height, len_ap=thickness, len_is=thickness)81 bar = self.brick(center_lr=center_lr, center_ap=center_ap, center_is=center_is, len_lr=thickness,82 len_ap=breadth, len_is=thickness)83 u_mask = np.logical_or(bar, np.logical_or(pole_a, pole_p))84 return u_mask85 def torus(self, center_lr, center_ap, center_is, torus_radius, tube_cross_section_radius):86 equation = np.square(np.sqrt((self.xx - center_lr) ** 2 + (self.yy - center_ap) ** 2) - torus_radius) + (87 self.zz - center_is) ** 2 < tube_cross_section_radius ** 2...

Full Screen

Full Screen

026.py

Source:026.py Github

copy

Full Screen

1"""找出小于 1000 的数字 d,1/d 的十进制表示含有最长的循环圈"""2# 扩10取余3def len_is(x):4 b = []5 a = 10 % x6 while a not in (b):7 b.append(a)8 a = (a * 10) % x9 return len(b)10# 找最长11max_num = 012max_len = 013for d in range(1, 1000):14 if len_is(d) > max_len:15 max_len = len_is(d)16 max_num = d...

Full Screen

Full Screen

problem26.py

Source:problem26.py Github

copy

Full Screen

1# 扩10取余2def len_is(x):3 b = []4 a = 10 % x5 while a not in (b):6 b.append(a)7 a = (a * 10) % x8 return len(b)910max_num = 011max_len = 012for d in range(1, 1000):13 if len_is(d) > max_len:14 max_len = len_is(d)15 max_num = d16print('答案是: ' + str(max_num)) ...

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