text:
QUnit.module("Image Processing", {});

QUnit.test("test_imgProc", function(assert) {
 // calcHist
  {
    var aa = 1;
    var source = new cv.MatVector();
    var channels = new cv.IntVector();
    var histSize = new cv.IntVector();
    var ranges = new cv.FloatVector();

    //var vec0 = new cv.Mat.zeros([20, 20], cv.CV_8UC1);
    var vec1 = new cv.Mat.ones([20, 20], cv.CV_8UC1);
    //source.push_back(vec0);
    source.push_back(vec1);
    channels.push_back(0);
    histSize.push_back(256);
    ranges.push_back(0); ranges.push_back(256);

    let hist = new cv.Mat();
    let mask = new cv.Mat();
    let binSize = cv._malloc(4);
    let binView = new Int32Array(cv.HEAP8.buffer, binSize);
    // Or, let binView = cv.HEAP32.subarray(binSize >> 2);
    binView[0] = 10;
    // TBD
    // float **: change this parameter to vector?
    cv.calcHist(source, channels, mask, hist, histSize, ranges, false);

    // hist should contains a N X 1 arrary.
    let size = hist.size();
    assert.equal(size.size(), 2);
    assert.equal(size.get(0), 256);
    assert.equal(size.get(1), 1);

    // Do we need to verify data in histogram?
    let dataView = hist.data();

    // Free resource
    cv._free(binSize);
    mask.delete();
    hist.delete();
    source.delete();
  }

  // C++
  //   void cvtColor(InputArray, OutputArray, int, int)
  // Embind
  //   void cvtColor(const Mat &, Mat &, int, int);
  {
    let source = new cv.Mat(10, 10, cv.CV_8UC3);
    let dest = new cv.Mat();

    cv.cvtColor(source, dest, cv.ColorConversionCodes.COLOR_BGR2GRAY.value, 0);
    assert.equal(dest.channels(), 1);

    cv.cvtColor(source, dest, cv.ColorConversionCodes.COLOR_BGR2BGRA.value, 0);
    assert.equal(dest.channels(), 4);

    dest.delete();
    source.delete();
  }
  // C++
  //   void equalizeHist(InputArray, OutputArray);
  // Embind
  //   void equalizeHist(const Mat &, Mat &);
  {
    let source = new cv.Mat(10, 10, cv.CV_8UC1);
    let dest = new cv.Mat();

    cv.equalizeHist(source, dest);

    // eualizeHist changes the content of a image, but does not alter meta data
    // of it.
    assert.equal(source.channels(), dest.channels());
    assert.equal(source.type(), dest.type());
    assert.equal(source.size().size(), dest.size().size());
    // Varifiy content>

    dest.delete();
    source.delete();
  }
});

QUnit.test("test_segmentation", function(assert) {
  const THRESHOLD = 127.0;
  const THRESHOLD_MAX = 210.0;

  // C++
  //   double threshold(InputArray, OutputArray, double, double, int)
  // Embind
  //   double threshold(const Mat&, Mat&, double, double, int)
  {
    let source = new cv.Mat(1, 5, cv.CV_8UC1);
    let sourceView = source.data();
    sourceView[0] = 0;   // < threshold
    sourceView[1] = 100; // < threshold
    sourceView[2] = 200; // > threshold

    let dest = new cv.Mat();

    cv.threshold(source, dest, THRESHOLD, THRESHOLD_MAX, cv.ThresholdTypes.THRESH_BINARY.value);

    let destView = dest.data();
    assert.equal(destView[0], 0);
    assert.equal(destView[1], 0);
    assert.equal(destView[2], THRESHOLD_MAX);
  }

  // C++
  //   void adaptiveThreshold(InputArray, OutputArray, double, int, int, int, double);
  // Embind
  //   void adaptiveThreshold(const Mat &, Mat &, double, int, int, int, double);
  {
    let source = cv.Mat.zeros(1, 5, cv.CV_8UC1);
    let sourceView = source.data();
    sourceView[0] = 50;
    sourceView[1] = 150;
    sourceView[2] = 200;

    let dest = new cv.Mat();
    let C = 0;
    const block_size = 3;
    cv.adaptiveThreshold(source, dest, THRESHOLD_MAX,
        cv.AdaptiveThresholdTypes.ADAPTIVE_THRESH_MEAN_C.value,
        cv.ThresholdTypes.THRESH_BINARY.value, block_size, C);

    let destView = dest.data();
    assert.equal(destView[0], 0);
    assert.equal(destView[1], THRESHOLD_MAX);
    assert.equal(destView[2], THRESHOLD_MAX);
  }
});

QUnit.test("test_filter", function(assert) {
  // C++
  //   void blur(InputArray, OutputArray, Size ksize, Point, int);
  // Embind
  //   void blur(const Mat &, Mat &, Size ksize, Point, int);
  {
      let mat1 = cv.Mat.ones(5, 5, cv.CV_8UC3);
      let mat2 = new cv.Mat();

      cv.blur(mat1, mat2, [3, 3], [-1, -1], cv.BORDER_DEFAULT);

      // Verify result.
      let view = mat2.data();
      let size = mat2.size();
      assert.equal(mat2.channels(), 3);
      assert.equal(size.get(0), 5);
      assert.equal(size.get(1), 5);
  }
  // C++
  //  void GaussianBlur(InputArray, OutputArray, Size, double, double, int);
  // Embind
  //  void GaussianBlur(Mat &, Mat&, Size, double, double, int);
  {
      let mat1 = cv.Mat.ones(7, 7, cv.CV_8UC1);
      let mat2 = new cv.Mat();

      cv.GaussianBlur(mat1, mat2, [3, 3], 0, 0, cv.BORDER_DEFAULT);

      // Verify result.
      let view = mat2.data();
      let size = mat2.size();
      assert.equal(mat2.channels(), 1);
      assert.equal(size.get(0), 7);
      assert.equal(size.get(1), 7);
  }

  // C++
  //   void medianBlur(InputArray, OutputArray, int);
  // Embind
  //   void medianBlur(Mat &, Mat &, int);
  {
      let mat1 = cv.Mat.ones(9, 9, cv.CV_8UC3);
      let mat2 = new cv.Mat();

      cv.medianBlur(mat1, mat2, 3);

      // Verify result.
      let view = mat2.data();
      let size = mat2.size();
      assert.equal(mat2.channels(), 3);
      assert.equal(size.get(0), 9);
      assert.equal(size.get(1), 9);
  }

  // Transpose
  {
      let mat1 = cv.Mat.eye(9, 9, cv.CV_8UC3);
      let mat2 = new cv.Mat();

      cv.transpose(mat1, mat2);

      // Verify result.
      let view = mat2.data();
      let size = mat2.size();
      assert.equal(mat2.channels(), 3);
      assert.equal(size.get(0), 9);
      assert.equal(size.get(1), 9);
  }

  // C++
  //   void bilateralFilter(InputArray, OutputArray, int, double, double, int borderType);
  // Embind
  //   void bilateralFilter(Mat &, Mat &, int, double, double, int borderType);
  {
      let mat1 = cv.Mat.ones(11, 11, cv.CV_8UC3);
      let mat2 = new cv.Mat();

      cv.bilateralFilter(mat1, mat2, 3, 6, 1.5, cv.BORDER_DEFAULT);

      // Verify result.
      let view = mat2.data();
      let size = mat2.size();
      assert.equal(mat2.channels(), 3);
      assert.equal(size.get(0), 11);
      assert.equal(size.get(1), 11);

  }

  // Watershed
  {
      let mat = cv.Mat.ones(11, 11, cv.CV_8UC3);
      let out = new cv.Mat(11, 11, cv.CV_32SC1);

      cv.watershed(mat, out);

      // Verify result.
      let size = out.size();
      assert.equal(out.channels(), 1);
      assert.equal(size.get(0), 11);
      assert.equal(size.get(1), 11);
      assert.equal(out.elemSize1(), 4);

      mat.delete();
      out.delete();
  }

  // Concat
  {
      let mat = cv.Mat.ones([10, 5], cv.CV_8UC3);
      let mat2 = cv.Mat.eye([10, 5], cv.CV_8UC3);
      let mat3 = cv.Mat.eye([10, 5], cv.CV_8UC3);

      let out = new cv.Mat();
      let input = new cv.MatVector();
      input.push_back(mat);
      input.push_back(mat2);
      input.push_back(mat3);

      cv.vconcat(input, out);

      // Verify result.
      let size = out.size();
      assert.equal(out.channels(), 3);
      assert.equal(size.get(0), 30);
      assert.equal(size.get(1), 5);
      assert.equal(out.elemSize1(), 1);

      cv.hconcat(input, out);

      // Verify result.
      size = out.size();
      assert.equal(out.channels(), 3);
      assert.equal(size.get(0), 10);
      assert.equal(size.get(1), 15);
      assert.equal(out.elemSize1(), 1);

      mat.delete();
      mat2.delete();
      mat3.delete();
      out.delete();
      input.delete();
  }

  // distanceTransform variants
  {
      let mat = cv.Mat.ones(11, 11, cv.CV_8UC1);
      let out = new cv.Mat(11, 11, cv.CV_32FC1);
      let labels = new cv.Mat(11, 11, cv.CV_32FC1);
      let maskSize = 3;
      cv.distanceTransform(mat, out, cv.DistanceTypes.DIST_L2.value, maskSize, cv.CV_32F);

      // Verify result.
      let size = out.size();
      assert.equal(out.channels(), 1);
      assert.equal(size.get(0), 11);
      assert.equal(size.get(1), 11);
      assert.equal(out.elemSize1(), 4);

      cv.distanceTransformWithLabels(mat, out, labels, cv.DistanceTypes.DIST_L2.value, maskSize, cv.DistanceTransformLabelTypes.DIST_LABEL_CCOMP.value);

      // Verify result.
      size = out.size();
      assert.equal(out.channels(), 1);
      assert.equal(size.get(0), 11);
      assert.equal(size.get(1), 11);
      assert.equal(out.elemSize1(), 4);

      size = labels.size();
      assert.equal(labels.channels(), 1);
      assert.equal(size.get(0), 11);
      assert.equal(size.get(1), 11);
      assert.equal(labels.elemSize1(), 4);

      mat.delete();
      out.delete();
      labels.delete();
  }

  // Min, Max
  {
      var data1 = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9]);
      var data2 = new Uint8Array([0, 4, 0, 8, 0, 12, 0, 16, 0]);

      var expectedMin = new Uint8Array([0, 2, 0, 4, 0, 6, 0, 8, 0]);
      var expectedMax = new Uint8Array([1, 4, 3, 8, 5, 12, 7, 16, 9]);

      var dataPtr = cv._malloc(3*3*1);
      var dataPtr2 = cv._malloc(3*3*1);

      var dataHeap = new Uint8Array(cv.HEAPU8.buffer, dataPtr, 3*3*1);
      dataHeap.set(new Uint8Array(data1.buffer));

      var dataHeap2 = new Uint8Array(cv.HEAPU8.buffer, dataPtr2, 3*3*1);
      dataHeap2.set(new Uint8Array(data2.buffer));

      let mat1 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr, 0);
      let mat2 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr2, 0);

      let mat3 = new cv.Mat();

      cv.min(mat1, mat2, mat3);
      // Verify result.
      let view = mat2.data();
      let size = mat2.size();
      assert.equal(mat2.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data(), expectedMin);

      cv.max(mat1, mat2, mat3);
      // Verify result.
      view = mat2.data();
      size = mat2.size();
      assert.equal(mat2.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data(), expectedMax);

      cv._free(dataPtr);
      cv._free(dataPtr2);
  }

  // Bitwise operations
  {
      var data1 = new Uint8Array([0, 1, 2, 4, 8, 16, 32, 64, 128]);
      var data2 = new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255]);

      var expectedAnd = new Uint8Array([0, 1, 2, 4, 8, 16, 32, 64, 128]);
      var expectedOr = new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255]);
      var expectedXor = new Uint8Array([255, 254, 253, 251, 247, 239, 223, 191, 127]);

      var expectedNot = new Uint8Array([255, 254, 253, 251, 247, 239, 223, 191, 127]);

      var dataPtr = cv._malloc(3*3*1);
      var dataPtr2 = cv._malloc(3*3*1);

      var dataHeap = new Uint8Array(cv.HEAPU8.buffer, dataPtr, 3*3*1);
      dataHeap.set(new Uint8Array(data1.buffer));

      var dataHeap2 = new Uint8Array(cv.HEAPU8.buffer, dataPtr2, 3*3*1);
      dataHeap2.set(new Uint8Array(data2.buffer));

      let mat1 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr, 0);
      let mat2 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr2, 0);

      let mat3 = new cv.Mat();
      let none = new cv.Mat();

      cv.bitwise_not(mat1, mat3, none);
      // Verify result.
      let view = mat3.data();
      let size = mat3.size();
      assert.equal(mat3.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data(), expectedNot);

      cv.bitwise_and(mat1, mat2, mat3, none);
      // Verify result.
      view = mat3.data();
      size = mat3.size();
      assert.equal(mat3.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data(), expectedAnd);

      cv.bitwise_or(mat1, mat2, mat3, none);
      // Verify result.
      view = mat3.data();
      size = mat3.size();
      assert.equal(mat3.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data(), expectedOr);

      cv.bitwise_xor(mat1, mat2, mat3, none);
      // Verify result.
      size = mat3.size();
      assert.equal(mat3.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data(), expectedXor);

      cv._free(dataPtr);
      cv._free(dataPtr2);
  }

  // Acc
  {
      var data1 = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8]);
      var data2 = new Uint8Array([0, 2, 4, 6, 8, 10, 12, 14, 16]);
      var data3 = new Float32Array([0, 1, 0, 1, 0, 1, 0, 1, 0]);

      // data3 += data1
      var expectedAcc = new Float32Array([0, 2, 2, 4, 4, 6, 6, 8, 8]);
      // data3 += data1*data2
      var expectedAccMul = new Float32Array([0, 3, 8, 19, 32, 51, 72, 99, 128]);
      // data3 += data1*data1
      var expectedAccSquare = new Float32Array([0, 3, 8, 15, 24, 37, 48, 63, 80]);

      var dataPtr1 = cv._malloc(3*3*1);
      var dataPtr2 = cv._malloc(3*3*1);
      var dataPtr3 = cv._malloc(3*3*4);

      var dataHeap = new Uint8Array(cv.HEAPU8.buffer, dataPtr1, 3*3*1);
      dataHeap.set(new Uint8Array(data1.buffer));
      dataHeap = new Uint8Array(cv.HEAPU8.buffer, dataPtr2, 3*3*1);
      dataHeap.set(new Uint8Array(data2.buffer));
      dataHeap = new Uint8Array(cv.HEAPU8.buffer, dataPtr3, 3*3*4);
      dataHeap.set(new Uint8Array(data3.buffer));

      let mat1 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr1, 0);
          mat2 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr2, 0),
          mat3 = new cv.Mat([3, 3], cv.CV_32FC1, dataPtr3, 0),
          none = new cv.Mat();

      let mat4 = mat3.clone();
      cv.accumulate(mat1, mat4, none);
      // Verify result.
      size = mat4.size();
      assert.equal(mat4.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat4.data32f(), expectedAcc);

      cv.accumulateProduct(mat1, mat2, mat3, none);
      // Verify result.
      size = mat3.size();
      assert.equal(mat3.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(mat3.data32f(), expectedAccMul);

  }
  // Arithmatic operations
  {
      var data1 = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8]);
      var data2 = new Uint8Array([0, 2, 4, 6, 8, 10, 12, 14, 16]);
      var data3 = new Uint8Array([0, 1, 0, 1, 0, 1, 0, 1, 0]);

      // |data1 - data2|
      var expectedAbsDiff = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 8]);
      var expectedAdd = new Uint8Array([0, 3, 6, 9, 12, 15, 18, 21, 24]);

      // data2 += data1
      var expectedAcc = new Uint8Array([0, 3, 6, 9, 12, 15, 18, 21, 24]);
      // data3 += data1*data2
      var expectedAccMul = new Uint8Array([0, 3, 8, 19, 12, 16, 72, 99, 128]);
      // data2 += data1*data1
      var expectedAccSquare = new Uint8Array([0, 3, 8, 15, 24, 37, 48, 63, 80]);

      let alpha = 4,
          beta = -1,
          gamma = 3;
      // 4*data1 - data2 + 3
      var expectedWeightedAdd = new Uint8Array([3, 5, 7, 9, 11, 13, 15, 17, 19]);

      var dataPtr = cv._malloc(3*3*1);
      var dataPtr2 = cv._malloc(3*3*1);
      var dataPtr3 = cv._malloc(3*3*1);

      var dataHeap = new Uint8Array(cv.HEAPU8.buffer, dataPtr, 3*3*1);
      dataHeap.set(new Uint8Array(data1.buffer));
      var dataHeap2 = new Uint8Array(cv.HEAPU8.buffer, dataPtr2, 3*3*1);
      dataHeap2.set(new Uint8Array(data2.buffer));
      var dataHeap3 = new Uint8Array(cv.HEAPU8.buffer, dataPtr3, 3*3*1);
      dataHeap3.set(new Uint8Array(data3.buffer));

      let mat1 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr, 0);
      let mat2 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr2, 0);
      let mat3 = new cv.Mat([3, 3], cv.CV_8UC1, dataPtr3, 0);

      let dst = new cv.Mat();
      let none = new cv.Mat();

      cv.absdiff(mat1, mat2, dst);
      // Verify result.
      let view = dst.data();
      let size = dst.size();
      assert.equal(dst.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(dst.data(), expectedAbsDiff);

      cv.add(mat1, mat2, dst, none, -1);
      // Verify result.
      view = dst.data();
      size = dst.size();
      assert.equal(dst.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(dst.data(), expectedAdd);

      cv.addWeighted(mat1, alpha, mat2, beta, gamma, dst, -1);
      // Verify result.
      view = dst.data();
      size = dst.size();
      assert.equal(dst.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);

      assert.deepEqual(dst.data(), expectedWeightedAdd);

      mat1.delete();
      mat2.delete();
      mat3.delete();
      none.delete();
  }

  // getStructuringElement, Erode, dilate
  {
      let mat1 = cv.Mat.ones([100, 100], cv.CV_8UC3);
      let mat2 = new cv.Mat();
      let size = 3;

      let element = cv.getStructuringElement(cv.MorphShapes.MORPH_RECT.value,
                                        [2*size + 1, 2*size+1 ],
                                        [size, size] );

      cv.erode(mat1, mat2, element, [-1, -1], 1, cv.BORDER_CONSTANT, cv.Scalar.all(Number.MAX_VALUE));

      // Verify result.
      let view = mat2.data();
      let matSize = mat2.size();
      assert.equal(mat2.channels(), 3);
      assert.equal(matSize.get(0), 100);
      assert.equal(matSize.get(1), 100);

      element = cv.getStructuringElement(cv.MorphShapes.MORPH_ELLIPSE.value,
                                       [2*size + 1, 2*size+1],
                                       [size, size] );
      cv.dilate(mat1, mat2, element, [-1, -1], 1, cv.BORDER_CONSTANT, cv.Scalar.all(Number.MAX_VALUE));
      // Verify result.
      view = mat2.data();
      matSize = mat2.size();
      assert.equal(mat2.channels(), 3);
      assert.equal(matSize.get(0), 100);
      assert.equal(matSize.get(1), 100);

      mat1.delete();
      mat2.delete();
      element.delete();
  }

  // Integral variants
  {
      let mat = cv.Mat.eye([100, 100], cv.CV_8UC3);
      let sum = new cv.Mat();
      let sqSum = new cv.Mat();
      let title = new cv.Mat();

      cv.integral(mat, sum, -1);

      // Verify result.
      let size = sum.size();
      assert.equal(sum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      cv.integral2(mat, sum, sqSum, -1, -1);
      // Verify result.
      size = sum.size();
      assert.equal(sum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      size = sqSum.size();
      assert.equal(sqSum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      cv.integral3(mat, sum, sqSum, title, -1, -1);
      // Verify result.
      size = sum.size();
      assert.equal(sum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      size = sqSum.size();
      assert.equal(sqSum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      size = title.size();
      assert.equal(title.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      mat.delete();
      sum.delete();
      sqSum.delete();
      title.delete();
  }

  // Mean, meanSTDev
  {
      let mat = cv.Mat.eye([100, 100], cv.CV_8UC3);
      let sum = new cv.Mat();
      let sqSum = new cv.Mat();
      let title = new cv.Mat();

      cv.integral(mat, sum, -1);

      // Verify result.
      let size = sum.size();
      assert.equal(sum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      cv.integral2(mat, sum, sqSum, -1, -1);
      // Verify result.
      size = sum.size();
      assert.equal(sum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      size = sqSum.size();
      assert.equal(sqSum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      cv.integral3(mat, sum, sqSum, title, -1, -1);
      // Verify result.
      size = sum.size();
      assert.equal(sum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      size = sqSum.size();
      assert.equal(sqSum.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      size = title.size();
      assert.equal(title.channels(), 3);
      assert.equal(size.get(0), 100+1);
      assert.equal(size.get(1), 100+1);

      mat.delete();
      sum.delete();
      sqSum.delete();
      title.delete();
  }

  // Invert
  {
      let inv1 = new cv.Mat(),
          inv2 = new cv.Mat(),
          inv3 = new cv.Mat(),
          inv4 = new cv.Mat();

      var data1 = new Float32Array([1, 0, 0,
                                    0, 1, 0,
                                    0, 0, 1]);
      var data2 = new Float32Array([0, 0, 0,
                                    0, 5, 0,
                                    0, 0, 0]);
      var data3 = new Float32Array([1, 1, 1, 0,
                                    0, 3, 1, 2,
                                    2, 3, 1, 0,
                                    1, 0, 2, 1]);
      var data4 = new Float32Array([1, 4, 5,
                                    4, 2, 2,
                                    5, 2, 2]);

      var expected1 = new Float32Array([1, 0, 0,
                                        0, 1, 0,
                                        0, 0, 1]);
      // Inverse does not exist!
      var expected2 = new Float32Array([1, 0, 0,
                                        0, 0, 0,
                                        0, 0, 1]);
      var expected3 = new Float32Array([-3, -1/2, 3/2, 1,
                                        1, 1/4, -1/4, -1/2,
                                        3, 1/4, -5/4, -1/2,
                                        -3, 0, 1, 1]);
      var expected4 = new Float32Array([0, -1, 1,
                                        -1, 23/2, -9,
                                        1, -9, 7]);

      var dataPtr1 = cv._malloc(3*3*4);
      var dataPtr2 = cv._malloc(3*3*4);
      var dataPtr3 = cv._malloc(4*4*4);
      var dataPtr4 = cv._malloc(3*3*4);

      var dataHeap = new Float32Array(cv.HEAP32.buffer, dataPtr1, 3*3);
      dataHeap.set(new Float32Array(data1.buffer));
      var dataHeap2 = new Float32Array(cv.HEAP32.buffer, dataPtr2, 3*3);
      dataHeap2.set(new Float32Array(data2.buffer));
      var dataHeap3 = new Float32Array(cv.HEAP32.buffer, dataPtr3, 4*4);
      dataHeap3.set(new Float32Array(data3.buffer));
      var dataHeap4 = new Float32Array(cv.HEAP32.buffer, dataPtr4, 3*3);
      dataHeap4.set(new Float32Array(data4.buffer));

      let mat1 = new cv.Mat([3, 3], cv.CV_32FC1, dataPtr1, 0);
      let mat2 = new cv.Mat([3, 3], cv.CV_32FC1, dataPtr2, 0);
      let mat3 = new cv.Mat([4, 4], cv.CV_32FC1, dataPtr3, 0);
      let mat4 = new cv.Mat([3, 3], cv.CV_32FC1, dataPtr4, 0);

      let dst = new cv.Mat();
      let none = new cv.Mat();

      QUnit.assert.deepEqualWithTolerance = function( value, expected, tolerance ) {
        for (i = 0 ; i < value.length; i= i+1) {
          this.pushResult( {
              result: Math.abs(value[i]-expected[i]) < tolerance,
              actual: value[i],
              expected: expected[i],
//              message: message
          } );
        }
      };

      // DECOMP_LU       = 0
      // DECOMP_SVD      = 1

      // Matrix must be symmetric
      // DECOMP_EIG      = 2
      // DECOMP_CHOLESKY = 3

      cv.invert(mat1, inv1, 0);
      // Verify result.
      let size = inv1.size();
      assert.equal(inv1.channels(), 1);
      assert.equal(size.get(0), 3);
      assert.equal(size.get(1), 3);
      assert.deepEqualWithTolerance(inv1.data32f(), expected1, 0.0001);

      cv.invert(mat2, inv2, 0);
      // Verify result.
      assert.deepEqualWithTolerance(inv3.data32f(), expected3, 0.0001);

      cv.invert(mat3, inv3, 0);
      // Verify result.
      size = inv3.size();
      assert.equal(inv3.channels(), 1);
      assert.equal(size.get(0), 4);
      assert.equal(size.get(1), 4);
      assert.deepEqualWithTolerance(inv3.data32f(), expected3, 0.0001);
      console.log(inv3.data32f());

      cv.invert(mat3, inv3, 1);
      // Verify result.
      assert.deepEqualWithTolerance(inv3.data32f(), expected3, 0.0001);

      cv.invert(mat4, inv4, 2);
      // Verify result.
      assert.deepEqualWithTolerance(inv4.data32f(), expected4, 0.0001);

      cv.invert(mat4, inv4, 3);
      // Verify result.
      assert.deepEqualWithTolerance(inv4.data32f(), expected4, 0.0001);

      mat1.delete();
      mat2.delete();
      mat3.delete();
      mat4.delete();
      inv1.delete();
      inv2.delete();
      inv3.delete();
      inv4.delete();
  }

/*
  function("Canny", select_overload<void(const cv::Mat&, cv::Mat&, double, double, int, bool)>(&Wrappers::Canny_wrapper));
  function("HoughCircles", select_overload<void(const cv::Mat&, cv::Mat&, int, double, double, double, double, int, int)>(&Wrappers::HoughCircles_wrapper));
  function("HoughLines", select_overload<void(const cv::Mat&, cv::Mat&, double, double, int, double, double, double, double)>(&Wrappers::HoughLines_wrapper));
  function("HoughLinesP", select_overload<void(const cv::Mat&, cv::Mat&, double, double, int, double, double)>(&Wrappers::HoughLinesP_wrapper));
  function("HuMoments", select_overload<void(const Moments&, cv::Mat&)>(&Wrappers::HuMoments_wrapper));
  function("LUT", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::LUT_wrapper));
  function("Laplacian", select_overload<void(const cv::Mat&, cv::Mat&, int, int, double, double, int)>(&Wrappers::Laplacian_wrapper));
  function("Mahalanobis", select_overload<double(const cv::Mat&, const cv::Mat&, const cv::Mat&)>(&Wrappers::Mahalanobis_wrapper));
  function("PCABackProject", select_overload<void(const cv::Mat&, const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::PCABackProject_wrapper));
  function("PCACompute", select_overload<void(const cv::Mat&, cv::Mat&, cv::Mat&, int)>(&Wrappers::PCACompute_wrapper));
  function("PCACompute1", select_overload<void(const cv::Mat&, cv::Mat&, cv::Mat&, double)>(&Wrappers::PCACompute_wrapper1));
  function("PCAProject", select_overload<void(const cv::Mat&, const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::PCAProject_wrapper));
  function("PSNR", select_overload<double(const cv::Mat&, const cv::Mat&)>(&Wrappers::PSNR_wrapper));
  function("SVBackSubst", select_overload<void(const cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::SVBackSubst_wrapper));
  function("SVDecomp", select_overload<void(const cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int)>(&Wrappers::SVDecomp_wrapper));
  function("Scharr", select_overload<void(const cv::Mat&, cv::Mat&, int, int, int, double, double, int)>(&Wrappers::Scharr_wrapper));
  function("Sobel", select_overload<void(const cv::Mat&, cv::Mat&, int, int, int, int, double, double, int)>(&Wrappers::Sobel_wrapper));
  function("applyColorMap", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::applyColorMap_wrapper));
  function("approxPolyDP", select_overload<void(const cv::Mat&, cv::Mat&, double, bool)>(&Wrappers::approxPolyDP_wrapper));
  function("arcLength", select_overload<double(const cv::Mat&, bool)>(&Wrappers::arcLength_wrapper));
  function("arrowedLine", select_overload<void(cv::Mat&, Point, Point, const Scalar&, int, int, int, double)>(&Wrappers::arrowedLine_wrapper));
  function("batchDistance", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, int, cv::Mat&, int, int, const cv::Mat&, int, bool)>(&Wrappers::batchDistance_wrapper));
  function("borderInterpolate", select_overload<int(int, int, int)>(&Wrappers::borderInterpolate_wrapper));
  function("boundingRect", select_overload<Rect(const cv::Mat&)>(&Wrappers::boundingRect_wrapper));
  function("boxFilter", select_overload<void(const cv::Mat&, cv::Mat&, int, Size, Point, bool, int)>(&Wrappers::boxFilter_wrapper));
  function("boxPoints", select_overload<void(RotatedRect, cv::Mat&)>(&Wrappers::boxPoints_wrapper));
  function("calcBackProject", select_overload<void(const std::vector<cv::Mat>&, const std::vector<int>&, const cv::Mat&, cv::Mat&, const std::vector<float>&, double)>(&Wrappers::calcBackProject_wrapper));
  function("calcCovarMatrix", select_overload<void(const cv::Mat&, cv::Mat&, cv::Mat&, int, int)>(&Wrappers::calcCovarMatrix_wrapper));
  function("cartToPolar", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, cv::Mat&, bool)>(&Wrappers::cartToPolar_wrapper));
  function("circle", select_overload<void(cv::Mat&, Point, int, const Scalar&, int, int, int)>(&Wrappers::circle_wrapper));
  function("clipLine", select_overload<bool(Rect, Point&, Point&)>(&Wrappers::clipLine_wrapper));
  function("compare", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, int)>(&Wrappers::compare_wrapper));
  function("compareHist", select_overload<double(const cv::Mat&, const cv::Mat&, int)>(&Wrappers::compareHist_wrapper));
  function("completeSymm", select_overload<void(cv::Mat&, bool)>(&Wrappers::completeSymm_wrapper));
  function("connectedComponents", select_overload<int(const cv::Mat&, cv::Mat&, int, int)>(&Wrappers::connectedComponents_wrapper));
  function("connectedComponentsWithStats", select_overload<int(const cv::Mat&, cv::Mat&, cv::Mat&, cv::Mat&, int, int)>(&Wrappers::connectedComponentsWithStats_wrapper));
  function("contourArea", select_overload<double(const cv::Mat&, bool)>(&Wrappers::contourArea_wrapper));
  function("convertMaps", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, cv::Mat&, int, bool)>(&Wrappers::convertMaps_wrapper));
  function("convertScaleAbs", select_overload<void(const cv::Mat&, cv::Mat&, double, double)>(&Wrappers::convertScaleAbs_wrapper));
  function("convexHull", select_overload<void(const cv::Mat&, cv::Mat&, bool, bool)>(&Wrappers::convexHull_wrapper));
  function("convexityDefects", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::convexityDefects_wrapper));
  function("copyMakeBorder", select_overload<void(const cv::Mat&, cv::Mat&, int, int, int, int, int, const Scalar&)>(&Wrappers::copyMakeBorder_wrapper));
  function("cornerEigenValsAndVecs", select_overload<void(const cv::Mat&, cv::Mat&, int, int, int)>(&Wrappers::cornerEigenValsAndVecs_wrapper));
  function("cornerHarris", select_overload<void(const cv::Mat&, cv::Mat&, int, int, double, int)>(&Wrappers::cornerHarris_wrapper));
  function("cornerMinEigenVal", select_overload<void(const cv::Mat&, cv::Mat&, int, int, int)>(&Wrappers::cornerMinEigenVal_wrapper));
  function("cornerSubPix", select_overload<void(const cv::Mat&, cv::Mat&, Size, Size, TermCriteria)>(&Wrappers::cornerSubPix_wrapper));
  function("countNonZero", select_overload<int(const cv::Mat&)>(&Wrappers::countNonZero_wrapper));
  function("createCLAHE", select_overload<Ptr<CLAHE>(double, Size)>(&Wrappers::createCLAHE_wrapper));
  function("createHanningWindow", select_overload<void(cv::Mat&, Size, int)>(&Wrappers::createHanningWindow_wrapper));
  function("createLineSegmentDetector", select_overload<Ptr<LineSegmentDetector>(int, double, double, double, double, double, double, int)>(&Wrappers::createLineSegmentDetector_wrapper));
  function("dct", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::dct_wrapper));
  function("demosaicing", select_overload<void(const cv::Mat&, cv::Mat&, int, int)>(&Wrappers::demosaicing_wrapper));
  function("determinant", select_overload<double(const cv::Mat&)>(&Wrappers::determinant_wrapper));
  function("dft", select_overload<void(const cv::Mat&, cv::Mat&, int, int)>(&Wrappers::dft_wrapper));
  function("divide", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, double, int)>(&Wrappers::divide_wrapper));
  function("divide1", select_overload<void(double, const cv::Mat&, cv::Mat&, int)>(&Wrappers::divide_wrapper1));
  function("drawContours", select_overload<void(cv::Mat&, const std::vector<cv::Mat>&, int, const Scalar&, int, int, const cv::Mat&, int, Point)>(&Wrappers::drawContours_wrapper));
  function("eigen", select_overload<bool(const cv::Mat&, cv::Mat&, cv::Mat&)>(&Wrappers::eigen_wrapper));
  function("ellipse", select_overload<void(cv::Mat&, Point, Size, double, double, double, const Scalar&, int, int, int)>(&Wrappers::ellipse_wrapper));
  function("ellipse1", select_overload<void(cv::Mat&, const RotatedRect&, const Scalar&, int, int)>(&Wrappers::ellipse_wrapper1));
  function("ellipse2Poly", select_overload<void(Point, Size, int, int, int, int, std::vector<Point>&)>(&Wrappers::ellipse2Poly_wrapper));
  function("equalizeHist", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::equalizeHist_wrapper));
  function("exp", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::exp_wrapper));
  function("extractChannel", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::extractChannel_wrapper));
  function("fillConvexPoly", select_overload<void(cv::Mat&, const cv::Mat&, const Scalar&, int, int)>(&Wrappers::fillConvexPoly_wrapper));
  function("fillPoly", select_overload<void(cv::Mat&, const std::vector<cv::Mat>&, const Scalar&, int, int, Point)>(&Wrappers::fillPoly_wrapper));
  function("filter2D", select_overload<void(const cv::Mat&, cv::Mat&, int, const cv::Mat&, Point, double, int)>(&Wrappers::filter2D_wrapper));
  function("findContours", select_overload<void(cv::Mat&, std::vector<cv::Mat>&, cv::Mat&, int, int, Point)>(&Wrappers::findContours_wrapper));
  function("findNonZero", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::findNonZero_wrapper));
  function("fitEllipse", select_overload<RotatedRect(const cv::Mat&)>(&Wrappers::fitEllipse_wrapper));
  function("fitLine", select_overload<void(const cv::Mat&, cv::Mat&, int, double, double, double)>(&Wrappers::fitLine_wrapper));
  function("flip", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::flip_wrapper));
  function("gemm", select_overload<void(const cv::Mat&, const cv::Mat&, double, const cv::Mat&, double, cv::Mat&, int)>(&Wrappers::gemm_wrapper));
  function("getAffineTransform", select_overload<Mat(const cv::Mat&, const cv::Mat&)>(&Wrappers::getAffineTransform_wrapper));
  function("getDefaultNewCameraMatrix", select_overload<Mat(const cv::Mat&, Size, bool)>(&Wrappers::getDefaultNewCameraMatrix_wrapper));
  function("getDerivKernels", select_overload<void(cv::Mat&, cv::Mat&, int, int, int, bool, int)>(&Wrappers::getDerivKernels_wrapper));
  function("getGaborKernel", select_overload<Mat(Size, double, double, double, double, double, int)>(&Wrappers::getGaborKernel_wrapper));
  function("getGaussianKernel", select_overload<Mat(int, double, int)>(&Wrappers::getGaussianKernel_wrapper));
  function("getOptimalDFTSize", select_overload<int(int)>(&Wrappers::getOptimalDFTSize_wrapper));
  function("getPerspectiveTransform", select_overload<Mat(const cv::Mat&, const cv::Mat&)>(&Wrappers::getPerspectiveTransform_wrapper));
  function("getRectSubPix", select_overload<void(const cv::Mat&, Size, Point2f, cv::Mat&, int)>(&Wrappers::getRectSubPix_wrapper));
  function("getRotationMatrix2D", select_overload<Mat(Point2f, double, double)>(&Wrappers::getRotationMatrix2D_wrapper));
  function("getTextSize", select_overload<Size(const String&, int, double, int, int*)>(&Wrappers::getTextSize_wrapper), allow_raw_pointers());
  function("goodFeaturesToTrack", select_overload<void(const cv::Mat&, cv::Mat&, int, double, double, const cv::Mat&, int, bool, double)>(&Wrappers::goodFeaturesToTrack_wrapper));
  function("grabCut", select_overload<void(const cv::Mat&, cv::Mat&, Rect, cv::Mat&, cv::Mat&, int, int)>(&Wrappers::grabCut_wrapper));
  function("idct", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::idct_wrapper));
  function("idft", select_overload<void(const cv::Mat&, cv::Mat&, int, int)>(&Wrappers::idft_wrapper));
  function("inRange", select_overload<void(const cv::Mat&, const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::inRange_wrapper));
  function("initUndistortRectifyMap", select_overload<void(const cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&, Size, int, cv::Mat&, cv::Mat&)>(&Wrappers::initUndistortRectifyMap_wrapper));
  function("initWideAngleProjMap", select_overload<float(const cv::Mat&, const cv::Mat&, Size, int, int, cv::Mat&, cv::Mat&, int, double)>(&Wrappers::initWideAngleProjMap_wrapper));
  function("insertChannel", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::insertChannel_wrapper));
  function("intersectConvexConvex", select_overload<float(const cv::Mat&, const cv::Mat&, cv::Mat&, bool)>(&Wrappers::intersectConvexConvex_wrapper));
  function("invertAffineTransform", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::invertAffineTransform_wrapper));
  function("isContourConvex", select_overload<bool(const cv::Mat&)>(&Wrappers::isContourConvex_wrapper));
  function("kmeans", select_overload<double(const cv::Mat&, int, cv::Mat&, TermCriteria, int, int, cv::Mat&)>(&Wrappers::kmeans_wrapper));
  function("line", select_overload<void(cv::Mat&, Point, Point, const Scalar&, int, int, int)>(&Wrappers::line_wrapper));
  function("linearPolar", select_overload<void(const cv::Mat&, cv::Mat&, Point2f, double, int)>(&Wrappers::linearPolar_wrapper));
  function("log", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::log_wrapper));
  function("logPolar", select_overload<void(const cv::Mat&, cv::Mat&, Point2f, double, int)>(&Wrappers::logPolar_wrapper));
  function("magnitude", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&)>(&Wrappers::magnitude_wrapper));
  function("matchShapes", select_overload<double(const cv::Mat&, const cv::Mat&, int, double)>(&Wrappers::matchShapes_wrapper));
  function("matchTemplate", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, int, const cv::Mat&)>(&Wrappers::matchTemplate_wrapper));
  function("mean", select_overload<Scalar(const cv::Mat&, const cv::Mat&)>(&Wrappers::mean_wrapper));
  function("meanStdDev", select_overload<void(const cv::Mat&, cv::Mat&, cv::Mat&, const cv::Mat&)>(&Wrappers::meanStdDev_wrapper));
  function("merge", select_overload<void(const std::vector<cv::Mat>&, cv::Mat&)>(&Wrappers::merge_wrapper));
  function("minAreaRect", select_overload<RotatedRect(const cv::Mat&)>(&Wrappers::minAreaRect_wrapper));
  function("minEnclosingTriangle", select_overload<double(const cv::Mat&, cv::Mat&)>(&Wrappers::minEnclosingTriangle_wrapper));
  function("mixChannels", select_overload<void(const std::vector<cv::Mat>&, InputOutputArrayOfArrays, const std::vector<int>&)>(&Wrappers::mixChannels_wrapper));
  function("moments", select_overload<Moments(const cv::Mat&, bool)>(&Wrappers::moments_wrapper));
  function("morphologyEx", select_overload<void(const cv::Mat&, cv::Mat&, int, const cv::Mat&, Point, int, int, const Scalar&)>(&Wrappers::morphologyEx_wrapper));
  function("mulSpectrums", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, int, bool)>(&Wrappers::mulSpectrums_wrapper));
  function("mulTransposed", select_overload<void(const cv::Mat&, cv::Mat&, bool, const cv::Mat&, double, int)>(&Wrappers::mulTransposed_wrapper));
  function("multiply", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, double, int)>(&Wrappers::multiply_wrapper));
  function("norm", select_overload<double(const cv::Mat&, int, const cv::Mat&)>(&Wrappers::norm_wrapper));
  function("norm1", select_overload<double(const cv::Mat&, const cv::Mat&, int, const cv::Mat&)>(&Wrappers::norm_wrapper1));
  function("normalize", select_overload<void(const cv::Mat&, cv::Mat&, double, double, int, int, const cv::Mat&)>(&Wrappers::normalize_wrapper));
  function("patchNaNs", select_overload<void(cv::Mat&, double)>(&Wrappers::patchNaNs_wrapper));
  function("perspectiveTransform", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&)>(&Wrappers::perspectiveTransform_wrapper));
  function("phase", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, bool)>(&Wrappers::phase_wrapper));
  function("pointPolygonTest", select_overload<double(const cv::Mat&, Point2f, bool)>(&Wrappers::pointPolygonTest_wrapper));
  function("polarToCart", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, cv::Mat&, bool)>(&Wrappers::polarToCart_wrapper));
  function("polylines", select_overload<void(cv::Mat&, const std::vector<cv::Mat>&, bool, const Scalar&, int, int, int)>(&Wrappers::polylines_wrapper));
  function("pow", select_overload<void(const cv::Mat&, double, cv::Mat&)>(&Wrappers::pow_wrapper));
  function("preCornerDetect", select_overload<void(const cv::Mat&, cv::Mat&, int, int)>(&Wrappers::preCornerDetect_wrapper));
  function("putText", select_overload<void(cv::Mat&, const String&, Point, int, double, Scalar, int, int, bool)>(&Wrappers::putText_wrapper));
  function("pyrDown", select_overload<void(const cv::Mat&, cv::Mat&, const Size&, int)>(&Wrappers::pyrDown_wrapper));
  function("pyrMeanShiftFiltering", select_overload<void(const cv::Mat&, cv::Mat&, double, double, int, TermCriteria)>(&Wrappers::pyrMeanShiftFiltering_wrapper));
  function("pyrUp", select_overload<void(const cv::Mat&, cv::Mat&, const Size&, int)>(&Wrappers::pyrUp_wrapper));
  function("randn", select_overload<void(cv::Mat&, const cv::Mat&, const cv::Mat&)>(&Wrappers::randn_wrapper));
  function("randu", select_overload<void(cv::Mat&, const cv::Mat&, const cv::Mat&)>(&Wrappers::randu_wrapper));
  function("rectangle", select_overload<void(cv::Mat&, Point, Point, const Scalar&, int, int, int)>(&Wrappers::rectangle_wrapper));
  function("reduce", select_overload<void(const cv::Mat&, cv::Mat&, int, int, int)>(&Wrappers::reduce_wrapper));
  function("remap", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&, const cv::Mat&, int, int, const Scalar&)>(&Wrappers::remap_wrapper));
  function("repeat", select_overload<void(const cv::Mat&, int, int, cv::Mat&)>(&Wrappers::repeat_wrapper));
  function("resize", select_overload<void(const cv::Mat&, cv::Mat&, Size, double, double, int)>(&Wrappers::resize_wrapper));
  function("rotatedRectangleIntersection", select_overload<int(const RotatedRect&, const RotatedRect&, cv::Mat&)>(&Wrappers::rotatedRectangleIntersection_wrapper));
  function("scaleAdd", select_overload<void(const cv::Mat&, double, const cv::Mat&, cv::Mat&)>(&Wrappers::scaleAdd_wrapper));
  function("sepFilter2D", select_overload<void(const cv::Mat&, cv::Mat&, int, const cv::Mat&, const cv::Mat&, Point, double, int)>(&Wrappers::sepFilter2D_wrapper));
  function("setIdentity", select_overload<void(cv::Mat&, const Scalar&)>(&Wrappers::setIdentity_wrapper));
  function("solve", select_overload<bool(const cv::Mat&, const cv::Mat&, cv::Mat&, int)>(&Wrappers::solve_wrapper));
  function("solveCubic", select_overload<int(const cv::Mat&, cv::Mat&)>(&Wrappers::solveCubic_wrapper));
  function("solvePoly", select_overload<double(const cv::Mat&, cv::Mat&, int)>(&Wrappers::solvePoly_wrapper));
  function("sort", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::sort_wrapper));
  function("sortIdx", select_overload<void(const cv::Mat&, cv::Mat&, int)>(&Wrappers::sortIdx_wrapper));
  function("split", select_overload<void(const cv::Mat&, std::vector<cv::Mat>&)>(&Wrappers::split_wrapper));
  function("sqrBoxFilter", select_overload<void(const cv::Mat&, cv::Mat&, int, Size, Point, bool, int)>(&Wrappers::sqrBoxFilter_wrapper));
  function("sqrt", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::sqrt_wrapper));
  function("subtract", select_overload<void(const cv::Mat&, const cv::Mat&, cv::Mat&, const cv::Mat&, int)>(&Wrappers::subtract_wrapper));
  function("sumElems", select_overload<Scalar(const cv::Mat&)>(&Wrappers::sum_wrapper));
  function("trace", select_overload<Scalar(const cv::Mat&)>(&Wrappers::trace_wrapper));
  function("transform", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&)>(&Wrappers::transform_wrapper));
  function("transpose", select_overload<void(const cv::Mat&, cv::Mat&)>(&Wrappers::transpose_wrapper));
  function("undistort", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&)>(&Wrappers::undistort_wrapper));
  function("undistortPoints", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&, const cv::Mat&)>(&Wrappers::undistortPoints_wrapper));
  function("warpAffine", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&, Size, int, int, const Scalar&)>(&Wrappers::warpAffine_wrapper));
  function("warpPerspective", select_overload<void(const cv::Mat&, cv::Mat&, const cv::Mat&, Size, int, int, const Scalar&)>(&Wrappers::warpPerspective_wrapper));
  function("finish", select_overload<void()>(&Wrappers::finish_wrapper));
*/

});


text:
/* node , babel es6 */
require('babel-core/register');
require('babel-polyfill');
require('./server-graphql');

redpajama_set_name: RedPajamaGithub


text:
package org.kurento.repository;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

/**
 * Attributes implementation.
 */
public class RepositoryItemAttributes {

  /**
   * HTTP date format.
   */
  protected static final SimpleDateFormat format =
      new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);

  /**
   * Date formats using for Date parsing.
   */
  protected static final SimpleDateFormat[] formats =
      { new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US),
          new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US),
          new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) };

  protected static final TimeZone gmtZone = TimeZone.getTimeZone("GMT");

  /**
   * GMT timezone - all HTTP dates are on GMT.
   */
  static {

    format.setTimeZone(gmtZone);

    formats[0].setTimeZone(gmtZone);
    formats[1].setTimeZone(gmtZone);
    formats[2].setTimeZone(gmtZone);

  }

  /**
   * Content length.
   */
  protected long contentLength = -1;

  /**
   * Creation time.
   */
  protected long creation = -1;

  /**
   * Creation date.
   */
  protected Date creationDate;

  /**
   * Last modified time.
   */
  protected long lastModified = -1;

  /**
   * Last modified date.
   */
  protected Date lastModifiedDate;

  /**
   * Last modified date in HTTP format.
   */
  protected String lastModifiedHttp;

  /**
   * MIME type.
   */
  protected String mimeType;

  /**
   * Weak ETag.
   */
  protected String weakETag;

  /**
   * Strong ETag.
   */
  protected String strongETag;

  /**
   * Get content length.
   *
   * @return content length value
   */
  public long getContentLength() {
    return contentLength;
  }

  /**
   * Set content length.
   *
   * @param contentLength
   *          New content length value
   */
  public void setContentLength(long contentLength) {
    this.contentLength = contentLength;
  }

  /**
   * Get creation time.
   *
   * @return creation time value
   */
  public long getCreation() {
    return creation;
  }

  /**
   * Get creation date.
   *
   * @return Creation date value
   */
  public Date getCreationDate() {
    return creationDate;
  }

  /**
   * Creation date mutator.
   *
   * @param creationDate
   *          New creation date
   */
  public void setCreationDate(Date creationDate) {
    this.creationDate = creationDate;
    this.creation = creationDate.getTime();
  }

  /**
   * Creation date mutator.
   *
   * @param creation
   *          New creation date as a long
   */
  public void setCreation(long creation) {
    this.creation = creation;
    this.creationDate = new Date(creation);
  }

  public void setCreationDateHttp(String creationDateValue) throws ParseException {
    this.creationDate = parseHttpDate(creationDateValue);
    this.creation = creationDate.getTime();
  }

  /**
   * Get last modified time.
   *
   * @return lastModified time value
   */
  public long getLastModified() {
    return lastModified;
  }

  /**
   * Set last modified.
   *
   * @param lastModified
   *          New last modified value
   */
  public void setLastModified(long lastModified) {
    this.lastModified = lastModified;
    this.lastModifiedDate = new Date(lastModified);
  }

  /**
   * Get lastModified date.
   *
   * @return LastModified date value
   */
  public Date getLastModifiedDate() {
    return lastModifiedDate;
  }

  /**
   * Last modified date mutator.
   *
   * @param lastModifiedDate
   *          New last modified date
   */
  public void setLastModifiedDate(Date lastModifiedDate) {
    this.lastModified = lastModifiedDate.getTime();
    this.lastModifiedDate = lastModifiedDate;
  }

  /**
   * @return Returns the lastModifiedHttp.
   */
  public String getLastModifiedHttp() {

    if (lastModifiedHttp != null) {
      return lastModifiedHttp;
    }

    Date modifiedDate = getLastModifiedDate();
    if (modifiedDate == null) {
      modifiedDate = getCreationDate();
    }

    if (modifiedDate == null) {
      modifiedDate = new Date();
    }

    synchronized (format) {
      lastModifiedHttp = format.format(modifiedDate);
    }

    return lastModifiedHttp;
  }

  private Date parseHttpDate(String creationDate) throws ParseException {

    Date newCreationDate = null;

    // Parsing the HTTP Date
    for (int i = 0; newCreationDate == null && i < formats.length; i++) {
      try {
        newCreationDate = formats[i].parse(creationDate);
      } catch (ParseException e) {
        // Ignore
      }
    }

    if (newCreationDate == null) {
      throw new ParseException("Exception while parsing http date", -1);
    } else {
      return newCreationDate;
    }
  }

  /**
   * @param lastModifiedHttp
   *          The lastModifiedHttp to set.
   * @throws ParseException
   *           in case the http date can't be parsed
   */
  public void setLastModifiedHttp(String lastModifiedHttp) throws ParseException {
    this.lastModifiedDate = parseHttpDate(lastModifiedHttp);
    this.lastModified = lastModifiedDate.getTime();
    this.lastModifiedHttp = lastModifiedHttp;
  }

  /**
   * @return Returns the mimeType.
   */
  public String getMimeType() {
    return mimeType;
  }

  /**
   * @param mimeType
   *          The mimeType to set.
   */
  public void setMimeType(String mimeType) {
    this.mimeType = mimeType;
  }

  /**
   * Get ETag.
   *
   * @return strong ETag if available, else weak ETag.
   */
  public String getETag() {

    String result = null;

    if (strongETag != null) {
      // The strong ETag must always be calculated by the resources
      result = strongETag;
    } else {
      // The weakETag is contentLength + lastModified
      if (weakETag == null) {
        long contentLength = getContentLength();
        long lastModified = getLastModified();
        if (contentLength >= 0 || lastModified >= 0) {
          weakETag = "W/\"" + contentLength + "-" + lastModified + "\"";
        }
      }
      result = weakETag;
    }

    return result;
  }

  /**
   * Set strong ETag.
   */
  public void setETag(String eTag) {
    this.strongETag = eTag;
  }

}


text:
"use strict";

const util = require("util");
const exec = util.promisify(require("child_process").exec);

module.exports = function () {
  return exec("npm run build");
};


text:
package ru.job4j.controlQuestion;

import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
//import static org.hamcrest.number.IsCloseTo.closeTo;

/**
 * TwoMassiveMergeTest.
 *
 * @author Daniil Permin
 * @version 1.0
 * @since 13.05.2017
 */
public class TwoMassiveMergeTest {
/**
*  Тест слияния двух массивов.
*/
@Test
    public void massiveMergeSortOne() {
     TwoMassiveMerge twoMassive = new TwoMassiveMerge();
		int[] masA = {1, 2, 3, 4, 5, 5, 7};
		int[] masB = {1, 8};
		int[] resultMas = TwoMassiveMerge.sortMerge(masA, masB);
		int[] expectMas = {1, 1, 2, 3, 4, 5, 5, 7, 8};
		assertThat(resultMas, is(expectMas));
    }
/**
*  Тест слияния двух массивов, если один массив нулевой.
*/
    public void massiveMergeSortTwo() {
     TwoMassiveMerge twoMassive = new TwoMassiveMerge();
		int[] masA = {1, 2, 3, 4, 5, 5, 7};
		int[] masB = {};
		int[] resultMas = TwoMassiveMerge.sortMerge(masA, masB);
		int[] expectMas = {1, 2, 3, 4, 5, 5, 7};
		assertThat(resultMas, is(expectMas));
    }
/**
*  Тест слияния двух равных массивов.
*/
    public void massiveMergeSortTrith() {
     TwoMassiveMerge twoMassive = new TwoMassiveMerge();
		int[] masA = {1, 3, 5};
		int[] masB = {2, 4, 5};
		int[] resultMas = TwoMassiveMerge.sortMerge(masA, masB);
		int[] expectMas = {1, 2, 3, 4, 5, 5};
		assertThat(resultMas, is(expectMas));
    }

}


text:
using System;
using UnityEngine;

public class BrokenClass : MonoBehaviour
{
    public int MyAuto{on}Prop1 { get;
}


text:
package v1

import (
	"knative.dev/pkg/apis"
)

// SubCondSet is a condition set with Ready as the happy condition and
// ReferencesResolved and ChannelReady as the dependent conditions.
var SubCondSet = apis.NewLivingConditionSet(SubscriptionConditionReferencesResolved, SubscriptionConditionAddedToChannel, SubscriptionConditionChannelReady)

const (
	// SubscriptionConditionReady has status True when all subconditions below have been set to True.
	SubscriptionConditionReady = apis.ConditionReady
	// SubscriptionConditionReferencesResolved has status True when all the specified references have been successfully
	// resolved.
	SubscriptionConditionReferencesResolved apis.ConditionType = "ReferencesResolved"

	// SubscriptionConditionAddedToChannel has status True when controller has successfully added a
	// subscription to the spec.channel resource.
	SubscriptionConditionAddedToChannel apis.ConditionType = "AddedToChannel"

	// SubscriptionConditionChannelReady has status True when the channel has marked the subscriber as 'ready'
	SubscriptionConditionChannelReady apis.ConditionType = "ChannelReady"
)

// GetConditionSet retrieves the condition set for this resource. Implements the KRShaped interface.
func (*Subscription) GetConditionSet() apis.ConditionSet {
	return SubCondSet
}

// GetCondition returns the condition currently associated with the given type, or nil.
func (ss *SubscriptionStatus) GetCondition(t apis.ConditionType) *apis.Condition {
	return SubCondSet.Manage(ss).GetCondition(t)
}

// GetTopLevelCondition returns the top level Condition.
func (ss *SubscriptionStatus) GetTopLevelCondition() *apis.Condition {
	return SubCondSet.Manage(ss).GetTopLevelCondition()
}

// IsReady returns true if the resource is ready overall.
func (ss *SubscriptionStatus) IsReady() bool {
	return SubCondSet.Manage(ss).IsHappy()
}

// IsAddedToChannel returns true if SubscriptionConditionAddedToChannel is true
func (ss *SubscriptionStatus) IsAddedToChannel() bool {
	return ss.GetCondition(SubscriptionConditionAddedToChannel).IsTrue()
}

// AreReferencesResolved returns true if SubscriptionConditionReferencesResolved is true
func (ss *SubscriptionStatus) AreReferencesResolved() bool {
	return ss.GetCondition(SubscriptionConditionReferencesResolved).IsTrue()
}

// InitializeConditions sets relevant unset conditions to Unknown state.
func (ss *SubscriptionStatus) InitializeConditions() {
	SubCondSet.Manage(ss).InitializeConditions()
}

// MarkReferencesResolved sets the ReferencesResolved condition to True state.
func (ss *SubscriptionStatus) MarkReferencesResolved() {
	SubCondSet.Manage(ss).MarkTrue(SubscriptionConditionReferencesResolved)
}

// MarkChannelReady sets the ChannelReady condition to True state.
func (ss *SubscriptionStatus) MarkChannelReady() {
	SubCondSet.Manage(ss).MarkTrue(SubscriptionConditionChannelReady)
}

// MarkAddedToChannel sets the AddedToChannel condition to True state.
func (ss *SubscriptionStatus) MarkAddedToChannel() {
	SubCondSet.Manage(ss).MarkTrue(SubscriptionConditionAddedToChannel)
}

// MarkReferencesNotResolved sets the ReferencesResolved condition to False state.
func (ss *SubscriptionStatus) MarkReferencesNotResolved(reason, messageFormat string, messageA ...interface{}) {
	SubCondSet.Manage(ss).MarkFalse(SubscriptionConditionReferencesResolved, reason, messageFormat, messageA...)
}

// MarkReferencesResolvedUnknown sets the ReferencesResolved condition to Unknown state.
func (ss *SubscriptionStatus) MarkReferencesResolvedUnknown(reason, messageFormat string, messageA ...interface{}) {
	SubCondSet.Manage(ss).MarkUnknown(SubscriptionConditionReferencesResolved, reason, messageFormat, messageA...)
}

// MarkChannelFailed sets the ChannelReady condition to False state.
func (ss *SubscriptionStatus) MarkChannelFailed(reason, messageFormat string, messageA ...interface{}) {
	SubCondSet.Manage(ss).MarkFalse(SubscriptionConditionChannelReady, reason, messageFormat, messageA...)
}

// MarkChannelUnknown sets the ChannelReady condition to Unknown state.
func (ss *SubscriptionStatus) MarkChannelUnknown(reason, messageFormat string, messageA ...interface{}) {
	SubCondSet.Manage(ss).MarkUnknown(SubscriptionConditionChannelReady, reason, messageFormat, messageA...)
}

// MarkNotAddedToChannel sets the AddedToChannel condition to False state.
func (ss *SubscriptionStatus) MarkNotAddedToChannel(reason, messageFormat string, messageA ...interface{}) {
	SubCondSet.Manage(ss).MarkFalse(SubscriptionConditionAddedToChannel, reason, messageFormat, messageA...)
}


text:
from .sub_resource import SubResource

class NetworkInterfaceIPConfiguration(SubResource):
    """IPConfiguration in a network interface.

    :param id: Resource ID.
    :type id: str
    :param application_gateway_backend_address_pools: The reference of
     ApplicationGatewayBackendAddressPool resource.
    :type application_gateway_backend_address_pools:
     list[~azure.mgmt.network.v2017_08_01.models.ApplicationGatewayBackendAddressPool]
    :param load_balancer_backend_address_pools: The reference of
     LoadBalancerBackendAddressPool resource.
    :type load_balancer_backend_address_pools:
     list[~azure.mgmt.network.v2017_08_01.models.BackendAddressPool]
    :param load_balancer_inbound_nat_rules: A list of references of
     LoadBalancerInboundNatRules.
    :type load_balancer_inbound_nat_rules:
     list[~azure.mgmt.network.v2017_08_01.models.InboundNatRule]
    :param private_ip_address: Private IP address of the IP configuration.
    :type private_ip_address: str
    :param private_ip_allocation_method: Defines how a private IP address is
     assigned. Possible values are: 'Static' and 'Dynamic'. Possible values
     include: 'Static', 'Dynamic'
    :type private_ip_allocation_method: str or
     ~azure.mgmt.network.v2017_08_01.models.IPAllocationMethod
    :param private_ip_address_version: Available from Api-Version 2016-03-30
     onwards, it represents whether the specific ipconfiguration is IPv4 or
     IPv6. Default is taken as IPv4.  Possible values are: 'IPv4' and 'IPv6'.
     Possible values include: 'IPv4', 'IPv6'
    :type private_ip_address_version: str or
     ~azure.mgmt.network.v2017_08_01.models.IPVersion
    :param subnet: Subnet bound to the IP configuration.
    :type subnet: ~azure.mgmt.network.v2017_08_01.models.Subnet
    :param primary: Gets whether this is a primary customer address on the
     network interface.
    :type primary: bool
    :param public_ip_address: Public IP address bound to the IP configuration.
    :type public_ip_address:
     ~azure.mgmt.network.v2017_08_01.models.PublicIPAddress
    :param provisioning_state: The provisioning state of the network interface
     IP configuration. Possible values are: 'Updating', 'Deleting', and
     'Failed'.
    :type provisioning_state: str
    :param name: The name of the resource that is unique within a resource
     group. This name can be used to access the resource.
    :type name: str
    :param etag: A unique read-only string that changes whenever the resource
     is updated.
    :type etag: str
    """

    _attribute_map = {
        'id': {'key': 'id', 'type': 'str'},
        'application_gateway_backend_address_pools': {'key': 'properties.applicationGatewayBackendAddressPools', 'type': '[ApplicationGatewayBackendAddressPool]'},
        'load_balancer_backend_address_pools': {'key': 'properties.loadBalancerBackendAddressPools', 'type': '[BackendAddressPool]'},
        'load_balancer_inbound_nat_rules': {'key': 'properties.loadBalancerInboundNatRules', 'type': '[InboundNatRule]'},
        'private_ip_address': {'key': 'properties.privateIPAddress', 'type': 'str'},
        'private_ip_allocation_method': {'key': 'properties.privateIPAllocationMethod', 'type': 'str'},
        'private_ip_address_version': {'key': 'properties.privateIPAddressVersion', 'type': 'str'},
        'subnet': {'key': 'properties.subnet', 'type': 'Subnet'},
        'primary': {'key': 'properties.primary', 'type': 'bool'},
        'public_ip_address': {'key': 'properties.publicIPAddress', 'type': 'PublicIPAddress'},
        'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
        'name': {'key': 'name', 'type': 'str'},
        'etag': {'key': 'etag', 'type': 'str'},
    }

    def __init__(self, id=None, application_gateway_backend_address_pools=None, load_balancer_backend_address_pools=None, load_balancer_inbound_nat_rules=None, private_ip_address=None, private_ip_allocation_method=None, private_ip_address_version=None, subnet=None, primary=None, public_ip_address=None, provisioning_state=None, name=None, etag=None):
        super(NetworkInterfaceIPConfiguration, self).__init__(id=id)
        self.application_gateway_backend_address_pools = application_gateway_backend_address_pools
        self.load_balancer_backend_address_pools = load_balancer_backend_address_pools
        self.load_balancer_inbound_nat_rules = load_balancer_inbound_nat_rules
        self.private_ip_address = private_ip_address
        self.private_ip_allocation_method = private_ip_allocation_method
        self.private_ip_address_version = private_ip_address_version
        self.subnet = subnet
        self.primary = primary
        self.public_ip_address = public_ip_address
        self.provisioning_state = provisioning_state
        self.name = name
        self.etag = etag


text:
import { setupDefaults } from './defaults';
import { setupScreens } from './screens';

export default opts => {
  // Register plugin defaults
  const defaults = setupDefaults(opts);
  // Install support for responsive screens
  setupScreens(defaults.screens, true);
  return defaults;
};


text:
<?php

/**
* This file is part of cloak.
*
* (c) Noritaka Horio <holy.shared.design@gmail.com>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace cloak\configuration;

use \RuntimeException;

/**
* Class ConfigurationFileNotFoundException
* @package cloak\configuration
*/
class ConfigurationFileNotFoundException extends RuntimeException
{
}


text:
============
Installation
============

If you are (relatively) new to installing python packages, please jump to the
getting started tutorial (:doc:`tutorials/getting_started_tutorial`)
for an opinionated step-by-step procedure.

Stable release
--------------

The preferred way to install ``cellpy`` is by using conda:

.. code-block:: console

    $ conda install cellpy --channel conda-forge

This will also install all of the critical dependencies, as well as ``jupyter``
that comes in handy when working with ``cellpy``.

If you would like to install only ``cellpy``, you should install using pip.
You also need to take into account that ``cellpy`` uses several packages
that are a bit cumbersome to install on
windows. It is therefore recommended to install one of the ``anaconda``
python packages (python 3.8 or above) before installing ``cellpy``.
If you chose ``miniconda``, you should install
``scipy``, ``numpy`` and ``pytables`` using ``conda``:

.. code-block:: console

    $ conda install scipy numpy pytables

Then install ``cellpy``, by running this command in your terminal:

.. code-block:: console

    $ pip install cellpy

You can install pre-releases by adding the ``--pre`` flag.

If you are on Windows and plan to work with Arbin files,
we recommend that you try to install `pyodbc`_ (Python ODBC bridge).
Either by using pip or from conda-forge:

.. code-block:: console

    $ pip install pyodbc

or:

.. code-block:: console

    $ conda install -c conda-forge pyodbc

.. _pyodbc: https://github.com/mkleehammer/pyodbc/

Some of the utilities in ``cellpy`` have additional dependencies:

- Using the ``ocv_rlx`` utilities requires ``lmfit`` and ``matplotlib``.
- For using the ``batch`` utilities efficiently, ``holoviews`` is needed, as
  well as ``bokeh`` and ``matplotlib`` for plotting.

If this is the first time you install ``cellpy``, it is recommended
that you run the setup script:

.. code-block:: console

    $ cellpy setup -i

This will install a ``.cellpy_prms_USER.conf`` file in your home directory
(USER = your user name).
Feel free to edit this to fit your needs.

If you are OK with letting ``cellpy`` select your settings, you can omit
the `-i` (interactive mode).

.. hint:: It is recommended to run the command also after
    each time you upgrade ``cellpy``. It will keep the settings you already
    have in your prms-file and, if the newer version
    has introduced some new parameters, it will add those too.

.. hint:: You can restore your prms-file by running ``cellpy setup -r`` if needed
    (*i.e.* get a copy of the default file copied to your user folder).

.. caution:: Since Arbin (at least some versions) uses access database files, you
    will need to install ``pyodbc``, a python ODBC bridge that can talk to database
    files. On windows, at least if you don´t have a newer version of office 365,
    you  most likely need to use Microsoft's dll for handling access
    database formats, and you might run into 32bit *vs.* 64bit issues.
    The simplest solution is to have the same "bit" for python and
    the access dll (or office). More advanced options are explained in more details
    in the getting-started tutorial. For Posix-type systems, you will need to download
    and install ``mdbtools``. If you are on Windows and you cannot get your
    ``pyodbc`` to work, you can try the same there also (search for Windows
    binaries and set the appropriate settings in your ``cellpy`` config file).

From sources
------------

The sources for ``cellpy`` can be downloaded from the `Github repo`_.

You can clone the public repository by:

.. code-block:: console

    $ git clone git://github.com/jepegit/cellpy

Once you have a copy of the source, you can install in development
mode using pip:

.. code-block:: console

    $ pip install -e .

(assuming that you are in the project folder, *i. e.* the folder that
contains the setup.py file)

Further reading
---------------

You can find more information in the Tutorials, particularly
in :doc:`tutorials/getting_started_tutorial`.

.. _Github repo: https://github.com/jepegit/cellpy


text:
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where

import Control.Lens
import Data.Aeson
import Data.Proxy
import Data.Text (Text)
import GHC.Generics

import Data.Swagger
import Data.Swagger.Declare
import Data.Swagger.Lens
import Data.Swagger.Operation

type Username = Text

data UserSummary = UserSummary
  { summaryUsername :: Username
  , summaryUserid   :: Int
  } deriving (Generic)

instance ToSchema UserSummary where
  declareNamedSchema _ = do
    usernameSchema <- declareSchemaRef (Proxy :: Proxy Username)
    useridSchema   <- declareSchemaRef (Proxy :: Proxy Int)
    return $ NamedSchema (Just "UserSummary") $ mempty
      & type_ ?~ SwaggerObject
      & properties .~
          [ ("summaryUsername", usernameSchema )
          , ("summaryUserid"  , useridSchema   )
          ]
      & required .~ [ "summaryUsername"
                    , "summaryUserid"   ]

type Group = Text

data UserDetailed = UserDetailed
  { username :: Username
  , userid   :: Int
  , groups   :: [Group]
  } deriving (Generic, ToSchema)

newtype Package = Package { packageName :: Text }
  deriving (Generic, ToSchema)

hackageSwagger :: Swagger
hackageSwagger = spec & definitions .~ defs
  where
    (defs, spec) = runDeclare declareHackageSwagger mempty

declareHackageSwagger :: Declare (Definitions Schema) Swagger
declareHackageSwagger = do
  -- param schemas
  let usernameParamSchema = toParamSchema (Proxy :: Proxy Username)

  -- responses
  userSummaryResponse   <- declareResponse (Proxy :: Proxy UserSummary)
  userDetailedResponse  <- declareResponse (Proxy :: Proxy UserDetailed)
  packagesResponse      <- declareResponse (Proxy :: Proxy [Package])

  return $ mempty
    & paths .~
        [ ("/users", mempty & get ?~ (mempty
            & produces ?~ MimeList ["application/json"]
            & at 200 ?~ Inline userSummaryResponse))
        , ("/user/{username}", mempty & get ?~ (mempty
            & produces ?~ MimeList ["application/json"]
            & parameters .~ [ Inline $ mempty
                & name .~ "username"
                & required ?~ True
                & schema .~ ParamOther (mempty
                    & in_ .~ ParamPath
                    & paramSchema .~ usernameParamSchema) ]
            & at 200 ?~ Inline userDetailedResponse))
        , ("/packages", mempty & get ?~ (mempty
            & produces ?~ MimeList ["application/json"]
            & at 200 ?~ Inline packagesResponse))
        ]

main :: IO ()
main = putStrLn . read . show . encode $ hackageSwagger


text:
import { forwardRef } from "react";

import { FontIcon, FontIconProps } from "@react-md/icon";

export const ViewCompactFontIcon = forwardRef<HTMLElement, FontIconProps>(
  function ViewCompactFontIcon(props, ref) {
    return (
      <FontIcon {...props} ref={ref}>
        view_compact
      </FontIcon>
    );
  }
);


text:
@interface JKNewNotificationListener : JKNotificationListener
@property (nonatomic, strong) id<UNUserNotificationCenterDelegate>originalDelegate;
@end


text:
ACCEPTED

#### According to
The Catalogue of Life, 3rd January 2011

#### Published in
Mycologia 18(5): 250 (1926)

#### Original name
Bagnisiopsis eucalypti Dearn. & Barthol., 1926

### Remarks
null


text:
import { expectAssignable, expectError, expectNotAssignable, expectNotType, expectType } from 'tsd';

import { Document, ObjectId } from '../../src/bson';
import type { Collection } from '../../src/collection';
import type { WithId } from '../../src/mongo_types';

type InsertOneFirstParam<Schema extends Document> = Parameters<Collection<Schema>['insertOne']>[0];

interface Circle {
  _id: ObjectId;
  radius: number;
}
interface Rectangle {
  _id: ObjectId;
  height: number;
  width: number;
}
type Shape = Circle | Rectangle;

type ShapeInsert = InsertOneFirstParam<Shape>;
expectNotAssignable<ShapeInsert>({ height: 2, width: 2, radius: 2 }); // This is not permitted...
// error cases, should not insert a portion of a type
expectNotAssignable<ShapeInsert>({ height: 2 });
expectError<ShapeInsert>({
  radius: 4,
  extraKey: 'I should not be allowed',
  _id: new ObjectId()
});
// valid cases
expectAssignable<ShapeInsert>({ height: 4, width: 4, _id: new ObjectId() });
expectAssignable<ShapeInsert>({ radius: 4, _id: new ObjectId() });

const c: Collection<Shape> = null as never;
expectType<Promise<WithId<Shape> | null>>(c.findOne({ height: 4, width: 4 }));
// collection API can only respect TSchema given, cannot pick a type inside a union
expectNotType<Promise<Rectangle | null>>(c.findOne({ height: 4, width: 4 }));

interface A {
  _id: number;
}
interface B {
  _id: string;
}
type Data = A | B;
expectAssignable<InsertOneFirstParam<Data>>({ _id: 2 });
expectAssignable<InsertOneFirstParam<Data>>({ _id: 'hi' });


text:
Sequoia
=======

[![Build Status](https://travis-ci.org/futoase/Sequoia.png?branch=master)](https://travis-ci.org/futoase/Sequoia)
[![NPM version](https://badge.fury.io/js/sequoia.png)](http://badge.fury.io/js/sequoia)

Generate linear variable.

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/futoase/sequoia/trend.png)](https://bitdeli.com/free "Bitdeli Badge")


text:
default_target: all
.PHONY : default_target

#=============================================================================
# Special targets provided by cmake.

# Disable implicit rules so canoncical targets will work.
.SUFFIXES:

# Remove some rules from gmake that .SUFFIXES does not remove.
SUFFIXES =

.SUFFIXES: .hpux_make_needs_suffix_list

# Suppress display of executed commands.
$(VERBOSE).SILENT:

# A target that is always out of date.
cmake_force:
.PHONY : cmake_force

#=============================================================================
# Set environment variables for the build.

# The shell in which to execute make rules.
SHELL = /bin/sh

# The CMake executable.
CMAKE_COMMAND = /usr/bin/cmake

# The command to remove a file.
RM = /usr/bin/cmake -E remove -f

# The program to use to edit the cache.
CMAKE_EDIT_COMMAND = /usr/bin/cmake-gui

# The top-level source directory on which CMake was run.
CMAKE_SOURCE_DIR = /opt/kinect/LAB/Eclipse/TuxSimbad

# The top-level build directory on which CMake was run.
CMAKE_BINARY_DIR = /opt/kinect/LAB/Eclipse/TuxSimbad

#=============================================================================
# Targets provided globally by CMake.

# Special rule for the target edit_cache
edit_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
	/usr/bin/cmake-gui -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : edit_cache

# Special rule for the target edit_cache
edit_cache/fast: edit_cache
.PHONY : edit_cache/fast

# Special rule for the target install
install: preinstall
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
	/usr/bin/cmake -P cmake_install.cmake
.PHONY : install

# Special rule for the target install
install/fast: preinstall/fast
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
	/usr/bin/cmake -P cmake_install.cmake
.PHONY : install/fast

# Special rule for the target install/local
install/local: preinstall
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
	/usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
.PHONY : install/local

# Special rule for the target install/local
install/local/fast: install/local
.PHONY : install/local/fast

# Special rule for the target install/strip
install/strip: preinstall
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
	/usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
.PHONY : install/strip

# Special rule for the target install/strip
install/strip/fast: install/strip
.PHONY : install/strip/fast

# Special rule for the target list_install_components
list_install_components:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
.PHONY : list_install_components

# Special rule for the target list_install_components
list_install_components/fast: list_install_components
.PHONY : list_install_components/fast

# Special rule for the target package
package: preinstall
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool..."
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && /usr/bin/cpack --config ./CPackConfig.cmake
.PHONY : package

# Special rule for the target package
package/fast: package
.PHONY : package/fast

# Special rule for the target package_source
package_source:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Run CPack packaging tool for source..."
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && /usr/bin/cpack --config ./CPackSourceConfig.cmake /opt/kinect/LAB/Eclipse/TuxSimbad/CPackSourceConfig.cmake
.PHONY : package_source

# Special rule for the target package_source
package_source/fast: package_source
.PHONY : package_source/fast

# Special rule for the target rebuild_cache
rebuild_cache:
	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
	/usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
.PHONY : rebuild_cache

# Special rule for the target rebuild_cache
rebuild_cache/fast: rebuild_cache
.PHONY : rebuild_cache/fast

# The main all target
all: cmake_check_build_system
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(CMAKE_COMMAND) -E cmake_progress_start /opt/kinect/LAB/Eclipse/TuxSimbad/CMakeFiles /opt/kinect/LAB/Eclipse/TuxSimbad/Samples/ParticleFX/CMakeFiles/progress.marks
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f CMakeFiles/Makefile2 Samples/ParticleFX/all
	$(CMAKE_COMMAND) -E cmake_progress_start /opt/kinect/LAB/Eclipse/TuxSimbad/CMakeFiles 0
.PHONY : all

# The main clean target
clean:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f CMakeFiles/Makefile2 Samples/ParticleFX/clean
.PHONY : clean

# The main clean target
clean/fast: clean
.PHONY : clean/fast

# Prepare targets for installation.
preinstall: all
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f CMakeFiles/Makefile2 Samples/ParticleFX/preinstall
.PHONY : preinstall

# Prepare targets for installation.
preinstall/fast:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f CMakeFiles/Makefile2 Samples/ParticleFX/preinstall
.PHONY : preinstall/fast

# clear depends
depend:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
.PHONY : depend

# Convenience name for target.
Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/rule:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f CMakeFiles/Makefile2 Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/rule
.PHONY : Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/rule

# Convenience name for target.
Sample_ParticleFX: Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/rule
.PHONY : Sample_ParticleFX

# fast build rule for target.
Sample_ParticleFX/fast:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/build.make Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/build
.PHONY : Sample_ParticleFX/fast

src/ParticleFX.o: src/ParticleFX.cpp.o
.PHONY : src/ParticleFX.o

# target to build an object file
src/ParticleFX.cpp.o:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/build.make Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/src/ParticleFX.cpp.o
.PHONY : src/ParticleFX.cpp.o

src/ParticleFX.i: src/ParticleFX.cpp.i
.PHONY : src/ParticleFX.i

# target to preprocess a source file
src/ParticleFX.cpp.i:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/build.make Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/src/ParticleFX.cpp.i
.PHONY : src/ParticleFX.cpp.i

src/ParticleFX.s: src/ParticleFX.cpp.s
.PHONY : src/ParticleFX.s

# target to generate assembly for a file
src/ParticleFX.cpp.s:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(MAKE) -f Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/build.make Samples/ParticleFX/CMakeFiles/Sample_ParticleFX.dir/src/ParticleFX.cpp.s
.PHONY : src/ParticleFX.cpp.s

# Help Target
help:
	@echo "The following are some of the valid targets for this Makefile:"
	@echo "... all (the default if no target is provided)"
	@echo "... clean"
	@echo "... depend"
	@echo "... Sample_ParticleFX"
	@echo "... edit_cache"
	@echo "... install"
	@echo "... install/local"
	@echo "... install/strip"
	@echo "... list_install_components"
	@echo "... package"
	@echo "... package_source"
	@echo "... rebuild_cache"
	@echo "... src/ParticleFX.o"
	@echo "... src/ParticleFX.i"
	@echo "... src/ParticleFX.s"
.PHONY : help

#=============================================================================
# Special targets to cleanup operation of make.

# Special rule to run CMake to check the build system integrity.
# No rule that depends on this can have commands that come from listfiles
# because they might be regenerated.
cmake_check_build_system:
	cd /opt/kinect/LAB/Eclipse/TuxSimbad && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
.PHONY : cmake_check_build_system


text:
/* global AudioContext */
var load = require('audio-loader')
var player = require('..')
var ac = new AudioContext()

document.body.innerHTML = '
Midi (sample-player example)
(open the dev console)'
console.log('Loading samples...')

load(ac, 'examples/audio/piano.js').then(function (buffers) {
  console.log('Samples loaded.')
  var piano = player(ac, buffers, { map: 'midi', adsr: [0.01, 0.1, 0.9, 1] }).connect(ac.destination)
  window.navigator.requestMIDIAccess().then(function (midiAccess) {
    console.log('Midi Access!', midiAccess)
    midiAccess.inputs.forEach(function (midiInput, channelKey) {
      console.log('Connecting to: ', midiInput)
      piano.listenToMidi(midiInput)
    }, function (msg) {
      console.log("Can't access midi: " + msg)
    })
  })
})


text:
//Originally written by Erwin Coumans

#ifndef B3_GPU_PGS_CONSTRAINT_SOLVER_H
#define B3_GPU_PGS_CONSTRAINT_SOLVER_H

struct b3Contact4;
struct b3ContactPoint;

class b3Dispatcher;

#include "Bullet3Dynamics/ConstraintSolver/b3TypedConstraint.h"
#include "Bullet3Dynamics/ConstraintSolver/b3ContactSolverInfo.h"
#include "b3GpuSolverBody.h"
#include "b3GpuSolverConstraint.h"
#include "Bullet3OpenCL/ParallelPrimitives/b3OpenCLArray.h"
struct b3RigidBodyData;
struct b3InertiaData;

#include "Bullet3OpenCL/Initialize/b3OpenCLInclude.h"
#include "b3GpuGenericConstraint.h"

class b3GpuPgsConstraintSolver
{
protected:
	int m_staticIdx;
	struct b3GpuPgsJacobiSolverInternalData* m_gpuData;
	protected:
	b3AlignedObjectArray<b3GpuSolverBody>      m_tmpSolverBodyPool;
	b3GpuConstraintArray			m_tmpSolverContactConstraintPool;
	b3GpuConstraintArray			m_tmpSolverNonContactConstraintPool;
	b3GpuConstraintArray			m_tmpSolverContactFrictionConstraintPool;
	b3GpuConstraintArray			m_tmpSolverContactRollingFrictionConstraintPool;

	b3AlignedObjectArray<unsigned int> m_tmpConstraintSizesPool;

	bool						m_usePgs;
	void						averageVelocities();

	int							m_maxOverrideNumSolverIterations;

	int							m_numSplitImpulseRecoveries;

//	int	getOrInitSolverBody(int bodyIndex, b3RigidBodyData* bodies,b3InertiaData* inertias);
	void	initSolverBody(int bodyIndex, b3GpuSolverBody* solverBody, b3RigidBodyData* rb);

public:
	b3GpuPgsConstraintSolver (cl_context ctx, cl_device_id device, cl_command_queue queue,bool usePgs);
	virtual~b3GpuPgsConstraintSolver ();

	virtual b3Scalar solveGroupCacheFriendlyIterations(b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints1,int numConstraints,const b3ContactSolverInfo& infoGlobal);
	virtual b3Scalar solveGroupCacheFriendlySetup(b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
	b3Scalar solveGroupCacheFriendlyFinish(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias,int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);

	b3Scalar solveGroup(b3OpenCLArray<b3RigidBodyData>* gpuBodies,b3OpenCLArray<b3InertiaData>* gpuInertias, int numBodies,b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints,int numConstraints,const b3ContactSolverInfo& infoGlobal);
	void	solveJoints(int numBodies, b3OpenCLArray<b3RigidBodyData>* gpuBodies, b3OpenCLArray<b3InertiaData>* gpuInertias,
				int numConstraints, b3OpenCLArray<b3GpuGenericConstraint>* gpuConstraints);

	int sortConstraintByBatch3( struct b3BatchConstraint* cs, int numConstraints, int simdWidth , int staticIdx, int numBodies);
	void	recomputeBatches();
};

#endif //B3_GPU_PGS_CONSTRAINT_SOLVER_H


text:
**redis-migrate-tool** is a convenient and useful tool for migrating data between [redis](https://github.com/antirez/redis).

## [中文介绍](http://www.oschina.net/p/redis-migrate-tool)

## Features

+ Fast.
+ Multi-Threads.
+ Based on redis replication.
+ Live migration.
+ In the process of migrating data, the source redis can also provide services for users.
+ Heterogeneous migration.
+ Twemproxy and redis cluster support.
+ When the target is twemproxy, keys are direct imported into redis behind the twemproxy.
+ Migration Status view.
+ Data Verification Mechanism.

## Dependence

Please install automake, libtool, autoconf and bzip2 at first.

## Build

To build redis-migrate-tool:

    $ cd redis-migrate-tool
    $ autoreconf -fvi
	$ ./configure
    $ make
    $ src/redis-migrate-tool -h

## RUN

    src/redis-migrate-tool -c rmt.conf -o log -d

## WARNING

Before run this tool, make sure your source redis machines have enough memory allowed at least one redis generate rdb file.

If your source machines have large enough memory allowed all the redis generate rdb files at one time, you can set 'source_safe: false' in the rmt.conf.

## Not supported redis command

The following commands are not supported to be propagated to the target redis group, because the keys in those commands maybe cross different target redis nodes:

RENAME,RENAMENX,RPOPLPUSH,BRPOPLPUSH,FLUSHALL,FLUSHDB,BITOP,MOVE,GEORADIUS,GEORADIUSBYMEMBER,EVAL,EVALSHA,SCRIPT,PFMERGE

## Configuration

Config file has three parts: source, target and common.

### source OR target:

+ **type**: The group redis type. Possible values are:
 + single
 + twemproxy
 + redis cluster
 + rdb file
 + aof file
+ **servers:**: The list of redis address in the group. If type is twemproxy, this is same as the twemproxy config file. If type is rdb file, this is the file name.
+ **redis_auth**: Authenticate to the Redis server on connect.
+ **timeout**: Timeout in milliseconds for read/write with Redis server. Now just for source redis group. Defaults to 120000.
+ **hash**: The name of the hash function. Just for type is twemproxy. Possible values are:
 + one_at_a_time
 + md5
 + crc16
 + crc32 (crc32 implementation compatible with [libmemcached](http://libmemcached.org/))
 + crc32a (correct crc32 implementation as per the spec)
 + fnv1_64
 + fnv1a_64
 + fnv1_32
 + fnv1a_32
 + hsieh
 + murmur
 + jenkins
+ **hash_tag**: A two character string that specifies the part of the key used for hashing. Eg "{}" or "$$". [Hash tag](notes/recommendation.md#hash-tags) enable mapping different keys to the same server as long as the part of the key within the tag is the same. Just for type is twemproxy.
+ **distribution**: The key distribution mode. Just for type is twemproxy. Possible values are:
 + ketama
 + modula
 + random

### common:
+ **listen**: The listening address and port (name:port or ip:port). Defaults to 127.0.0.1:8888.
+ **max_clients**: The max clients count for the listen port. Defaults to 100.
+ **threads**: The max threads count can be used by redis-migrate-tool. Defaults to the cpu core count.
+ **step**: The step for parse request. The higher the number, the more quickly to migrate, but the more memory used. Defaults to 1.
+ **mbuf_size**: Mbuf size for request. Defaults to 512.
+ **noreply**: A boolean value that decide whether to check the target group replies. Defaults to false.
+ **source_safe**: A boolean value that protect the source group machines memory safe. If it is true, the tool can guarantee only one redis to generate rdb file at one time on the same machine for source group. In addition, 'source_safe: true' may use less threads then you set. Defaults to true.
+ **dir**: Work directory, used to store files(such as rdb file). Defaults to the current directory.
+ **filter**: Filter keys if they do not match the pattern. The pattern is Glob-style. Defaults is NULL.

**filter** supported glob-style patterns:

+ h?llo matches hello, hallo and hxllo

+ h*llo matches hllo and heeeello

+ h[ae]llo matches hello and hallo, but not hillo

+ h[^e]llo matches hallo, hbllo, ... but not hello

+ h[a-b]llo matches hallo and hbllo

Use \ to escape special characters if you want to match them verbatim.

For example, the configuration file shown below is to migrate data from single to twemproxy.

    [source]
    type: single
    servers:
     - 127.0.0.1:6379
     - 127.0.0.1:6380
     - 127.0.0.1:6381
     - 127.0.0.1:6382

    [target]
    type: twemproxy
    hash: fnv1a_64
    hash_tag: "{}"
    distribution: ketama
    servers:
     - 127.0.0.1:6380:1 server1
     - 127.0.0.1:6381:1 server2
     - 127.0.0.1:6382:1 server3
     - 127.0.0.1:6383:1 server4

    [common]
    listen: 0.0.0.0:8888
    threads: 2
    step: 1
    mbuf_size: 1024
    source_safe: true

Migrate data from twemproxy to redis cluster.

    [source]
    type: twemproxy
    hash: fnv1a_64
    hash_tag: "{}"
    distribution: ketama
    servers:
     - 127.0.0.1:6379
     - 127.0.0.1:6380
     - 127.0.0.1:6381
     - 127.0.0.1:6382

    [target]
    type: redis cluster
    servers:
     - 127.0.0.1:7379

    [common]
    listen: 0.0.0.0:8888
    step: 1
    mbuf_size: 512

Migrate data from a redis cluster to another redis cluster with key filter(key's prefix is "abc").

    [source]
    type: redis cluster
    servers:
     - 127.0.0.1:8379

    [target]
    type: redis cluster
    servers:
     - 127.0.0.1:7379

    [common]
    listen: 0.0.0.0:8888
    filter: abc*

Load data from rdb file to redis cluster.

    [source]
    type: rdb file
    servers:
     - /data/redis/dump1.rdb
	 - /data/redis/dump2.rdb

    [target]
    type: redis cluster
    servers:
     - 127.0.0.1:7379

    [common]
    listen: 0.0.0.0:8888
    step: 2
    mbuf_size: 512
    source_safe: false

Just save rdb file from redis cluster.

    [source]
    type: redis cluster
    servers:
     - 127.0.0.1:7379

    [target]
    type: rdb file

    [common]
    listen: 0.0.0.0:8888
    source_safe: true

Load data from aof file to redis cluster.

    [source]
    type: aof file
    servers:
     - /data/redis/appendonly1.aof
     - /data/redis/appendonly2.aof

    [target]
    type: redis cluster
    servers:
     - 127.0.0.1:7379

    [common]
    listen: 0.0.0.0:8888
    step: 2

## STATUS

You can use redis-cli to connect with redis-migrate-tool. The listening address and port can be setted at common config.

### info command

For example, you try the **info** command:

    $redis-cli -h 127.0.0.1 -p 8888
    127.0.0.1:8888> info
    # Server
    version:0.1.0
    os:Linux 2.6.32-573.12.1.el6.x86_64 x86_64
    multiplexing_api:epoll
    gcc_version:4.4.7
    process_id:9199
    tcp_port:8888
    uptime_in_seconds:1662
    uptime_in_days:0
    config_file:/ect/rmt.conf

    # Clients
    connected_clients:1
    max_clients_limit:100
    total_connections_received:3

    # Memory
    mem_allocator:jemalloc-4.0.4

    # Group
    source_nodes_count:32
    target_nodes_count:48

    # Stats
    all_rdb_received:1
    all_rdb_parsed:1
    all_aof_loaded:0
    rdb_received_count:32
    rdb_parsed_count:32
    aof_loaded_count:0
    total_msgs_recv:7753587
    total_msgs_sent:7753587
    total_net_input_bytes:234636318
    total_net_output_bytes:255384129
    total_net_input_bytes_human:223.77M
    total_net_output_bytes_human:243.55M
    total_mbufs_inqueue:0
    total_msgs_outqueue:0
    127.0.0.1:8888>

**info** command response instruction:

#### Server:

+ **version**: The redis-migrate-tool version number.
+ **os**: The os uname.
+ **multiplexing_api**: Multiplexing API.
+ **gcc_version**: Gcc version.
+ **process_id**: The process id of the redis-migrate-tool.
+ **tcp_port**: The tcp port redis-migrate-tool listening.
+ **uptime_in_seconds**: Seconds the redis-migrate-tool running.
+ **uptime_in_days**: Days the redis-migrate-tool running.
+ **config_file**: The config file name for the redis-migrate-tool.

#### Clients:

+ **connected_clients**: The count of clients that connected at present.
+ **max_clients_limit**: The max number of clients that allows to accept at the same time.
+ **total_connections_received**: The total count of connections that received so far.

#### Group:

+ **source_nodes_count**: The nodes count of source redis group.
+ **target_nodes_count**: The nodes count of target redis group.

#### Stats:

+ **all_rdb_received**: Whether all the rdb of the nodes in source group received.
+ **all_rdb_parsed**: Whether all the rdb of the nodes in source group parsed finished.
+ **all_aof_loaded**: Whether all the aof file of the nodes in source group loaded finished.
+ **rdb_received_count**: The received rdb count for the nodes in source group.
+ **rdb_parsed_count**: The parsed finished rdb count for the nodes in source group.
+ **aof_loaded_count**: The loaded finished aof file count for the nodes in source group.
+ **total_msgs_recv**: The total count of messages that had received from the source group.
+ **total_msgs_sent**: The total count of messages that had sent to the target group and received response from target group.
+ **total_net_input_bytes**: The total count of input bytes that had received from the source group.
+ **total_net_output_bytes**: The total count of output bytes that had sent to the target group.
+ **total_net_input_bytes_human**: Same as the **total_net_input_bytes**, but convert into human readable.
+ **total_net_output_bytes_human**: Same as the **total_net_output_bytes**, but convert into human readable.
+ **total_mbufs_inqueue**: Cached commands data(not include rdb data) by mbufs input from source group.
+ **total_msgs_outqueue**: Msgs will be sent to target group and msgs had been sent to target but waiting for the response.

## OTHER COMMANDS

### shutdown [seconds|asap]

The command behavior is the following:

+ Stop the replication from the source redis.
+ Try to send the cached data in redis-migrate-tool to the target redis.
+ Redis-migrate-tool stop and exit.

Parameter:

+ **seconds**: Most of seconds that redis-migrate-tool can used to send cached data to target redis before exit. Defaults to 10 seconds.
+ **asap**: Don't care about the cached data, just exit right now.

For example, you try the **shutdown** command:

    $redis-cli -h 127.0.0.1 -p 8888
    127.0.0.1:8888> shutdown
    OK

## CHECK THE DATA

After migrate the data, you can use **redis_check** command to check data in the source group and target group.

Try the **redis_check** command:

    $src/redis-migrate-tool -c rmt.conf -o log -C redis_check
    Check job is running...

    Checked keys: 1000
    Inconsistent value keys: 0
    Inconsistent expire keys : 0
    Other check error keys: 0
    Checked OK keys: 1000

    All keys checked OK!
    Check job finished, used 1.041s

If you want check more keys, try the follow:

    $src/redis-migrate-tool -c rmt.conf -o log -C "redis_check 200000"
    Check job is running...

    Checked keys: 200000
    Inconsistent value keys: 0
    Inconsistent expire keys : 0
    Other check error keys: 0
    Checked OK keys: 200000

    All keys checked OK!
    Check job finished, used 11.962s

## INSERT SOME KEYS JUST FOR **TEST**

Try the **redis_testinsert** command:

    $src/redis-migrate-tool -c rmt.conf -o log -C "redis_testinsert"
    Test insert job is running...

    Insert string keys: 200
    Insert list keys  : 200
    Insert set keys   : 200
    Insert zset keys  : 200
    Insert hash keys  : 200
    Insert total keys : 1000

    Correct inserted keys: 1000
    Test insert job finished, used 0.525s

If you want insert more keys, try the follow:

    $src/redis-migrate-tool -c rmt.conf -o log -C "redis_testinsert 30000"
    Test insert job is running...

    Insert string keys: 6000
    Insert list keys  : 6000
    Insert set keys   : 6000
    Insert zset keys  : 6000
    Insert hash keys  : 6000
    Insert total keys : 30000

    Correct inserted keys: 30000
    Test insert job finished, used 15.486s

If you want insert only string type keys, try the follow:

    $src/redis-migrate-tool -c rmt.conf -o log -C "redis_testinsert string"
    Test insert job is running...

    Insert string keys: 1000
    Insert list keys  : 0
    Insert set keys   : 0
    Insert zset keys  : 0
    Insert hash keys  : 0
    Insert total keys : 1000

    Correct inserted keys: 1000
    Test insert job finished, used 0.024s

If you want insert some special type keys, try the follow:

    $src/redis-migrate-tool -c rmt.conf -o log -C "redis_testinsert string|set|list 10000"
    Test insert job is running...

    Insert string keys: 3336
    Insert list keys  : 3336
    Insert set keys   : 3328
    Insert zset keys  : 0
    Insert hash keys  : 0
    Insert total keys : 10000

    Correct inserted keys: 10000
    Test insert job finished, used 5.539s

## License

Copyright © 2016 VIPSHOP Inc.

Licensed under the Apache License, Version 2.0: http://www.apache.org/licenses/LICENSE-2.0