Esempio n. 1
0
    def __init__(self):

        pygame.init()

        self.play_on = True
        self.carry = False
        self.carried_bloc = -1

        self.screen_width = 432
        self.screen_height = 288

        # pygame.display.set_caption("Block Dude")
        self.screen = pygame.display.set_mode(
            (self.screen_width, self.screen_height))

        self.vel = 24

        self.x_player_init = [24]
        self.y_player_init = [264 - self.vel]
        self.x_blocks_init = []
        self.y_blocks_init = []

        self.player = Player(self.screen, self.x_player_init,
                             self.y_player_init, self.vel, self.vel)

        self.brick_bottom_x = [
            i * self.vel for i in range(int(self.screen_width / self.vel))
        ]
        self.brick_bottom_y = [
            self.screen_height - self.vel
            for i in range(len(self.brick_bottom_x))
        ]

        self.brick_bottom_x += [192, 168, 192]
        self.brick_bottom_y += [
            264 - self.vel, 264 - self.vel, 264 - 2 * self.vel
        ]

        self.bricks = Component(self.screen, 'BD_sprites/Brick.png',
                                self.brick_bottom_x, self.brick_bottom_y)

        self.blocks = Component(self.screen, 'BD_sprites/Block.png',
                                self.x_blocks_init, self.y_blocks_init)

        self.door = Component(self.screen, 'BD_sprites/Door.png', [408], [240])

        self.initial_obs = self.get_state()

        self.discrete_actions = [0, 1, 2, 3]
        self.action_space = Discrete(len(self.discrete_actions))
        self.action = np.random.choice(self.discrete_actions)
        self.observation_space = Box(low=0,
                                     high=255,
                                     shape=(self.screen_height,
                                            self.screen_width, 3),
                                     dtype=np.uint8)
        self.n_step = 0
        self.max_steps = 200
        self.viewer = None
    def test_creation(self):
        valid_guids = [
            uuid.UUID('71720bcd-feed-499c-8305-8cf68c0fa95f'),
            uuid.UUID('cc89478d-99a3-4481-8618-d9d0ea497235'),
            uuid.UUID('502a625c-6b4e-483d-8572-ac01d300b2b8'),
            uuid.UUID('954d9866-83ea-456c-8c6e-f995e31994ed'),
        ]

        invalid_guids = [
            1,
            '954d9866-83ea-456c-8c6e-f995e31994ed',
            -23,
            5 + 6,
            'c',
            'My name',
            False,
            True,
            10j,
            '',
        ]

        for guid in valid_guids:
            c = Component(guid, "my component")
            self.assertEqual(guid, c.guid)
            self.assertEqual(guid, c.get_guid())

        for invalid in invalid_guids:
            self.assertRaises(AssertionError, Component, invalid,
                              'my compnonent')

        valid_names = [
            'My component',
            'c',
            'front light'
            'l',
            '12345',
            '##$@@#%helfgstnha',
        ]

        invalid_names = [
            '',
            '    ',
            '\n',
            '    \n',
            12,
            -10,
        ]

        for name in valid_names:
            c = Component(uuid.UUID('71720bcd-feed-499c-8305-8cf68c0fa95f'),
                          name)
            self.assertEqual(c.name, name)
            self.assertEqual(c.get_name(), name)

        for name in invalid_names:
            self.assertRaises(
                AssertionError, Component,
                uuid.UUID('71720bcd-feed-499c-8305-8cf68c0fa95f'), name)
Esempio n. 3
0
 def add_class_and_parent_to_dict(self, class_name, line):
     self.comp = self.component_dict.get(class_name[0])
     if self.comp is None:
         self.comp = Component()
     self.comp.set_name(class_name[0])
     parent = self.comp_ext._extract_parents(line)
     for item in parent:
         if item != 'object':  # pragma: no cover
             parent = self.component_dict.get(item)
             if parent is None:
                 parent = Component()
         self.comp.get_parents().append(parent)
     self.component_dict[class_name[0]] = self.comp
    def setUp(self):
        self.idx_1 = pd.period_range('2017-07-01', periods=5, freq='M')

        self.comp_1 = Component("Comp_1", Type1.QUANTITY, Type2.FINANCIAL, Category.HYPOTHESIS, "$")
        self.comp_1.data = pd.Series([1, 2, 3, 4, 5], index=self.idx_1)

        self.comp_2 = Component("Comp_2", Type1.QUANTITY, Type2.FINANCIAL, Category.COMPUTED, "$")
        self.comp_2.data = pd.Series([5, 4, 3, 2, 1], index=self.idx_1)

        self.comp_3 = Component("Comp_3", Type1.QUANTITY, Type2.FINANCIAL, Category.HYPOTHESIS, "$")
        self.comp_3.data = pd.Series([2, 2, 2, 2, 2], index=self.idx_1)

        self.comp_parent = Component("Parent", Type1.QUANTITY, Type2.FINANCIAL, Category.COMPUTED, "$")
Esempio n. 5
0
    def __check_aligner_valid(self):
        """
		If aligner was specified in input args, check that it is valid and fill in the appropriate parameter
		If aligner arg not correct, throw an exception

		"""
        self.__get_aligner_info()
        available_aligners = self.builder_params.get('available_aligners')
        default_aligner = self.builder_params.get('default_aligner')

        # if no aligner specified in commandline:
        if not self.builder_params.get('aligner'):
            logging.info('Setting aligner to default: %s', default_aligner)
            self.builder_params.reset_param('aligner', default_aligner)
        elif self.builder_params.get('aligner') not in available_aligners:
            logging.error('Incorrect aligner: %s',
                          self.builder_params.get('aligner'))
            logging.error('Available aligners: %s', available_aligners)
            raise IncorrectAlignerException(
                "Unavailable aligner specified.  Check log and correct as necessary."
            )

        # now check that this aligner has a config file.  Does not check that the aligner+genome is OK.
        # That is done when the aligner is invoked.
        chosen_genome = self.builder_params.get('genome')
        aligner = self.builder_params.get('aligner')
        aligner_specific_dir = os.path.join(
            self.builder_params.get('aligners_dir'), aligner)
        logging.info(
            'Searching (but not parsing) for aligner configuration file in: %s',
            aligner_specific_dir)
        util_methods.locate_config(aligner_specific_dir)

        # create a component for the aligner:
        self.all_components.append(Component(aligner, aligner_specific_dir))
Esempio n. 6
0
  def __init__(self, config):
    # Logging.
    self.logger = logging.getLogger(__name__)

    # The overall configuration.
    self.config = config

    # The proxy being used to talk to HAProxy.
    self.proxy = Proxy()

    # The components, by name.
    self.components = {}

    # Build the components map.
    for component_config in config.components:
      self.components[component_config.name] = Component(self, component_config)

    # Create the lock for the watcher thread and the notification event.
    self.watcher_lock = threading.Lock()
    self.watcher_event = threading.Event()

    # The set of containers which should be terminated by the terminating workers.
    self.containers_to_terminate = Queue()

    # Start the thread used to watch and stop containers that are no longer needed.
    self.pool = ThreadPool()

    # Place to collect the results of the monitor
    self.monitor_futures = Queue()
Esempio n. 7
0
 def draw_tile_header(self, x, y, w, h, fcast):
     """ Draw tile header
     
     :param x: tile x coordinate
     :param y: tile y coordinate
     :param w: tile width
     :param h: tile height
     :param fcast: one day forecast
     """
     height = (h / 100) * TILE_HEADER_HEIGHT
     comp = Component(self.util)
     comp.content_x = x
     comp.content_y = y
     rect = pygame.Rect(x, y, w, height)
     comp.content = rect
     comp.fgr = self.semi_transparent_color
     comp.bgr = self.semi_transparent_color
     comp.bounding_box = rect
     self.add_component(comp)
     
     text_color = self.util.weather_config[COLOR_BRIGHT]
     font_size = int((height / 100) * DAY_HEIGHT)
     
     if fcast[DAY] == UNKNOWN:
         d = UNKNOWN
     else:
         d = self.weather_config[fcast[DAY].lower()]
         
     c = self.util.get_text_component(d, text_color, font_size)
     c.content_x = x + (w - c.content.get_size()[0]) / 2
     c.content_y = y + font_size / 8
     self.add_component(c)
Esempio n. 8
0
    def addElement(self, name):
        """Add a new kicad generic element to the list"""
        if self._curr_element == None:
            self.tree = xmlElement(name)
            self._curr_element = self.tree
        else:
            self._curr_element = self._curr_element.addChild(
                xmlElement(name, self._curr_element))

        # If this element is a component, add it to the components list
        if self._curr_element.name == "comp":
            self.components.append(
                Component(self._curr_element, prefs=self.prefs))

        # Assign the design element
        if self._curr_element.name == "design":
            self.design = self._curr_element

        # If this element is a library part, add it to the parts list
        if self._curr_element.name == "libpart":
            self.libparts.append(libpart(self._curr_element))

        # If this element is a net, add it to the nets list
        if self._curr_element.name == "net":
            self.nets.append(self._curr_element)

        # If this element is a library, add it to the libraries list
        if self._curr_element.name == "library":
            self.libraries.append(self._curr_element)

        return self._curr_element
Esempio n. 9
0
def gene_isoform_analysis(ref_gtf, seq_dict):

    gene_dict = dict()
    transcript_parent = dict()

    ref_gtf = pd.read_table(ref_gtf, sep='\t', header=None, low_memory=False)
    ref_gtf.columns = [
        'chr', 'source', 'type', 'start', 'end', 'score', 'strand', 'phase',
        'header'
    ]

    for i, data in ref_gtf.iterrows():
        regex = re.match('transcript_id "(\S+)"; gene_id "(\S+)"',
                         data['header'])
        if regex:
            transcript_name = regex.group(1)
            gene_name = regex.group(2)

            seq = seq_dict[transcript_name]
            seq.label['gene'] = gene_name

            gene = Component(gene_name)
            gene.add_member(seq)

            if gene_name in gene_dict:
                if seq not in gene_dict[gene_name].member:
                    gene_dict[gene_name].add_member(seq)
            else:
                gene_dict[gene_name] = gene

    return gene_dict
Esempio n. 10
0
    def initCompType(self, ctype):
        '''Initialize a component type'''
        ''' create a component object of the right class'''

        # Need to start working here, have to return stuff for the component
        print "Initializing: " + ctype
        return Component(self)
Esempio n. 11
0
 def AddNode(self, parent, node):
     # Append tree item
     try:
         comp = Manager.getNodeComp(node, None)
         className = comp.klass
     except:
         className = node.getAttribute('class')
         # Try to create some generic component on-the-fly
         attributes = []
         isContainer = False
         for n in node.childNodes:
             if is_object(n):
                 isContainer = True
             elif n.nodeType == node.ELEMENT_NODE and not n.tagName in attributes:
                 attributes.append(n.tagName)
         if isContainer:
             comp = Container(className, 'unknown', attributes)
         else:
             comp = Component(className, 'unknown', attributes)
         Manager.register(comp)
         wx.LogWarning(
             'Unknown component class "%s", registered as generic' %
             className)
     item = self.AppendItem(parent,
                            comp.getTreeText(node),
                            image=comp.getTreeImageId(node),
                            data=wx.TreeItemData(node))
     self.SetItemStyle(item, node)
     # Try to find children objects
     if comp.isContainer():
         for n in filter(is_object, node.childNodes):
             self.AddNode(item, comp.getTreeNode(n))
Esempio n. 12
0
 def read_frame(self, mode):
     """pos is end of marker"""
     length = self.read_2b()
     self.mode = mode
     sample_precision = self.read_1b() # almost always be 8
     assert sample_precision == 8, "Only precision 8 is supported"
     height = self.read_2b()
     width = self.read_2b()
     self.height, self.width = height, width
     nr_components = self.read_1b() # 3 for YCbCr or 1 for Y(grayscale)
     print(f"SOF, sample precision: {sample_precision}, height: {height}, width: {width}, number of components: {nr_components}")
     max_hf, max_vf = 1, 1
     for _ in range(nr_components):
         component_id = self.read_1b()
         hf, vf = self.read_2_4bit()
         if hf > max_hf: max_hf = hf
         if vf > max_vf: max_vf = vf
         qt_selector = self.read_1b()
         print(f"component_id: {component_id}, horizontal and vertical"
          f"sampling frequencies: {hf}-{vf}, qt selector: {qt_selector}")
         self.components[component_id] = Component(hf, vf, self.qts[qt_selector], component_id)
    
     self.MCU_width = 8 * max_hf
     self.MCU_height = 8 * max_hf
     self.nr_MCUs_ver = math.ceil(height / self.MCU_height)
     self.nr_MCUs_hor = math.ceil(width / self.MCU_width)
     self.stuffed_height = self.MCU_height * self.nr_MCUs_ver
     self.stuffed_width = self.MCU_width * self.nr_MCUs_hor
     for cp in self.components.values():
         cp.block_height = 8 * max_vf // cp.vf
         cp.block_width = 8 * max_hf // cp.hf
         cp.nr_blocks_ver = math.ceil(self.height/cp.block_height)
         cp.nr_blocks_hor = math.ceil(self.width/cp.block_width)
         cp.blocks = create_nd_array([self.stuffed_height//cp.block_height, self.stuffed_width//cp.block_width,64])
Esempio n. 13
0
 def find_function(self, path):
     """
     Obtain all fully qualified names from current header file.
     Args:
         path: The path of current header file.
     Returns:
         All fully qualified names in the header file.
     """
     # remove it when include dependencies resolved
     git_root = "hana"
     header = os.path.join(git_root, "rte", "rtebase", "include")
     arguments = ["-x", "c++", "-I" + git_root, "-I" + header]
     index = Index.create()
     tu = index.parse(path, arguments)
     func_dict = dict()
     decl_kinds = {
         "FUNCTION_DECL", "CXX_METHOD", "CONSTRUCTOR", "DESTRUCTOR",
         "CONVERSION_FUNCTION"
     }
     cpnt = Component().best_matched(path)
     for node in tu.cursor.walk_preorder():
         if node.location.file and node.location.file.name == path and node.spelling:
             if str(node.kind).split(".")[1] in decl_kinds:
                 func = self.fully_qualified(node, path)
                 func_dict[func] = cpnt
     return func_dict
Esempio n. 14
0
    def _getComponents(self, components_dict):
        """
        Create the components for this module.
        Return a list of items of class 'component'
        """

        # Store components here
        components = []

        # Get shapes for each component definition
        for refdef in components_dict:
            component_dict = components_dict[refdef]

            # Show or hide the component.
            # This will still account the component for the BoM
            show = component_dict.get('show', True)

            # Place or do not place the component
            # Also ignored for BoM
            place = component_dict.get('place', True)

            if (show == True) and (place == True):
                component = Component(refdef, component_dict)
                components.append(component)

        return components
Esempio n. 15
0
def surface_force(component=None, force_variables=None,
                  cg=(0, 0, 0)):
    ''' Compute the forces for a surface. Returns the forces, and
    moment about cg, and area for each component.

    optional arguments:
        components - (Component)
        force_variables - (list of str)
        cg - (list of float) (1-by-3)
    '''
    global _dataset

    if component is not None:
        assert isinstance(component, Component)
        zonelist = component.zonelist
    else:
        component = Component('All')
        zonelist = list(_dataset.zones())

    if force_variables is not None:
        for v in force_variables:
            _dataset.add_variable(v)

    for zone in zonelist:
        pres, fric, mmnt, area = zonal_forces(zone, cg)
        component.force_pressure[:] = component.force_pressure[:] + pres[:]
        component.force_friction[:] = component.force_friction[:] + fric[:]
        component.area = component.area + area
        component.moment = component.moment + mmnt

    return component
Esempio n. 16
0
def excluded_component(components, new_name="Other"):
    ''' Filter surface zones within a given box

    arguments:
        components - (list of Component)
    optional arguments:
        new_name - (str)
    '''
    global _dataset
    zonelist = list(_dataset.zones())
    left_out_zones = []

    for zone in zonelist:
        found = False
        for comp in components:
            if zone in comp.zonelist:
                found = True
                exit
        if not found:
            left_out_zones.append(zone)

    if len(left_out_zones) == 0:
        return None
    else:
        new_component = Component(new_name)
        new_component.zonelist[:] = left_out_zones[:]
        return new_component
Esempio n. 17
0
 def _set_class_name(self, class_name, line):
     component = Component()
     component.set_name(class_name[0])
     self._class_parent_name_handling(line, component)
     self.component_dict[class_name[0]] = component
     self.attribute_dictionary = {}
     return component
Esempio n. 18
0
def construct_graph(seq_dict, match_dict, threshold=90):

    uf = UnionFind(seq_dict)
    component_dict = dict()

    for match in match_dict.values():
        q_seq = seq_dict[match.q_name]
        r_seq = seq_dict[match.r_name]
        if match.q_global_identity > threshold or match.r_global_identity > threshold:
            uf.union(q_seq.name, r_seq.name)

    uf.rename_component()

    for seq_name in seq_dict.keys():
        seq = seq_dict[seq_name]

        component_label = uf.component_label[seq_name]
        component_size = uf.component_size[component_label]

        seq.label['component'] = component_label

        component = Component(component_label)
        component.add_member(seq)

        if component_label in component_dict:
            component_dict[component_label].add_member(seq)
        else:
            component_dict[component_label] = component

    return uf, component_dict
Esempio n. 19
0
def segmentationCallback(event):
    print "Running full segmentation; ignoring click location and doing something unrelated"
    com = seg.getCOM(im)
    for (size, c) in com:
        print "Finding component at", int(c[0]), int(c[1])
        components.append(Component(arr.shape[0], arr.shape[1]))
        makeComponent(components[-1], (int(c[0]), int(c[1])))
        seeComponent(components[-1])
    print "Done"
Esempio n. 20
0
def makeComponentCallback(event):
    print "click at ", event.x, event.y, " . Please wait."
    #print arr[event.y, event.x]
    components.append(Component(arr.shape[0], arr.shape[1]))
    #wires[-1].addPixelLoc([event.y, event.x])
    makeComponent(components[-1], (event.y, event.x))
    seeComponent(components[-1])
    components[-1].getLeftMostPixel()
    print "End click. Ready to process another"
Esempio n. 21
0
  def __call__(self, name, max_len, reuse=False):
    component_scope = self._variable_scope + name
    with tf.variable_scope(component_scope) as scope:
      if reuse:
        scope.reuse_variables()
      max_len = max_len + 2 if self._word_delimiters else max_len
      word_lens_source = tf.placeholder(dtype=tf.int32, shape=[None], name='source/word_lens')
      word_lens_target = tf.placeholder(dtype=tf.int32, shape=[None], name='source/word_target')

      chars_p_s = tf.placeholder(dtype=tf.int32, shape=[max_len, None],
                                 name='source/char_sequence%i' % max_len)
      chars_p_t = tf.placeholder(dtype=tf.int32, shape=[max_len, None],
                                 name='target/char_sequence%i' % max_len)

      chars_s = tf.nn.embedding_lookup(self.Wchar_s, chars_p_s)
      chars_s = tf.transpose(chars_s, [1, 0, 2])
      chars_t = tf.nn.embedding_lookup(self.Wchar_t, chars_p_t)
      chars_t = tf.transpose(chars_t, [1, 0, 2])
      chars = tf.concat([chars_s, chars_t], 2)


      enc_output_infer, enc_state_infer = tf.nn.dynamic_rnn(self.char_rnn_cell_infer, chars,  dtype=tf.float32,
                                                            sequence_length=tf.cast(word_lens_source, dtype=tf.int64),
                                                            swap_memory=True, scope='encoder')
      attn_keys, attn_values, attn_score_fn, attn_construct_fn = attention_decoder_fn.prepare_attention(enc_output_infer, 'luong', self.char_rnn_cell_infer.output_size)
      dec_fn_inf = attention_decoder_fn.attention_decoder_fn_train(
        enc_state_infer, attn_keys, attn_values, attn_score_fn, attn_construct_fn)
      outputs_infer, _, _ = seq2seq.dynamic_rnn_decoder(self.char_rnn_cell_infer, dec_fn_inf,
                                                     inputs=chars, sequence_length=word_lens_target, swap_memory=True,
                                                     scope='decoder')

      scope.reuse_variables()
      enc_output, enc_state = tf.nn.dynamic_rnn(self.char_rnn_cell_train, chars, dtype=tf.float32,
                                                            sequence_length=tf.cast(word_lens_source, dtype=tf.int64),
                                                            swap_memory=True, scope='encoder')
      attn_keys, attn_values, attn_score_fn, attn_construct_fn = attention_decoder_fn.prepare_attention(
        enc_output, 'luong', self.char_rnn_cell_infer.output_size)
      dec_fn = attention_decoder_fn.attention_decoder_fn_train(
        enc_state, attn_keys, attn_values, attn_score_fn, attn_construct_fn)
      outputs, _, _ = seq2seq.dynamic_rnn_decoder(self.char_rnn_cell_train, dec_fn, inputs=chars,
                                              sequence_length=word_lens_target, swap_memory=True,
                                              scope='decoder')

      output = _get_last_state_dyn(self.max_norm, word_lens_target, outputs)
      output_infer = _get_last_state_dyn(self.max_norm, word_lens_target, outputs_infer)
      inputs = [
        chars_p_s, word_lens_source,
        chars_p_t, word_lens_target
      ]

      char_feature_extractor1 = CharLevelInputExtraction(self._char_vocab_source, max_len, component_scope + 'source/')
      char_feature_extractor2 = CharLevelInputExtraction(self._char_vocab_target, max_len, component_scope + 'target/')
      char_feature_extractor = CombineFeatureExtraction(char_feature_extractor1, char_feature_extractor2)
      return Component(inputs, output,
                       output_infer=output_infer,
                       feature_extractor=char_feature_extractor,
                       name='c_rnn_joint')
Esempio n. 22
0
    def __init__(self, name='DEFAULT'):
        self.componentCount = 0

        root_ID = 'comp' + str(self.componentCount)
        self.PDT = Component(root_ID, 'root', None)
        self.PDT_Description = ""
        self.PDT_name = name

        self.PDT_end = self.PDT
        self.componentCount += 1
Esempio n. 23
0
 def addComponent(self, component_name):
     componentID = "%s/%s" % (self.port, component_name)
     if not componentID in self.components:
         self.components[componentID] = Component(componentID)
         self.em.publish("component-added", {"componentID": componentID})
         self.em.subscribe("%s/command" % componentID, self.sendCommand)
     self.sendCommand({
         "command": "%s: info" % component_name,
         "params": None
     })  #request info about this component
Esempio n. 24
0
    def __call__(self, max_len, reuse=False, name=''):
        component_scope = self._variable_scope + name
        with tf.variable_scope(component_scope) as scope:
            if reuse:
                scope.reuse_variables()
            max_len = max_len + 2 if self._word_delimiters else max_len
            word_lens_source = tf.placeholder(dtype=tf.int32,
                                              shape=[None],
                                              name='source/word_lens')
            word_lens_target = tf.placeholder(dtype=tf.int32,
                                              shape=[None],
                                              name='source/word_target')

            chars_p_s = tf.placeholder(dtype=tf.int32,
                                       shape=[max_len, None],
                                       name='source/char_sequence%i' % max_len)
            chars_p_t = tf.placeholder(dtype=tf.int32,
                                       shape=[max_len, None],
                                       name='target/char_sequence%i' % max_len)

            chars_s = tf.nn.embedding_lookup(self.Wchar_s, chars_p_s)
            chars_t = tf.nn.embedding_lookup(self.Wchar_t, chars_p_t)
            word_lens = tf.maximum(word_lens_source, word_lens_target)
            chars = tf.concat([chars_s, chars_t], 2)
            #output_infer, _ = tf.nn.dynamic_rnn(self.char_rnn_cell_infer, chars, sequence_length=tf.cast(word_lens, dtype=tf.int64))

            chars = [tf.squeeze(j, [0]) for j in tf.split(chars, max_len, 0)]
            outputs_infer, _ = tf.contrib.rnn.static_rnn(
                self.char_rnn_cell_infer,
                chars,
                dtype=tf.float32,
                sequence_length=tf.cast(word_lens, dtype=tf.int64))
            scope.reuse_variables()
            outputs, _ = tf.contrib.rnn.static_rnn(self.char_rnn_cell_train,
                                                   chars,
                                                   dtype=tf.float32,
                                                   sequence_length=tf.cast(
                                                       word_lens_source,
                                                       dtype=tf.int64))
            output = _get_last_state(self.max_norm, word_lens_source, outputs)
            output_infer = _get_last_state(self.max_norm, word_lens_source,
                                           outputs_infer)
            inputs = [chars_p_s, word_lens_source, chars_p_t, word_lens_target]

            char_feature_extractor1 = CharLevelInputExtraction(
                self._char_vocab_source, max_len, component_scope + 'source/')
            char_feature_extractor2 = CharLevelInputExtraction(
                self._char_vocab_target, max_len, component_scope + 'target/')
            char_feature_extractor = CombineFeatureExtraction(
                char_feature_extractor1, char_feature_extractor2)
            return Component(inputs,
                             output,
                             output_infer=output_infer,
                             feature_extractor=char_feature_extractor,
                             name='c_rnn_joint')
Esempio n. 25
0
def processClickList(frame):
    print "Processing click list!"
    comps = list()
    for click in clickList:
        mask = (frame.labels == frame.labels[click[0], click[1]])
        comps.append(Component(mask))
    showComps(comps)
    wires = list()
    for c in comps:
        wires.append(cu.makeWire(c.getPixels()))
    makeSchematic(wires, str(int(time.time())) + '_schematic')
Esempio n. 26
0
    def __init__(self, category=None, item_name='item'):
        UnitWithOrders.__init__(self)
        self.item = Component(Item.item_id, item_name)
        Item.item_id += 1
        self.category = category

        if not self.category:
            raise CategoryIsNotDefine()
        else:
            self.category.items.add(self.item)
            Item.all_items.add(self.item)
Esempio n. 27
0
    def determine_components(self):
        """
		This method contains the logic for which components to use, etc. in the pipeline 
		"""
        # call a method that inspects the components and ensures they are correctly configured
        self.__get_available_components()

        # a dict of component names mapped to component locations
        components_dict = self.available_components

        # create the components that are always invoked:
        for name in self.standard_components:
            logging.info('Creating component: %s' % name)
            self.all_components.append(Component(name, components_dict[name]))

        # add the analysis components, marking as appropriate
        for name in self.analysis_components:
            logging.info('Creating component: %s' % name)
            self.all_components.append(
                Component(name, components_dict[name], 'ANALYSIS'))
Esempio n. 28
0
    def __initialize_components(self):
        from component import Component

        component_config_path = self._api_common.get_config_path(
            self.COMPONENT_CONFIG)
        component_config = self._api_common.load_json_file(
            component_config_path)

        for index in range(0, component_config['component_num']):
            component = Component(index, conf=component_config)
            self._component_list.append(component)
Esempio n. 29
0
 def get_connected_component(self, component=None):
     if component==None:
         component = Component()
     component.add_vertex(self)
     for neighbour in self.neighbours:
         edge = set([self, neighbour])
         if edge not in component.edges:
             component.add_edge(edge)
         if neighbour not in component.vertices:
             component = neighbour.get_connected_component(component)
     return component
Esempio n. 30
0
    def TestStackPanel(w):
        s = StackPanel(w)
        #s.orientation = 'Horizontal'
        s.center = True
        s.bind('Mouse Wheel', s.onScroll)
        #s.autosize = True
        s.rect = 50, 50, 600, 170
        s.bgColor = color.gray

        c = Component(s)
        c.size = 250, 50
        c.bgColor = color.red

        c = Component(s)
        c.size = 300, 50
        c.bgColor = color.green

        c = Component(s)
        c.size = 300, 300
        c.bgColor = color.blue