Save index from bokeh textinput
191674
def callback_save_indices():
    ''''''
    import datetime
    import os
    import pylleo
    import yamlord

    if datadirs_select.value != 'None':
        path_dir = os.path.join(parent_input.value, datadirs_select.value)
        cal_yaml_path = os.path.join(path_dir, 'cal.yml')

        param = (param_select.value).lower().replace('-','_')
        region = region_select.value
        start = int(start_input.value)
        end   = int(end_input.value)

        msg = '''
              Updated calibration times for:<br>
              <b>{}/{}</b>
              <br>
              <br>
              star index: {}<br>
              end index:  {}<br>
              '''.format(param, region, start, end)
        output_window.text = output_template.format(msg)

        cal_dict = pylleo.lleocal.read_cal(cal_yaml_path)
        # Generalize for Class-ifying
        cal_dict = pylleo.lleocal.update(data, cal_dict, param, region, start, end)
        yamlord.write_yaml(cal_dict, cal_yaml_path)
    else:
        msg = '''
              You must first load data and select indices for calibration
              regions before you can save the indices to `cal.yml`
              '''
        output_window.text = output_template.format(msg)

    return None
851486
function updateoct(){
  var oct = octinputfield;
  if(octinputvalue != oct){
    updateall(octinputtobin(oct));
    clearallinputs();
    octinputfield = oct;
    octinputvalue = oct;
  }
}
420693
function saveText() {
  if (input.value.trim().length > 0) {
    let clientX = parseInt(input.style.left, 10);
    let clientY = parseInt(input.style.top, 10);
    let svg = findSVGAtPoint(clientX, clientY);
    if (!svg) {
      return;
    }

    let { documentId, pageNumber } = getMetadata(svg);
    let rect = svg.getBoundingClientRect();
    let annotation = Object.assign({
        type: 'textbox',
        size: _textSize,
        color: _textColor,
        content: input.value.trim()
      }, scaleDown(svg, {
        x: clientX - rect.left,
        y: clientY -  rect.top,
        width: input.offsetWidth,
        height: input.offsetHeight
      })
    );

    PDFJSAnnotate.getStoreAdapter().addAnnotation(documentId, pageNumber, annotation)
      .then((annotation) => {
        appendChild(svg, annotation);
      });
  }
  
  closeInput();
}
838901
def _MaybeWriteIndex(self, i, ts, mutation_pool):
    """"""
    if i > self._max_indexed and i % self.INDEX_SPACING == 0:
      # We only write the index if the timestamp is more than 5 minutes in the
      # past: hacky defense against a late write changing the count.
      if ts[0] < (rdfvalue.RDFDatetime.Now() -
                  self.INDEX_WRITE_DELAY).AsMicrosecondsSinceEpoch():
        mutation_pool.CollectionAddIndex(self.collection_id, i, ts[0], ts[1])
        self._index[i] = ts
        self._max_indexed = max(i, self._max_indexed)
20288
def get_output(self, index):
        
        pdata = ctypes.POINTER(mx_uint)()
        ndim = mx_uint()
        _check_call(_LIB.MXPredGetOutputShape(
            self.handle, index,
            ctypes.byref(pdata),
            ctypes.byref(ndim)))
        shape = tuple(pdata[:ndim.value])
        data = np.empty(shape, dtype=np.float32)
        _check_call(_LIB.MXPredGetOutput(
            self.handle, mx_uint(index),
            data.ctypes.data_as(mx_float_p),
            mx_uint(data.size)))
        return data
951483
def save_position(self):
        
        # save text cursor position:
        self.old_text_pos = self.index(tkinter.INSERT)
        # save scroll position:
        self.old_first, self.old_last = self.yview()
434456
function(input, output) {
		rxAnimation.lastIndex = 0;

		var animation;
		var rawKeyframes;
		var keyframe;
		var curAnimation;

		while((animation = rxAnimation.exec(input)) !== null) {
			//Grab the keyframes inside this animation.
			rxKeyframes.lastIndex = rxAnimation.lastIndex;
			rawKeyframes = rxKeyframes.exec(input);

			//Grab the single keyframes with their CSS properties.
			rxSingleKeyframe.lastIndex = 0;

			//Save the animation in an object using it's name as key.
			curAnimation = output[animation[1]] = {};

			while((keyframe = rxSingleKeyframe.exec(rawKeyframes[1])) !== null) {
				//Put all keyframes inside the animation using the keyframe (like botttom-top, or 100) as key
				//and the properties as value (just the raw string, newline stripped).
				curAnimation[keyframe[1]] = keyframe[2].replace(/[\n\r\t]/g, '');
			}
		}
	}
470197
def index(self):
        
        top, bottom = self.margins or Margins(0, self.lines - 1)
        if self.cursor.y == bottom:
            # TODO: mark only the lines within margins?
            self.dirty.update(range(self.lines))
            for y in range(top, bottom):
                self.buffer[y] = self.buffer[y + 1]
            self.buffer.pop(bottom, None)
        else:
            self.cursor_down()
688863
def saveToObject(self):
        """"""
        for i in range(self.ui.caleditorStack.count()):
            try:
                self.ui.caleditorStack.widget(i).saveToObject()
            except AttributeError:
                logger = logging.getLogger('main')
                logger.debug('index {} does not have method saveToObject'.format(i))
632626
def _grabix_index(data):
    
    in_file = data["bgzip_file"]
    config = data["config"]
    grabix = config_utils.get_program("grabix", config)
    gbi_file = _get_grabix_index(in_file)
    # We always build grabix input so we can use it for counting reads and doing downsampling
    if not gbi_file or _is_partial_index(gbi_file):
        if gbi_file:
            utils.remove_safe(gbi_file)
        else:
            gbi_file = in_file + ".gbi"
        with file_transaction(data, gbi_file) as tx_gbi_file:
            tx_in_file = os.path.splitext(tx_gbi_file)[0]
            utils.symlink_plus(in_file, tx_in_file)
            do.run([grabix, "index", tx_in_file], "Index input with grabix: %s" % os.path.basename(in_file))
    assert utils.file_exists(gbi_file)
    return [gbi_file]
1156172
def write_index(fn, index):
    
    with open(fn, "wb") as o_file:
        o_file.write(_CHECK_STRING)
        o_file.write(zlib.compress(bytes(
            index.to_csv(None, index=False, encoding="utf-8"),
            encoding="utf-8",
        )))
1158699
protected void fillIndexFromByteBuffer() {
        indexBuffer.rewind();
        for (int i = 0; i < numberOfChunks; i++) {
            maxKeyPerChunk[i] = new byte[keySize];
            indexBuffer.get(maxKeyPerChunk[i]);
            if (KeyUtils.isNull(maxKeyPerChunk[i]) && i > 0) {
                filledUpTo = i - 1;
                break;
            }
        }
    }
1158380
def index_map(data):
  """"""
  (entry, text_fn) = data
  text = text_fn()

  logging.debug("Got %s", entry.filename)
  for s in split_into_sentences(text):
    for w in split_into_words(s.lower()):
      yield (w, entry.filename)
1369092
function saveSlot(aList, bList, index, slot) {
	setEither(aList, bList, index, slot);

	var isInFirst = (index === 0 || index === aList.sizes.length);
	var len = isInFirst ? 0 : getEither(aList.sizes, bList.sizes, index - 1);

	setEither(aList.sizes, bList.sizes, index, len + length(slot));
}
1247003
def index_impute2(fn):
    
    logger.info("Indexing {} (IMPUTE2)".format(fn))
    impute2_index(fn, cols=[0, 1, 2], names=["chrom", "name", "pos"], sep=" ")
    logger.info("Index generated")
527745
def _flush_index(self):
        
        data = {'version': self.version, 'index': self._index}
        with open(self._get_path('index.json'), 'w') as f:
            json.dump(data, f)
        self.__index = None
1234165
def saveInputs(self, fname):
        
        # save current inputs to file for loading next time
        if not fname:
            return
            
        appdir = systools.get_appdir()
        if not os.path.isdir(appdir):
            os.makedirs(appdir)
        fname = os.path.join(appdir, fname)

        savedict = {}
        savedict['binsz'] = self.ui.binszSpnbx.value()
        savedict['aifs'] = self.ui.aifsSpnbx.value()
        savedict['tscale'] = self.tscale
        savedict['fscale'] = self.fscale
        savedict['saveformat'] = self.saveformat
        savedict['ex_nreps'] = self.ui.exploreStimEditor.repCount()
        savedict['reprate'] = self.ui.reprateSpnbx.value()
        savedict['windowsz'] = self.ui.windowszSpnbx.value()
        savedict['specargs'] = self.specArgs
        savedict['viewSettings'] = self.viewSettings
        savedict['calvals'] = self.calvals
        savedict['calparams'] = self.acqmodel.calibration_template()
        savedict['calreps'] = self.ui.calibrationWidget.ui.nrepsSpnbx.value()
        savedict['mphonesens'] = self.ui.mphoneSensSpnbx.value()
        savedict['mphonedb'] = self.ui.mphoneDBSpnbx.value()
        savedict['vocalpaths'] = Vocalization.paths
        savedict['aichans'] = self._aichans
        savedict['aichan_details'] = self._aichan_details

        # parameter settings -- save all tracks present
        savedict['explorestims'] = self.ui.exploreStimEditor.saveTemplate()

        savedict['advanced_options'] = self.advanced_options
        savedict['stim_view_defaults'] = StimulusView.getDefaults()

        savedict['tuning_curve'] = TCFactory.defaultInputs

        # filter out and non-native python types that are not json serializable
        savedict = convert2native(savedict)
        try:
            with open(fname, 'w') as jf:
                json.dump(savedict, jf)
        except:
            logger = logging.getLogger('main')
            logger.exception("Unable to save app data to file: {}".format(fname))