Converts the given pixel breakpoint object into a em breakpoint object
543323
function convertBreakpointsToEm(breakpointsInPx) {
    var breakpointsInEm = {};
    var breakpointNames = Object.keys(breakpointsInPx);
    breakpointNames.forEach(function (breakpointName) {
        breakpointsInEm[breakpointName] = px2em(breakpointsInPx[breakpointName]);
    });
    return breakpointsInEm;
}
656907
def invalid_pixel_mask(self):
        
        # init mask buffer
        mask = np.zeros([self.height, self.width, 1]).astype(np.uint8)

        # update invalid pixels
        zero_pixels = self.zero_pixels()
        nan_pixels = self.nan_pixels()
        mask[zero_pixels[:, 0], zero_pixels[:, 1]] = BINARY_IM_MAX_VAL
        mask[nan_pixels[:, 0], nan_pixels[:, 1]] = BINARY_IM_MAX_VAL
        return BinaryImage(mask, frame=self.frame)
145847
def getPixelAttrRandom(self, x, y):
        ''
        c = list(attr for attr, rows in self.pixels[y][x].items()
                         for r in rows if attr and attr not in self.hiddenAttrs)
        return random.choice(c) if c else 0
864794
public void process(GrayU8 binary , GrayS32 labeled ) {
		// initialize data structures
		labeled.reshape(binary.width,binary.height);

		// ensure that the image border pixels are filled with zero by enlarging the image
		if( border.width != binary.width+2 || border.height != binary.height+2)  {
			border.reshape(binary.width + 2, binary.height + 2);
			ImageMiscOps.fillBorder(border, 0, 1);
		}
		border.subimage(1,1,border.width-1,border.height-1, null).setTo(binary);

		// labeled image must initially be filled with zeros
		ImageMiscOps.fill(labeled,0);

		binary = border;
		packedPoints.reset();
		contours.reset();
		tracer.setInputs(binary,labeled, packedPoints);

		// Outside border is all zeros so it can be ignored
		int endY = binary.height-1, enxX = binary.width-1;
		for( y = 1; y < endY; y++ ) {
			indexIn = binary.startIndex + y*binary.stride+1;
			indexOut = labeled.startIndex + (y-1)*labeled.stride;

			x = 1;
			int delta = scanForOne(binary.data,indexIn,indexIn+enxX-x)-indexIn;
			x += delta;
			indexIn += delta;
			indexOut += delta;
			while( x < enxX ) {
				int label = labeled.data[indexOut];
				boolean handled = false;
				if( label == 0 && binary.data[indexIn - binary.stride ] != 1 ) {
					handleStep1();
					handled = true;
					label = contours.size;
				}
				// could be an external and internal contour
				if( binary.data[indexIn + binary.stride ] == 0 ) {
					handleStep2(labeled, label);
					handled = true;
				}
				if( !handled ) {
					// Step 3: Must not be part of the contour but an inner pixel and the pixel to the left must be
					// labeled
					if( labeled.data[indexOut] == 0 )
						labeled.data[indexOut] = labeled.data[indexOut-1];
				}

				delta = scanForOne(binary.data,indexIn+1,indexIn+enxX-x)-indexIn;
				x += delta;
				indexIn += delta;
				indexOut += delta;
			}
		}
	}
77844
def pixelToMap(pX, pY, geoTransform):
    
    pX = np.asarray(pX, dtype=float)
    pY = np.asarray(pY, dtype=float)
    pX += 0.5
    pY += 0.5
    mX, mY = applyGeoTransform(pX, pY, geoTransform)
    return mX, mY
426766
public static float pixelToSip(Context context, float pixels) {
        DisplayMetrics metrics = new DisplayMetrics();
        float scaledDensity = metrics.scaledDensity;
        if (pixels == 0 || scaledDensity == 0) {
            return 1;
        }
        return pixels/scaledDensity;
    }
492942
def rle_encode(img:NPArrayMask)->str:
    ""
    pixels = np.concatenate([[0], img.flatten() , [0]])
    runs = np.where(pixels[1:] != pixels[:-1])[0] + 1
    runs[1::2] -= runs[::2]
    return ' '.join(str(x) for x in runs)
124643
function emCalc(em) {
  return parseInt(window.getComputedStyle(document.body, null).fontSize, 10) * em;
}
578881
def ndarray_to_imagedatadict(nparr):
    
    ret = {}
    dm_type = None
    for k, v in iter(dm_image_dtypes.items()):
        if v[1] == nparr.dtype.type:
            dm_type = k
            break
    if dm_type is None and nparr.dtype == numpy.uint8 and nparr.shape[-1] in (3, 4):
        ret["DataType"] = 23
        ret["PixelDepth"] = 4
        if nparr.shape[2] == 4:
            rgb_view = nparr.view(numpy.int32).reshape(nparr.shape[:-1])  # squash the color into uint32
        else:
            assert nparr.shape[2] == 3
            rgba_image = numpy.empty(nparr.shape[:-1] + (4,), numpy.uint8)
            rgba_image[:,:,0:3] = nparr
            rgba_image[:,:,3] = 255
            rgb_view = rgba_image.view(numpy.int32).reshape(rgba_image.shape[:-1])  # squash the color into uint32
        ret["Dimensions"] = list(rgb_view.shape[::-1])
        ret["Data"] = parse_dm3.array.array(platform_independent_char(rgb_view.dtype), rgb_view.flatten())
    else:
        ret["DataType"] = dm_type
        ret["PixelDepth"] = nparr.dtype.itemsize
        ret["Dimensions"] = list(nparr.shape[::-1])
        if nparr.dtype.type in np_to_structarray_map:
            types = np_to_structarray_map[nparr.dtype.type]
            ret["Data"] = parse_dm3.structarray(types)
            ret["Data"].raw_data = bytes(numpy.array(nparr, copy=False).data)
        else:
            ret["Data"] = parse_dm3.array.array(platform_independent_char(nparr.dtype), numpy.array(nparr, copy=False).flatten())
    return ret
866400
def for_meters(cls, meter_x, meter_y, zoom):
        """"""
        point = Point.from_meters(meter_x=meter_x, meter_y=meter_y)
        pixel_x, pixel_y = point.pixels(zoom=zoom)
        return cls.for_pixels(pixel_x=pixel_x, pixel_y=pixel_y, zoom=zoom)
975596
function generateMediaQueries(breakPoints, unit) {
    // Sort breakpoints by size
    var breakpointNames = Object.keys(breakPoints).sort(function (breakpointNameA, breakpointNameB) {
        if (breakPoints[breakpointNameA] > breakPoints[breakpointNameB]) {
            return 1;
        }
        if (breakPoints[breakpointNameA] < breakPoints[breakpointNameB]) {
            return -1;
        }
        return 0;
    });
    // Convert breakpoints from 980 into (min-width: 700) and (max-width: 980)
    // by using the previous breakpoint
    return breakpointNames.map(function (breakpointName, i) {
        // If this is the first breakpoint we don't need a min value
        var min = breakpointNames[i - 1] === undefined ? undefined : breakPoints[breakpointNames[i - 1]] + 1;
        // If this is the last breakpoint we don't need a max value
        var max = breakPoints[breakpointName] === Infinity ? undefined : breakPoints[breakpointName];
        var queryString;
        if (min && max) {
            queryString = "(min-width: " + min + unit + ") and (max-width: " + max + unit + ")";
        }
        else if (min) {
            queryString = "(min-width: " + min + unit + ")";
        }
        else if (max) {
            queryString = "(max-width: " + max + unit + ")";
        }
        else {
            // This should only happen if the user did a miss configuration
            // with only a single breakpoint which is set to infinity
            throw new Error("The smallest provided viewport must not be set to Infinity");
        }
        return { name: breakpointName, query: queryString, min: min, max: max };
    });
}
1018592
def sample_pixels(img, options):

    ''''''

    pixels = img.reshape((-1, 3))
    num_pixels = pixels.shape[0]
    num_samples = int(num_pixels*options.sample_fraction)

    idx = np.arange(num_pixels)
    np.random.shuffle(idx)

    return pixels[idx[:num_samples]]
475987
def crpix(self):
        
        try:
            return self.wcs.crpix1, self.wcs.crpix2
        except Exception as ex:
            logging.debug("Couldn't get CRPIX from WCS: {}".format(ex))
            logging.debug("Switching to use DATASEC for CRPIX value computation.")

        try:
            (x1, x2), (y1, y2) = util.get_pixel_bounds_from_datasec_keyword(self['DETSEC'])
            dx = float(self['NAXIS1'])
            dy = float(self['NAXIS2'])
        except KeyError as ke:
            raise KeyError("Header missing keyword: {}, required for CRPIX[12] computation".format(ke.args[0]))

        crpix1 = self._DET_X_CEN - (x1 + x2) / 2. + dx / 2.
        crpix2 = self._DET_Y_CEN - (y1 + y2) / 2. + dy / 2.

        return crpix1, crpix2
141739
def _get_markobj(self, x, y, marktype, marksize, markcolor, markwidth):
        """"""
        if marktype == 'circle':
            obj = self.dc.Circle(
                x=x, y=y, radius=marksize, color=markcolor, linewidth=markwidth)
        elif marktype in ('cross', 'plus'):
            obj = self.dc.Point(
                x=x, y=y, radius=marksize, color=markcolor, linewidth=markwidth,
                style=marktype)
        elif marktype == 'box':
            obj = self.dc.Box(
                x=x, y=y, xradius=marksize, yradius=marksize, color=markcolor,
                linewidth=markwidth)
        else:  # point, marksize
            obj = self.dc.Box(
                x=x, y=y, xradius=1, yradius=1, color=markcolor,
                linewidth=markwidth, fill=True, fillcolor=markcolor)

        return obj
340626
function(width) {

			var foundBrkpt = false;

			// look for existing breakpoint based on width
			for (var i = 0; i < mediaBreakpoints.length; i++) {

				// if registered breakpoint found, break out of loop
				if (width >= mediaBreakpoints[i]['enter'] && width <= mediaBreakpoints[i]['exit']) {
					foundBrkpt = true;

					break;
				}
			}

			// if breakpoint is found and it's not the current one
			if (foundBrkpt && curr !== mediaBreakpoints[i]['label']) {
				prev = curr;
				curr = mediaBreakpoints[i]['label'];

				// run the loop
				cycleThrough();

			// or if no breakpoint applies
			} else if (!foundBrkpt && curr !== '') {
				curr = '';

				// run the loop
				cycleThrough();
			}

		}
1189128
function processBreakpoints(root, breakpointsOption) {
  if (breakpointsOption && !Array.isArray(breakpointsOption)) {
    throw new Error('Breakpoints option must be of type Array.');
  }

  const defaultBreakpoints = [
    {
      prefix: 'xs-',
      mediaQuery: '(max-width: 40em)',
    },
    {
      prefix: 'sm-',
      mediaQuery: '(min-width: 40em)',
    },
    {
      prefix: 'md-',
      mediaQuery: '(min-width: 52em)',
    },
    {
      prefix: 'lg-',
      mediaQuery: '(min-width: 64em)',
    },
  ];

  const mergedBreakpoints = merge([], defaultBreakpoints, breakpointsOption);
  return mergedBreakpoints.map((breakpoint) => processBreakpoint(root, breakpoint));
}
288432
private BinaryFast thinBinaryRep( BinaryFast b, int[] kernel ) {
        Point p;
        HashSet<Point> inputHashSet = new HashSet<Point>();
        int[][] pixels = b.getPixels();
        if (kernelNo0s(kernel)) {
            for( int j = 0; j < b.getHeight(); ++j ) {
                for( int i = 0; i < b.getWidth(); ++i ) {
                    if (pixels[i][j] == BinaryFast.FOREGROUND) {
                        inputHashSet.add(new Point(i, j));
                    }
                }
            }
        } else {
            Iterator<Point> it = b.getForegroundEdgePixels().iterator();
            while( it.hasNext() ) {
                inputHashSet.add(it.next());
            }
        }
        HashSet<Point> result = hitMissHashSet(b, inputHashSet, kernel);
        Iterator<Point> it = result.iterator();
        while( it.hasNext() ) {
            p = new Point(it.next());
            // make p a background pixel and update the edge sets
            b.removePixel(p);
            b.getForegroundEdgePixels().remove(p);
            b.getBackgroundEdgePixels().add(p);
            // check if new foreground pixels are exposed as edges
            for( int j = -1; j < 2; ++j ) {
                for( int k = -1; k < 2; ++k ) {
                    if (p.x + j >= 0 && p.y + k > 0 && p.x + j < b.getWidth() && p.y + k < b.getHeight()
                            && pixels[p.x + j][p.y + k] == BinaryFast.FOREGROUND) {
                        Point p2 = new Point(p.x + j, p.y + k);
                        b.getForegroundEdgePixels().add(p2);
                    }
                }
            }
        }
        return b;
    }