Extract direct Activation INDRA Statements.
359986
def get_activations(self):
        """"""
        act_events = self.tree.findall("EVENT/[type='ONT::ACTIVATE']")
        inact_events = self.tree.findall("EVENT/[type='ONT::DEACTIVATE']")
        inact_events += self.tree.findall("EVENT/[type='ONT::INHIBIT']")
        for event in (act_events + inact_events):
            event_id = event.attrib['id']
            if event_id in self._static_events:
                continue
            # Get the activating agent in the event
            agent = event.find(".//*[@role=':AGENT']")
            if agent is None:
                continue
            agent_id = agent.attrib.get('id')
            if agent_id is None:
                logger.debug(
                    'Skipping activation with missing activator agent')
                continue
            activator_agent = self._get_agent_by_id(agent_id, event_id)
            if activator_agent is None:
                continue

            # Get the activated agent in the event
            affected = event.find(".//*[@role=':AFFECTED']")
            if affected is None:
                logger.debug(
                    'Skipping activation with missing affected agent')
                continue
            affected_id = affected.attrib.get('id')
            if affected_id is None:
                logger.debug(
                    'Skipping activation with missing affected agent')
                continue

            affected_agent = self._get_agent_by_id(affected_id, event_id)
            if affected_agent is None:
                logger.debug(
                    'Skipping activation with missing affected agent')
                continue

            is_activation = True
            if _is_type(event, 'ONT::ACTIVATE'):
                self._add_extracted('ONT::ACTIVATE', event.attrib['id'])
            elif _is_type(event, 'ONT::INHIBIT'):
                is_activation = False
                self._add_extracted('ONT::INHIBIT', event.attrib['id'])
            elif _is_type(event, 'ONT::DEACTIVATE'):
                is_activation = False
                self._add_extracted('ONT::DEACTIVATE', event.attrib['id'])
            ev = self._get_evidence(event)
            location = self._get_event_location(event)
            for a1, a2 in _agent_list_product((activator_agent,
                                               affected_agent)):
                if is_activation:
                    st = Activation(a1, a2, evidence=[deepcopy(ev)])
                else:
                    st = Inhibition(a1, a2, evidence=[deepcopy(ev)])
                _stmt_location_to_agents(st, location)
                self.statements.append(st)
443730
def get_activation(self):
        """"""
        qstr = "$.events.frames[@.type is 'activation']"
        res = self.tree.execute(qstr)
        if res is None:
            return
        for r in res:
            epistemics = self._get_epistemics(r)
            if epistemics.get('negated'):
                continue
            sentence = r['verbose-text']
            annotations, context = self._get_annot_context(r)
            ev = Evidence(source_api='reach', text=sentence,
                          pmid=self.citation, annotations=annotations,
                          context=context, epistemics=epistemics)
            args = r['arguments']
            for a in args:
                if self._get_arg_type(a) == 'controller':
                    controller_agent, controller_coords = \
                        self._get_controller_agent(a)
                if self._get_arg_type(a) == 'controlled':
                    controlled = a['arg']
            controlled_agent, controlled_coords = \
                self._get_agent_from_entity(controlled)
            annotations['agents']['coords'] = [controller_coords,
                                               controlled_coords]
            if r['subtype'] == 'positive-activation':
                st = Activation(controller_agent, controlled_agent,
                                evidence=ev)
            else:
                st = Inhibition(controller_agent, controlled_agent,
                                evidence=ev)
            self.statements.append(st)
110528
def _extract_counters(self):
        """"""
        # extract counters (if present)
        counters = ['nscanned', 'nscannedObjects', 'ntoreturn', 'nreturned',
                    'ninserted', 'nupdated', 'ndeleted', 'r', 'w', 'numYields',
                    'planSummary', 'writeConflicts', 'keyUpdates']

        # TODO: refactor mtools to use current counter names throughout
        # Transitionary hack: mapping of current names into prior equivalents
        counter_equiv = {
            'docsExamined': 'nscannedObjects',
            'keysExamined': 'nscanned',
            'nDeleted': 'ndeleted',
            'nInserted': 'ninserted',
            'nMatched': 'nreturned',
            'nModified': 'nupdated'
        }
        counters.extend(counter_equiv.keys())

        split_tokens = self.split_tokens

        # trigger operation evaluation to get access to offset
        if self.operation:
            for t, token in enumerate(split_tokens[self.datetime_nextpos +
                                                   2:]):
                for counter in counters:
                    if token.startswith('%s:' % counter):
                        try:
                            # Remap counter to standard name, if applicable
                            counter = counter_equiv.get(counter, counter)
                            vars(self)['_' + counter] = int((token.split(':')
                                                             [-1]).replace(',',
                                                                           ''))
                        except ValueError:
                            # see if this is a pre-2.5.2 numYields with space
                            # in between (e.g. "numYields: 2")
                            # https://jira.mongodb.org/browse/SERVER-10101
                            if (counter == 'numYields' and
                                    token.startswith('numYields')):
                                try:
                                    self._numYields = int((split_tokens[t + 1 + self.datetime_nextpos + 2]).replace(',', ''))
                                except ValueError:
                                    pass
                            if (counter == 'planSummary' and
                                    token.startswith('planSummary')):
                                try:
                                    self._planSummary = split_tokens[t + 1 + self.datetime_nextpos + 2]
                                    if self._planSummary:
                                        if split_tokens[t + 1 + self.datetime_nextpos + 3] != '{':
                                            self._actualPlanSummary = self._planSummary
                                        else:
                                            self._actualPlanSummary = '%s %s' % (
                                                self._planSummary,
                                                self._find_pattern('planSummary: %s' % self._planSummary, actual=True)
                                            )
                                except ValueError:
                                    pass

                        # token not parsable, skip
                        break
61986
def watch_activations(self, flag):
        """"""
        lib.EnvSetDefruleWatchActivations(self._env, int(flag), self._rule)
506151
private void extractInstructions(InstructionGroup group) {
        for (InstructionGraphNode node : group.getNodes()) {
            if (node != group.getRoot()) {
                AbstractInsnNode insn = node.getInstruction();
                method.instructions.remove(insn);
                group.getInstructions().add(insn);
            }
        }
    }
1249165
def _process_info_installed_output(out, filter_attrs):
    '''
    
    '''
    ret = {}
    name = None
    attrs = {}
    attr = None

    for line in salt.utils.itertools.split(out, '\n'):
        if line and line[0] == ' ':
            # This is a continuation of the last attr
            if filter_attrs is None or attr in filter_attrs:
                line = line.strip()
                if attrs[attr]:
                    # If attr is empty, don't add leading newline
                    attrs[attr] += '\n'
                attrs[attr] += line
            continue
        line = line.strip()
        if not line:
            # Separator between different packages
            if name:
                ret[name] = attrs
            name = None
            attrs = {}
            attr = None
            continue
        key, value = line.split(':', 1)
        value = value.lstrip()
        attr = _convert_to_standard_attr(key)
        if attr == 'name':
            name = value
        elif filter_attrs is None or attr in filter_attrs:
            attrs[attr] = value

    if name:
        ret[name] = attrs
    return ret
458018
def extract_uasts(self):
        
        return UASTsDataFrame(self._engine_dataframe.extractUASTs(),
                              self._session, self._implicits)
80846
def bin_laid_out_activations(layout, activations, grid_size, threshold=5):
    """"""

    assert layout.shape[0] == activations.shape[0]

    # calculate which grid cells each activation's layout position falls into
    # first bin stays empty because nothing should be < 0, so we add an extra bin
    bins = np.linspace(0, 1, num=grid_size + 1)
    bins[-1] = np.inf  # last bin should include all higher values
    indices = np.digitize(layout, bins) - 1  # subtract 1 to account for empty first bin

    # because of thresholding we may need to return a variable number of means
    means, coordinates, counts = [], [], []

    # iterate over all grid cell coordinates to compute their average directions
    grid_coordinates = np.indices((grid_size, grid_size)).transpose().reshape(-1, 2)
    for xy_coordinates in grid_coordinates:
        mask = np.equal(xy_coordinates, indices).all(axis=1)
        count = np.count_nonzero(mask)
        if count > threshold:
            counts.append(count)
            coordinates.append(xy_coordinates)
            mean = np.average(activations[mask], axis=0)
            means.append(mean)

    assert len(means) == len(coordinates) == len(counts)
    if len(coordinates) == 0:
        raise RuntimeError("Binning activations led to 0 cells containing activations!")

    return means, coordinates, counts
1038775
def extract_rar (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    cmdlist = [cmd, 'x']
    if not interactive:
        cmdlist.extend(['-p-', '-y'])
    cmdlist.extend(['--', os.path.abspath(archive)])
    return (cmdlist, {'cwd': outdir})
1179635
def push_activations(activations, from_layer, to_layer):
    """"""
    inverse_covariance_matrix = layer_inverse_covariance(from_layer)
    activations_decorrelated = np.dot(inverse_covariance_matrix, activations.T).T
    covariance_matrix = layer_covariance(from_layer, to_layer)
    activation_recorrelated = np.dot(activations_decorrelated, covariance_matrix)
    return activation_recorrelated
1237423
def active_repositories(doc):
    """"""
    if doc.get('state') != 'deactivated':
        for repository_id, repo in doc.get('repositories', {}).items():
            if repo.get('state') != 'deactivated':
                repo['id'] = repository_id
                repo['organisation_id'] = doc['_id']

                yield repository_id, repo
707013
def getActivationsDict(self, nameList):
        
        retval = {}
        for name in nameList:
            retval[name] = self.layersByName[name].getActivationsList()
        return retval
750574
def extract(self, disp):
        
        res = copy.deepcopy(self)
        for i in range(self.ndims):
            d = disp[i]
            s = self.domain[i]
            if d > 0:
                res.domain[i] = slice(s.start, d)
            elif d < 0:
                res.domain[i] = slice(d, s.stop)
        return res
301635
def get_statements(self, reprocess=False):
        """"""
        if self._statements is None or reprocess:
            # Handle the case that there is no content.
            if self.content is None:
                self._statements = []
                return []

            # Map to the different processors.
            if self.reader == ReachReader.name:
                if self.format == formats.JSON:
                    # Process the reach json into statements.
                    json_str = json.dumps(self.content)
                    processor = reach.process_json_str(json_str)
                else:
                    raise ReadingError("Incorrect format for Reach output: %s."
                                       % self.format)
            elif self.reader == SparserReader.name:
                if self.format == formats.JSON:
                    # Process the sparser content into statements
                    processor = sparser.process_json_dict(self.content)
                    if processor is not None:
                        processor.set_statements_pmid(None)
                else:
                    raise ReadingError("Sparser should only ever be JSON, not "
                                       "%s." % self.format)
            elif self.reader == TripsReader.name:
                processor = trips.process_xml(self.content)
            else:
                raise ReadingError("Unknown reader: %s." % self.reader)

            # Get the statements from the processor, if it was resolved.
            if processor is None:
                logger.error("Production of statements from %s failed for %s."
                             % (self.reader, self.content_id))
                stmts = []
            else:
                stmts = processor.statements
            self._statements = stmts[:]
        else:
            stmts = self._statements[:]
        return stmts
1238477
def extract_alzip (archive, compression, cmd, verbosity, interactive, outdir):
    """"""
    return [cmd, '-d', outdir, archive]
1179330
def get_inc(self, native=False):
        
        if self.sdk_version == 'v7.0A':
            include = os.path.join(self.sdk_dir, 'include')
            if os.path.isdir(include):
                logging.info(_('using include: %s'), include)
                return [include]
            logging.debug(_('include not found: %s'), include)
            return []
        if self.sdk_version == 'v8.1':
            dirs = []
            if native:
                parts = ['km', os.path.join('km', 'crt'), 'shared']
            else:
                parts = ['um', 'winrt', 'shared']
            for part in parts:
                include = os.path.join(self.sdk_dir, 'include', part)
                if os.path.isdir(include):
                    logging.info(_('using include: %s'), include)
                    dirs.append(include)
                else:
                    logging.debug(_('inc not found: %s'), include)
            return dirs
        if self.sdk_version == 'v10.0':
            dirs = []
            extra = os.path.join('include', '10.0.10240.0')
            for mode in ['um', 'ucrt', 'shared', 'winrt']:
                include = os.path.join(self.sdk_dir, extra, mode)
                if os.path.isdir(include):
                    logging.info(_('using include: %s'), include)
                    dirs.append(include)
                else:
                    logging.debug(_('inc not found: %s'), include)
            return dirs
        message = 'unknown sdk version: {}'.format(self.sdk_version)
        raise RuntimeError(message)
1225301
def run_analysis(self, argv):
        """"""
        args = self._parser.parse_args(argv)

        name_keys = dict(target_type=args.ttype,
                         target_name=args.target,
                         sim_name=args.sim,
                         fullpath=True)

        orig_dir = NAME_FACTORY.targetdir(**name_keys)
        dest_dir = NAME_FACTORY.sim_targetdir(**name_keys)
        self.copy_target_dir(orig_dir, dest_dir,
                             args.roi_baseline, args.extracopy)