How to use __check_completion method in hypothesis

Best Python code snippet using hypothesis

CollectionGoal.py

Source:CollectionGoal.py Github

copy

Full Screen

...32 '''33 if self.__drop_off =={}: # find all drop off locations, its tile ID's and goal blocks34 self.__find_drop_off_locations(grid_world)35 # Go through each drop zone, and check if the blocks are there in the right order36 is_satisfied, progress = self.__check_completion(grid_world)37 # Progress in percentage38 self.__progress = progress / sum([len(goal_blocks)\39 for goal_blocks in self.__drop_off.values()])40 return is_satisfied41 def __find_drop_off_locations(self, grid_world:GridWorld):42 goal_blocks = {} # dict with as key the zone nr and values list of ghostly goal blocks43 all_objs = grid_world.environment_objects44 for obj_id, obj in all_objs.items(): # go through all objects45 if "drop_zone_nr" in obj.properties.keys(): # check if the object is part of a drop zone46 zone_nr = obj.properties["drop_zone_nr"] # obtain the zone number47 if obj.properties["is_goal_block"]: # check if the object is a ghostly goal block48 if zone_nr in goal_blocks.keys(): # create or add to the list49 goal_blocks[zone_nr].append(obj)50 else:51 goal_blocks[zone_nr] = [obj]52 self.__drop_off:dict = {}53 for zone_nr in goal_blocks.keys(): # go through all drop of zones and fill the drop_off dict54 # Instantiate the zone's dict.55 self.__drop_off[zone_nr] = {}56 # Obtain the zone's goal blocks.57 blocks = goal_blocks[zone_nr].copy()58 # The number of blocks is the maximum the max number blocks to collect for this zone.59 max_rank = len(blocks)60 # Find the 'bottom' location61 bottom_loc = (-np.inf, -np.inf)62 for block in blocks:63 if block.location[1] > bottom_loc[1]:64 bottom_loc = block.location65 # Now loop through blocks lists and add them to their appropriate ranks66 for rank in range(max_rank):67 loc = (bottom_loc[0], bottom_loc[1] - rank)68 # find the block at that location69 for block in blocks:70 if block.location == loc:71 # Add to self.drop_off72 self.__drop_off[zone_nr][rank] = [loc, block.visualize_shape, block.visualize_colour, None]73 def __check_completion(self, grid_world:GridWorld):74 # Get the current tick number75 curr_tick = grid_world.current_nr_ticks76 # loop through all zones, check the blocks and set the tick if satisfied77 for zone_nr, goal_blocks in self.__drop_off.items():78 # Go through all ranks of this drop off zone79 for rank, block_data in goal_blocks.items():80 loc = block_data[0] # the location, needed to find blocks here81 shape = block_data[1] # the desired shape82 colour = block_data[2] # the desired colour83 tick = block_data[3]84 # Retrieve all objects, the object ids at the location and obtain all BW4T Blocks from it85 all_objs = grid_world.environment_objects86 obj_ids = grid_world.get_objects_in_range(loc, object_type=EnvObject, sense_range=0)87 blocks = [all_objs[obj_id] for obj_id in obj_ids...

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