• Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • email

All Samples(3171)  |  Call(2863)  |  Derive(0)  |  Import(308)
floor(x)

Return the floor of x as a float.
This is the largest integral value <= x.

src/p/y/pygrace-HEAD/trunk/Examples/example_tools.py   pygrace(Download)
def colorplot():
    from random import normalvariate
    from math import floor,ceil
 
    # generate some synthetic data from eliptical Gaussian
    data = []
    for i in range(10000):
 
    # create quick and dirty histogram
    delta = 0.2
    f = lambda zs: floor(min(zs)/delta)*delta
    g = lambda zs: ceil(max(zs)/delta)*delta
    xmin,ymin = map(f,zip(*data))
    xmax,ymax = map(g,zip(*data))
    M = int(xmax/delta) - int(xmin/delta)
    N = int(ymax/delta) - int(ymin/delta)
    for datum in data:
        i = int(floor((datum[0]-xmin)/delta))
        j = int(floor((datum[1]-ymin)/delta))
        bin = bins[N*i + j]
        if not (bin.lwrbnd[0]<=datum[0] and datum[0]<bin.uprbnd[0] and

src/p/y/pygrace-HEAD/Examples/example_tools.py   pygrace(Download)
def colorplot():
    from random import normalvariate
    from math import floor,ceil
 
    # generate some synthetic data from eliptical Gaussian
    data = []
    for i in range(10000):
 
    # create quick and dirty histogram
    delta = 0.2
    f = lambda zs: floor(min(zs)/delta)*delta
    g = lambda zs: ceil(max(zs)/delta)*delta
    xmin,ymin = map(f,zip(*data))
    xmax,ymax = map(g,zip(*data))
    M = int(xmax/delta) - int(xmin/delta)
    N = int(ymax/delta) - int(ymin/delta)
    for datum in data:
        i = int(floor((datum[0]-xmin)/delta))
        j = int(floor((datum[1]-ymin)/delta))
        bin = bins[N*i + j]
        if not (bin.lwrbnd[0]<=datum[0] and datum[0]<bin.uprbnd[0] and

src/p/y/pygtk-HEAD/examples/pygtk-demo/demos/pixbufs.py   pygtk(Download)
 
            r = radius +(radius / 3.0) * math.sin(f * 2.0 * math.pi)
 
            xpos = math.floor(xmid + r * math.cos(ang) - iw / 2.0 + 0.5)
            ypos = math.floor(ymid + r * math.sin(ang) - ih / 2.0 + 0.5)
 
            if i % 2 == 0:

src/p/y/pyjamas-0.7/examples/gwtcanvas/SuiteDemo.py   Pyjamas(Download)
        self.canvas.setStrokeStyle(Color.Color("#FFA500"))
        for i in range(6):
            for j in range(6):
                self.canvas.setFillStyle(Color.Color(int (math.floor(255 - 42.5 * i)),
                                                     int(math.floor(255 - 42.5 * j)),
                                                     0))
                self.canvas.fillRect(j * 25, i * 25, 25, 25)
 
 
        self.canvas.translate(160, 160)
        for i in range(6):
            for j in range(6):
                self.canvas.setStrokeStyle(Color.Color(0,
                int( math.floor(255 - 42.5 * i)),
            for j in range(6):
                self.canvas.setStrokeStyle(Color.Color(0,
                int( math.floor(255 - 42.5 * i)),
                int( math.floor(255 - 42.5 * j))))
                self.canvas.beginPath()
                self.canvas.arc(12.5 + j * 25, 12.5 + i * 25, 10, 0,
                                     (math.pi * 2), True)

src/s/h/shedskin-HEAD/examples/bh.py   shedskin(Download)
from time import clock
from sys import stderr, maxint, argv
from copy import copy
from math import sqrt, pi, floor
 
class Random(object):
    """
        xp = Vec3()
 
        xsc = (self.pos[0] - tree.rmin[0]) / tree.rsize
        xp[0] = floor(Node.IMAX * xsc)
 
        xsc = (self.pos[1] - tree.rmin[1]) / tree.rsize
        xp[1] = floor(Node.IMAX * xsc)
 
        xsc = (self.pos[2] - tree.rmin[2]) / tree.rsize
        xp[2] = floor(Node.IMAX * xsc)
 
        xsc = (vp[0] - self.rmin[0]) / self.rsize
        if 0.0 <= xsc and xsc < 1.0:
            xp[0] = floor(Node.IMAX * xsc)
        else:
            return None
 
        xsc = (vp[1] - self.rmin[1]) / self.rsize
        if 0.0 <= xsc and xsc < 1.0:
            xp[1] = floor(Node.IMAX * xsc)
 
        xsc = (vp[2] - self.rmin[2]) / self.rsize
        if 0.0 <= xsc and xsc < 1.0:
            xp[2] = floor(Node.IMAX * xsc)
        else:
            return None
 

src/p/y/pyobjc-framework-Quartz-2.3/Examples/Programming with Quartz/BasicDrawing/PathDrawing.py   pyobjc-framework-Quartz(Download)
def alignPointToUserSpace(context, p):
    # Compute the coordinates of the point in device space.
    p = CGContextConvertPointToDeviceSpace(context, p)
    # Ensure that coordinates are at exactly the corner
    # of a device pixel.
    p.x = math.floor(p.x)
    p.y = math.floor(p.y)
def alignSizeToUserSpace(context, s):
    # Compute the size in device space.
    s = CGContextConvertSizeToDeviceSpace(context, s)
    # Ensure that size is an integer multiple of device pixels.
    s.width = math.floor(s.width)
    s.height = math.floor(s.height)
    # Convert back to user space.
    return CGContextConvertSizeToUserSpace(context, s)
 
def alignRectToUserSpace(context, r):
    # Compute the coordinates of the rectangle in device space.
    r = CGContextConvertRectToDeviceSpace(context, r)
    # Ensure that the x and y coordinates are at a pixel corner.
    r.origin.x = math.floor(r.origin.x)
def alignRectToUserSpace(context, r):
    # Compute the coordinates of the rectangle in device space.
    r = CGContextConvertRectToDeviceSpace(context, r)
    # Ensure that the x and y coordinates are at a pixel corner.
    r.origin.x = math.floor(r.origin.x)
    r.origin.y = math.floor(r.origin.y)
    # Ensure that the width and height are an integer number of
    # device pixels. Note that this produces a width and height
    # that is less than or equal to the original width. Another
    # approach is to use ceil to ensure that the new rectangle
    # encloses the original one.
    r.size.width = math.floor(r.size.width)
    r.size.height = math.floor(r.size.height)

src/p/y/pyjamas-0.7/examples/addonsgallery/CanvasTab.py   Pyjamas(Download)
from pyjamas.ui.RootPanel import RootPanel
from pyjamas.Canvas2D import Canvas, CanvasImage, ImageLoadListener
from pyjamas.Timer import Timer
from math import floor, cos, sin
import time
 
class CanvasTab(Sink):
    def draw(self):
        for i in range(0, 6):
            for j in range(0, 6):
                self.context.fillStyle = u'rgb(%d,%d,0)' % \
                                        ( floor(255-42.5*i), floor(255-42.5*j))
                self.context.fillRect(j*25,i*25,25,25)
 

src/t/w/twitstream-HEAD/examples/stats.py   twitstream(Download)
def log_spacing(integer):
    m = math.sqrt(10)
    if integer == 0:
        return 0
    return m ** math.floor(math.log(integer, m))
 
def linear_chunk(interval):
    def linear(x):
        return interval * math.floor(x/interval)

src/g/d/GDAL-1.7.1/samples/densify.py   GDAL(Download)
                        g.AddPoint(x, y)
 
                elif self.options.remainder.upper() == "END":
                    segcount = int(math.floor(d/threshold))
                    xa = None
                    ya = None
                    for p in range(1,segcount):
 
                    # I think this might put an extra point in at the end of the 
                    # first segment
                    segcount = int(math.floor(d/threshold))
                    xa = None
                    ya = None
                    xb = x0

src/p/y/pyjamas-desktop-HEAD/pyjamas-webkit/examples/addonsgallery/CanvasTab.py   pyjamas-desktop(Download)
from Sink import Sink, SinkInfo
from ui import Image, HTML, VerticalPanel, HorizontalPanel
from Canvas import Canvas, CanvasImage, ImageLoadListener
from Timer import Timer
from math import floor, cos, sin
 
class CanvasTab(Sink):
    def draw(self):
        for i in range(0, 6):
            for j in range(0, 6):
                self.context.fillStyle = 'rgb(' + floor(255-42.5*i) + ',' + floor(255-42.5*j) + ',0)'
                self.context.fillRect(j*25,i*25,25,25)
 
 

  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9  Next