Create new sketch
        Params:
            <int> width
            <int> max_value
            <str> path
            <int> flags
            <int> seed
345332
def create(self, width=0, max_value=0, path=None, flags=0, seed=0):
        
        return _madoka.Sketch_create(self, width, max_value, path, flags, seed)
81270
def create_for_data(cls, data, format, width, height, stride=None):
        
        return cls(format, width, height, data, stride)
796888
function _createPathData(d) {
  var sX = d.source.y,
      sY = d.source.x,
      tX = d.target.y,
      tY = d.target.x,
      mX = (sX + tX)/2,
      mY = (sY + tY)/2,

      sH = Math.abs(sX - tX) * 0.35,
      sV = 0; // strength

  if(d.isBackwardLink) {
    if(sY === tY) {
      sV = 45;
      mY -= 50;
      if(sX === tX) {
        sX += _layout.linkDelta;
        tX -= _layout.linkDelta;
      }
    }
    sH = Math.abs(sX - tX) * 1.1;
  }

  return _layout.pathFormatter(
    sX, sY,

    sX + sH, sY - sV,
    mX, mY,

    tX - sH, tY - sV,
    tX, tY
  );
}
1111842
function () {
			var series = this,
				dataMin = Number.MAX_VALUE,
				dataMax = Number.MIN_VALUE;
	
			series.generatePoints();
	
			each(series.data, function (point) {
				
				point.shapeType = 'path';
				point.shapeArgs = {
					d: series.translatePath(point.path)
				};
				
				// TODO: do point colors in drawPoints instead of point.init
				if (typeof point.y === 'number') {
					if (point.y > dataMax) {
						dataMax = point.y;
					} else if (point.y < dataMin) {
						dataMin = point.y;
					}
				}
			});
			
			series.translateColors(dataMin, dataMax);
		}
983324
private BufferedImage create_BIG_ROSE_POINTER_Image(final int WIDTH) {
        final BufferedImage IMAGE = UTIL.createImage((int) (WIDTH * 0.0546875f), (int) (WIDTH * 0.2f), java.awt.Transparency.TRANSLUCENT);
        final Graphics2D G2 = IMAGE.createGraphics();

        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION, RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);

        final int IMAGE_WIDTH = IMAGE.getWidth();
        final int IMAGE_HEIGHT = IMAGE.getHeight();

        G2.setStroke(new BasicStroke(0.75f));

        // Define arrow shape of pointer
        final GeneralPath POINTER_WHITE_LEFT = new GeneralPath();
        final GeneralPath POINTER_WHITE_RIGHT = new GeneralPath();

        POINTER_WHITE_LEFT.moveTo(IMAGE_WIDTH - IMAGE_WIDTH * 0.95f, IMAGE_HEIGHT);
        POINTER_WHITE_LEFT.lineTo(IMAGE_WIDTH / 2.0f, 0);
        POINTER_WHITE_LEFT.lineTo(IMAGE_WIDTH / 2.0f, IMAGE_HEIGHT);
        POINTER_WHITE_LEFT.closePath();

        POINTER_WHITE_RIGHT.moveTo(IMAGE_WIDTH * 0.95f, IMAGE_HEIGHT);
        POINTER_WHITE_RIGHT.lineTo(IMAGE_WIDTH / 2.0f, 0);
        POINTER_WHITE_RIGHT.lineTo(IMAGE_WIDTH / 2.0f, IMAGE_HEIGHT);
        POINTER_WHITE_RIGHT.closePath();

        final Area POINTER_FRAME_WHITE = new Area(POINTER_WHITE_LEFT);
        POINTER_FRAME_WHITE.add(new Area(POINTER_WHITE_RIGHT));

        final Color STROKE_COLOR = getBackgroundColor().SYMBOL_COLOR.darker();
        final Color FILL_COLOR = getBackgroundColor().SYMBOL_COLOR;

        G2.setColor(STROKE_COLOR);
        G2.fill(POINTER_WHITE_RIGHT);
        G2.setColor(FILL_COLOR);
        G2.fill(POINTER_WHITE_LEFT);
        G2.setColor(STROKE_COLOR);
        G2.draw(POINTER_FRAME_WHITE);

        G2.dispose();

        return IMAGE;
    }
638889
public static void main(String[] args) {
		final int trials = 10000;
		final int maxLength = 10000;

		Random rnd = new Random();
		final int seed = rnd.nextInt();

		System.out.print("Test correctness... ");
		rnd = new Random(seed);
		for (int i = 0; i < trials; i++) {
			int[] x = new int[rnd.nextInt(maxLength)];
			for (int j = 0; j < x.length; j++)
				x[j] = rnd.nextInt(Integer.MAX_VALUE);

			int size1 = 0;
			for (int j = 0; j < x.length; j++)
				size1 += Integer.bitCount(x[j]);
			int size2 = count(x);

			if (size1 != size2) {
				System.out.println("i = " + i);
				System.out.println("ERRORE!");
				System.out.println(size1 + ", " + size2);
				for (int j = 0; j < x.length; j++)
					System.out.format("x[%d] = %d --> %d\n", j, x[j], Integer.bitCount(x[j]));
				return;
			}
		}
		System.out.println("done!");

		System.out.print("Test correctness II... ");
		rnd = new Random(seed);
		for (int i = 0; i < trials; i++) {
			int[] x = new int[rnd.nextInt(maxLength << 1)];
			for (int j = 1; j < x.length; j += 2)
				x[j] = rnd.nextInt(Integer.MAX_VALUE);

			int size1 = 0;
			for (int j = 1; j < x.length; j += 2)
				size1 += Integer.bitCount(x[j]);
			int size2 = count_2(x);

			if (size1 != size2) {
				System.out.println("i = " + i);
				System.out.println("ERRORE!");
				System.out.println(size1 + ", " + size2);
				for (int j = 1; j < x.length; j += 2)
					System.out.format("x[%d] = %d --> %d\n", j, x[j], Integer.bitCount(x[j]));
				return;
			}
		}
		System.out.println("done!");

		System.out.print("Test time count(): ");
		rnd = new Random(seed);
		long t = System.currentTimeMillis();
		for (int i = 0; i < trials; i++) {
			int[] x = new int[rnd.nextInt(maxLength)];
			for (int j = 0; j < x.length; j++)
				x[j] = rnd.nextInt(Integer.MAX_VALUE);

			@SuppressWarnings("unused")
			int size = 0;
			for (int j = 0; j < x.length; j++)
				size += Integer.bitCount(x[j]);
		}
		System.out.println(System.currentTimeMillis() - t);

		System.out.print("Test time BitCount.count():   ");
		rnd = new Random(seed);
		t = System.currentTimeMillis();
		for (int i = 0; i < trials; i++) {
			int[] x = new int[rnd.nextInt(maxLength)];
			for (int j = 0; j < x.length; j++)
				x[j] = rnd.nextInt(Integer.MAX_VALUE);
			count(x);
		}
		System.out.println(System.currentTimeMillis() - t);

		System.out.print("Test II time count(): ");
		rnd = new Random(seed);
		t = System.currentTimeMillis();
		for (int i = 0; i < trials; i++) {
			int[] x = new int[rnd.nextInt(maxLength << 1)];
			for (int j = 1; j < x.length; j += 2)
				x[j] = rnd.nextInt(Integer.MAX_VALUE);

			@SuppressWarnings("unused")
			int size = 0;
			for (int j = 1; j < x.length; j += 2)
				size += Integer.bitCount(x[j]);
		}
		System.out.println(System.currentTimeMillis() - t);

		System.out.print("Test II time BitCount.count():   ");
		rnd = new Random(seed);
		t = System.currentTimeMillis();
		for (int i = 0; i < trials; i++) {
			int[] x = new int[rnd.nextInt(maxLength << 1)];
			for (int j = 1; j < x.length; j += 2)
				x[j] = rnd.nextInt(Integer.MAX_VALUE);
			count_2(x);
		}
		System.out.println(System.currentTimeMillis() - t);
	}
558709
private void initAnsiWidths() {
        ansiWidth = new int[256];
        for (int i = 0; i < 256; i++) {
            ansiWidth[i] = mtxTab[0].getWx();
        }

        // Create an index hash to the ansiWidth
        // Can't just index the winAnsiEncoding when inserting widths
        // same char (eg bullet) is repeated more than one place
        ansiIndex = new java.util.HashMap();
        for (int i = 32; i < Glyphs.WINANSI_ENCODING.length; i++) {
            Integer ansi = new Integer(i);
            Integer uni = new Integer(Glyphs.WINANSI_ENCODING[i]);

            List v = (List)ansiIndex.get(uni);
            if (v == null) {
                v = new java.util.ArrayList();
                ansiIndex.put(uni, v);
            }
            v.add(ansi);
        }
    }
168617
@SuppressWarnings({ "unchecked", "null" })
  public void update(final Sketch<S> sketchIn) {
    final boolean isFirstCall = isFirstCall_;
    isFirstCall_ = false;
    if (sketchIn == null) {
      isEmpty_ = true;
      sketch_ = null;
      return;
    }
    theta_ = min(theta_, sketchIn.getThetaLong());
    isEmpty_ |= sketchIn.isEmpty();
    if (isEmpty_ || (sketchIn.getRetainedEntries() == 0)) {
      sketch_ = null;
      return;
    }
    // assumes that constructor of QuickSelectSketch bumps the requested size up to the nearest power of 2
    if (isFirstCall) {
      sketch_ = new QuickSelectSketch<>(sketchIn.getRetainedEntries(), ResizeFactor.X1.lg(), null);
      final SketchIterator<S> it = sketchIn.iterator();
      while (it.next()) {
        final S summary = (S)it.getSummary().copy();
        sketch_.insert(it.getKey(), summary);
      }
    } else {
      if (sketch_ == null) {
        return;
      }
      final int matchSize = min(sketch_.getRetainedEntries(), sketchIn.getRetainedEntries());
      final long[] matchKeys = new long[matchSize];
      S[] matchSummaries = null;
      int matchCount = 0;
      final SketchIterator<S> it = sketchIn.iterator();
      while (it.next()) {
        final S summary = sketch_.find(it.getKey());
        if (summary != null) {
          matchKeys[matchCount] = it.getKey();
          if (matchSummaries == null) {
            matchSummaries = (S[]) Array.newInstance(summary.getClass(), matchSize);
          }
          matchSummaries[matchCount] =
              summarySetOps_.intersection(summary, it.getSummary());
          matchCount++;
        }
      }
      sketch_ = null;
      if (matchCount > 0) {
        sketch_ = new QuickSelectSketch<>(matchCount, ResizeFactor.X1.lg(), null);
        for (int i = 0; i < matchCount; i++) {
          sketch_.insert(matchKeys[i], matchSummaries[i]);
        }
      }
    }
    if (sketch_ != null) {
      sketch_.setThetaLong(theta_);
      sketch_.setNotEmpty();
    }
  }
612290
private void createShape() {
    if (shape == null) {
      float firstItemMargin = noxConfig.getNoxItemMargin();
      float firstItemSize = noxConfig.getNoxItemSize();
      int viewHeight = getMeasuredHeight();
      int viewWidth = getMeasuredWidth();
      int numberOfElements = noxItemCatalog.size();
      ShapeConfig shapeConfig =
          new ShapeConfig(numberOfElements, viewWidth, viewHeight, firstItemSize, firstItemMargin);
      shape = ShapeFactory.getShapeByKey(defaultShapeKey, shapeConfig);
    } else {
      shape.setNumberOfElements(noxItemCatalog.size());
    }
    shape.calculate();
  }
1149856
function createAtlas(width, height, name, repeat) {
         return {
           "meta": {
             "app": "melonJS",
             "size": {
               "w": width,
               "h": height
             },
             "repeat": repeat || "no-repeat",
             "image": "default"
           },
           "frames": [{
             "filename": name || "default",
             "frame": {
               "x": 0,
               "y": 0,
               "w": width,
               "h": height
             }
           }]
         };
       }
34518
def run_sketch(self):
        
        Sketch.instance = self
        self.init()
        frame = self.create_frame()
        if frame:
            frame.add(self)
            frame.pack()
            frame.visible = 1
129599
def random_draw(self, size=None):
        
        if size is None:
            size = 1
            single_val = True
        else:
            single_val = False
        
        out_shape = [len(self.bounds)]
        try:
            out_shape.extend(size)
        except TypeError:
            out_shape.append(size)
        
        out = scipy.zeros(out_shape)
        for j in xrange(0, len(self.bounds)):
            if j != 2:
                out[j, :] = numpy.random.uniform(low=self.bounds[j][0],
                                                 high=self.bounds[j][1],
                                                 size=size)
            else:
                out[j, :] = numpy.random.uniform(low=self.bounds[j][0],
                                                 high=out[j - 1, :],
                                                 size=size)
        if not single_val:
            return out
        else:
            return out.ravel()
8158
def draw(self):
        '''
        
        '''
        observed_arr = self.noise_sampler.generate()
        arr = self.inference(observed_arr)
        return arr
1043745
private static void genRanks(int noDocs, String path) {

		Random rand = new Random(Calendar.getInstance().getTimeInMillis());

		try (BufferedWriter fw = new BufferedWriter(new FileWriter(path))) {
			for (int i = 0; i < noDocs; i++) {
				// Rank
				StringBuilder rank = new StringBuilder(rand.nextInt(100) + "|");
				// URL
				rank.append("url_" + i + "|");
				// Average duration
				rank.append(rand.nextInt(10) + rand.nextInt(50) + "|\n");

				fw.write(rank.toString());
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
456753
def draw(self, value, newline=True, flush=True):
        
        # This is essentially winch-handling without having
        #   to do winch-handling; cleanly redrawing on winch is difficult
        #   and out of the intended scope of this class; we *can*
        #   however, adjust the next draw to be proper by re-measuring
        #   the terminal since the code is mostly written dynamically
        #   and many attributes and dynamically calculated properties.
        self._measure_terminal()
        
        # To avoid zero division, set amount_complete to 100% if max_value has been stupidly set to 0
        amount_complete = 1.0 if self.max_value == 0 else value / self.max_value
        fill_amount = int(floor(amount_complete * self.max_width))
        empty_amount = self.max_width - fill_amount

        # e.g., '10/20' if 'fraction' or '50%' if 'percentage'
        amount_complete_str = (
            u"{}/{}".format(value, self.max_value)
            if self._num_rep == "fraction" else
            u"{}%".format(int(floor(amount_complete * 100)))
        )

        # Write title if supposed to be above
        if self._title_pos == "above":
            title_str = u"{}{}\n".format(
                " " * self._indent,
                self.title,
            )
            self._write(title_str, ignore_overflow=True)

        # Construct just the progress bar
        bar_str = u''.join([
            u(self.filled(self._filled_char * fill_amount)),
            u(self.empty(self._empty_char * empty_amount)),
        ])
        # Wrap with start and end character
        bar_str = u"{}{}{}".format(self.start_char, bar_str, self.end_char)
        # Add on title if supposed to be on left or right
        if self._title_pos == "left":
            bar_str = u"{} {}".format(self.title, bar_str)
        elif self._title_pos == "right":
            bar_str = u"{} {}".format(bar_str, self.title)
        # Add indent
        bar_str = u''.join([" " * self._indent, bar_str])
        # Add complete percentage or fraction
        bar_str = u"{} {}".format(bar_str, amount_complete_str)
        # Set back to normal after printing
        bar_str = u"{}{}".format(bar_str, self.term.normal)
        # Finally, write the completed bar_str
        self._write(bar_str, s_length=self.full_line_width)

        # Write title if supposed to be below
        if self._title_pos == "below":
            title_str = u"\n{}{}".format(
                " " * self._indent,
                self.title,
            )
            self._write(title_str, ignore_overflow=True)

        # Newline to wrap up
        if newline:
            self.cursor.newline()
        if flush:
            self.cursor.flush()
682200
private static void updateWindowed(final CpcSketch sketch, final int rowCol) {
    assert ((sketch.windowOffset >= 0) && (sketch.windowOffset <= 56));
    final int k = 1 << sketch.lgK;
    final long c32pre = sketch.numCoupons << 5;
    assert c32pre >= (3L * k); // C < 3K/32, in other words flavor >= HYBRID
    final long c8pre = sketch.numCoupons << 3;
    final int w8pre = sketch.windowOffset << 3;
    assert c8pre < ((27L + w8pre) * k); // C < (K * 27/8) + (K * windowOffset)

    boolean isNovel = false; //novel if new coupon
    final int col = rowCol & 63;

    if (col < sketch.windowOffset) { // track the surprising 0's "before" the window
      isNovel = PairTable.maybeDelete(sketch.pairTable, rowCol); // inverted logic
    }
    else if (col < (sketch.windowOffset + 8)) { // track the 8 bits inside the window
      assert (col >= sketch.windowOffset);
      final int row = rowCol >>> 6;
      final byte oldBits = sketch.slidingWindow[row];
      final byte newBits = (byte) (oldBits | (1 << (col - sketch.windowOffset)));
      if (newBits != oldBits) {
        sketch.slidingWindow[row] = newBits;
        isNovel = true;
      }
    }
    else { // track the surprising 1's "after" the window
      assert col >= (sketch.windowOffset + 8);
      isNovel = PairTable.maybeInsert(sketch.pairTable, rowCol); // normal logic
    }

    if (isNovel) {
      sketch.numCoupons += 1;
      updateHIP(sketch, rowCol);
      final long c8post = sketch.numCoupons << 3;
      if (c8post >= ((27L + w8pre) * k)) {
        modifyOffset(sketch, sketch.windowOffset + 1);
        assert (sketch.windowOffset >= 1) && (sketch.windowOffset <= 56);
        final int w8post = sketch.windowOffset << 3;
        assert c8post < ((27L + w8post) * k); // C < (K * 27/8) + (K * windowOffset)
      }
    }
  }
1126519
public void update(final ArrayOfDoublesSketch sketchIn) {
    if (sketchIn == null) { return; }
    Util.checkSeedHashes(seedHash_, sketchIn.getSeedHash());
    if (sketch_.getNumValues() != sketchIn.getNumValues()) {
      throw new SketchesArgumentException("Incompatible sketches: number of values mismatch "
          + sketch_.getNumValues() + " and " + sketchIn.getNumValues());
    }
    if (sketchIn.isEmpty()) { return; }
    if (sketchIn.getThetaLong() < theta_) { theta_ = sketchIn.getThetaLong(); }
    final ArrayOfDoublesSketchIterator it = sketchIn.iterator();
    while (it.next()) {
      sketch_.merge(it.getKey(), it.getValues());
    }
  }