def test__given_west_rotation_and_south_active__then_rotate(self): node_list = [ node.Node(0, 2, is_center=False, is_active=False), # top line node.Node(1, 2, is_center=False, is_active=False), # top line node.Node(2, 2, is_center=False, is_active=True), # top line node.Node(0, 1, is_center=True, is_active=True), # middle line node.Node(1, 1, is_center=True, is_active=False), # middle line node.Node(2, 1, is_center=True, is_active=True), # middle line node.Node(0, 0, is_center=False, is_active=True), # bottom line node.Node(1, 0, is_center=True, is_active=False), # bottom line node.Node(2, 0, is_center=False, is_active=True), # bottom line node.Node(1, -1, is_center=False, is_active=True) ] # ultra bottom line central_node = node.Node(0, 1, is_center=True, is_active=True) conf = configuration.Configuration(node_list) rotated_conf = conf.get_rotated_configuration(central_node) self.assertEqual(True, (node.Node(0, 1, is_center=True, is_active=True) in rotated_conf.nodes)) # center self.assertEqual(True, (node.Node(0, 2, is_center=False, is_active=True) in rotated_conf.nodes)) # north self.assertEqual(True, (node.Node(1, 1, is_center=True, is_active=False) in rotated_conf.nodes)) # east self.assertEqual(True, (node.Node(0, 0, is_center=False, is_active=False) in rotated_conf.nodes)) # south
def test__given_middle_rotation_and_north_east_active__then_rotate(self): node_list = ([ node.Node(0, 2, is_center=False, is_active=False), node.Node(1, 2, is_center=False, is_active=True), node.Node(2, 2, is_center=False, is_active=True), node.Node(0, 1, is_center=True, is_active=False), node.Node(1, 1, is_center=True, is_active=True), node.Node(2, 1, is_center=True, is_active=True), node.Node(0, 0, is_center=False, is_active=True), node.Node(1, 0, is_center=True, is_active=False), node.Node(2, 0, is_center=False, is_active=False), node.Node(1, -1, is_center=False, is_active=True) ]) central_node = node.Node(1, 1, is_center=True, is_active=True) conf = configuration.Configuration(node_list) rotated_conf = conf.get_rotated_configuration(central_node) self.assertEqual(True, (node.Node(1, 1, is_center=True, is_active=True) in rotated_conf.nodes)) # center self.assertEqual(True, (node.Node(1, 2, is_center=False, is_active=False) in rotated_conf.nodes)) # north self.assertEqual(True, (node.Node(2, 1, is_center=True, is_active=True) in rotated_conf.nodes)) # east self.assertEqual(True, (node.Node(1, 0, is_center=True, is_active=True) in rotated_conf.nodes)) # south self.assertEqual(True, (node.Node(0, 1, is_center=True, is_active=False) in rotated_conf.nodes)) # west
def test__given_unknown_central_node__when_rotation__then_exception(self): node_list = [ node.Node(0, 2, is_center=False, is_active=False), # top line node.Node(1, 2, is_center=False, is_active=False), # top line node.Node(2, 2, is_center=False, is_active=False), # top line node.Node(0, 1, is_center=True, is_active=True), # middle line node.Node(1, 1, is_center=True, is_active=True), # middle line node.Node(2, 1, is_center=True, is_active=True), # middle line node.Node(0, 0, is_center=False, is_active=False), # bottom line node.Node(1, 0, is_center=True, is_active=True), # bottom line node.Node(2, 0, is_center=False, is_active=True), # bottom line node.Node(1, -1, is_center=False, is_active=True) ] # ultra bottom line central_node = node.Node(6, 1) # unknown node conf = configuration.Configuration(node_list) with self.assertRaises(ValueError): conf.get_rotated_configuration(central_node)
# commodity structure for retrieving the nodes that trigger the rotation that will lead to the solution edges_map[key] = rotation_node start_nodes = ([ node.Node(0, 2, is_center=False, is_active=True), node.Node(1, 2, is_center=False, is_active=True), node.Node(2, 2, is_center=False, is_active=True), node.Node(0, 1, is_center=True, is_active=True), node.Node(1, 1, is_center=True, is_active=True), node.Node(2, 1, is_center=True, is_active=False), node.Node(0, 0, is_center=False, is_active=False), node.Node(1, 0, is_center=True, is_active=False), node.Node(2, 0, is_center=False, is_active=True), node.Node(1, -1, is_center=False, is_active=False) ]) start_configuration = configuration.Configuration(start_nodes) end_nodes = ([ node.Node(0, 2, is_center=False, is_active=True), node.Node(1, 2, is_center=False, is_active=False), node.Node(2, 2, is_center=False, is_active=True), node.Node(0, 1, is_center=True, is_active=True), node.Node(1, 1, is_center=True, is_active=False), node.Node(2, 1, is_center=True, is_active=False), node.Node(0, 0, is_center=False, is_active=True), node.Node(1, 0, is_center=True, is_active=True), node.Node(2, 0, is_center=False, is_active=True), node.Node(1, -1, is_center=False, is_active=False) ]) end_configuration = configuration.Configuration(end_nodes)
def __init__(self, action, debug_flag=False): self.debug_flag = debug_flag self.base_directory = os.path.dirname(__file__) # Conditions for Loading Context # Either GUI, TRAINING print('Starting the Face Recognition Module Context Creation for ', action) print('Creating Configuration Module in Context') # Load Configuration for UI and training self.configuration = config.Configuration(self.base_directory, debug_flag) self.configuration.load_configuration( os.path.join(os.path.dirname(__file__), "configuration/application/app.config")) print('Creating Tensorflow in Session') # Load tensorflow session for training # self.config = tf.ConfigProto() # self.config.gpu_options.allow_growth = False # self.sess = tf.InteractiveSession(config=self.config) print('Creating Data Module in Context') # Load Data Module which will do everything about data Reading, Writing, Separating data self.data_loader = data_loader.DataLoader(self.base_directory, self.configuration) print('Creating Model Module in Context') # Load Model module to store and restore model after training or testing time self.model_loader = model.Model(self.base_directory, self.configuration) print('Creating Information Module in Context') # Load Info Module to see the information about the module self.info = info.Information() print('Creating Pre Processing Module in Context') # Load Preprocessing Module will do the preprocessing self.preprocess = preprocess.Preprocessing(self.configuration) self.resultwritter = rs.ResultWriter(self.base_directory, self.configuration) if action == "TRAIN": print('Creating Data Augmentation Module in Context') # Load DataAugumentation Module will do the data augumentation self.augment = augment1.Augmentation(self.configuration) print('Creating data separation Module in context') self.data_separation = dataseparation.DataSeparation( self.configuration) print('Creating Model Preparation Module in Context') self.model_preparation = nnmodel.NNModel(self.base_directory, self.configuration) print('Creating Batch Module in Context') self.batch_prepare = pb.Prepare_Batch() print('Creating Evaluation Module in Context') # Load Detection Module if action == "GUI": print('Creating Face Detection Module in Context') self.detect = self.face_detector() print('Creating Face Recognition Module in Context') self.recognize = self.face_recognizer( self.configuration.recognizer_type) print('Creating Post Processing Module in Context') # Post Processing Module self.postprocess = postprocess.Postprocessing(self.data_loader)