Export matrices as ``*.npy`` files to an output folder.
492453
def export(self, output_folder):
        """"""
        if not os.path.exists(output_folder):
            os.makedirs(output_folder)
        self._interact_with_folder(output_folder, 'w')
1004808
def dump_to_pyc(co, python_version, output_dir):
    """"""
    # assume Windows path information from the .exe
    pyc_basename = ntpath.basename(co.co_filename)
    pyc_name = pyc_basename + '.pyc'

    if pyc_name not in IGNORE:
        logging.info("Extracting %s", pyc_name)
        pyc_header = _generate_pyc_header(python_version, len(co.co_code))
        destination = os.path.join(output_dir, pyc_name)
        pyc = open(destination, 'wb')
        pyc.write(pyc_header)
        marshaled_code = marshal.dumps(co)
        pyc.write(marshaled_code)
        pyc.close()
    else:
        logging.info("Skipping %s", pyc_name)
981475
def export_project(self):
        
        generated_projects = deepcopy(self.generated_projects)
        self.process_data_for_makefile(self.workspace)
        generated_projects['path'], generated_projects['files']['makefile'] = self.gen_file_jinja('makefile_armcc.tmpl', self.workspace, 'Makefile', self.workspace['output_dir']['path'])
        return generated_projects
1344366
def write_float_matrices(scp_path, ark_path, matrices):
        

        scp_entries = []

        with open(ark_path, 'wb') as f:
            for utterance_id in sorted(list(matrices.keys())):
                matrix = matrices[utterance_id]

                assert (matrix.dtype == np.float32)

                f.write(('{} '.format(utterance_id)).encode('utf-8'))

                offset = f.tell()

                f.write(b'\x00B')
                f.write(b'FM ')
                f.write(b'\x04')
                f.write(struct.pack('<i', np.size(matrix, 0)))
                f.write(b'\x04')
                f.write(struct.pack('<i', np.size(matrix, 1)))

                flattened = matrix.reshape(np.size(matrix, 0) * np.size(matrix, 1))
                flattened.tofile(f, sep='')

                scp_entries.append('{} {}:{}'.format(utterance_id, ark_path, offset))

        with open(scp_path, 'w') as f:
            f.write('\n'.join(scp_entries))
444907
def export(app, local, no_scrub):
    """"""
    log(header, chevrons=False)
    data.export(str(app), local=local, scrub_pii=(not no_scrub))
455431
def copy_mx_model_to(model_path, model_epoch, output_folder):
    
    target_path = os.path.join(output_folder, os.path.basename(model_path))
    logger.info("Copying image model from {} to {}".format(model_path,
                                                           target_path))
    suffix = ['-symbol.json', '-%04d.params' % (model_epoch,)]
    for s in suffix:
        copyfile(model_path + s, target_path + s)
    return target_path
264385
def export(self, fn:PathOrStr, **kwargs):
        ""
        pickle.dump(self.get_state(**kwargs), open(fn, 'wb'))
1020629
def output_files(self):
        """"""
        for dep in self.subgraph.successors(self.address):
            dep_rule = self.subgraph.node[dep]['target_obj']
            for out_file in dep_rule.output_files:
                yield out_file
140830
def _project_eigenvectors(self):
        """"""

        self._p_eigenvectors = []
        for vecs_q in self._eigenvectors:
            p_vecs_q = []
            for vecs in vecs_q.T:
                p_vecs_q.append(np.dot(vecs.reshape(-1, 3),
                                       self._projection_direction))
            self._p_eigenvectors.append(np.transpose(p_vecs_q))
        self._p_eigenvectors = np.array(self._p_eigenvectors)
1181255
def _create_model_matrices(self):
        

        self.model_Y = np.array(self.data[self.max_lag:self.data.shape[0]])
        self.model_scores = np.zeros(self.model_Y.shape[0])
27578
def temp_to_spmatrix(self, ty):
        
        assert ty in ('jac0', 'jac')

        jac0s = ['Fx0', 'Fy0', 'Gx0', 'Gy0']
        jacs = ['Fx', 'Fy', 'Gx', 'Gy']

        if ty == 'jac0':
            todo = jac0s
        elif ty == 'jac':
            todo = jacs

        for m in todo:
            self.__dict__[m] = spmatrix(self._temp[m]['V'],
                                        self._temp[m]['I'], self._temp[m]['J'],
                                        self.get_size(m), 'd')
            if ty == 'jac':
                self.__dict__[m] += self.__dict__[m + '0']

        self.apply_set(ty)
1146384
def convert_notebook(self, name):
        """"""

        #subprocess.call(["jupyter","nbconvert","--to","python",
        #                self.get_path("%s.ipynb"%name)])
        exporter = nbconvert.exporters.python.PythonExporter()
        relative_path = self.convert_path(name)
        file_path = self.get_path("%s.ipynb"%relative_path)
        code = exporter.from_filename(file_path)[0]
        self.write_code(name, code)
        self.clean_code(name, [])
1082095
def _visit_pyfiles(list, dirname, names):
    """"""
    # get extension for python source files
    if not globals().has_key('_py_ext'):
        global _py_ext
#        _py_ext = [triple[0] for triple in imp.get_suffixes()
#                   if triple[2] == imp.PY_SOURCE][0]
        _py_ext = [triple[0] for triple in imp.get_suffixes()
                   if triple[2] == imp.PY_SOURCE]
        
    # don't recurse into CVS directories
    if 'CVS' in names:
        names.remove('CVS')

    if '.svn' in names:
        names.remove('.svn')

    if '.git' in names:
        names.remove('.git')

    if 'static' in names:
        names.remove('static')
    
    # add all *.py files to list
    list.extend(
        [os.path.join(dirname, file) for file in names
         if os.path.splitext(file)[1] in _py_ext]
        )
627454
def save_disagg_to_csv(metadata, matrices):
    
    skip_keys = ('Mag', 'Dist', 'Lon', 'Lat', 'Eps', 'TRT')
    base_header = ','.join(
        '%s=%s' % (key, value) for key, value in metadata.items()
        if value is not None and key not in skip_keys)
    for disag_tup, (poe, iml, matrix, fname) in matrices.items():
        header = '%s,poe=%.7f,iml=%.7e\n' % (base_header, poe, iml)

        if disag_tup == ('Mag', 'Lon', 'Lat'):
            matrix = numpy.swapaxes(matrix, 0, 1)
            matrix = numpy.swapaxes(matrix, 1, 2)
            disag_tup = ('Lon', 'Lat', 'Mag')

        axis = [metadata[v] for v in disag_tup]
        header += ','.join(v for v in disag_tup)
        header += ',poe'

        # compute axis mid points
        axis = [(ax[: -1] + ax[1:]) / 2. if ax.dtype == float
                else ax for ax in axis]

        values = None
        if len(axis) == 1:
            values = numpy.array([axis[0], matrix.flatten()]).T
        else:
            grids = numpy.meshgrid(*axis, indexing='ij')
            values = [g.flatten() for g in grids]
            values.append(matrix.flatten())
            values = numpy.array(values).T

        writers.write_csv(fname, values, comment=header, fmt='%.5E')
1036529
def output_files(self):
        
        outs = [os.path.join(self.address.repo, self.address.path, x)
                for x in self.params['outs']]
        return outs
838846
def create_log2fc_bigwigs(matrix, outdir, args):
    # type: (pd.DataFrame, str, Namespace) -> None
    """"""

    call("mkdir -p {}".format(outdir), shell=True)
    genome_size_dict = args.chromosome_sizes

    outpaths = []
    for bed_file in matrix[args.treatment]:
        outpath = join(outdir, splitext(basename(bed_file))[0] + "_log2fc.bw")
        outpaths.append(outpath)

    data = create_log2fc_data(matrix, args)

    Parallel(n_jobs=args.number_cores)(delayed(_create_bigwig)(bed_column, outpath, genome_size_dict) for outpath, bed_column in zip(outpaths, data))
586720
def _reformat_matrix(self):
        
        nxax = len(self.current_table.data['independent_variables'])
        nyax = len(self.current_table.data['dependent_variables'])
        npts = len(self.current_table.data['dependent_variables'][0]['values'])

        # check if 1 x-axis, and npts (>=2) equals number of y-axes
        if nxax != 1 or nyax != npts or npts < 2:
            return False

        # add second independent variable with each value duplicated npts times
        if len(self.current_table.xheaders) == 2:
            xheader = self.current_table.xheaders[1]
        else:
            xheader = copy.deepcopy(self.current_table.data['independent_variables'][0]['header'])
        self.current_table.data['independent_variables'].append({'header': xheader, 'values': []})
        for value in self.current_table.data['independent_variables'][0]['values']:
            self.current_table.data['independent_variables'][1]['values'].extend([copy.deepcopy(value) for npt in range(npts)])

        # duplicate values of first independent variable npts times
        self.current_table.data['independent_variables'][0]['values'] \
            = [copy.deepcopy(value) for npt in range(npts) for value in self.current_table.data['independent_variables'][0]['values']]

        # suppress header if different for second y-axis
        if self.current_table.data['dependent_variables'][0]['header'] != \
                self.current_table.data['dependent_variables'][1]['header']:
            self.current_table.data['dependent_variables'][0]['header'] = {'name': ''}

        # remove qualifier if different for second y-axis
        iqdel = [] # list of qualifier indices to be deleted
        for iq, qualifier in enumerate(self.current_table.data['dependent_variables'][0]['qualifiers']):
            if qualifier != self.current_table.data['dependent_variables'][1]['qualifiers'][iq]:
                iqdel.append(iq)
        for iq in iqdel[::-1]: # need to delete in reverse order
            del self.current_table.data['dependent_variables'][0]['qualifiers'][iq]

        # append values of second and subsequent y-axes to first dependent variable
        for iy in range(1, nyax):
            for value in self.current_table.data['dependent_variables'][iy]['values']:
                self.current_table.data['dependent_variables'][0]['values'].append(value)

        # finally, delete the second and subsequent y-axes in reverse order
        for iy in range(nyax-1, 0, -1):
            del self.current_table.data['dependent_variables'][iy]

        return True