helper function to set the internal representation of cells
337935
def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, style_name)
      key = [y, x + i]
      @cell_type[sheet] ||= {}
      @cell_type[sheet][key] = value_type.to_sym if value_type
      @formula[sheet] ||= {}
      if formula
        ['of:', 'oooc:'].each do |prefix|
          if formula[0, prefix.length] == prefix
            formula = formula[prefix.length..-1]
          end
        end
        @formula[sheet][key] = formula
      end
      @cell[sheet] ||= {}
      @style[sheet] ||= {}
      @style[sheet][key] = style_name
      case @cell_type[sheet][key]
      when :float
        @cell[sheet][key] = (table_cell.attributes['value'].to_s.include?(".") || table_cell.children.first.text.include?(".")) ? v.to_f : v.to_i
      when :percentage
        @cell[sheet][key] = v.to_f
      when :string
        @cell[sheet][key] = str_v
      when :date
        # TODO: if table_cell.attributes['date-value'].size != "XXXX-XX-XX".size
        if attribute(table_cell, 'date-value').size != 'XXXX-XX-XX'.size
          #-- dann ist noch eine Uhrzeit vorhanden
          #-- "1961-11-21T12:17:18"
          @cell[sheet][key]      = DateTime.parse(attribute(table_cell, 'date-value').to_s)
          @cell_type[sheet][key] = :datetime
        else
          @cell[sheet][key] = table_cell.attributes['date-value']
        end
      when :time
        hms = v.split(':')
        @cell[sheet][key] = hms[0].to_i * 3600 + hms[1].to_i * 60 + hms[2].to_i
      else
        @cell[sheet][key] = v
      end
    end
173075
function gridMesh(nx, ny, origin, dx, dy) {
  //Unpack default arguments
  origin = origin || [0,0]
  if(!dx || dx.length < origin.length) {
    dx = dup(origin.length)
    if(origin.length > 0) {
      dx[0] = 1
    }
  }
  if(!dy || dy.length < origin.length) {
    dy = dup(origin.length)
    if(origin.length > 1) {
      dy[1] = 1
    }
  }
  //Initialize cells
  var cells = []
    , positions = dup([(nx+1) * (ny+1), origin.length])
    , i, j, k, q, d = origin.length
  for(j=0; j<ny; ++j) {
    for(i=0; i<nx; ++i) {
      cells.push([ p(i,j,nx), p(i+1, j,nx), p(i, j+1,nx) ])
      cells.push([ p(i+1,j,nx), p(i+1,j+1,nx), p(i,j+1,nx) ])
    }
  }
  //Initialize positions
  for(j=0; j<=ny; ++j) {
    for(i=0; i<=nx; ++i) {
      q = positions[ p(i, j, nx) ]
      for(k=0; k<d; ++k) {
        q[k] = origin[k] + dx[k] * i + dy[k] * j
      }
    }
  }
  return {
    positions: positions,
    cells: cells
  }
}
581633
function setCell(map, key, columnCount, columnIndex, value) {
  if (!map.has(key)) map.set(key, new Array(columnCount));
  map.get(key)[columnIndex] = value;
}
229303
def cell_type_specificity(ax):
    ''''''
    masked_array = np.ma.array(params.T_yX, mask=params.T_yX==0)
    # cmap = plt.get_cmap('hot', 20)
    # cmap.set_bad('k', 0.5)
    # im = ax.imshow(masked_array, cmap=cmap, vmin=0, interpolation='nearest')
    im = ax.pcolormesh(masked_array, cmap=cmap, vmin=0, ) #interpolation='nearest')
    ax.axis(ax.axis('tight'))
    ax.invert_yaxis()
    ax.xaxis.set_ticks_position('top')
    ax.set_xticks(np.arange(9)+0.5)
    ax.set_yticks(np.arange(16)+0.5)
    ax.set_xticklabels(params.X, rotation=270)
    ax.set_yticklabels(params.y, )
    ax.xaxis.set_label_position('top')
    ax.set_xlabel(r'$X$', labelpad=-1,fontsize=8)
    ax.set_ylabel(r'$y$', labelpad=0, rotation=0,fontsize=8)

    rect = np.array(ax.get_position().bounds)
    rect[0] += rect[2] + 0.01
    rect[2] = 0.01
    fig = plt.gcf()
    cax = fig.add_axes(rect)

    cbar = plt.colorbar(im, cax=cax)
    #cbar.set_label(r'$\mathcal{T}_{yX}$', ha='center')
    cbar.set_label(r'$\mathcal{T}_{yX}$', labelpad=0)
1183631
function (startCell, endCell, callback) {
      var result = {
        index: [], // list of cell index: A1, A2, A3
        value: []  // list of cell value
      };

      var cols = {
        start: 0,
        end: 0
      };

      if (endCell.col >= startCell.col) {
        cols = {
          start: startCell.col,
          end: endCell.col
        };
      } else {
        cols = {
          start: endCell.col,
          end: startCell.col
        };
      }

      var rows = {
        start: 0,
        end: 0
      };

      if (endCell.row >= startCell.row) {
        rows = {
          start: startCell.row,
          end: endCell.row
        };
      } else {
        rows = {
          start: endCell.row,
          end: startCell.row
        };
      }

      for (var column = cols.start; column <= cols.end; column++) {
        for (var row = rows.start; row <= rows.end; row++) {
          var cellIndex = instance.utils.toChar(column) + (row + 1),
              cellValue = instance.helper.cellValue.call(this, cellIndex);

          result.index.push(cellIndex);
          result.value.push(cellValue);
        }
      }

      if (instance.utils.isFunction(callback)) {
        return callback.apply(callback, [result]);
      } else {
        return result;
      }
    }
63467
function _addMergedCell(base, cellData, startRowIndex, startCellIndex) {
  const {
    colspan,
    rowspan,
    nodeName
  } = cellData;
  const colMerged = colspan > 1;
  const rowMerged = rowspan > 1;

  if (!colMerged && !rowMerged) {
    return;
  }

  const limitRowIndex = startRowIndex + rowspan;
  const limitCellIndex = startCellIndex + colspan;

  util.range(startRowIndex, limitRowIndex).forEach(rowIndex => {
    base[rowIndex] = base[rowIndex] || [];

    util.range(startCellIndex, limitCellIndex).forEach(cellIndex => {
      const mergedData = {
        nodeName
      };

      if (rowIndex === startRowIndex && cellIndex === startCellIndex) {
        return;
      }

      if (colMerged) {
        mergedData.colMergeWith = startCellIndex;
      }

      if (rowMerged) {
        mergedData.rowMergeWith = startRowIndex;
      }

      base[rowIndex][cellIndex] = mergedData;
    });
  });
}
945100
def get_cell_boundary_map(ds):
    '''
    
    '''
    boundary_map = {}
    for variable in ds.get_variables_by_attributes(bounds=lambda x: x is not None):
        if variable.bounds in ds.variables:
            boundary_map[variable.name] = variable.bounds
    return boundary_map
97128
function cellref (ref) {
  if (R1C1.test(ref)) {
    return convertR1C1toA1(ref)
  }

  if (A1.test(ref)) {
    return convertA1toR1C1(ref)
  }

  throw new Error(`could not detect cell reference notation for ${ref}`)
}
1304971
def filtered_cell(cell, preserve_outputs, cell_metadata_filter):
    """"""
    metadata = copy(cell.metadata)
    filter_metadata(metadata, cell_metadata_filter, _IGNORE_CELL_METADATA)

    filtered = {'cell_type': cell.cell_type,
                'source': cell.source,
                'metadata': metadata}

    if preserve_outputs:
        for key in ['execution_count', 'outputs']:
            if key in cell:
                filtered[key] = cell[key]

    return filtered
573975
function Cell(north, east, south, west) {
    this._north = north;
    this._east = east;
    this._south = south;
    this._west = west;
}
637095
def set_main_and_cell_language(metadata, cells, ext):
    """"""
    main_language = (metadata.get('kernelspec', {}).get('language') or
                     metadata.get('jupytext', {}).get('main_language') or
                     _SCRIPT_EXTENSIONS.get(ext, {}).get('language'))

    if main_language is None:
        languages = {'python': 0.5}
        for cell in cells:
            if 'language' in cell['metadata']:
                language = cell['metadata']['language']
                languages[language] = languages.get(language, 0.0) + 1

        main_language = max(languages, key=languages.get)

    # save main language when no kernel is set
    if 'language' not in metadata.get('kernelspec', {}):
        metadata.setdefault('jupytext', {})['main_language'] = main_language

    # Remove 'language' meta data and add a magic if not main language
    for cell in cells:
        if 'language' in cell['metadata']:
            language = cell['metadata'].pop('language')
            if language != main_language and language in _JUPYTER_LANGUAGES:
                if 'magic_args' in cell['metadata']:
                    magic_args = cell['metadata'].pop('magic_args')
                    cell['source'] = u'%%{} {}\n'.format(language, magic_args) + cell['source']
                else:
                    cell['source'] = u'%%{}\n'.format(language) + cell['source']
1162682
def preprocess_cell(self, cell, resources, cell_index):
        """"""
        from nbformat.notebooknode import NotebookNode

        attach_names = []

        # Just move the attachment into an output

        for k, attach in cell.get('attachments', {}).items():
            for mime_type in self.extract_output_types:
                if mime_type in attach:

                    if not 'outputs' in cell:
                        cell['outputs'] = []

                    o = NotebookNode({
                        'data': NotebookNode({mime_type: attach[mime_type]}),
                        'metadata': NotebookNode({
                            'filenames': {mime_type: k}  # Will get re-written
                        }),
                        'output_type': 'display_data'
                    })

                    cell['outputs'].append(o)

                    attach_names.append((mime_type, k))

        nb, resources = super().preprocess_cell(cell, resources, cell_index)

        output_names = list(resources.get('outputs', {}).keys())

        if attach_names:
            # We're going to assume that attachments are only on Markdown cells, and Markdown cells
            # can't generate output, so all of the outputs wee added.

            # reverse + zip matches the last len(attach_names) elements from output_names

            for output_name, (mimetype, an) in zip(reversed(output_names), reversed(attach_names)):
                # We'll post process to set the final output directory
                cell.source = re.sub('\(attachment:{}\)'.format(an),
                                     '(__IMGDIR__/{})'.format(output_name), cell.source)

        return nb, resources
110339
function(cells, opt) {

        var preparedCells = joint.util.toArray(cells).map(function(cell) {
            return this._prepareCell(cell, opt);
        }, this);
        this.get('cells').reset(preparedCells, opt);

        return this;
    }
215877
function _setState (lattice, size) {
    for (var num = 0; num < size; num++) {
      var cell = {}
      cell.state = getRandomState()
      lattice.push(cell)
    }

    return lattice
  }
8479
private void internalAdd(Cell cell)
    {
        if (cells.length == size)
            cells = Arrays.copyOf(cells, Math.max(MINIMAL_CAPACITY, size * 3 / 2 + 1));
        cells[size++] = cell;
    }
721671
function convertArrayCell (cell) {
  const {item} = cell
  const arrayOptions = _.chain(item)
  .pick(ARRAY_CELL_PROPERTIES)
  .assign({
    itemCell: convertCell(item)
  })
  .value()
  return {
    arrayOptions,
    model: cell.model
  }
}
1111943
function cloneCells(cells) {
  var ncells = new Array(cells.length)
  for(var i=0, il=cells.length; i<il; ++i) {
    ncells[i] = cells[i].slice(0)
  }
  return ncells
}