Saves all of the de-trending information to disk in an `npz` file
505918
def _save_npz(self):
        '''
        

        '''

        # Save the data
        d = dict(self.__dict__)
        d.pop('_weights', None)
        d.pop('_A', None)
        d.pop('_B', None)
        d.pop('_f', None)
        d.pop('_mK', None)
        d.pop('K', None)
        d.pop('dvs', None)
        d.pop('clobber', None)
        d.pop('clobber_tpf', None)
        d.pop('_mission', None)
        d.pop('debug', None)
        np.savez(os.path.join(self.dir, self.name + '.npz'), **d)
221807
def save(path, params = {})
            options =
            {
                delinearize: true,
                recompile: true,
                decrypt: false
            }
            options.update(params)

            if self.frozen? # incompatible flags with frozen doc (signed)
                options[:recompile] =
                options[:rebuild_xrefs] =
                options[:noindent] =
                options[:obfuscate] = false
            end

            if path.respond_to?(:write)
                fd = path
            else
                path = File.expand_path(path)
                fd = File.open(path, 'w').binmode
                close = true
            end

            load_all_objects unless loaded?

            intents_as_pdfa1 if options[:intent] =~ /pdf[\/-]?A1?/i
            self.delinearize! if options[:delinearize] and self.linearized?
            compile(options) if options[:recompile]

            fd.write output(options)
            fd.close if close

            self
        end
641494
def demean(in_file, in_mask, only_mask=False, newpath=None):
    """"""
    import os
    import numpy as np
    import nibabel as nb
    from nipype.utils.filemanip import fname_presuffix

    out_file = fname_presuffix(in_file, suffix='_demeaned',
                               newpath=os.getcwd())
    nii = nb.load(in_file)
    msk = nb.load(in_mask).get_data()
    data = nii.get_data()
    if only_mask:
        data[msk > 0] -= np.median(data[msk > 0])
    else:
        data -= np.median(data[msk > 0])
    nb.Nifti1Image(data, nii.affine, nii.header).to_filename(
        out_file)
    return out_file
124213
def cleanup_all_temporary_files(self):
        # type: (Descriptor) -> None
        
        # delete local file
        try:
            self.final_path.unlink()
        except OSError:
            pass
        # iterate unchecked chunks and delete
        for key in self._unchecked_chunks:
            ucc = self._unchecked_chunks[key]['ucc']
            if ucc.temp:
                try:
                    ucc.file_path.unlink()
                except OSError:
                    pass
1314866
def write_to_files_np(features, tokenizer, max_seq_length,
                      max_predictions_per_seq, output_files):
    # pylint: disable=unused-argument
    """"""
    next_sentence_labels = []
    valid_lengths = []

    assert len(output_files) == 1, 'numpy format only support single output file'
    output_file = output_files[0]
    (input_ids, segment_ids, masked_lm_positions, masked_lm_ids,
     masked_lm_weights, next_sentence_labels, valid_lengths) = features
    total_written = len(next_sentence_labels)

    # store variable length numpy array object directly.
    outputs = collections.OrderedDict()
    outputs['input_ids'] = np.array(input_ids, dtype=object)
    outputs['segment_ids'] = np.array(segment_ids, dtype=object)
    outputs['masked_lm_positions'] = np.array(masked_lm_positions, dtype=object)
    outputs['masked_lm_ids'] = np.array(masked_lm_ids, dtype=object)
    outputs['masked_lm_weights'] = np.array(masked_lm_weights, dtype=object)
    outputs['next_sentence_labels'] = np.array(next_sentence_labels, dtype='int32')
    outputs['valid_lengths'] = np.array(valid_lengths, dtype='int32')

    np.savez_compressed(output_file, **outputs)
    logging.info('Wrote %d total instances', total_written)
1307178
def _denoise(seeds, x, dico, sup_bound, n_atoms, verbose=False, indep=True,
             stop_crit=None, selection_rule=None, pad=0,
             memory=Memory(None)):
    
    approx = []
    for seed in seeds:
        if verbose > 0:
            print("Run seed %d" % seed)
        if indep:
            approx.append(_single_mp_run(x, dico, sup_bound, n_atoms,
                                         verbose=verbose, pad=pad,
                                         random_state=seed,
                                         memory=memory)[0])
        else:
            approx.append(_single_multichannel_mp_run(x, dico, sup_bound,
                                                      selection_rule,
                                                      stop_crit,
                                                      n_atoms, verbose=verbose,
                                                      pad=pad,
                                                      random_state=seed,
                                                      memory=memory)[0])
    return approx
487747
function saveFiles(path, opts, obj, cb) {
  const noDot = opts.noDot
  var root  = ''

  walk.walk(path, walkFn, function (err) {
    if (err) cb(err)
    cb(null, obj)
  })

  function walkFn(baseDir, filename, stat, next) {
    if (!root) root = baseDir
    baseDir = stripLeadingSlash(baseDir.split(root)[1])

    if (stat.isDirectory()) return next()
    if (noDot) {
      if (/^\./.test(filename)) return next()
    }
    pushArr(baseDir, obj, filename)
    next()
  }
}
562087
def saveParList(self, *args, **kw):
        """"""
        if 'filename' in kw:
            filename = kw['filename']
        if not filename:
            filename = self.getFilename()
        if not filename:
            raise ValueError("No filename specified to save parameters")

        if hasattr(filename,'write'):
            fh = filename
            absFileName = os.path.abspath(fh.name)
        else:
            absFileName = os.path.expanduser(filename)
            absDir = os.path.dirname(absFileName)
            if len(absDir) and not os.path.isdir(absDir): os.makedirs(absDir)
            fh = open(absFileName,'w')
        numpars = len(self.__paramList)
        if self._forUseWithEpar: numpars -= 1
        if not self.final_comment: self.final_comment = [''] # force \n at EOF
        # Empty the ConfigObj version of section.defaults since that is based
        # on an assumption incorrect for us, and override with our own list.
        # THIS IS A BIT OF MONKEY-PATCHING!  WATCH FUTURE VERSION CHANGES!
        # See Trac ticket #762.
        while len(self.defaults):
            self.defaults.pop(-1) # empty it, keeping ref
        for key in self._neverWrite:
            self.defaults.append(key)
        # Note also that we are only overwriting the top/main section's
        # "defaults" list, but EVERY [sub-]section has such an attribute...

        # Now write to file, delegating work to ConfigObj (note that ConfigObj
        # write() skips any items listed by name in the self.defaults list)
        self.write(fh)
        fh.close()
        retval = str(numpars) + " parameters written to " + absFileName
        self.filename = absFileName # reset our own ConfigObj filename attr
        self.debug('Keys not written: '+str(self.defaults))
        return retval
679389
def decompile(input_, file_, output, format_, jar, limit, decompiler):
    
    from androguard import session
    if file_ and input_:
        print("Can not give --input and positional argument! "
              "Please use only one of them!", file=sys.stderr)
        sys.exit(1)

    if not input_ and not file_:
        print("Give one file to decode!", file=sys.stderr)
        sys.exit(1)

    if input_:
        fname = input_
    else:
        fname = file_

    s = session.Session()
    with open(fname, "rb") as fd:
        s.add(fname, fd.read())
    export_apps_to_format(fname, s, output, limit,
                          jar, decompiler, format_)
1118571
def Dump(self):
        
        prefs_file = open(self.prefs_path, 'w')
        for n in range(0,len(self.prefs)):
            if len(list(self.prefs.items())[n]) > 1:
                prefs_file.write(str(list(self.prefs.items())[n][0]) + ' = ' +
                                 str(list(self.prefs.items())[n][1]) + '\n')
        prefs_file.close()
365985
def pitremove(np, dem, filleddem, workingdir=None, mpiexedir=None, exedir=None, log_file=None,
                  runtime_file=None, hostfile=None):
        
        fname = TauDEM.func_name('pitremove')
        return TauDEM.run(FileClass.get_executable_fullpath(fname, exedir),
                          {'-z': dem}, workingdir,
                          None,
                          {'-fel': filleddem},
                          {'mpipath': mpiexedir, 'hostfile': hostfile, 'n': np},
                          {'logfile': log_file, 'runtimefile': runtime_file})
790269
def clean(self):
        
        logger.info('Cleaning up archive')
        shutil.move(
            os.path.join(
                self.data_dir,
                'var/IRS/data/scripts/pofd/download/FullDataFile.txt'
            ),
            self.final_path
        )

        shutil.rmtree(os.path.join(self.data_dir, 'var'))
        os.remove(self.zip_path)
926773
def freeze_archive(tmp_dir, dest_prefix):
    """"""
    zip_filename = "%s/aomi-blah.zip" % tmp_dir
    archive = zipfile.ZipFile(zip_filename, 'w')
    for root, _dirnames, filenames in os.walk(dest_prefix):
        for filename in filenames:
            relative_path = subdir_path(root, dest_prefix).split(os.sep)[1:]
            relative_path = os.sep.join(relative_path)
            archive.write("%s/%s" % (root, filename),
                          "%s/%s" % (relative_path, filename))

    archive.close()
    return zip_filename
1227596
def _save_params(self):
        
        self.model.save_params_to_file(self.current_params_fname)
        utils.cleanup_params_files(self.model.output_dir, self.max_params_files_to_keep, self.state.checkpoint,
                                   self.state.best_checkpoint, self.keep_initializations)
713423
def store(self, filename=None, label=None, desc=None, date=None):
        
        date = date if date else datetime.now()
        date = date.replace(microsecond=0).isoformat()
        filename = filename if filename else date + '.mat'

        matfile = {
            'model': str(type(self)),
            'date': date,
            'dim': len(self.init_sol.shape),
            'dimlesses': self.coeffs,
            'init_solution': self.init_sol,
            'num_iters': self.num_iters,
            'num_nodes': self.num_nodes,
            'order': self.order,
            'originals': self.originals,
            'pumping': self.getPumping(),
            'spatial_step': self.dx,
            'time_step': self.dt,
        }

        if desc:
            matfile['desc'] = desc
        if label:
            matfile['label'] = label

        savemat(filename, matfile)
281158
def save(self, data, dtype_out_time, dtype_out_vert=False,
             save_files=True, write_to_tar=False):
        """"""
        self._update_data_out(data, dtype_out_time)
        if save_files:
            self._save_files(data, dtype_out_time)
        if write_to_tar and self.proj.tar_direc_out:
            self._write_to_tar(dtype_out_time)
        logging.info('\t{}'.format(self.path_out[dtype_out_time]))
128591
def save_info_df(self):
        """"""
        logger.debug("running save_info_df")

        info_df = self.info_df
        top_level_dict = {'info_df': info_df, 'metadata': self._prm_packer()}

        # packing prms

        jason_string = json.dumps(top_level_dict,
                                  default=lambda info_df: json.loads(
                                      info_df.to_json()))
        with open(self.info_file, 'w') as outfile:
            outfile.write(jason_string)
        logger.info("Saved file to {}".format(self.info_file))