How to use _extract_name method in autotest

Best Python code snippet using autotest_python Github


Full Screen

...273 for contact in cdata.result.contacts:274 cg = contact.o1275 if cg == geom:276 cg = contact.o2277 name = self._extract_name(cg)278 names = (name, '__external')279 if cg == contact.o2:280 names = tuple(reversed(names))281 if return_names:282 objs_in_collision.add(name)283 if return_data:284 contact_data.append(ContactData(names, contact))285 if return_names and return_data:286 return result, objs_in_collision, contact_data287 elif return_names:288 return result, objs_in_collision289 elif return_data:290 return result, contact_data291 else:292 return result293 def in_collision_internal(self, return_names=False, return_data=False):294 """295 Check if any pair of objects in the manager collide with one another.296 Parameters297 ----------298 return_names : bool299 If true, a set is returned containing the names300 of all pairs of objects in collision.301 return_data : bool302 If true, a list of ContactData is returned as well303 Returns304 -------305 is_collision : bool306 True if a collision occurred between any pair of objects307 and False otherwise308 names : set of 2-tup309 The set of pairwise collisions. Each tuple310 contains two names in alphabetical order indicating311 that the two corresponding objects are in collision.312 contacts : list of ContactData313 All contacts detected314 """315 cdata = fcl.CollisionData()316 if return_names or return_data:317 cdata = fcl.CollisionData(request=fcl.CollisionRequest(318 num_max_contacts=100000, enable_contact=True))319 self._manager.collide(cdata, fcl.defaultCollisionCallback)320 result = cdata.result.is_collision321 objs_in_collision = set()322 contact_data = []323 if return_names or return_data:324 for contact in cdata.result.contacts:325 names = (self._extract_name(contact.o1),326 self._extract_name(contact.o2))327 if return_names:328 objs_in_collision.add(tuple(sorted(names)))329 if return_data:330 contact_data.append(ContactData(names, contact))331 if return_names and return_data:332 return result, objs_in_collision, contact_data333 elif return_names:334 return result, objs_in_collision335 elif return_data:336 return result, contact_data337 else:338 return result339 def in_collision_other(self, other_manager,340 return_names=False, return_data=False):341 """342 Check if any object from this manager collides with any object343 from another manager.344 Parameters345 -------------------346 other_manager : CollisionManager347 Another collision manager object348 return_names : bool349 If true, a set is returned containing the names350 of all pairs of objects in collision.351 return_data : bool352 If true, a list of ContactData is returned as well353 Returns354 -------------355 is_collision : bool356 True if a collision occurred between any pair of objects357 and False otherwise358 names : set of 2-tup359 The set of pairwise collisions. Each tuple360 contains two names (first from this manager,361 second from the other_manager) indicating362 that the two corresponding objects are in collision.363 contacts : list of ContactData364 All contacts detected365 """366 cdata = fcl.CollisionData()367 if return_names or return_data:368 cdata = fcl.CollisionData(369 request=fcl.CollisionRequest(370 num_max_contacts=100000,371 enable_contact=True))372 self._manager.collide(other_manager._manager,373 cdata,374 fcl.defaultCollisionCallback)375 result = cdata.result.is_collision376 objs_in_collision = set()377 contact_data = []378 if return_names or return_data:379 for contact in cdata.result.contacts:380 reverse = False381 names = (self._extract_name(contact.o1),382 other_manager._extract_name(contact.o2))383 if names[0] is None:384 names = (self._extract_name(contact.o2),385 other_manager._extract_name(contact.o1))386 reverse = True387 if return_names:388 objs_in_collision.add(names)389 if return_data:390 if reverse:391 names = tuple(reversed(names))392 contact_data.append(ContactData(names, contact))393 if return_names and return_data:394 return result, objs_in_collision, contact_data395 elif return_names:396 return result, objs_in_collision397 elif return_data:398 return result, contact_data399 else:400 return result401 def min_distance_single(self,402 mesh,403 transform=None,404 return_name=False,405 return_data=False):406 """407 Get the minimum distance between a single object and any408 object in the manager.409 Parameters410 ---------------411 mesh : Trimesh object412 The geometry of the collision object413 transform : (4,4) float414 Homogeneous transform matrix for the object415 return_names : bool416 If true, return name of the closest object417 return_data : bool418 If true, a DistanceData object is returned as well419 Returns420 -------------421 distance : float422 Min distance between mesh and any object in the manager423 name : str424 The name of the object in the manager that was closest425 data : DistanceData426 Extra data about the distance query427 """428 if transform is None:429 transform = np.eye(4)430 # create BVH/Convex431 geom = self._get_fcl_obj(mesh)432 # create the FCL transform from (4,4) matrix433 t = fcl.Transform(transform[:3, :3], transform[:3, 3])434 o = fcl.CollisionObject(geom, t)435 # Collide with manager's objects436 ddata = fcl.DistanceData(fcl.DistanceRequest(enable_signed_distance=True))437 if return_data:438 ddata = fcl.DistanceData(439 fcl.DistanceRequest(440 enable_nearest_points=True,441 enable_signed_distance=True442 ),443 fcl.DistanceResult()444 )445 self._manager.distance(o, ddata, fcl.defaultDistanceCallback)446 distance = ddata.result.min_distance447 # If we want to return the objects that were collision, collect them.448 name, data = None, None449 if return_name or return_data:450 cg = ddata.result.o1451 if cg == geom:452 cg = ddata.result.o2453 name = self._extract_name(cg)454 names = (name, '__external')455 if cg == ddata.result.o2:456 names = tuple(reversed(names))457 data = DistanceData(names, ddata.result)458 if return_name and return_data:459 return distance, name, data460 elif return_name:461 return distance, name462 elif return_data:463 return distance, data464 else:465 return distance466 def min_distance_internal(self, return_names=False, return_data=False):467 """468 Get the minimum distance between any pair of objects in the manager.469 Parameters470 -------------471 return_names : bool472 If true, a 2-tuple is returned containing the names473 of the closest objects.474 return_data : bool475 If true, a DistanceData object is returned as well476 Returns477 -----------478 distance : float479 Min distance between any two managed objects480 names : (2,) str481 The names of the closest objects482 data : DistanceData483 Extra data about the distance query484 """485 ddata = fcl.DistanceData(fcl.DistanceRequest(enable_signed_distance=True))486 if return_data:487 ddata = fcl.DistanceData(488 fcl.DistanceRequest(489 enable_nearest_points=True,490 enable_signed_distance=True,491 ),492 fcl.DistanceResult()493 )494 self._manager.distance(ddata, fcl.defaultDistanceCallback)495 distance = ddata.result.min_distance496 names, data = None, None497 if return_names or return_data:498 names = (self._extract_name(ddata.result.o1),499 self._extract_name(ddata.result.o2))500 data = DistanceData(names, ddata.result)501 names = tuple(sorted(names))502 if return_names and return_data:503 return distance, names, data504 elif return_names:505 return distance, names506 elif return_data:507 return distance, data508 else:509 return distance510 def min_distance_other(self, other_manager,511 return_names=False, return_data=False):512 """513 Get the minimum distance between any pair of objects,514 one in each manager.515 Parameters516 ----------517 other_manager : CollisionManager518 Another collision manager object519 return_names : bool520 If true, a 2-tuple is returned containing521 the names of the closest objects.522 return_data : bool523 If true, a DistanceData object is returned as well524 Returns525 -----------526 distance : float527 The min distance between a pair of objects,528 one from each manager.529 names : 2-tup of str530 A 2-tuple containing two names (first from this manager,531 second from the other_manager) indicating532 the two closest objects.533 data : DistanceData534 Extra data about the distance query535 """536 ddata = fcl.DistanceData(fcl.DistanceRequest(enable_signed_distance=True))537 if return_data:538 ddata = fcl.DistanceData(539 fcl.DistanceRequest(540 enable_nearest_points=True,541 enable_signed_distance=True,542 ),543 fcl.DistanceResult()544 )545 self._manager.distance(other_manager._manager,546 ddata,547 fcl.defaultDistanceCallback)548 distance = ddata.result.min_distance549 names, data = None, None550 if return_names or return_data:551 reverse = False552 names = (self._extract_name(ddata.result.o1),553 other_manager._extract_name(ddata.result.o2))554 if names[0] is None:555 reverse = True556 names = (self._extract_name(ddata.result.o2),557 other_manager._extract_name(ddata.result.o1))558 dnames = tuple(names)559 if reverse:560 dnames = tuple(reversed(dnames))561 data = DistanceData(dnames, ddata.result)562 if return_names and return_data:563 return distance, names, data564 elif return_names:565 return distance, names566 elif return_data:567 return distance, data568 else:569 return distance570 def _get_fcl_obj(self, mesh):571 """572 Get a BVH or Convex for a mesh.573 Parameters574 -------------575 mesh : Trimesh576 Mesh to create BVH/Convex for577 Returns578 --------------579 obj : fcl.BVHModel or fcl.Convex580 BVH/Convex object of source mesh581 """582 if mesh.is_convex:583 obj = mesh_to_convex(mesh)584 else:585 obj = mesh_to_BVH(mesh)586 return obj587 def _extract_name(self, geom):588 """589 Retrieve the name of an object from the manager by its590 CollisionObject, or return None if not found.591 Parameters592 -----------593 geom : CollisionObject or BVHModel594 Input model595 Returns596 ------------597 names : hashable598 Name of input geometry599 """600 return self._names[id(geom)]601def mesh_to_BVH(mesh):...

Full Screen

Full Screen Github


Full Screen

...4import typing5logger = logging.getLogger(__name__)6PathLike = typing.Union[str, pathlib.Path]7class DefaultSpringCloudConfigParser:8 def _extract_name(self, name: str) -> str:9 basename = os.path.basename(name)10 return os.path.splitext(basename)[0]11 def __call__(self, raw_data: dict, *args, **kwargs) -> dict:12 expected = raw_data['name']13 for source in raw_data['propertySources']:14 if source['name'].endswith('application.yaml'):15 config = source['source']16 break17 else:18 logger.warning('No application.yaml found in response; using empty config as base')19 config = {}20 names = []21 for source in raw_data['propertySources']:22 if source['name'].endswith('application.yaml'):23 continue24 else:25 name = self._extract_name(source['name'])26 names.append(name)27 config.update(source['source'])28 if expected not in names:29 raise ValueError("expected config with name '{}' was not found in response".format(expected))...

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:


You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest 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?