Best Python code snippet using sure_python
shape_creator.py
Source: shape_creator.py
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...
026.py
Source: 026.py
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...
problem26.py
Source: problem26.py
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))
...
Check out the latest blogs from LambdaTest on this topic:
Ever came across the situation where you really need to open a web page fast and it’s taking forever because of slow internet speed? May be someone in your network is downloading a torrent choking the bandwidth?
In today’s scenario, software testing has become an important entity across every domain for the benefits it offers. We have already explored a lot about software testing in general in our post need of software testing.
This article is a part of our Content Hub. For more in-depth resources, check out our content hub on Mobile Testing Tutorial.
Before development of a project begins, the project manager’s job is to determine which methodology should be used for the project life cycle. The 2 most popular methodologies are
In human physiology, vision plays a major role as 83% of the information humans perceive is via sight. So, your website should never lack in visual appeal. In web design, this is even more important. Every new iteration of design leaves some minor deviations. Sometimes, these minor visual deviations can be very hard to fix or unknowingly break the whole user experience. Hence, it is necessary to make sure that your website provides a perfect and working interface design to the user.
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!