Did I find the right examples for you? yes no

All Samples(14)  |  Call(12)  |  Derive(0)  |  Import(2)
Round *value* to the nearest value evenly divisible by *interval*.

        def nearest(value, interval):
    """Round *value* to the nearest value evenly divisible by *interval*."""
    distance = value % interval
    if distance > (interval/2):
        distance -= interval
    return value - distance
        


src/c/a/cadnano2-HEAD/views/sliceview/emptyhelixitem.py   cadnano2(Download)
                    try:
                        # resize to the nearest prexover on either side of idx
                        newLo = util.nearest(idx, part.getPreXoversHigh(strandType, p2, maxIdx=idx-10))
                        newHi = util.nearest(idx, part.getPreXoversLow(strandType, p2, minIdx=idx+10))
                        if strand1.canResizeTo(newLo, newHi) and \
                    try:
                        # resize to the nearest prexover on either side of idx
                        newLo1 = newLo2 = util.nearest(idx, part.getPreXoversHigh(StrandType.Scaffold, p2, maxIdx=idx-8))
                        newHi = util.nearest(idx, part.getPreXoversLow(StrandType.Scaffold, p2, minIdx=idx+8))
 
                    try:
                        # resize to the nearest prexover on either side of idx
                        newLo = util.nearest(idx, part.getPreXoversHigh(StrandType.Scaffold, p2, maxIdx=idx-8))
 
                        if strand1.canResizeTo(newLo, strand1.highIdx()) and \

src/c/a/cadnano2-HEAD/model/parts/part.py   cadnano2(Download)
            neighborIdx = neighbors.index(connectedVh)
            try:
                newIdx = util.nearest(idx + delta,
                                    preXovers(strandType,
                                                neighborIdx,

src/t/s/tsar-HEAD/lib/tsar/model.py   tsar(Download)
 
from . import errors
from .util import nearest
 
__all__ = ["Records", "connect", "db"]
        lastval = 0
        for timestamp, value in data:
            timestamp = nearest(timestamp, interval)
            if lasttime is not None and lasttime > timestamp:
                raise errors.RecordError(
        for i, last in enumerate(self.db.mget(lkeys)):
            interval, samples = self.intervals[i]
            istart, istop = nearest(start, interval), nearest(stop, interval)
            lkey = lkeys[i]
 
    def select(self, start, stop, interval, lasttime=None):
        log = logger(self)
        start, stop = self.types.Time(start), self.types.Time(stop)
        istart, istop = nearest(start, interval), nearest(stop, interval)
        ikey = self.subkey(interval)

src/t/s/tsar-HEAD/lib/tsar/manage.py   tsar(Download)
from . import model
from .commands import ClientMixin, DBMixin, SubCommand
from .util import Decorator, nearest
 
def intorfloat(value):
        if i < lasti and count == 0:
            continue
        count = nearest(delta, n)/n
        return "%d %s%s" % (count, identifier, count != 1 and 's' or '')