Loads a single fixmat (fixmatfile).
    
    Parameters:
        fixmatfile : string
            The matlab fixmat that should be loaded.
        categories : instance of stimuli.Categories, optional
            Links data in categories to data in fixmat.
773460
def FixmatFactory(fixmatfile, categories = None, var_name = 'fixmat', field_name='x'):
    
    try:
        data = loadmat(fixmatfile, struct_as_record = False)
        keys = list(data.keys())
        data = data[var_name][0][0]
    except KeyError:
        raise RuntimeError('%s is not a field of the matlab structure. Possible'+
                'Keys are %s'%str(keys))
    
    num_fix = data.__getattribute__(field_name).size

    # Get a list with fieldnames and a list with parameters
    fields = {}
    parameters = {}
    for field in data._fieldnames:
        if data.__getattribute__(field).size == num_fix:
            fields[field] = data.__getattribute__(field)
        else:            
            parameters[field] = data.__getattribute__(field)[0].tolist()
            if len(parameters[field]) == 1:
                parameters[field] = parameters[field][0]
    
    # Generate FixMat
    fixmat = FixMat(categories = categories)
    fixmat._fields = list(fields.keys())
    for (field, value) in list(fields.items()):
        fixmat.__dict__[field] = value.reshape(-1,) 

    fixmat._parameters = parameters
    fixmat._subjects = None
    for (field, value) in list(parameters.items()):
        fixmat.__dict__[field] = value
    fixmat._num_fix = num_fix
    return fixmat
868885
def load(self, patterns, dirs, ignore=None):
        
        for path in self.find_files(patterns=patterns, dirs=dirs, ignore=ignore):
            data = self.read_file(path=path)
            if data:
                self.paths[path] = data
1307511
def fix(args):
    
    p = OptionParser(fix.__doc__)
    p.add_option("--ignore_sym_pat", default=False, action="store_true",
        help="Do not fix names matching symbol patterns i.e." + \
        " names beginning or ending with gene symbols or a series of numbers." + \
        " e.g. `ARM repeat superfamily protein`, `beta-hexosaminidase 3`," + \
        " `CYCLIN A3;4`, `WALL ASSOCIATED KINASE (WAK)-LIKE 10`")
    p.set_outfile()
    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(not p.print_help())

    csvfile, = args
    fp = open(csvfile)
    fw = must_open(opts.outfile, "w")
    for row in fp:
        if row[0] == '#':
            continue
        if row.strip() == "":
            continue
        atoms = row.rstrip("\r\n").split("\t")
        name, hit, ahrd_code, desc = atoms[:4] \
                if len(atoms) > 2 else \
                (atoms[0], None, None, atoms[-1])

        newdesc = fix_text(desc, ignore_sym_pat=opts.ignore_sym_pat)
        if hit and hit.strip() != "" and newdesc == Hypothetical:
            newdesc = "conserved " + newdesc
        print("\t".join(atoms[:4] + [newdesc] + atoms[4:]), file=fw)
868760
def fixations(self):
        
        if not self._fixations:
            raise RuntimeError('This Images object does not have'
                +' an associated fixmat')
        return self._fixations[(self._fixations.category == self.category) &
                               (self._fixations.filenumber == self.image)]
20969
def Load(file):
    
    with open(file, 'rb') as file:
        model = dill.load(file)
        return model
893059
def _add(self, fixed=None, random=None, priors=None, family='gaussian',
             link=None, categorical=None, append=True):
        '''
        '''

        # use cleaned data with NAs removed (if user requested)
        data = self.clean_data
        # alter this pandas flag to avoid false positive SettingWithCopyWarnings
        data._is_copy = False

        # Explicitly convert columns to category if desired--though this
        # can also be done within the formula using C().
        if categorical is not None:
            data = data.copy()
            cats = listify(categorical)
            data[cats] = data[cats].apply(lambda x: x.astype('category'))

        if fixed is not None:
            if '~' in fixed:
                # check to see if formula is using the 'y[event] ~ x' syntax
                # (for bernoulli models). If so, chop it into groups:
                # 1 = 'y[event]', 2 = 'y', 3 = 'event', 4 = 'x'
                # If this syntax is not being used, event = None
                event = re.match(r'^((\S+)\[(\S+)\])\s*~(.*)$', fixed)
                if event is not None:
                    fixed = '{}~{}'.format(event.group(2), event.group(4))
                y, X = dmatrices(fixed, data=data, NA_action='raise')
                y_label = y.design_info.term_names[0]
                if event is not None:
                    # pass in new Y data that has 1 if y=event and 0 otherwise
                    y_data = y[:, y.design_info.column_names.index(event.group(1))]
                    y_data = pd.DataFrame({event.group(3): y_data})
                    self._add_y(y_label, family=family, link=link, data=y_data)
                else:
                    # use Y as-is
                    self._add_y(y_label, family=family, link=link)
            else:
                X = dmatrix(fixed, data=data, NA_action='raise')

            # Loop over predictor terms
            for _name, _slice in X.design_info.term_name_slices.items():
                cols = X.design_info.column_names[_slice]
                term_data = pd.DataFrame(X[:, _slice], columns=cols)
                prior = priors.pop(_name, priors.get('fixed', None))
                self.terms[_name] = Term(_name, term_data, prior=prior)

        # Random effects
        if random is not None:

            random = listify(random)

            for f in random:

                f = f.strip()

                # Split specification into intercept, predictor, and grouper
                patt = r'^([01]+)*[\s\+]*([^\|]+)*\|(.*)'

                intcpt, pred, grpr = re.search(patt, f).groups()
                label = '{}|{}'.format(pred, grpr) if pred else grpr
                prior = priors.pop(label, priors.get('random', None))

                # Treat all grouping variables as categoricals, regardless of
                # their dtype and what the user may have specified in the
                # 'categorical' argument.
                var_names = re.findall('(\w+)', grpr)
                for v in var_names:
                    if v in data.columns:
                        data.loc[:, v] = data.loc[:, v].astype('category')
                        self.clean_data.loc[:, v] = data.loc[:, v]

                # Default to including random intercepts
                intcpt = 1 if intcpt is None else int(intcpt)

                grpr_df = dmatrix('0+%s' % grpr, data, return_type='dataframe',
                                  NA_action='raise')

                # If there's no predictor, we must be adding random intercepts
                if not pred and grpr not in self.terms:
                    name = '1|' + grpr
                    pred = np.ones((len(grpr_df), 1))
                    term = RandomTerm(name, grpr_df, pred, grpr_df.values,
                                      categorical=True, prior=prior)
                    self.terms[name] = term
                else:
                    pred_df = dmatrix('%s+%s' % (intcpt, pred), data,
                                      return_type='dataframe',
                                      NA_action='raise')
                    # determine value of the 'constant' attribute
                    const = np.atleast_2d(pred_df.T).T.sum(1).var() == 0

                    for col, i in pred_df.design_info.column_name_indexes.items():
                        pred_data = pred_df.iloc[:, i]
                        lev_data = grpr_df.multiply(pred_data, axis=0)

                        # Also rename intercepts and skip if already added.
                        # This can happen if user specifies something like
                        # random=['1|school', 'student|school'].
                        if col == 'Intercept':
                            if grpr in self.terms:
                                continue
                            label = '1|%s' % grpr
                        else:
                            label = col + '|' + grpr

                        prior = priors.pop(label, priors.get('random', None))

                        # Categorical or continuous is determined from data
                        ld = lev_data.values
                        if ((ld == 0) | (ld == 1)).all():
                            lev_data = lev_data.astype(int)
                            cat = True
                        else:
                            cat = False

                        pred_data = pred_data[:, None]  # Must be 2D later
                        term = RandomTerm(label, lev_data, pred_data,
                                          grpr_df.values, categorical=cat,
                                          constant=const if const else None,
                                          prior=prior)
                        self.terms[label] = term
410675
def load(path):
    
    f = h5py.File(path,'r')
    if 'Fixmat' in f:
      fm_group = f['Fixmat']
    else:
      fm_group = f['Datamat']
    fields = {}
    params = {}
    for field, value in list(fm_group.items()):
        fields[field] = np.array(value)
    for param, value in list(fm_group.attrs.items()):
        params[param] = value
    f.close()
    return VectorFixmatFactory(fields, params)
1295603
public function catarts()
    {
        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('bl_rssCategories')) {
            $oCat = oxNew(\OxidEsales\Eshop\Application\Model\Category::class);
            if ($oCat->load(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter('cat'))) {
                $this->_getRssFeed()->loadCategoryArticles($oCat);
            }
        } else {
            error_404_handler();
        }
    }
83728
def load_data(self):
        
        images = list()
        labels = list()
        emotion_index_map = dict()
        label_directories = [dir for dir in os.listdir(self.datapath) if not dir.startswith('.')]
        for label_directory in label_directories:
            if self.target_emotion_map:
                if label_directory not in self.target_emotion_map.keys():    continue
            self._add_new_label_to_map(label_directory, emotion_index_map)
            label_directory_path = self.datapath + '/' + label_directory

            if self.time_delay:
                self._load_series_for_single_emotion_directory(images, label_directory, label_directory_path, labels)
            else:
                image_files = [image_file for image_file in os.listdir(label_directory_path) if not image_file.startswith('.')]
                self._load_images_from_directory_to_array(image_files, images, label_directory, label_directory_path, labels)

        vectorized_labels = self._vectorize_labels(emotion_index_map, labels)
        self._check_data_not_empty(images)
        return self._load_dataset(np.array(images), np.array(vectorized_labels), emotion_index_map)
507268
def mergemat(args):
    
    p = OptionParser(mergemat.__doc__)
    p.set_outfile(outfile="out")
    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(not p.print_help())

    npyfiles = args
    A = np.load(npyfiles[0])
    logging.debug("Load `{}`: matrix of shape {}:; sum={}"
                  .format(npyfiles[0], A.shape, A.sum()))
    for npyfile in npyfiles[1:]:
        B = np.load(npyfile)
        A += B
        logging.debug("Load `{}`: sum={}"
                      .format(npyfiles[0], A.sum()))

    pf = opts.outfile
    np.save(pf, A)
    logging.debug("Combined {} files into `{}.npy`".format(len(npyfiles), pf))
806622
def run(
    categories, param_file, project_dir, plugin, target,
    status_update_interval
):
    
    return _run(
        categories, param_file, project_dir, plugin, target,
        status_update_interval
    )
157804
def _parse_include_section(cfg, parser, section):
    '''
    
    '''
    for _name, pattern in cfg.items(section):
        if not os.path.isabs(pattern):
            pattern = os.path.join(configure.confdir, pattern)
        matches = glob.glob(pattern)
        matches.sort()
        for filename in matches:
            f = open(filename, 'r')
            parse_file(parser, f)
1265284
def get_categories(self, catpath="/"):

        

        response = self._req('/browse/categorytree', {
            "catpath":catpath
        })

        categories = response['categories']

        return categories
664499
protected function load_category_settings() {
        global $CFG;

        // We can land here while being in the context of a block, in which case we
        // should get the parent context which should be the category one. See self::initialise().
        if ($this->context->contextlevel == CONTEXT_BLOCK) {
            $catcontext = $this->context->get_parent_context();
        } else {
            $catcontext = $this->context;
        }

        // Let's make sure that we always have the right context when getting here.
        if ($catcontext->contextlevel != CONTEXT_COURSECAT) {
            throw new coding_exception('Unexpected context while loading category settings.');
        }

        $categorynodetype = navigation_node::TYPE_CONTAINER;
        $categorynode = $this->add($catcontext->get_context_name(), null, $categorynodetype, null, 'categorysettings');
        $categorynode->nodetype = navigation_node::NODETYPE_BRANCH;
        $categorynode->force_open();

        if (can_edit_in_category($catcontext->instanceid)) {
            $url = new moodle_url('/course/management.php', array('categoryid' => $catcontext->instanceid));
            $editstring = get_string('managecategorythis');
            $categorynode->add($editstring, $url, self::TYPE_SETTING, null, null, new pix_icon('i/edit', ''));
        }

        if (has_capability('moodle/category:manage', $catcontext)) {
            $editurl = new moodle_url('/course/editcategory.php', array('id' => $catcontext->instanceid));
            $categorynode->add(get_string('editcategorythis'), $editurl, self::TYPE_SETTING, null, 'edit', new pix_icon('i/edit', ''));

            $addsubcaturl = new moodle_url('/course/editcategory.php', array('parent' => $catcontext->instanceid));
            $categorynode->add(get_string('addsubcategory'), $addsubcaturl, self::TYPE_SETTING, null, 'addsubcat', new pix_icon('i/withsubcat', ''));
        }

        // Assign local roles
        $assignableroles = get_assignable_roles($catcontext);
        if (!empty($assignableroles)) {
            $assignurl = new moodle_url('/'.$CFG->admin.'/roles/assign.php', array('contextid' => $catcontext->id));
            $categorynode->add(get_string('assignroles', 'role'), $assignurl, self::TYPE_SETTING, null, 'roles', new pix_icon('i/assignroles', ''));
        }

        // Override roles
        if (has_capability('moodle/role:review', $catcontext) or count(get_overridable_roles($catcontext)) > 0) {
            $url = new moodle_url('/'.$CFG->admin.'/roles/permissions.php', array('contextid' => $catcontext->id));
            $categorynode->add(get_string('permissions', 'role'), $url, self::TYPE_SETTING, null, 'permissions', new pix_icon('i/permissions', ''));
        }
        // Check role permissions
        if (has_any_capability(array('moodle/role:assign', 'moodle/role:safeoverride',
                'moodle/role:override', 'moodle/role:assign'), $catcontext)) {
            $url = new moodle_url('/'.$CFG->admin.'/roles/check.php', array('contextid' => $catcontext->id));
            $categorynode->add(get_string('checkpermissions', 'role'), $url, self::TYPE_SETTING, null, 'checkpermissions', new pix_icon('i/checkpermissions', ''));
        }

        // Add the context locking node.
        $this->add_context_locking_node($categorynode, $catcontext);

        // Cohorts
        if (has_any_capability(array('moodle/cohort:view', 'moodle/cohort:manage'), $catcontext)) {
            $categorynode->add(get_string('cohorts', 'cohort'), new moodle_url('/cohort/index.php',
                array('contextid' => $catcontext->id)), self::TYPE_SETTING, null, 'cohort', new pix_icon('i/cohort', ''));
        }

        // Manage filters
        if (has_capability('moodle/filter:manage', $catcontext) && count(filter_get_available_in_context($catcontext)) > 0) {
            $url = new moodle_url('/filter/manage.php', array('contextid' => $catcontext->id));
            $categorynode->add(get_string('filters', 'admin'), $url, self::TYPE_SETTING, null, 'filters', new pix_icon('i/filter', ''));
        }

        // Restore.
        if (has_capability('moodle/restore:restorecourse', $catcontext)) {
            $url = new moodle_url('/backup/restorefile.php', array('contextid' => $catcontext->id));
            $categorynode->add(get_string('restorecourse', 'admin'), $url, self::TYPE_SETTING, null, 'restorecourse', new pix_icon('i/restore', ''));
        }

        // Let plugins hook into category settings navigation.
        $pluginsfunction = get_plugins_with_function('extend_navigation_category_settings', 'lib.php');
        foreach ($pluginsfunction as $plugintype => $plugins) {
            foreach ($plugins as $pluginfunction) {
                $pluginfunction($categorynode, $catcontext);
            }
        }

        return $categorynode;
    }
800581
function files(specs, category) {
        var ret = [];
        var src, dst, file;
        var i, j, k;
        var ignoreDirs = cog.getOption('ignore_dirs');

        if (specs) {
            if (typeof(specs) === 'string') {
                // Handle known file collections.
                if (db.known[category] && specs in db.known[category]) {
                    var spec = db.known[category][specs];
                    spec.required = true;
                    ret = ret.concat(files(spec, category));
                // All strings containing non-alpha characters are direct file patterns.
                } else if (/[^a-zA-Z]/.test(specs) || fs.existsSync(specs)) {
                    src = grunt.file.expand(specs);
                    for (i=0; i < src.length; i++) {
                        var skip = false;
                        if (ignoreDirs) {
                            for (k=0; k < ignoreDirs.length; k++) {
                                if (src[i].substr(0, ignoreDirs[k].length) === ignoreDirs[k]) {
                                    skip = true;
                                    break;
                                }
                            }
                        }
                        if (!skip && !grunt.file.isDir(src[i])) {
                            ret.push({src: src[i], dst: src[i], drop: ''});
                        }
                    }
                } else {
                    grunt.fail.fatal("Unknown build file specification '" + specs +"' for '" + category + "'.");
                }
            } else if (specs instanceof Array) {
                // Handle array of specs one by one.
                for (i = 0; i < specs.length; i++) {
                    ret = ret.concat(files(specs[i], category));
                }
            } else if (typeof(specs) === 'object') {

                // Collect dependencies.
                if (specs.needs) {
                    ret = files(specs.needs, category);
                }

                // Calculate path prefix for file sources.
                var srcPrefix = '';
                if (specs.src.substr(0,12) === 'node_modules') {
                    srcPrefix = cog.prefix(specs.src);
                    if (srcPrefix.substr(-13) === 'node_modules/') {
                        srcPrefix = srcPrefix.substr(0, srcPrefix.length - 13);
                    }
                }

                // Here we expand pattens from 'src' and combine them with 'dst'.
                src = grunt.file.expand(srcPrefix + specs.src);

                // Check required files.
                if (src.length === 0 && specs.required) {
                    grunt.fail.fatal("Cannot find required files '" + specs.src + "'.");
                }

                // Calculate resulting specifications.
                for (j=0; j < src.length; j++) {
                    var drop = specs.drop;
                    if (!drop && drop !=='') {
                        // If dst is null, then we keep the file where it is originally.
                        if (specs.dst === null) {
                            drop = '';
                        } else {
                            // Otherwise look for the last directory not having wild-cards.
                            drop = specs.src;
                            while (drop.indexOf('*') >= 0) {
                                drop = path.dirname(drop);
                            }
                        }
                    }

                    // Construct final file description.
                    file = {};
                    // Use source path as is and we can skip directories.
                    file.src = src[j];
                    if (grunt.file.isDir(file.src)) {
                        continue;
                    }

                    // Destination path is calculated.
                    var dstPrefix = specs.dst === null ? srcPrefix : specs.dst;
                    if (dstPrefix.substr(0, 7) === 'CONFIG:') {
                        dstPrefix = cog.getConfig(dstPrefix.substr(7), 'lib');
                    }

                    // Drop source prefix.
                    dst = src[j].substr(srcPrefix.length);
                    // Drop explicit dropping.
                    if (dst.substr(0, drop.length) === drop) {
                        dst = dst.substr(drop.length);
                    }

                    // Add explicit destination.
                    file.dst = path.join(dstPrefix, dst);

                    ret.push(file);
                }
            }
        }

        // Drop duplicates.
        var seen = {};
        var results = [];
        for(i=0; i < ret.length; i++) {
            var name = ret[i].src + ' => ' + ret[i].dst;
            if (seen[name]) {
                continue;
            }
            seen[name] = true;
            results.push(ret[i]);
        }
        return results;
    }
322516
def _parse_category(fname, categories):
        """"""
        version, date, values = None, None, []
        print("parsing {} ..".format(fname))
        for line in open(fname, 'rb'):
            uline = line.decode('utf-8')
            if version is None:
                version = uline.split(None, 1)[1].rstrip()
                continue
            elif date is None:
                date = uline.split(':', 1)[1].rstrip()
                continue
            if uline.startswith('#') or not uline.lstrip():
                continue
            addrs, details = uline.split(';', 1)
            addrs, details = addrs.rstrip(), details.lstrip()
            if any(details.startswith('{} #'.format(value))
                   for value in categories):
                start, stop = addrs, addrs
                if '..' in addrs:
                    start, stop = addrs.split('..')
                values.extend(range(int(start, 16), int(stop, 16) + 1))
        return version, date, sorted(values)
899780
def scatmat(df, category=None, colors='rgob',
            num_plots=4, num_topics=100, num_columns=4,
            show=False, block=False, data_path=DATA_PATH, save=False, verbose=1):
    """"""
    if category is None:
        category = list(df.columns)[-1]
    if isinstance(category, (str, bytes, int)) and category in df.columns:
        category = df[category]
    else:
        category = pd.Series(category)

    suffix = '{}x{}'.format(*list(df.shape))
    # suffix = compose_suffix(len(df), num_topics, save)
    # save = bool(save)
    for i in range(min(num_plots * num_columns, num_topics) / num_plots):
        scatter_matrix(df[df.columns[i * num_columns:(i + 1) * num_columns]],
                       marker='+', c=[colors[int(x) % len(colors)] for x in category.values],
                       figsize=(18, 12))
    if save:
        name = 'scatmat_topics_{}-{}.jpg'.format(i * num_columns, (i + 1) * num_columns) + suffix
        plt.savefig(os.path.join(data_path, name + '.jpg'))
    if show:
        if block:
            plt.show()
        else:
            plt.show(block=False)