take the scatters and skylines and make final ivars
335640
def make_full_ivar():
    

    # skylines come as an ivar
    # don't use them for now, because I don't really trust them...
    # skylines = np.load("%s/skylines.npz" %DATA_DIR)['arr_0']

    ref_flux = np.load("%s/ref_flux_all.npz" %DATA_DIR)['arr_0']
    ref_scat = np.load("%s/ref_spec_scat_all.npz" %DATA_DIR)['arr_0']
    test_flux = np.load("%s/test_flux.npz" %DATA_DIR)['arr_0']
    test_scat = np.load("%s/test_spec_scat.npz" %DATA_DIR)['arr_0']
    ref_ivar = np.ones(ref_flux.shape) / ref_scat[:,None]**2
    test_ivar = np.ones(test_flux.shape) / test_scat[:,None]**2

    # ref_ivar = (ref_ivar_temp * skylines[None,:]) / (ref_ivar_temp + skylines)
    # test_ivar = (test_ivar_temp * skylines[None,:]) / (test_ivar_temp + skylines)

    ref_bad = np.logical_or(ref_flux <= 0, ref_flux > 1.1)
    test_bad = np.logical_or(test_flux <= 0, test_flux > 1.1)
    SMALL = 1.0 / 1000000000.0
    ref_ivar[ref_bad] = SMALL
    test_ivar[test_bad] = SMALL
    np.savez("%s/ref_ivar_corr.npz" %DATA_DIR, ref_ivar)
    np.savez("%s/test_ivar_corr.npz" %DATA_DIR, test_ivar)
290834
private void fillM( Point2D_F64 x1 , Point2D_F64 x2 , Point2D_F64 x3 ) {
		M.data[0] = x1.x; M.data[1] = x1.y; M.data[2] = 1;
		M.data[3] = x2.x; M.data[4] = x2.y; M.data[5] = 1;
		M.data[6] = x3.x; M.data[7] = x3.y; M.data[8] = 1;
	}
6957
private void init() {
        quantiles = new double[data.length][8];
        for (int i = 0; i < data.length; i++) {
            int n = data[i].length;
            Arrays.sort(data[i]);
            quantiles[i][1] = data[i][n / 4];
            quantiles[i][2] = data[i][n / 2];
            quantiles[i][3] = data[i][3 * n / 4];
            quantiles[i][5] = quantiles[i][3] - quantiles[i][1]; // interquartile range
            quantiles[i][6] = quantiles[i][1] - 1.5 * quantiles[i][5];
            quantiles[i][7] = quantiles[i][3] + 1.5 * quantiles[i][5];
            quantiles[i][0] = quantiles[i][6] < data[i][0] ? data[i][0] : quantiles[i][6];
            quantiles[i][4] = quantiles[i][7] > data[i][data[i].length - 1] ? data[i][data[i].length - 1] : quantiles[i][7];
        }
    }
720848
def finalize(self, **kwargs):
        
        # Set the title
        self.set_title(
            'RadViz for {} Features'.format(len(self.features_))
        )

        # Remove the ticks from the graph
        self.ax.set_yticks([])
        self.ax.set_xticks([])

        # Add the legend
        colors = [self._colors[c] for c in self.classes_]
        manual_legend(self, self.classes_, colors, loc='best')
929372
private List<Callable<List<EvaluatedCandidate<T>>>> createEpochTasks(int populationSize,
                                                                         int eliteCount,
                                                                         int epochLength,
                                                                         List<List<T>> islandPopulations)
    {
        List<Callable<List<EvaluatedCandidate<T>>>> islandEpochs
            = new ArrayList<Callable<List<EvaluatedCandidate<T>>>>(islands.size());
        for (int i = 0; i < islands.size(); i++)
        {
            islandEpochs.add(new Epoch<T>(islands.get(i),
                                          populationSize,
                                          eliteCount,
                                          islandPopulations.isEmpty() ? Collections.<T>emptyList() : islandPopulations.get(i),
                                          new GenerationCount(epochLength)));
        }
        return islandEpochs;
    }
243203
public void combine(LongSummaryStatistics other) {
        count += other.count;
        sum += other.sum;
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }
13518
public void combine(IntSummaryStatistics other) {
        count += other.count;
        sum += other.sum;
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }
1290567
def run(self):
        '''
        

        '''

        try:

            # Load raw data
            log.info("Loading target data...")
            self.load_tpf()
            self.mask_planets()
            self.plot_aperture([self.dvs.top_right() for i in range(4)])
            self.init_kernel()
            M = self.apply_mask(np.arange(len(self.time)))
            self.cdppr_arr = self.get_cdpp_arr()
            self.cdpp_arr = np.array(self.cdppr_arr)
            self.cdppv_arr = np.array(self.cdppr_arr)
            self.cdppr = self.get_cdpp()
            self.cdpp = self.cdppr
            self.cdppv = self.cdppr

            log.info("%s (Raw): CDPP = %s" % (self.name, self.cdpps))
            self.plot_lc(self.dvs.left(), info_right='Raw', color='k')

            # Loop
            for n in range(self.pld_order):
                self.lam_idx += 1
                self.get_outliers()
                if n > 0 and self.optimize_gp:
                    self.update_gp()
                self.cross_validate(self.dvs.right(), info='CV%d' % n)
                self.cdpp_arr = self.get_cdpp_arr()
                self.cdppv_arr *= self.cdpp_arr
                self.cdpp = self.get_cdpp()
                self.cdppv = np.nanmean(self.cdppv_arr)
                log.info("%s (%d/%d): CDPP = %s" %
                         (self.name, n + 1, self.pld_order, self.cdpps))
                self.plot_lc(self.dvs.left(), info_right='LC%d' % (
                    n + 1), info_left='%d outliers' % len(self.outmask))

            # Save
            self.finalize()
            self.plot_final(self.dvs.top_left())
            self.plot_info(self.dvs)
            self.save_model()

        except:

            self.exception_handler(self.debug)
459310
function simplifyRadialDist(points, sqTolerance) {

    var prevPoint = points[0],
        newPoints = [prevPoint],
        point;

    for (var i = 1, len = points.length; i < len; i++) {
        point = points[i];

        if (getSqDist(point, prevPoint) > sqTolerance) {
            newPoints.push(point);
            prevPoint = point;
        }
    }

    if (prevPoint !== point) newPoints.push(point);

    return newPoints;
}
379076
public synchronized void finish() {
        if (!isFinished) {
            isFinished = true;
            try {
                matrixDos.close();
                // Re-open as a random access file so we can overwrite the 3 int
                // header that specifies the number of dimensions and values.
                // Note that the location of the matrix data is dependent on
                // whether the matrix is to be transposed.
                File dataFile = (transposeData)
                    ? transposedMatrixFile
                    : matrixFile;
                RandomAccessFile matrixRaf =
                    new RandomAccessFile(dataFile, "rw");

                // Back fill the dimensions of the matrix and the number of
                // non-zero values as the 3 int header in the file
                matrixRaf.writeInt(numRows);
                matrixRaf.writeInt(curCol);
                matrixRaf.writeInt(nonZeroValues);
                matrixRaf.close();

            } catch (IOException ioe) {
                throw new IOError(ioe);
            }

            // If the user specified that the matrix should be tranposed, then
            // transposedMatrixFile will contain the matrix in its un-transposed
            // form.  Issue a call to SVDLIBC to transposed the file contents
            // for us.
            if (transposeData) {
                boolean svdlibcFailed = false;
                try {                    
                    String commandLine = "svd  -r sb " + " -w sb -t -c " 
                        + transposedMatrixFile + " " + matrixFile;
                    Process svdlibc = Runtime.getRuntime().exec(commandLine);
                    LOGGER.fine("transposing svdlibc sparse matrix: " + commandLine);
                    BufferedReader stdout = new BufferedReader(
                        new InputStreamReader(svdlibc.getInputStream()));
                    BufferedReader stderr = new BufferedReader(
                        new InputStreamReader(svdlibc.getErrorStream()));
                    
                    StringBuilder output = new StringBuilder("SVDLIBC output:\n");
                    for (String line = null; (line = stderr.readLine()) != null; ) {
                        output.append(line).append("\n");
                    }
                    LOGGER.fine(output.toString());
                    
                    int exitStatus = svdlibc.waitFor();
                    LOGGER.fine("svdlibc exit status: " + exitStatus);
                    if (exitStatus != 0) {
                        StringBuilder sb = new StringBuilder();
                        for (String line = null; (line = stderr.readLine()) != null; ) {
                            sb.append(line).append("\n");
                        }
                        // warning or error?
                        LOGGER.warning("svdlibc exited with error status.  " + 
                                       "stderr:\n" + sb.toString());
                        svdlibcFailed = true;
                    } 
                }
                catch (Exception e) {
                    svdlibcFailed = true;
                    LOGGER.log(Level.WARNING,
                               "an exception occurred when trying to transpose " + 
                               "with svdlibc; retrying with Java code", e);
                }
                // If SVDLIBC failed in any way, use MatrixIO to transpose the
                // data for us.
                if (svdlibcFailed) {
                    LOGGER.fine("retrying failed svdlibc transpose " + 
                                "with MatrixIO transpose");
                    try {
                        matrixFile = MatrixIO.convertFormat(
                            transposedMatrixFile, Format.SVDLIBC_SPARSE_BINARY,
                            Format.SVDLIBC_SPARSE_BINARY, true);
                    } catch (IOException ioe) {
                        throw new IOError(ioe);
                    }
                }
            }
        }
    }
1070613
def finalize(self, **kwargs):
        
        # Set the aspect ratio to make the visualization square
        # TODO: still unable to make plot square using make_axes_locatable
        # x0,x1 = self.ax.get_xlim()
        # y0,y1 = self.ax.get_ylim()
        # self.ax.set_aspect(abs(x1-x0)/abs(y1-y0))

        # Add the title to the plot if the user has set one.
        self.set_title("")

        # Set the legend with full opacity patches using manual legend.
        # Or Add the colorbar if this is a continuous plot.
        self.ax.legend(loc="best", frameon=True)

        # Finalize the histograms
        if self.hist:
            plt.setp(self.xhax.get_xticklabels(), visible=False)
            plt.setp(self.yhax.get_yticklabels(), visible=False)
            plt.sca(self.ax)

        # Call tight layout to maximize readability
        plt.tight_layout()
1182466
List<Integer> convexhull(List<Float> pts) {
        int npts = pts.size() / 3;
        List<Integer> out = new ArrayList<>();
        // Find lower-leftmost point.
        int hull = 0;
        for (int i = 1; i < npts; ++i) {
            float[] a = new float[] { pts.get(i * 3), pts.get(i * 3 + 1), pts.get(i * 3 + 2) };
            float[] b = new float[] { pts.get(hull * 3), pts.get(hull * 3 + 1), pts.get(hull * 3 + 2) };
            if (cmppt(a, b)) {
                hull = i;
            }
        }
        // Gift wrap hull.
        int endpt = 0;
        do {
            out.add(hull);
            endpt = 0;
            for (int j = 1; j < npts; ++j) {
                float[] a = new float[] { pts.get(hull * 3), pts.get(hull * 3 + 1), pts.get(hull * 3 + 2) };
                float[] b = new float[] { pts.get(endpt * 3), pts.get(endpt * 3 + 1), pts.get(endpt * 3 + 2) };
                float[] c = new float[] { pts.get(j * 3), pts.get(j * 3 + 1), pts.get(j * 3 + 2) };
                if (hull == endpt || left(a, b, c)) {
                    endpt = j;
                }
            }
            hull = endpt;
        } while (endpt != out.get(0));

        return out;
    }
734146
private void scatter(Graphics g, int i) {

    	int height = getHeight();
    	int width = getWidth();

    	int x = (int)(((this.variedParamValues[i] - this.lower_x_value) / (this.upper_x_value - this.lower_x_value)) * width); 
    	double value = this.measures[i].getLastValue(this.measureSelected);  

        if(Double.isNaN(value)){
        	// no result for this budget yet
            return;
        }

        int y = (int)(height - (value / this.upper_y_value) * height);

        g.setColor(this.colors[i]);

        if (this.isStandardDeviationPainted) {
            int len = (int) ((this.measureStds[i].getLastValue(this.measureSelected)/this.upper_y_value)*height);
            paintStandardDeviation(g, len, x, y);
        }

    	g.fillOval(x - DOT_SIZE/2, y - DOT_SIZE/2, DOT_SIZE, DOT_SIZE);

    }
430090
function scorePattern(point, ratios, matrix) {
        try {
            const horizontalRun = countBlackWhiteRun(point, { x: -1, y: point.y }, matrix, ratios.length);
            const verticalRun = countBlackWhiteRun(point, { x: point.x, y: -1 }, matrix, ratios.length);
            const topLeftPoint = {
                x: Math.max(0, point.x - point.y) - 1,
                y: Math.max(0, point.y - point.x) - 1,
            };
            const topLeftBottomRightRun = countBlackWhiteRun(point, topLeftPoint, matrix, ratios.length);
            const bottomLeftPoint = {
                x: Math.min(matrix.width, point.x + point.y) + 1,
                y: Math.min(matrix.height, point.y + point.x) + 1,
            };
            const bottomLeftTopRightRun = countBlackWhiteRun(point, bottomLeftPoint, matrix, ratios.length);
            const horzError = scoreBlackWhiteRun(horizontalRun, ratios);
            const vertError = scoreBlackWhiteRun(verticalRun, ratios);
            const diagDownError = scoreBlackWhiteRun(topLeftBottomRightRun, ratios);
            const diagUpError = scoreBlackWhiteRun(bottomLeftTopRightRun, ratios);
            const ratioError = Math.sqrt(horzError.error * horzError.error +
                vertError.error * vertError.error +
                diagDownError.error * diagDownError.error +
                diagUpError.error * diagUpError.error);
            const avgSize = (horzError.averageSize + vertError.averageSize + diagDownError.averageSize + diagUpError.averageSize) / 4;
            const sizeError = (Math.pow((horzError.averageSize - avgSize), 2) +
                Math.pow((vertError.averageSize - avgSize), 2) +
                Math.pow((diagDownError.averageSize - avgSize), 2) +
                Math.pow((diagUpError.averageSize - avgSize), 2)) / avgSize;
            return ratioError + sizeError;
        }
        catch (_a) {
            return Infinity;
        }
    }
12913
function mapToValues(v){
        function mapRec(e){
            if(!isAVector(e)) return e;
            return mapRec(e.get(0));
        }
        return v.map(mapRec);
    }
1193080
def finalizer(self, data):
        '''
        
        '''
        def explore(data):
            if isinstance(data, (dict, OrderedDict)):
                return PrintableDict(
                    [(key, explore(value)) for key, value in six.iteritems(data)]
                )
            elif isinstance(data, (list, tuple, set)):
                return data.__class__([explore(value) for value in data])
            return data
        return explore(data)
523204
public void combine(DoubleSummaryStatistics other) {
        count += other.count;
        simpleSum += other.simpleSum;
        sumWithCompensation(other.sum);
        sumWithCompensation(other.sumCompensation);
        min = Math.min(min, other.min);
        max = Math.max(max, other.max);
    }