Takes one or two values in the domain and returns a LinearOrderedCell
        with the same domain
776651
def coerce(self, value):
        
        if isinstance(value, LinearOrderedCell) and (self.domain == value.domain or \
            list_diff(self.domain, value.domain) == []):
            # is LinearOrderedCell with same domain
            return value
        elif value in self.domain:
            return LinearOrderedCell(self.domain, value, value)
        elif isinstance(value, (list, tuple)) and all(map(value in self.domain, value)):
            if len(value) == 1:
                return LinearOrderedCell(self.domain, value[0], value[0])
            elif len(value) == 2:
                return LinearOrderedCell(self.domain, *value)
            else:
                sorted_vals = sorted(value, key=lambda x: self.to_i(x))
                return LinearOrderedCell(self.domain, sorted_vals[0], sorted_vals[-1])
        else:
            raise Exception("Cannot coerce %s into LinearOrderedCell" % (str(value)))
1183070
def _call(self, x, out=None):
        """"""
        if out is None:
            out = self.range.element()
        out.lincomb(self.a, x[0], self.b, x[1])
        return out
1158389
def get_cell(self, index, column):
        
        i = sorted_index(self._index, index) if self._sort else self._index.index(index)
        c = self._columns.index(column)
        return self._data[c][i]
280739
def getLeastUsedCell(self, c):
    """"""
    segmentsPerCell = numpy.zeros(self.cellsPerColumn, dtype='uint32')
    for i in range(self.cellsPerColumn):
      segmentsPerCell[i] = self.getNumSegmentsInCell(c,i)

    cellMinUsage = numpy.where(segmentsPerCell==segmentsPerCell.min())[0]
    # return cellMinUsage[0] # return the first cell with minimum usage

    # if multiple cells has minimum usage, randomly pick one
    self._random.getUInt32(len(cellMinUsage))
    return cellMinUsage[self._random.getUInt32(len(cellMinUsage))]
998428
function getRangeInformation(range, selectionMgr) {
  const $selectedCells = selectionMgr.getSelectedCells();
  let rangeInformation, startCell;

  if ($selectedCells.length) {
    rangeInformation = selectionMgr.getSelectionRangeFromTable($selectedCells.first().get(0),
      $selectedCells.last().get(0));
  } else {
    const {startContainer} = range;
    startCell = domUtil.isTextNode(startContainer) ? $(startContainer).parent('td,th')[0] : startContainer;
    rangeInformation = selectionMgr.getSelectionRangeFromTable(startCell, startCell);
  }

  return rangeInformation;
}
1028523
def _call(self, x, out=None):
        """"""
        if self.domain == self.range:
            if out is None:
                out = 0 * x
            else:
                out.lincomb(0, x)
        else:
            result = self.range.zero()
            if out is None:
                out = result
            else:
                out.assign(result)
        return out
1261565
def _call(self, x, out=None):
        """"""
        if self.domain.is_real:
            return self._call_real(x, out)

        elif self.domain.is_complex:
            result_parts = [
                self._call_real(x.real, getattr(out, 'real', None)),
                self._call_real(x.imag, getattr(out, 'imag', None))]

            if out is None:
                out = self.range.element()
                out.real = result_parts[0]
                out.imag = result_parts[1]

            return out

        else:
            raise RuntimeError('bad domain {!r}'.format(self.domain))
1111727
def flattened(self, order=None, include_smaller=True):
        """"""

        if order is None:
            order = self.order
        else:
            order = self._validate_order(order)

        # Start with the cells which are already at this order.
        flat = set(self[order])

        # Look at lower orders and expand them into this set.
        # Based on the "map" algorithm from Appendix A of the
        # MOC recommendation.
        for order_i in range(0, order):
            shift = 2 * (order - order_i)

            for cell in self[order_i]:
                flat.update(range(cell << shift, (cell + 1) << shift))

        # Look at higher orders unless we have been told to exclude
        # them.
        if include_smaller:
            for order_i in range(order + 1, MAX_ORDER + 1):
                shift = 2 * (order_i - order)

                for cell in self[order_i]:
                    flat.add(cell >> shift)

        return flat
1319936
def _order_as_range(order):
    """"""
    order = order.split('-')
    order = [int(o) for o in order]
    if len(order) > 1:
        order = range(order[0], (order[-1] + 1))
    return order
104271
def get_domain(self, value):
        
        return [k for k, v in self.all if v == value]
353984
def parse_cell(self, cell, coords, cell_mode=CellMode.cooked):
    """"""
    # pylint: disable=too-many-return-statements
    if cell_mode == CellMode.cooked:
      if cell.covered or cell.value_type is None or cell.value is None:
        return None

      vtype = cell.value_type

      if vtype == 'string':
        return cell.value

      if vtype == 'float' or vtype == 'percentage' or vtype == 'currency':
        return cell.value

      if vtype == 'boolean':
        return cell.value

      if vtype == 'date':
        date_tuple = tuple([int(i) if i is not None else 0 \
                            for i in _DATE_REGEX.match(cell.value).groups()])
        return self.tuple_to_datetime(date_tuple)

      if vtype == 'time':
        hour, minute, second = _TIME_REGEX.match(cell.value).groups()
        # TODO: This kills off the microseconds
        date_tuple = (0, 0, 0, int(hour), int(minute), round(float(second)))
        return self.tuple_to_datetime(date_tuple)

      raise ValueError("Unhandled cell type: {0}".format(vtype))
    else:
      return cell
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;
      }
    }
1179650
function(fn) {

                return function() {

                    var args = Array.from(arguments);
                    var n = args.length;
                    var cells = n > 0 && args[0] || [];
                    var opt = n > 1 && args[n - 1] || {};

                    if (!Array.isArray(cells)) {

                        if (opt instanceof joint.dia.Cell) {
                            cells = args;
                        } else if (cells instanceof joint.dia.Cell) {
                            if (args.length > 1) {
                                args.pop();
                            }
                            cells = args;
                        }
                    }

                    if (opt instanceof joint.dia.Cell) {
                        opt = {};
                    }

                    return fn.call(this, cells, opt);
                };
            }
605919
public static ICellValue from(Object o) {
        if (o == null) { return BLANK; }
        else if (o instanceof String) { return new CellValue(o, String.class); }
        else if (o instanceof Double) { return new CellValue(o, Double.class); }
        else if (o instanceof Integer) { return new CellValue(new Double((Integer) o)); }
        else if (o instanceof Boolean) { return new CellValue(o, Boolean.class); }

        throw new CalculationEngineException(String.format("The object %s of class %s is not supported as type for CellValue", o, o.getClass().getSimpleName()));
    }
1332242
def get_scalar(self, name, preference='cell', info=False):
        
        return get_scalar(self, name, preference=preference, info=info)
661762
def cells(options = {}, &block)
      cell_regex = /^cell_([0-9]+)_/

      options ||= { }

      result = block_given? ? yield : (options[:values] || [''])

      cell_options = result.map { {} }
      common_options = {}

      options.each do |k,v|
        # if the option starts with 'cell_#_' then apply it accordingly.
        if (m = cell_regex.match(k.to_s))
          k = k.to_s[m[0].length..-1].to_sym
          cell_options[m[1].to_i - 1][k] = v

        # the 'column' option applies only to the first cell.
        elsif k == :column
          cell_options[0][k] = v

        # everything else applies to all cells, unless overridden explicitly.
        elsif k != :values
          common_options[k] = v
        end
      end

      cell_options.each_with_index do |opt,idx|
        cell common_options.merge(opt).merge( { value: result[idx] } )
      end
    end
1072583
public Cell createCell(double value) {

        Cell cell = this.getNextCell(CellType.NUMERIC);
        cell.setCellValue(value);
        cell.setCellStyle(this.style.getNumberCs());
        return cell;
    }