Rotate PDF by increments of 90 degrees.
165625
def rotate(file_name, rotation, suffix='rotated', tempdir=None, method='pypdf3'):
    """"""
    return str(Rotate(file_name, rotation, suffix, tempdir, method))
628606
def mag_roll(RAW_IMU, inclination, declination):
    ''''''
    m = mag_rotation(RAW_IMU, inclination, declination)
    (r, p, y) = m.to_euler()
    return degrees(r)
882643
function rotate(out, a, rad) {
  var a00 = a[0],
      a01 = a[1],
      a02 = a[2],
      a10 = a[3],
      a11 = a[4],
      a12 = a[5],
      a20 = a[6],
      a21 = a[7],
      a22 = a[8],
      s = Math.sin(rad),
      c = Math.cos(rad);

  out[0] = c * a00 + s * a10;
  out[1] = c * a01 + s * a11;
  out[2] = c * a02 + s * a12;

  out[3] = c * a10 - s * a00;
  out[4] = c * a11 - s * a01;
  out[5] = c * a12 - s * a02;

  out[6] = a20;
  out[7] = a21;
  out[8] = a22;
  return out;
}
364471
public static void rotateCW( GrayS32 input , GrayS32 output ) {
		if( input.width != output.height || input.height != output.width )
			throw new IllegalArgumentException("Incompatible shapes");

		int h = input.height-1;

		for( int y = 0; y < input.height; y++ ) {
			int indexIn = input.startIndex + y*input.stride;
			for (int x = 0; x < input.width; x++) {
				output.unsafe_set(h-y,x,input.data[indexIn++]);
			}
		}
	}
43558
def _pdf(self, x, dist, cache):
        """"""
        output = evaluation.evaluate_density(dist, numpy.arccosh(x), cache=cache)
        output /= numpy.where(x != 1, numpy.sqrt(x*x-1), numpy.inf)
        return output
1223864
def rotate_dom_by_yaw(self, dom_id, heading, centre_point=None):
        """"""
        pmts = self.pmts[self.pmts.dom_id == dom_id]
        if centre_point is None:
            centre_point = self.dom_positions[dom_id]

        for pmt in pmts:
            pmt_pos = np.array([pmt.pos_x, pmt.pos_y, pmt.pos_z])
            pmt_dir = np.array([pmt.dir_x, pmt.dir_y, pmt.dir_z])
            pmt_radius = np.linalg.norm(centre_point - pmt_pos)
            index = self._pmt_index_by_pmt_id[pmt.pmt_id]
            pmt_ref = self.pmts[index]

            dir_rot = qrot_yaw([pmt.dir_x, pmt.dir_y, pmt.dir_z], heading)
            pos_rot = pmt_pos - pmt_dir * pmt_radius + dir_rot * pmt_radius

            pmt_ref.dir_x = dir_rot[0]
            pmt_ref.dir_y = dir_rot[1]
            pmt_ref.dir_z = dir_rot[2]
            pmt_ref.pos_x = pos_rot[0]
            pmt_ref.pos_y = pos_rot[1]
            pmt_ref.pos_z = pos_rot[2]
        self.reset_caches()
948824
def _expval(self, f, nopdf):
        
        def ff(theta, nopdf=nopdf):
            tan_theta = numpy.tan(theta)
            x = self.scale * tan_theta
            jac = self.scale * (tan_theta ** 2 + 1.)
            if nopdf:
                pdf = jac * self.pdf.pjac[None, :]
            else:
                pdf = jac * numpy.exp(-(x ** 2) / 2.) / numpy.sqrt(2 * numpy.pi)
            dp = self.pdf.x2dpflat(x)
            parg = None
            ans = None
            fparg_is_dict = False
            # iterate through the batch
            for i, (dpi, pdfi) in enumerate(zip(dp, pdf)):
                p = self.pdf.meanflat + dpi
                if parg is None:
                    # first time only
                    if self.pdf.shape is None:
                        parg = _gvar.BufferDict(self.pdf.g, buf=p)
                    else:
                        parg = p.reshape(self.pdf.shape)
                else:
                    if parg.shape is None:
                        parg.buf = p
                    else:
                        parg.flat[:] = p
                fparg = 1. if f is None else f(parg)
                if ans is None:
                    # first time only
                    if hasattr(fparg, 'keys'):
                        fparg_is_dict = True
                        if not isinstance(fparg, _gvar.BufferDict):
                            fparg = _gvar.BufferDict(fparg)
                        ans = _gvar.BufferDict()
                        for k in fparg:
                            ans[k] = numpy.empty(
                                (len(pdf),) + fparg.slice_shape(k)[1], float
                                )
                    else:
                        if numpy.shape(fparg) == ():
                            ans = numpy.empty(len(pdf), float)
                        else:
                            ans = numpy.empty(
                                (len(pdf),) + numpy.shape(fparg), float
                                )
                if fparg_is_dict:
                    prod_pdfi = numpy.prod(pdfi)
                    for k in ans:
                        ans[k][i] = fparg[k]
                        ans[k][i] *= prod_pdfi
                else:
                    if not isinstance(fparg, numpy.ndarray):
                        fparg = numpy.asarray(fparg)
                    ans[i] = fparg * numpy.prod(pdfi)
            return ans
        return ff
731151
def rotate_window(self, count=1):
        "  "
        w = self.get_active_window()
        w.rotate(count=count)
900668
def _pdf(self, x, dist, cache):
        """"""
        return evaluation.evaluate_density(
            dist, numpy.arctan(x), cache=cache)/(1+x*x)
376251
private long rotateMapHeight(long width, long height) {
    if (rotation != null && (rotation == ROTATE_90 || rotation == ROTATE_270)) {
      return width;
    }
    else {
      return height;
    }
  }
194492
def _pdf(self, x, dist, cache):
        """"""
        return evaluation.evaluate_density(
            dist, numpy.arcsinh(x), cache=cache)/numpy.sqrt(1+x*x)
295621
def _pdf(self, xloc, dist, length, cache):
        
        output = evaluation.evaluate_density(
            dist, xloc.reshape(1, -1)).reshape(length, -1)
        assert xloc.shape == output.shape
        return output
74803
def _pdf(self, xloc, dist, base, cache):
        """"""
        return evaluation.evaluate_density(
            dist, base**xloc, cache=cache)*base**xloc*numpy.log(base)
749925
def do_rotation(self, mirror, rot):
        """"""
        infile = self.tmpfile
        outfile = self.basename + '.rot'
        # NOTE: pnmrotate: angle must be between -90 and 90 and
        # rotations is CCW not CW per IIIF spec
        #
        # BUG in pnmrotate: +90 and -90 rotations the output image
        # size may be off. See for example a 1000x1000 image becoming
        # 1004x1000:
        #
        # simeon@RottenApple iiif>file testimages/67352ccc-d1b0-11e1-89ae-279075081939.png
        # testimages/67352ccc-d1b0-11e1-89ae-279075081939.png: PNG image data, 1000 x 1000, 8-bit/color RGB, non-interlaced
        # simeon@RottenApple iiif>cat testimages/67352ccc-d1b0-11e1-89ae-279075081939.png  | pngtopnm | pnmrotate -90 | pnmtopng > a.png; file a.png; rm a.png
        # a.png: PNG image data, 1004 x 1000, 8-bit/color RGB, non-interlaced
        # simeon@RottenApple iiif>cat testimages/67352ccc-d1b0-11e1-89ae-279075081939.png  | pngtopnm | pnmrotate 90 | pnmtopng > a.png; file a.png; rm a.png
        # a.png: PNG image data, 1004 x 1000, 8-bit/color RGB, non-interlaced
        #
        # WORKAROUND is to add a pnmscale for the 90degree case, some
        # simeon@RottenApple iiif>cat testimages/67352ccc-d1b0-11e1-89ae-279075081939.png  | pngtopnm | pnmrotate -90| pnmscale -width 1000 -height 1000 | pnmtopng > a.png; file a.png; rm a.png
        # a.png: PNG image data, 1000 x 1000, 8-bit/color RGB, non-interlaced
        #
        # FIXME - add mirroring
        #
        if (rot == 0.0):
            # print "rotation: no rotation"
            self.tmpfile = infile
        elif (rot <= 90.0 or rot >= 270.0):
            if (rot >= 270.0):
                rot -= 360.0
            # print "rotation: by %f degrees clockwise" % (rot)
            if (self.shell_call('cat ' + infile + ' | ' + self.pnmrotate + ' -background=#FFF ' + str(-rot) + '  > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmrotate.")
            self.tmpfile = outfile
        else:
            # Between 90 and 270 = flip and then -90 to 90
            rot -= 180.0
            # print "rotation: by %f degrees clockwise" % (rot)
            if (self.shell_call('cat ' + infile + ' | ' + self.pnmflip + ' -rotate180 | ' + self.pnmrotate + ' ' + str(-rot) + '  > ' + outfile)):
                raise IIIFError(
                    text="Oops... got nonzero output from pnmrotate.")
            self.tmpfile = outfile
        # Fixup size for 90s
        if (abs(rot % 180.0 - 90.0) < 0.001):
            outfile2 = self.basename + '.rot2'
            if (self.shell_call('cat ' + self.tmpfile + ' | ' + self.pnmscale + ' -width ' + str(self.height) + ' -height ' + str(self.width) + ' > ' + outfile2)):
                raise IIIFError(
                    text="Oops... failed to fixup size after pnmrotate.")
            self.tmpfile = outfile2
78681
def pts_rotate(pts=[], angle=[0.0], center=(0.0, 0.0)):
    '''
    '''
    assert isinstance(pts, list) and len(pts) > 0
    l_pt_prev = None
    for pt in pts:
        assert isinstance(pt, tuple)
        l_pt = len(pt)
        assert l_pt > 1
        for i in pt:
            assert isinstance(i, float)
        if l_pt_prev is not None:
            assert l_pt == l_pt_prev
        l_pt_prev = l_pt
    assert isinstance(angle, list)
    l_angle = len(angle)
    assert l_angle == l_pt-1
    for i in angle:
        assert isinstance(i, float)
        assert abs(i) <= 2*pi
    assert isinstance(center, tuple)
    assert len(center) == l_pt
    for i in center:
        assert isinstance(i, float)

    return [pt_rotate(pt, angle, center) for pt in pts]
1257295
def OnCellTextRotation(self, event):
        """"""

        with undo.group(_("Rotation")):
            self.grid.actions.toggle_attr("angle")

        self.grid.ForceRefresh()

        self.grid.update_attribute_toolbar()

        if is_gtk():
            try:
                wx.Yield()
            except:
                pass

        event.Skip()
969807
def pdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)             
        return (1.0/float(self.sigma0))*np.exp(-(0.5*(mu-self.mu0)**2)/float(self.sigma0**2))