text stringlengths 0 1.05M | meta dict |
|---|---|
from fov import fov
import sys
TEST_CASES = ("""
.....
... .......
... ..... .......
0 .1. ..2.. ...3...
... ..... .......
... .......
.....
""", """
....
. ......
.. ......
....#.....
.......#..
#.5.....
.....#....
....... .
......
......
.....
""", ""... | {
"repo_name": "elemel/python-fov",
"path": "src/fov_test.py",
"copies": "1",
"size": "2634",
"license": "mit",
"hash": 1284434797091196200,
"line_mean": 24.0857142857,
"line_max": 68,
"alpha_frac": 0.4540622627,
"autogenerated": false,
"ratio": 3.443137254901961,
"config_test": true,
"has_no_... |
from foxy_player_api.models import Album, Artist, Track, Cover
from foxy_player.settings import COVERS_DIR
from celery import shared_task,current_task
import mutagen
import hashlib
import errno
import uuid
import sys
import os
class CoverInfo:
def __init__(self, data, is_artist):
self.data = data
s... | {
"repo_name": "TheCheshireFox/foxy-player",
"path": "foxy_player/foxy_player_api/tasks.py",
"copies": "1",
"size": "6129",
"license": "apache-2.0",
"hash": 514895653605067140,
"line_mean": 33.8238636364,
"line_max": 258,
"alpha_frac": 0.5956926089,
"autogenerated": false,
"ratio": 3.5022857142857... |
from foxy_player_api.models import Album, Artist, Track, Cover
from foxy_player.settings import COVERS_DIR
import logging
import mutagen
import hashlib
import errno
import uuid
import sys
import os
logger = logging.getLogger('SCAN')
logger.setLevel(logging.DEBUG)
ch = logging.StreamHandler()
ch.setLevel(logging.DEBUG)... | {
"repo_name": "TheCheshireFox/foxy-player",
"path": "foxy_player/foxy_player_api/scanner.py",
"copies": "1",
"size": "5037",
"license": "apache-2.0",
"hash": 6405423530287085000,
"line_mean": 31.2884615385,
"line_max": 258,
"alpha_frac": 0.5989676395,
"autogenerated": false,
"ratio": 3.3737441393... |
from foyer.atomtyper import (
Element, NeighborCount, NeighborsAtLeast, NeighborsExactly, Whitelist,
Blacklist, check_atom, InWhitelist)
from foyer.chemical_groups import benzene, dioxolane13
# -------------- #
# House of rules #
# -------------- #
@Element('O')
@NeighborCount(2)
@NeighborsExactly('H', 2)
@W... | {
"repo_name": "Jonestj1/foyer",
"path": "foyer/oplsaa/rules.py",
"copies": "1",
"size": "13563",
"license": "mit",
"hash": 8349115432062241000,
"line_mean": 18.1028169014,
"line_max": 78,
"alpha_frac": 0.6475705965,
"autogenerated": false,
"ratio": 2.637176745090414,
"config_test": false,
"ha... |
from fparser.Fortran2003 import *
from fparser.api import get_reader
from nose.tools import assert_equal
def assertRaises(exc, cls, s):
try:
cls(s)
raise AssertionError('Expected %s but got nothing' % exc)
except exc:
pass
#############################################################... | {
"repo_name": "pemryan/f2py",
"path": "fparser/tests/test_Fortran2003.py",
"copies": "2",
"size": "100189",
"license": "bsd-3-clause",
"hash": 4358014117541049300,
"line_mean": 28.2950292398,
"line_max": 191,
"alpha_frac": 0.5257762828,
"autogenerated": false,
"ratio": 3.0171956875263506,
"conf... |
from fparser import api
def test_reproduce_issue():
source_str = '''\
subroutine bl(a,
&b,
&c)
integer a, b, c
a = b + c
end subroutine bl
subroutine blc(a,
c here's an annoying comment line
&b,
&c,
c another annoying comment
&d,
c a third annoying comm... | {
"repo_name": "dagss/f2py-g3",
"path": "fparser/tests/test_blank_lines.py",
"copies": "3",
"size": "1354",
"license": "bsd-3-clause",
"hash": -6812056673824198000,
"line_mean": 21.5666666667,
"line_max": 77,
"alpha_frac": 0.5214180207,
"autogenerated": false,
"ratio": 3.278450363196126,
"config... |
from .fpbench import fpcparser
from .arithmetic import ieee754, optimistic, np, evalctx
from .titanic import sinking
from .arithmetic import core2math
from .titanic import wolfmath
fpc_minimal = fpcparser.compile(
"""(FPCore (a b) (- (+ a b) a))
""")[0]
fpc_example = fpcparser.compile(
"""(FPCore (a b c)
:name "NMS... | {
"repo_name": "billzorn/fpunreal",
"path": "titanfp/demo.py",
"copies": "1",
"size": "2962",
"license": "mit",
"hash": 1014998696301748200,
"line_mean": 30.1789473684,
"line_max": 159,
"alpha_frac": 0.6107359892,
"autogenerated": false,
"ratio": 2.786453433678269,
"config_test": false,
"has_n... |
from .fpbench import fpcparser
from .arithmetic import ieee754, sinking
quadratic = fpcparser.compile1(
"""(FPCore (a b c)
:name "NMSE p42, positive"
:cite (hamming-1987 herbie-2015)
:fpbench-domain textbook
:pre (and (>= (* b b) (* 4 (* a c))) (!= a 0))
(/ (+ (- b) (sqrt (- (* b b) (* 4 (* a c))))) (* 2 a)))
"""... | {
"repo_name": "billzorn/fpunreal",
"path": "titanfp/techcon_examples.py",
"copies": "1",
"size": "1961",
"license": "mit",
"hash": 520844143474523970,
"line_mean": 34.0178571429,
"line_max": 112,
"alpha_frac": 0.5517593065,
"autogenerated": false,
"ratio": 2.476010101010101,
"config_test": fals... |
from fpdf import FPDF, HTMLMixin
from .. import models
import actions
import flockappsecret as secret
import datetime
class MyFPDF(FPDF, HTMLMixin):
pass
def generate_report(trk,usr):
html = """
<h3 align="center">Expense Report</h3>
<h3>Employee Expense Report</h3>
<table border="0" width="90%"... | {
"repo_name": "akhilraj95/xpense",
"path": "xpense/flockapp/flockapplib/exports.py",
"copies": "1",
"size": "6240",
"license": "mit",
"hash": 9192891040462992000,
"line_mean": 40.3245033113,
"line_max": 326,
"alpha_frac": 0.5551282051,
"autogenerated": false,
"ratio": 3.1278195488721803,
"confi... |
from fpdf import FPDF
import re
import sys
import os
import subprocess
from AdaptivePELE.analysis import plotAdaptive
import argparse
CONTACTS = "contacts"
BE = "bindingEnergy"
SASA = "sasa"
kind_Print, colModifier, traj_range = "PRINT_BE_RMSD", 4, None
def arg_parse():
parser = argparse.ArgumentParser(descript... | {
"repo_name": "AdaptivePELE/AdaptivePELE",
"path": "AdaptivePELE/analysis/reportSimulation.py",
"copies": "1",
"size": "6288",
"license": "mit",
"hash": -7933567651086778000,
"line_mean": 38.0559006211,
"line_max": 150,
"alpha_frac": 0.6442430025,
"autogenerated": false,
"ratio": 3.25634386328327... |
from fpdf import FPDF
class Style(FPDF):
"""
A simple static class to set default style content
"""
def feature(self, text):
"""
:param self: PDF self. to set style
:param text: text to be molded
:return:
"""
self.set_font('Times', '', 10)
self... | {
"repo_name": "yurireeis/bddocs",
"path": "bddocs/src/pdf/style.py",
"copies": "1",
"size": "1748",
"license": "mit",
"hash": 2240590846411681500,
"line_mean": 26.746031746,
"line_max": 60,
"alpha_frac": 0.4771167048,
"autogenerated": false,
"ratio": 3.420743639921722,
"config_test": false,
"... |
from fpga_sdrlib import config
errorcode_shift = 1
errorcode_mod = pow(2, config.msg_errorcode_width)
modulecode_shift = errorcode_shift * errorcode_mod
modulecode_mod = pow(2, config.msg_modulecode_width)
formatcode_shift = modulecode_shift * modulecode_mod
formatcode_mod = pow(2, config.msg_formatcode_width)
length_... | {
"repo_name": "benreynwar/fpga-sdrlib",
"path": "python/fpga_sdrlib/message/msg_codes.py",
"copies": "1",
"size": "1654",
"license": "mit",
"hash": -1243110355134682400,
"line_mean": 40.35,
"line_max": 116,
"alpha_frac": 0.6964933495,
"autogenerated": false,
"ratio": 3.5417558886509637,
"config... |
from fpl_reader.pseudo_object import PseudoObject
from fpl_reader.cool_io import CoolIO
from fpl_reader.windows_time import get_time_from_ticks
class Playlist:
def __init__(self, tracks):
self.tracks = tracks
def __repr__(self):
return (
'Playlist([\n'
+ ',\n\n'.join(r... | {
"repo_name": "rr-/fpl_reader",
"path": "fpl_reader/playlist_reader.py",
"copies": "1",
"size": "3898",
"license": "mit",
"hash": -8171546773321731000,
"line_mean": 32.0338983051,
"line_max": 79,
"alpha_frac": 0.6092868138,
"autogenerated": false,
"ratio": 3.1924651924651926,
"config_test": fal... |
from fp.monads.monad import Monad, MonadPlus
class Maybe(Monad, MonadPlus):
"""
A Maybe monad.
The Maybe monad is helpful when dealing with sequences of
functions that could return None.
For instance, when fetching a key from a dictionary that may not
be there:
>>> from fp.monads.maybe ... | {
"repo_name": "ericmoritz/fp",
"path": "fp/monads/maybe.py",
"copies": "1",
"size": "6907",
"license": "bsd-2-clause",
"hash": -5438758310285660000,
"line_mean": 24.6765799257,
"line_max": 76,
"alpha_frac": 0.5073114232,
"autogenerated": false,
"ratio": 4.206455542021924,
"config_test": false,
... |
from FPPbrowser import app
from flask import render_template, request, jsonify, flash
from matplotlib import pyplot as plt
from bokeh import plotting as bkplt
from bokeh.embed import file_html, components
from bokeh.resources import CDN
import numpy as np
import os, os.path
# import vespa
import json
import mpld3
# s... | {
"repo_name": "timothydmorton/vespa-visualization",
"path": "FPPbrowser/FPPbrowser/views.py",
"copies": "1",
"size": "1895",
"license": "mit",
"hash": 1856541644909099300,
"line_mean": 29.0793650794,
"line_max": 109,
"alpha_frac": 0.7124010554,
"autogenerated": false,
"ratio": 2.778592375366569,
... |
from fq.curator.models import Item
from fq.collage.models import Spread
class ContentIndex(object):
"""
Content Index
"""
index_name = "content"
doc_types = ["item", "spread"]
active_field = "published"
item_mapping = {
# Item Mapping
"title": {"type": "string", "store": "... | {
"repo_name": "codespresso/djes",
"path": "djes/indexes.py",
"copies": "1",
"size": "2467",
"license": "mit",
"hash": -193499701843153730,
"line_mean": 33.2638888889,
"line_max": 90,
"alpha_frac": 0.4698013782,
"autogenerated": false,
"ratio": 3.665676077265973,
"config_test": false,
"has_no_... |
from fqn_decorators import get_fqn
from influxdb.influxdb08.client import InfluxDBClientError
from tests.conftest import Dummy, go
from tests.test_base_backend import TestBaseBackend
from time_execution import settings
from time_execution.backends.influxdb import InfluxBackend
class TestTimeExecution(TestBaseBackend)... | {
"repo_name": "snelis/timeexecution",
"path": "tests/test_influxdb.py",
"copies": "1",
"size": "2447",
"license": "apache-2.0",
"hash": 7270559573298978000,
"line_mean": 28.8414634146,
"line_max": 66,
"alpha_frac": 0.6072742133,
"autogenerated": false,
"ratio": 4.154499151103566,
"config_test":... |
from fractal import Fractal
from geometry import Point, midpoint, distance
import math
def from_degrees(angle):
return math.pi* 2 * angle / 360
def rotated_about(p, center, theta):
radius = distance(p, center)
angle = math.atan2(p.y - center.y, p.x - center.x)
angle += theta
dx = radius * math.cos... | {
"repo_name": "kms70847/Animation",
"path": "src/Zooming_Fractals/koch.py",
"copies": "1",
"size": "1558",
"license": "mit",
"hash": 5374191854181327000,
"line_mean": 35.2558139535,
"line_max": 88,
"alpha_frac": 0.5295250321,
"autogenerated": false,
"ratio": 3.2662473794549265,
"config_test": f... |
from fractal import Fractal
from geometry import Point, midpoint
import math
class Sierpinsky(Fractal):
def __init__(self):
self.zoom_change = 2
#use this height for the largest isoceles triangle that can fit in the bounding box.
#height = 1
#use this height for an equilateral trian... | {
"repo_name": "kms70847/Animation",
"path": "src/Zooming_Fractals/sierpinsky.py",
"copies": "1",
"size": "1112",
"license": "mit",
"hash": -1454253894178546700,
"line_mean": 38.7142857143,
"line_max": 92,
"alpha_frac": 0.529676259,
"autogenerated": false,
"ratio": 3.0718232044198897,
"config_te... |
from fractal import Fractal
from geometry import Point
from boundingbox import BoundingBox
def product(max):
"""cartesian product of range(max) and range(max)"""
for i in range(max):
for j in range(max):
yield (i,j)
class GridFractal(Fractal):
def __init__(self, grid):
"""
... | {
"repo_name": "kms70847/Animation",
"path": "src/Zooming_Fractals/gridFractal.py",
"copies": "1",
"size": "1471",
"license": "mit",
"hash": 6424392615919623000,
"line_mean": 34.0476190476,
"line_max": 101,
"alpha_frac": 0.5227736234,
"autogenerated": false,
"ratio": 3.5878048780487806,
"config_... |
from fractions import Fraction as F
from itertools import count, islice, repeat, chain, starmap
import math
try:
from itertools import izip as zip
from itertools import imap as map
except ImportError: # will be 3.x series
pass
pstestlimit = 5
def memoizedGenerator( gen ):
_iter = gen()
_cache = [... | {
"repo_name": "michibo/pwrsrs",
"path": "pwrsrs.py",
"copies": "1",
"size": "19361",
"license": "mit",
"hash": 2497000329371177500,
"line_mean": 24.4415243101,
"line_max": 115,
"alpha_frac": 0.4776096276,
"autogenerated": false,
"ratio": 3.539488117001828,
"config_test": false,
"has_no_keywor... |
from fractions import Fraction as f
import sys
import math
# strange patterns by looking at pythagorean triples
#
# this is using the '1-t^2,1+t^2' paramterization of the circle
#
# but with attempting to make 'rings' instead of the circle itself
# using fractions as input to 't', we get a pretty smooth rational tess... | {
"repo_name": "donbright/piliko",
"path": "experiment/miscpatterns/pythpattern16.py",
"copies": "1",
"size": "2265",
"license": "bsd-3-clause",
"hash": -6053218248368979000,
"line_mean": 22.112244898,
"line_max": 79,
"alpha_frac": 0.6335540839,
"autogenerated": false,
"ratio": 2.3230769230769233,... |
from fractions import Fraction as f
import sys
# draw points of squares->tiling a rectangle
# size of squares = fibonacci seq
def sqr(x): return x*x
def greenq(x,y,x2,y2): return 2*(x2-x)*(y2-y)
def redq(x,y,x2,y2): return sqr(x2-x)-sqr(y2-y)
def blueq(x,y,x2,y2): return sqr(x2-x)+sqr(y2-y)
xs,ys=[],[]
class Cursor:... | {
"repo_name": "donbright/piliko",
"path": "experiment/fiborec2.py",
"copies": "1",
"size": "1353",
"license": "bsd-3-clause",
"hash": -5658109309877241000,
"line_mean": 22.7368421053,
"line_max": 64,
"alpha_frac": 0.6555801922,
"autogenerated": false,
"ratio": 2.107476635514019,
"config_test": ... |
from fractions import Fraction as F
import sys
# rational paramterization / approximation of bernoulli's lemniscate
# in a 3 dimensional 'dumbbell' arrangement.
# (note - this uses terms from Norman Wildberger's rational
# trigonometry/chromogeometry. briefly for a vector from 0,0 to x,y:
#
# blue quadrance (x,y) = ... | {
"repo_name": "donbright/piliko",
"path": "experiment/bernoulli/pythberntest.py",
"copies": "1",
"size": "2265",
"license": "bsd-3-clause",
"hash": -8104407733391525000,
"line_mean": 26.2891566265,
"line_max": 72,
"alpha_frac": 0.6291390728,
"autogenerated": false,
"ratio": 2.2403560830860534,
... |
from fractions import Fraction as f
import sys
# rational paramterization of a 'green' hyperbola, using Norman
# Wildberger's Chromogeometry.
# for a full explanation see the file 'pythhyp1.py'.
# this file, pythhyp2, differs only in that we generate the 'green'
# hyperbola ( based on the equation 2xy = r^2 = con... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythhyp2.py",
"copies": "1",
"size": "1744",
"license": "bsd-3-clause",
"hash": 1945501276878332400,
"line_mean": 23.5633802817,
"line_max": 72,
"alpha_frac": 0.6381880734,
"autogenerated": false,
"ratio": 2.2416452442159382,
"config_test": ... |
from fractions import Fraction as f
import sys
# rational paramterization of hyperbola, using Norman Wildberger's
# Chromogeometry.
#
# step 1. lets review the rational paramterization of an ordinary circle
# (blue circle). in an ordinary circle, x^2+y^2 = radius^2. for a unit
# circle, you can say x^2+y^2=1. in ... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythhyp3.py",
"copies": "2",
"size": "3625",
"license": "bsd-3-clause",
"hash": 912623015376498300,
"line_mean": 26.8846153846,
"line_max": 79,
"alpha_frac": 0.6708965517,
"autogenerated": false,
"ratio": 2.522616562282533,
"config_test": fa... |
from fractions import Fraction as f
import sys
# strange patterns by looking at pythagorean triples
#
# in this example the rational paramterization of the circle
# is superimposed upon the 'raw' pythagorean triples
#
# it forms a sort of weird non-symmetrical rational tesellation of the circle
# (in that all the poin... | {
"repo_name": "donbright/piliko",
"path": "experiment/miscpatterns/pythpattern8.py",
"copies": "1",
"size": "1369",
"license": "bsd-3-clause",
"hash": -1978826158160213000,
"line_mean": 23.4464285714,
"line_max": 77,
"alpha_frac": 0.650109569,
"autogenerated": false,
"ratio": 2.1661392405063293,
... |
from fractions import Fraction as f
import sys
# strange patterns by looking at pythagorean triples
#
# this is an attempt to have different 'rings' of the circle
# instead of just a flat circle
# it provides a non-symmetrical but totally rational 'tessellation' of
# some rational points on a circle ... in that all ... | {
"repo_name": "donbright/piliko",
"path": "experiment/miscpatterns/pythpattern12.py",
"copies": "1",
"size": "1282",
"license": "bsd-3-clause",
"hash": 7546570581992916000,
"line_mean": 23.1886792453,
"line_max": 71,
"alpha_frac": 0.635725429,
"autogenerated": false,
"ratio": 2.2530755711775043,
... |
from fractions import Fraction as f
import sys
# strange patterns by looking at pythagorean triples
#
# this is using the '1-t^2,1+t^2' paramterization of the circle
#
# but with attempting to make 'rings' instead of the circle itself
# also using the farey seq as input to 't'
# result is an interesting sort of tes... | {
"repo_name": "donbright/piliko",
"path": "experiment/miscpatterns/pythpattern14.py",
"copies": "1",
"size": "1452",
"license": "bsd-3-clause",
"hash": 3578969215421626000,
"line_mean": 22.8032786885,
"line_max": 69,
"alpha_frac": 0.6542699725,
"autogenerated": false,
"ratio": 2.2546583850931676,... |
from fractions import Fraction as F
# exploring the sides of the triangles formed by the centers of
# ford circles
def sqr(x): return x*x
def f2s(x):
return str(x.numerator) + '/' + str(x.denominator)
class fordcirc:
def __init__(self,numerator,denominator):
self.xcoord = F(numerator,denominator)
self.radius... | {
"repo_name": "donbright/piliko",
"path": "experiment/fordpyth.py",
"copies": "1",
"size": "1046",
"license": "bsd-3-clause",
"hash": 8689890312249166000,
"line_mean": 23.3255813953,
"line_max": 64,
"alpha_frac": 0.65583174,
"autogenerated": false,
"ratio": 2.288840262582057,
"config_test": fal... |
from fractions import Fraction as Frac
from copy import copy
def pivot(matrix, line, column):
store = [ [0 for _ in range(len(matrix[0]))] for _ in range(len(matrix))]
for l in range(len(matrix)):
for c in range(len(matrix[0])):
if l == line and c == column:
store[l][c] = F... | {
"repo_name": "rdragos/work",
"path": "research/implementations/simplex/main.py",
"copies": "1",
"size": "2640",
"license": "mit",
"hash": -3455021598792578000,
"line_mean": 29.3448275862,
"line_max": 105,
"alpha_frac": 0.4007575758,
"autogenerated": false,
"ratio": 3.6464088397790055,
"config_... |
from fractions import Fraction as Fract
import sys
# rational paramterization / approximation of bernoulli's lemniscate
# traditional form: ( x^2 + y^2 ) ^2 = 2*( x^2 - y^2 )
# chromogeometry form:
# x = (blueq/redq) / blueq( blueq/redq, greenq/redq )
# y = (greenq/redq) / blueq( blueq/redq, greenq/redq )
# where q =... | {
"repo_name": "donbright/piliko",
"path": "experiment/bernoulli/pythbernlem2.py",
"copies": "1",
"size": "1332",
"license": "bsd-3-clause",
"hash": 6925270413695541000,
"line_mean": 27.9565217391,
"line_max": 68,
"alpha_frac": 0.6306306306,
"autogenerated": false,
"ratio": 2.0683229813664594,
"... |
from fractions import Fraction as Fract
##########
#
# rational parameterization of the 'dumbbell' p-orbital shape. sort of
# like bernoulli's lemniscate, but in 3d. using four input variables,
# m1,n1 m2,n2 all rational/integer
#
# chromogeometry notation is used here. 3 'quadrance' functions, input is 'a,b'
# blu... | {
"repo_name": "donbright/piliko",
"path": "experiment/ratparam3d/pythdumbell.py",
"copies": "1",
"size": "3319",
"license": "bsd-3-clause",
"hash": -842917242504187600,
"line_mean": 26.2049180328,
"line_max": 79,
"alpha_frac": 0.6272973787,
"autogenerated": false,
"ratio": 2.3032616238723107,
"... |
from fractions import Fraction as Fract
##########
#
# rational parameterization of the torus
#
#########
#
# consider a basic torus
#
# x^2 + y^2 = 1 - l ^2
# l^2 + z^2 = 1
#
# use similar method to param of sphere, we get m1,n1,m2,n2 forming the torus.
#
xs,ys,zs=[],[],[]
depth=8
big_radius = 5
small_radius = 2... | {
"repo_name": "donbright/piliko",
"path": "experiment/ratparam3d/pythtorus.py",
"copies": "1",
"size": "1354",
"license": "bsd-3-clause",
"hash": -7243578622081862000,
"line_mean": 20.8387096774,
"line_max": 78,
"alpha_frac": 0.5731166913,
"autogenerated": false,
"ratio": 2.1189358372456963,
"c... |
from fractions import Fraction as Fract
##########
#
# rational parameterization of the torus
#
#
# this torus has a non-circular 'tube' cross-section. its kind of warped
# triangular.
#
#########
# theory,briefly: consider a torus.
#
# x^2 + y^2 = 1 - l ^2
# l^2 + z^2 = 1
#
# use similar method to param of sphere,... | {
"repo_name": "donbright/piliko",
"path": "experiment/ratparam3d/pythtorus3.py",
"copies": "1",
"size": "2299",
"license": "bsd-3-clause",
"hash": 1912181482502070500,
"line_mean": 25.125,
"line_max": 78,
"alpha_frac": 0.6180948238,
"autogenerated": false,
"ratio": 2.240740740740741,
"config_te... |
from fractions import Fraction as Fr
import sys
import numpy as np
import matplotlib.pylab as plt
def plot(xs, ys):
maxx=max(xs)
minx=min(xs)
maxy=max(ys)
miny=min(ys)
fig,ax = plt.subplots(figsize=(8,8))
ax.set_xlim([minx-2,maxx+2])
ax.set_ylim([miny-2,maxy+2])
... | {
"repo_name": "donbright/piliko",
"path": "phyllo/grow.py",
"copies": "1",
"size": "1060",
"license": "bsd-3-clause",
"hash": -1157534941902116900,
"line_mean": 17.9285714286,
"line_max": 62,
"alpha_frac": 0.5594339623,
"autogenerated": false,
"ratio": 2.124248496993988,
"config_test": false,
... |
from fractions import Fraction as rational
import Environment
import Exceptions
import Schemify
import Evaluate
import Parser
if __name__ == '__main__':
'''Run from the command line.'''
import os, sys
# Create the base environment.
base_environment = Environment.Environment()
# Load the global environment.... | {
"repo_name": "jpverkamp/schempy",
"path": "Schempy.py",
"copies": "1",
"size": "1511",
"license": "bsd-3-clause",
"hash": 5486998871713610000,
"line_mean": 22.609375,
"line_max": 72,
"alpha_frac": 0.6565188617,
"autogenerated": false,
"ratio": 3.27765726681128,
"config_test": false,
"has_no_... |
from fractions import Fraction, gcd
from math import sqrt, ceil
from itertools import count
def af(x):
if x >= 2.0 / (1 + sqrt(5)):
return None
else:
return x / (1 - x - x*x)
xx = [(1, 2), (2, 3), (3, 4), (3, 5), (5, 6), (4, 7), (5, 7), (5, 8), (5, 9), (7, 9), (7, 10), (5, 11), (7, 11), (7, ... | {
"repo_name": "peterstace/project-euler",
"path": "OLD_PY_CODE/project_euler_old_old/137/137.py",
"copies": "1",
"size": "1325",
"license": "unlicense",
"hash": 415491898630126850,
"line_mean": 29.1136363636,
"line_max": 404,
"alpha_frac": 0.4339622642,
"autogenerated": false,
"ratio": 2.61857707... |
from fractions import Fraction, gcd
from number_theory import isqrt, factors, decomp, prime_sieve, decomp_sieve
from math import sqrt
SIZE = 1000000000000
found = []
primes = prime_sieve(70000000)
for sqrtn in range(1, isqrt(SIZE)):
n = sqrtn * sqrtn
for d in range(2, sqrtn):
q = n // d
r = ... | {
"repo_name": "peterstace/project-euler",
"path": "OLD_PY_CODE/project_euler_old_old/141/141.py",
"copies": "1",
"size": "3128",
"license": "unlicense",
"hash": -7173329828947846000,
"line_mean": 25.0666666667,
"line_max": 75,
"alpha_frac": 0.4718670077,
"autogenerated": false,
"ratio": 2.1797909... |
from fractions import Fraction, gcd
from string import find, count, split
# use this for errors in this module
class Error(Exception):
pass
class Contradiction(Error):
pass
# kinds of inequalities
GT, GE, LE, LT = range(4)
comp_str = {GT: '>', GE: '>=', LT: '<', LE: '<='}
# swaps GT and LT, GE and L... | {
"repo_name": "avigad/boole",
"path": "boole/interfaces/ineqs/classes.py",
"copies": "1",
"size": "33640",
"license": "apache-2.0",
"hash": -2231618062790129400,
"line_mean": 30.234911792,
"line_max": 92,
"alpha_frac": 0.4906064209,
"autogenerated": false,
"ratio": 3.7599195260981335,
"config_t... |
from fractions import Fraction
# compute voltage drops across empty hex board, with 1.0 on top and 0.0 on bottom
# remove connection between adjacent cells in first and last row, as
# these are not in any minimal winning path
# notice that node with biggest voltage drop is 2,2, not center :)
slim, n = True, 2
assert... | {
"repo_name": "ryanbhayward/games-puzzles-algorithms",
"path": "simple/hex/voltage/volt.py",
"copies": "1",
"size": "2207",
"license": "mit",
"hash": 5461877393816983000,
"line_mean": 22.9891304348,
"line_max": 81,
"alpha_frac": 0.566379701,
"autogenerated": false,
"ratio": 2.3329809725158563,
... |
from fractions import Fraction
from .array import Array
class EndOfAlgorithm(Exception):
'''
The algorithm stopped on an optimal solution.
'''
pass
class Unbounded(Exception):
'''
There is no optimal solution (unbounded).
'''
pass
class Empty(Exception):
'''
There ... | {
"repo_name": "Ezibenroc/simplex",
"path": "simplex/simplex.py",
"copies": "1",
"size": "9469",
"license": "mit",
"hash": 3189466330715884000,
"line_mean": 37.4918699187,
"line_max": 139,
"alpha_frac": 0.5549688457,
"autogenerated": false,
"ratio": 3.883921246923708,
"config_test": false,
"ha... |
from fractions import Fraction
from collections import namedtuple
import math
class Durations(object):
whole = Fraction(1, 1)
dot_half = Fraction(3,4)
half = Fraction(1, 2)
dot_quarter = Fraction(3, 8)
quarter = Fraction(1, 4)
dot_eighth = Fraction(3, 16)
eighth = Fraction(1, 8)
dot_six... | {
"repo_name": "JasonFruit/Tabinator",
"path": "tab.py",
"copies": "1",
"size": "3667",
"license": "unlicense",
"hash": -239037586389369630,
"line_mean": 34.9509803922,
"line_max": 75,
"alpha_frac": 0.4346877557,
"autogenerated": false,
"ratio": 3.851890756302521,
"config_test": false,
"has_no... |
from fractions import Fraction
from copy import deepcopy
from functools import reduce
ENV = {}
def scanner(input_str):
'''Scans the input string from standard input and replaces '(' with ' [ '
and ')' with ' ] ' '''
split_tokens = []
input_str = input_str.replace('(', ' ( ')
input_str = input_... | {
"repo_name": "manoj-makkuboy/lisp-scheme-interpreter",
"path": "lispy.py",
"copies": "1",
"size": "9237",
"license": "mit",
"hash": 3141046700680921000,
"line_mean": 31.6395759717,
"line_max": 160,
"alpha_frac": 0.5416260691,
"autogenerated": false,
"ratio": 3.5636574074074074,
"config_test": ... |
from fractions import Fraction
from copy import deepcopy
z_val = {}
def gcd(a, b):
if b == 0:
return a
return gcd(b, a%b)
def lcm(a, b):
return a * b / gcd(a, b)
class PolyTerm(object):
def __init__(self, frac=Fraction(0, 1)):
self.coef = frac
self.a = [] # a_i^j sub & pow [... | {
"repo_name": "ecustacm/ecustacm.github.io",
"path": "assets/2017-05-08/a/solution/main.py",
"copies": "1",
"size": "4094",
"license": "mit",
"hash": -4697172123889366000,
"line_mean": 19.9948717949,
"line_max": 77,
"alpha_frac": 0.4433317049,
"autogenerated": false,
"ratio": 3.246629659000793,
... |
from fractions import Fraction
from decimal import Decimal
from collections import Counter
import itertools as it
from math import factorial
from dice_roller.DiceParser import DiceParser
from dice_roller.DiceThrower import DiceThrower
import sympy
class DiceProbability(object):
parser = DiceParser()
def calc... | {
"repo_name": "pknull/rpg-dice",
"path": "dice_roller/DiceProbabilty.py",
"copies": "1",
"size": "5541",
"license": "mit",
"hash": 5967422565423916000,
"line_mean": 35.2156862745,
"line_max": 87,
"alpha_frac": 0.5728207905,
"autogenerated": false,
"ratio": 3.6121251629726205,
"config_test": fal... |
from fractions import Fraction
from functools import reduce
from operator import mul
def is_curious(num, den):
if(num==den):
return False
num_s, den_s = str(num), str(den)
if num_s[1] == den_s[1] == '0':
return False
try:
if num_s[0] == den_s[0] and Fraction(num, den) ==Fraction... | {
"repo_name": "dawran6/project-euler",
"path": "33-digit-cancelling-fractions.py",
"copies": "1",
"size": "1087",
"license": "mit",
"hash": 7180736491412512000,
"line_mean": 30.0571428571,
"line_max": 95,
"alpha_frac": 0.5427782889,
"autogenerated": false,
"ratio": 3.0880681818181817,
"config_t... |
from fractions import Fraction
from functools import reduce
def findCancelling():
# Need num/denom with at least one digit in common
# but not the same or multiple of 10
# i.e. no 0's
fracList = []
for i in range(1, 10):
for j in range(1, 10):
if i == j: continue
nu... | {
"repo_name": "WalrusCow/euler",
"path": "Solutions/problem33.py",
"copies": "1",
"size": "1365",
"license": "mit",
"hash": -8759356507908133000,
"line_mean": 30.0227272727,
"line_max": 57,
"alpha_frac": 0.5318681319,
"autogenerated": false,
"ratio": 3.8022284122562673,
"config_test": false,
... |
from fractions import Fraction
from itertools import chain, cycle
from typing import Generator, Iterable, List, Tuple
from ..sqrt import sqrt
def convergent_sequence(generator: Iterable[int]) -> \
Generator[Fraction, None, None]:
h = (0, 1)
k = (1, 0)
for a in generator:
h = h[1], a * h... | {
"repo_name": "cryvate/project-euler",
"path": "project_euler/library/number_theory/continued_fractions.py",
"copies": "1",
"size": "1208",
"license": "mit",
"hash": -5600411549018548000,
"line_mean": 23.6530612245,
"line_max": 68,
"alpha_frac": 0.5985099338,
"autogenerated": false,
"ratio": 3.36... |
from fractions import Fraction
from itertools import product, combinations
from functools import reduce
from operator import mul
def sols(i, target, current_subset, pool, pool_rev_acc):
s = 0
if pool[i] == target:
yield current_subset
if i == len(pool) - 1:
return
if pool_rev_acc[i+1... | {
"repo_name": "peterstace/project-euler",
"path": "OLD_PY_CODE/project_euler_old_old/152/152.py",
"copies": "1",
"size": "5595",
"license": "unlicense",
"hash": 3986781973994174000,
"line_mean": 24.9027777778,
"line_max": 95,
"alpha_frac": 0.4893655049,
"autogenerated": false,
"ratio": 3.17356778... |
from fractions import Fraction
from math import factorial
import random
import itertools
def cross(A, B):
"O conjunto de formas de concatenar os itens de A e B (produto cartesiano)"
return {a + b
for a in A for b in B
}
def combos(items, n):
"Todas as combinações de n items; cada co... | {
"repo_name": "jacksongomesbr/academia-md",
"path": "probabilidade/funcoes.py",
"copies": "1",
"size": "2410",
"license": "cc0-1.0",
"hash": 4627996829514267000,
"line_mean": 34.1764705882,
"line_max": 115,
"alpha_frac": 0.6387959866,
"autogenerated": false,
"ratio": 3.062740076824584,
"config_... |
from fractions import Fraction
from math import pi
import numpy as np
from bokeh.colors.named import colors
from bokeh.io import show
from bokeh.models import ColumnDataSource, Plot, PolarTransform
from bokeh.plotting import figure, gridplot
dark_colors = iter(color for color in colors if color.brightness < 0.6)
col... | {
"repo_name": "bokeh/bokeh",
"path": "examples/plotting/file/polar.py",
"copies": "1",
"size": "1159",
"license": "bsd-3-clause",
"hash": 4887362504728388000,
"line_mean": 23.1458333333,
"line_max": 71,
"alpha_frac": 0.6289905091,
"autogenerated": false,
"ratio": 3.066137566137566,
"config_test... |
from fractions import Fraction
from math import pi
import numpy as np
from bokeh.colors.named import colors
from bokeh.io import show
from bokeh.models import ColumnDataSource, PolarTransform, Range1d
from bokeh.plotting import figure
dark_colors = iter(color for color in colors if color.brightness < 0.6)
color_map ... | {
"repo_name": "bokeh/bokeh",
"path": "examples/plotting/file/polar_subcoordinates.py",
"copies": "1",
"size": "1246",
"license": "bsd-3-clause",
"hash": 7057420847617400000,
"line_mean": 24.9583333333,
"line_max": 80,
"alpha_frac": 0.6107544141,
"autogenerated": false,
"ratio": 2.8253968253968256... |
from fractions import Fraction
from math import sqrt
from time import time
##half = 1/2
##
##blue = 3
##improve = 4/10
##while True:
## red = blue * improve
## while red > 0:
## total = blue + red
##
## probability = (blue/total) * ((blue - 1) / (total - 1))
##
## dif = abs(probability - 0.5... | {
"repo_name": "feliposz/project-euler-solutions",
"path": "python/euler100.py",
"copies": "1",
"size": "7103",
"license": "mit",
"hash": 5697255830186038000,
"line_mean": 28.4730290456,
"line_max": 121,
"alpha_frac": 0.5697592567,
"autogenerated": false,
"ratio": 2.7898664571877454,
"config_tes... |
from fractions import Fraction
from math import sqrt
from time import time
# Looking at the data, I stumbled upon 2 "magic" numbers for this
# problem.
# One is the ratio blue chips / total chips that converges to sqrt(2).
# So I use an approximation to get the value of total based on the
# current estimate for blue ... | {
"repo_name": "feliposz/project-euler-solutions",
"path": "python/euler100e.py",
"copies": "1",
"size": "1383",
"license": "mit",
"hash": 896459871761372200,
"line_mean": 22.8448275862,
"line_max": 70,
"alpha_frac": 0.6240057845,
"autogenerated": false,
"ratio": 3.2928571428571427,
"config_test... |
from fractions import Fraction
from midi import MIDI
import numbers
import itertools
# These functions should remain static if MidiBackend is ever made a class.
def insert_keyed(in_list, val, key):
# Locate the leftmost value >= x
for idx, element in enumerate(in_list):
if key(element) >= key(val):
... | {
"repo_name": "jimbo1qaz/sseq3midi",
"path": "msh/util.py",
"copies": "1",
"size": "3702",
"license": "mit",
"hash": -5641433541091159000,
"line_mean": 24.5310344828,
"line_max": 93,
"alpha_frac": 0.5983252296,
"autogenerated": false,
"ratio": 3.472795497185741,
"config_test": false,
"has_no_... |
from fractions import Fraction
from numbers import Integral
from weakref import WeakValueDictionary
class QFormat:
"""The precision and position of the binary point in a signed fixed point number.
"""
_instances = WeakValueDictionary()
@classmethod
def from_str(cls, s):
"""Create a QForm... | {
"repo_name": "sixty-north/fixedpointtest",
"path": "fixedpoint/qformat.py",
"copies": "1",
"size": "4682",
"license": "mit",
"hash": -6998757928772263000,
"line_mean": 35.3023255814,
"line_max": 116,
"alpha_frac": 0.6121315677,
"autogenerated": false,
"ratio": 4.454804947668887,
"config_test":... |
from fractions import Fraction
from queue import Queue
from typing import Callable, Generator, Tuple # noqa: F401 (used in comment)
from .euler_totient import phi_range
def mediant(left: Fraction, right: Fraction) -> Fraction:
return Fraction(left.numerator + right.numerator,
left.denominat... | {
"repo_name": "cryvate/project-euler",
"path": "project_euler/library/number_theory/stern_brocot_tree.py",
"copies": "1",
"size": "1149",
"license": "mit",
"hash": -4180628722256273400,
"line_mean": 27.725,
"line_max": 77,
"alpha_frac": 0.6153176675,
"autogenerated": false,
"ratio": 4.07446808510... |
from fractions import Fraction
from SB import SB
from CH import CH
from config import *
from GSM import *
import numpy as np
from convCode import convCode
class SCH(CH):
__burst__ = SB
"""
ncc =
(decoded_data[ 7] << 2) |
(decoded_data[ 6] << 1) |
(decoded_data[ 5] << 0);
bcc =
(decoded... | {
"repo_name": "RP7/R7-OCM",
"path": "src/host/python/gsmlib/SCH.py",
"copies": "2",
"size": "3328",
"license": "apache-2.0",
"hash": 277755715420330600,
"line_mean": 22.2727272727,
"line_max": 116,
"alpha_frac": 0.5438701923,
"autogenerated": false,
"ratio": 2.365316275764037,
"config_test": fa... |
from fractions import Fraction
from .simplex import Simplex, Unbounded, Empty, latexWrap, fractionToLatex
from .array import Array
class Literal:
'''
Represents a literal: a variable (a string) with a factor (a fraction).
'''
def __init__(self, factor, variable):
self.factor = factor
... | {
"repo_name": "Ezibenroc/simplex",
"path": "simplex/linearProgram.py",
"copies": "1",
"size": "11434",
"license": "mit",
"hash": -3384217499701639000,
"line_mean": 41.1918819188,
"line_max": 135,
"alpha_frac": 0.5936680077,
"autogenerated": false,
"ratio": 4.048866855524079,
"config_test": fals... |
from fractions import Fraction
from typing import Tuple
import pytest
from hypothesis import HealthCheck, assume, example, given, settings
from hypothesis.strategies import integers
from raiden.tests.unit.transfer.test_channel import make_hash_time_lock_state
from raiden.tests.utils import factories
from raiden.tests... | {
"repo_name": "raiden-network/raiden",
"path": "raiden/tests/unit/transfer/mediated_transfer/test_mediation_fee.py",
"copies": "1",
"size": "25218",
"license": "mit",
"hash": 1918191036204514800,
"line_mean": 38.2192846034,
"line_max": 99,
"alpha_frac": 0.6423982869,
"autogenerated": false,
"rati... |
from fractions import Fraction
from warnings import warn
class Simplex(object):
def __init__(self, num_vars, constraints, objective_function):
"""
num_vars: Number of variables
equations: A list of strings representing constraints
each variable should be start with x followed by a... | {
"repo_name": "khalibartan/simplex-method",
"path": "simplex.py",
"copies": "1",
"size": "10290",
"license": "mit",
"hash": 724590232115722100,
"line_mean": 36.5547445255,
"line_max": 145,
"alpha_frac": 0.5430515063,
"autogenerated": false,
"ratio": 3.576642335766423,
"config_test": false,
"h... |
from fractions import Fraction
import io
import logging
import os
import random
import string
import time
try:
from picamera import PiCamera
except ImportError:
print 'Warning: PiCamera module not available'
from PIL import Image
import config
logger = logging.getLogger(__name__)
class Camera(object):
... | {
"repo_name": "mattskone/garage_alarm",
"path": "camera.py",
"copies": "2",
"size": "5699",
"license": "mit",
"hash": 5265074437494414000,
"line_mean": 30.6611111111,
"line_max": 83,
"alpha_frac": 0.5739603439,
"autogenerated": false,
"ratio": 3.930344827586207,
"config_test": true,
"has_no_k... |
from fractions import Fraction
import math
import itertools
def succ(x):
"""
takes an element of the Calkin Wilf tree and returns the next element
following a breadth first traversal
:param x: Fraction
:return: Fraction
"""
x_int = Fraction(math.floor(x))
x_nonint = Fraction(x.numerato... | {
"repo_name": "richardmillson/Calkin_Wilf_tree",
"path": "tree.py",
"copies": "1",
"size": "2316",
"license": "mit",
"hash": 8124205700382237000,
"line_mean": 22.3939393939,
"line_max": 75,
"alpha_frac": 0.6101036269,
"autogenerated": false,
"ratio": 3.815485996705107,
"config_test": false,
"... |
from fractions import Fraction
import math
"""Allow distributions to omit events totalling this probability.
This acts as a sanity check, to ensure that other optimisations you set, such
as PROB_EVENT_TOLERANCE, or using floats instead of Fractions, don't result in
wildly-inaccurate results.
"""
PROB_SPACE_TOLERANCE ... | {
"repo_name": "infinity0/bjsim",
"path": "bj/prob.py",
"copies": "1",
"size": "3571",
"license": "bsd-3-clause",
"hash": -2492331912072677000,
"line_mean": 28.5123966942,
"line_max": 112,
"alpha_frac": 0.6765611873,
"autogenerated": false,
"ratio": 2.9512396694214877,
"config_test": false,
"h... |
from fractions import Fraction
import numpy as np
import config
import GSM as gsm
import struct
from ctypes import *
class item:
def getLen(self):
if hasattr(self,"field"):
l = 0
for x in self.field:
l += x.getLen()
return l
else:
return self.__class__.length
@staticmethod
def gmsk_mapper( inp,... | {
"repo_name": "RP7/R7-OCM",
"path": "src/host/python/gsmlib/Burst.py",
"copies": "2",
"size": "3192",
"license": "apache-2.0",
"hash": -7287733684203221000,
"line_mean": 20.5675675676,
"line_max": 76,
"alpha_frac": 0.649122807,
"autogenerated": false,
"ratio": 2.5659163987138265,
"config_test":... |
from fractions import Fraction
import pytest
from typing import List, Tuple
from .continued_fractions import convergent_sequence, \
continued_fraction_sqrt, \
convergents_sqrt
CONVERGENTS = [
(
[0, 1, 5, 2, 2],
[Fraction(0, 1),
... | {
"repo_name": "cryvate/project-euler",
"path": "project_euler/library/number_theory/test_continued_fractions.py",
"copies": "1",
"size": "2486",
"license": "mit",
"hash": -9153207450810181000,
"line_mean": 17.0144927536,
"line_max": 79,
"alpha_frac": 0.391391794,
"autogenerated": false,
"ratio": ... |
from fractions import Fraction
import re
from jsonschema._utils import (
ensure_list,
equal,
extras_msg,
find_additional_properties,
types_msg,
unbool,
uniq,
)
from jsonschema.exceptions import FormatError, ValidationError
def patternProperties(validator, patternProperties, instance, sche... | {
"repo_name": "Julian/jsonschema",
"path": "jsonschema/_validators.py",
"copies": "1",
"size": "12397",
"license": "mit",
"hash": 7216111643228076000,
"line_mean": 31.1165803109,
"line_max": 79,
"alpha_frac": 0.6055497298,
"autogenerated": false,
"ratio": 4.282210708117444,
"config_test": false... |
from fractions import Fraction
import sys,math
# compare two tessellations of a circular disk
# trascendental vs rational coordinates
# (aka cos/sin vs integer/integer)
# roughly equal density and number of points
# which is more compressible in data size?
#####
## result
#
# when using standard python ASCII outpu... | {
"repo_name": "donbright/piliko",
"path": "experiment/compression.py",
"copies": "1",
"size": "5748",
"license": "bsd-3-clause",
"hash": 4433263777076189700,
"line_mean": 28.6288659794,
"line_max": 98,
"alpha_frac": 0.6838900487,
"autogenerated": false,
"ratio": 2.7293447293447293,
"config_test... |
from fractions import Fraction
import sys
# depth-blueq.
# alter depth, it wil change the number of 'dots' in the center of the shape
def sqr(x): return x*x
def greenq_pts(x,y,x2,y2): return 2*(x2-x)*(y2-y)
def redq_pts(x,y,x2,y2): return sqr(x2-x)-sqr(y2-y)
def blueq_pts(x,y,x2,y2): return sqr(x2-x)+sqr(y2-y)
def ... | {
"repo_name": "donbright/piliko",
"path": "experiment/miscpatterns/pattern_alien.py",
"copies": "1",
"size": "1105",
"license": "bsd-3-clause",
"hash": 4786485728442121000,
"line_mean": 23.0217391304,
"line_max": 76,
"alpha_frac": 0.636199095,
"autogenerated": false,
"ratio": 2.0500927643784785,
... |
from fractions import Fraction
import sys
layer = [Fraction(0,1),Fraction(1,1)]
newlayer = []
depth=4
for i in range(1,depth):
for i in range(len(layer)-1):
new_numer = layer[i].numerator+layer[i+1].numerator
new_denom = layer[i].denominator+layer[i+1].denominator
new_number = Fraction( new_numer, new_denom )
... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythsphere2.py",
"copies": "1",
"size": "1109",
"license": "bsd-3-clause",
"hash": -9076185396909536000,
"line_mean": 21.18,
"line_max": 57,
"alpha_frac": 0.5879170424,
"autogenerated": false,
"ratio": 2.187376725838264,
"config_test": false... |
from fractions import Fraction
import sys
# rational approximation of a unit circle using farey sequence and a
# Chromogeometry - ish paramterization of unit pts on circle. requires
# numpy, matplotlib
# also this version limits blue quadrance between points... so you get a
# sort of rational approximation of a 'r... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythcirc2.py",
"copies": "1",
"size": "1825",
"license": "bsd-3-clause",
"hash": 5449986788195171000,
"line_mean": 24.3472222222,
"line_max": 73,
"alpha_frac": 0.6690410959,
"autogenerated": false,
"ratio": 2.6034236804564905,
"config_test":... |
from fractions import Fraction
import sys
# rational approximation of a unit circle using
# Chromogeometry - ish paramterization of unit pts on circle. requires
# numpy, matplotlib
# uses 'flat' list of input fractions. not farey sequence as in other
# experiments
# also this version limits blue quadrance between ... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythcirc3.py",
"copies": "1",
"size": "1423",
"license": "bsd-3-clause",
"hash": 3141934924668593000,
"line_mean": 23.5344827586,
"line_max": 73,
"alpha_frac": 0.6676036543,
"autogenerated": false,
"ratio": 2.4790940766550524,
"config_test":... |
from fractions import Fraction
import sys
# rational approximation of unit circle... with 'warping'
# introduced by playing around with inputs to the quadrance functions
# for example, instead of 0,0,m,n use '-n,0,m,n'
def sqr(x): return x*x
def greenq(x,y,x2,y2): return 2*(x2-x)*(y2-y)
def redq(x,y,x2,y2): return s... | {
"repo_name": "donbright/piliko",
"path": "experiment/warppng/pythwarp4.py",
"copies": "1",
"size": "1056",
"license": "bsd-3-clause",
"hash": 2065447238614279400,
"line_mean": 24.1428571429,
"line_max": 69,
"alpha_frac": 0.6373106061,
"autogenerated": false,
"ratio": 2.1204819277108435,
"confi... |
from fractions import Fraction
import sys
# rational paramterization / approximation of bernoulli's lemniscate
# traditional form: ( x^2 + y^2 ) ^2 = 2*a*( x^2 - y^2 )
# (note - this uses terms from Norman Wildberger's rational
# trigonometry/chromogeometry. briefly for a vector from 0,0 to x,y:
#
# blue quadrance (... | {
"repo_name": "donbright/piliko",
"path": "experiment/bernoulli/pythbernlem.py",
"copies": "1",
"size": "5304",
"license": "bsd-3-clause",
"hash": -3807664013547784000,
"line_mean": 30.3846153846,
"line_max": 79,
"alpha_frac": 0.6742081448,
"autogenerated": false,
"ratio": 2.638805970149254,
"c... |
from fractions import Fraction
import sys
# this is a demonstration of the 'fox head' algorithm for finding
# the 'side' of a line that a point is on.
# consider two points, p1, and p2. then imagine a line between p1, p2
# lets call it l. the foxhead of p1, p2, p3 will tell you which 'side'
# of the line l that p3 i... | {
"repo_name": "donbright/piliko",
"path": "experiment/foxhead.py",
"copies": "1",
"size": "1570",
"license": "bsd-3-clause",
"hash": 7069769607742223000,
"line_mean": 23.53125,
"line_max": 73,
"alpha_frac": 0.6210191083,
"autogenerated": false,
"ratio": 2.1805555555555554,
"config_test": false,... |
from fractions import Fraction
import sys
# very simple rational paramterization / approximation of blue circle
# (x^2+y^2=1) useful as base for building other ideas
def sqr(x): return x*x
def greenq_pts(x,y,x2,y2): return 2*(x2-x)*(y2-y)
def redq_pts(x,y,x2,y2): return sqr(x2-x)-sqr(y2-y)
def blueq_pts(x,y,x2,y2): r... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythcircsimple.py",
"copies": "1",
"size": "1094",
"license": "bsd-3-clause",
"hash": 4415822418530542000,
"line_mean": 23.8636363636,
"line_max": 69,
"alpha_frac": 0.647166362,
"autogenerated": false,
"ratio": 2.083809523809524,
"config_tes... |
from fractions import Fraction
import sys
# very simple rational paramterization / approximation of red hyperbola
# (x^2-y^2=1) useful as base for building other ideas
def sqr(x): return x*x
def greenq_pts(x,y,x2,y2): return 2*(x2-x)*(y2-y)
def redq_pts(x,y,x2,y2): return sqr(x2-x)-sqr(y2-y)
def blueq_pts(x,y,x2,y2)... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythhypsimple.py",
"copies": "1",
"size": "1089",
"license": "bsd-3-clause",
"hash": -3927679404987441000,
"line_mean": 23.75,
"line_max": 72,
"alpha_frac": 0.6409550046,
"autogenerated": false,
"ratio": 2.0625,
"config_test": false,
"has_... |
from fractions import Fraction
import time
def gen_random():
s = 290797
while True:
s = (s * s) % 50515093
t = s % 500
yield int(t)
# https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
def calc_intersect(line1, line2):
x1, y1, x2, y2 = line1
x3, y3, x4, y4 = line2
... | {
"repo_name": "zeyuanxy/project-euler",
"path": "vol4/165.py",
"copies": "2",
"size": "1483",
"license": "mit",
"hash": 3291102074586256400,
"line_mean": 23.7166666667,
"line_max": 107,
"alpha_frac": 0.4585300067,
"autogenerated": false,
"ratio": 2.736162361623616,
"config_test": false,
"has_... |
from fractions import Fraction
def _e_partial_value_at_idx(idx):
return 2 if idx == 0 else 2 * (idx // 3 + 1) if idx % 3 == 2 else 1
class EPartialValueIterator:
def __init__(self, start=0, stop=None, step=1):
self._index = start or 0
self._stop = stop
self._step = step or 1
def... | {
"repo_name": "WalrusCow/euler",
"path": "Solutions/problem65.py",
"copies": "1",
"size": "1445",
"license": "mit",
"hash": -5888098057353828000,
"line_mean": 25.2727272727,
"line_max": 71,
"alpha_frac": 0.584083045,
"autogenerated": false,
"ratio": 3.686224489795918,
"config_test": false,
"h... |
from fractions import Fraction
def IsCancellingDigitFraction(numerator, denominator):
#Do they share a digit in both numerator and denominator?
f = Fraction(numerator, denominator)
numeratorStr = str(numerator)
denominatorStr = str(denominator)
for nd in str(numeratorStr):
if nd in denomina... | {
"repo_name": "danroberts728/Project-Euler-Answers",
"path": "python/Problem33.py",
"copies": "1",
"size": "1052",
"license": "mit",
"hash": -6673479327114582000,
"line_mean": 35.275862069,
"line_max": 76,
"alpha_frac": 0.6064638783,
"autogenerated": false,
"ratio": 4.515021459227468,
"config_t... |
from fractions import Fraction
def spread(start, end, count, mode=1):
"""spread(start, end, count [, mode]) -> generator
Yield a sequence of evenly-spaced numbers between start and end.
The range start...end is divided into count evenly-spaced (or as close to
evenly-spaced as possible) intervals. The... | {
"repo_name": "ActiveState/code",
"path": "recipes/Python/577878_Generate_equallyspaced_floats/recipe-577878.py",
"copies": "1",
"size": "1772",
"license": "mit",
"hash": -7987312560855622000,
"line_mean": 34.44,
"line_max": 77,
"alpha_frac": 0.6439051919,
"autogenerated": false,
"ratio": 3.89450... |
from fractions import Fraction
from function.generic_univariate_pitch_function import GenericUnivariatePitchFunction
from function.piecewise_linear_function import PiecewiseLinearFunction
from function.scalar_range_interpreter import ScalarRangeInterpreter
from function.chromatic_range_interpreter import ChromaticRang... | {
"repo_name": "dpazel/music_rep",
"path": "transformation/reshape/t_reshape_book_examples.py",
"copies": "1",
"size": "10839",
"license": "mit",
"hash": 6108142017910697000,
"line_mean": 37.0315789474,
"line_max": 120,
"alpha_frac": 0.6651905157,
"autogenerated": false,
"ratio": 3.160979877515310... |
from fractions import Fraction
from ..library.base import number_to_list
from ..library.sqrt import is_square
from ..library.number_theory.continued_fractions import convergents_sqrt
def solve(bound: int=100, digits: int=100, base: int=10):
sufficient = base ** digits
accumulate = 0
for n in range(boun... | {
"repo_name": "cryvate/project-euler",
"path": "project_euler/solutions/problem_80.py",
"copies": "1",
"size": "1051",
"license": "mit",
"hash": -4858770439012118000,
"line_mean": 26.6578947368,
"line_max": 79,
"alpha_frac": 0.555661275,
"autogenerated": false,
"ratio": 4.54978354978355,
"confi... |
from fractions import Fraction
from raiden.constants import DAI_TOKEN_ADDRESS, WETH_TOKEN_ADDRESS
from raiden.settings import DEFAULT_DAI_FLAT_FEE, DEFAULT_WETH_FLAT_FEE, MediationFeeConfig
from raiden.utils.typing import Dict, FeeAmount, ProportionalFeeAmount, TokenAddress, Tuple
def ppm_fee_per_channel(per_hop_fee... | {
"repo_name": "raiden-network/raiden",
"path": "raiden/utils/mediation_fees.py",
"copies": "1",
"size": "2497",
"license": "mit",
"hash": 8149381115258195000,
"line_mean": 42.0517241379,
"line_max": 91,
"alpha_frac": 0.7136563877,
"autogenerated": false,
"ratio": 3.148802017654477,
"config_test... |
from fractions import Fraction
from typing import Tuple
from .base import list_to_number
Representation = Tuple[Tuple[int, int], Tuple[int, int]]
def unit_fraction_to_representation(denominator: int,
base: int=10) -> Representation:
return fraction_to_representation(Fractio... | {
"repo_name": "cryvate/project-euler",
"path": "project_euler/library/fraction_representation.py",
"copies": "1",
"size": "2055",
"license": "mit",
"hash": -6591926126896780000,
"line_mean": 26.4,
"line_max": 73,
"alpha_frac": 0.6199513382,
"autogenerated": false,
"ratio": 4.237113402061856,
"c... |
from fractions import Fraction
if __name__ == "__main__":
n = input()
y = map(int, raw_input().split())
used = set()
for i in xrange(1, n):
if i in used:
continue
k = Fraction(y[i] - y[0], i)
in_line = set()
in_line.add(0)
in_line.add(i)
... | {
"repo_name": "EdisonAlgorithms/CodeForces",
"path": "contest/849/B.py",
"copies": "3",
"size": "1318",
"license": "mit",
"hash": -5042312554069364000,
"line_mean": 21.724137931,
"line_max": 79,
"alpha_frac": 0.3474962064,
"autogenerated": false,
"ratio": 3.5912806539509536,
"config_test": fals... |
from fractions import Fraction
import math
class Probability(Fraction, object):
def probability(self):
return 1 - self.relative_probability()
def relative_probability(self):
return self.numerator / self.denominator
def combination(objects, selections):
return math.factorial(objects) / ... | {
"repo_name": "Chronotron/chaos-beast",
"path": "MA120/probability/probality_functions.py",
"copies": "1",
"size": "1155",
"license": "mit",
"hash": 2561127477094951400,
"line_mean": 22.5714285714,
"line_max": 104,
"alpha_frac": 0.7177489177,
"autogenerated": false,
"ratio": 3.9827586206896552,
... |
from fractions import Fraction
import numpy as np
def normalize(v):
"""
Normalize a vector v.
"""
return np.array(v) / np.sqrt(abs(np.dot(v, v)))
def make_symmetry_matrix(upper_triangle):
"""
Given three or six integers/rationals, fill them into a 3x3 (or 4x4)
symmetric matrix. Always r... | {
"repo_name": "neozhaoliang/pywonderland",
"path": "src/uniform-tilings/helpers.py",
"copies": "1",
"size": "8300",
"license": "mit",
"hash": 1224635133088532500,
"line_mean": 29.737037037,
"line_max": 88,
"alpha_frac": 0.519219183,
"autogenerated": false,
"ratio": 2.6901134521880063,
"config_t... |
from fractions import Fraction
import pytest
from mugen.mixins.Weightable import Weightable, WeightableList
@pytest.fixture
def weightable_list_a() -> WeightableList:
return WeightableList([Weightable(weight=1), Weightable(weight=1), Weightable(weight=1), Weightable(weight=1)])
@pytest.fixture
def weightable_... | {
"repo_name": "scherroman/mugen",
"path": "tests/unit/mixins/test_Weightable.py",
"copies": "1",
"size": "3380",
"license": "mit",
"hash": 1986731233781931500,
"line_mean": 40.7283950617,
"line_max": 119,
"alpha_frac": 0.6846153846,
"autogenerated": false,
"ratio": 3.0783242258652095,
"config_t... |
from fractions import Fraction
class Vertex:
def __init__(self, x, y, z):
self.coordinates = (x, y, z)
def __eq__(self, other):
return (
isinstance(other, Vertex) and
self.coordinates == other.coordinates
)
def quadrance(vertex_1, vertex_2):
return sum(
... | {
"repo_name": "jtauber/folds",
"path": "folds.py",
"copies": "1",
"size": "1545",
"license": "mit",
"hash": 3773064388715422700,
"line_mean": 24.3278688525,
"line_max": 78,
"alpha_frac": 0.5313915858,
"autogenerated": false,
"ratio": 2.803992740471869,
"config_test": false,
"has_no_keywords":... |
from fractions import Fraction
def parse_sexp(string):
"""
Parses an S-Expression into a list-based tree.
parse_sexp("(+ 5 (+ 3 5))") results in [['+', '5', ['+', '3', '5']]]
"""
sexp = [[]]
word = ''
in_str = False
for c in string:
if c == '(' and not in_str:
sexp.append([])
elif c... | {
"repo_name": "luisenp/mdp-lib",
"path": "scripts/reduced/ppddl_util.py",
"copies": "1",
"size": "8867",
"license": "mit",
"hash": -5750514457806868000,
"line_mean": 35.1959183673,
"line_max": 81,
"alpha_frac": 0.6605390775,
"autogenerated": false,
"ratio": 3.572522159548751,
"config_test": fal... |
from fractions import Fraction
def rectangle_dot_count(vertices):
""" Count rectangle dot count include edge """
assert len(vertices) == 2
width = abs(vertices[0][0] - vertices[1][0])
height = abs(vertices[0][1] - vertices[1][1])
dot_count = (width + 1) * (height + 1)
return dot_count
def di... | {
"repo_name": "gongbudaizhe/bilib",
"path": "demos/carrot_land/solution.py",
"copies": "1",
"size": "14673",
"license": "mit",
"hash": -999249502180946200,
"line_mean": 46.954248366,
"line_max": 78,
"alpha_frac": 0.4898793703,
"autogenerated": false,
"ratio": 3.9507269789983845,
"config_test": ... |
from fractions import Fraction
##########
##########
#
# rational parameterization of a hyperbolic 3 dimensional sheet thing.
#
# equation:
#
# x^2 + y^2 - z^2 = 1
#
#########
#########
# this is the same theory used to make the paramterization of the unit sphere
# using four integers, m,n,m1,n1.
## consider a basi... | {
"repo_name": "donbright/piliko",
"path": "experiment/ratparam3d/pythhypsheet.py",
"copies": "1",
"size": "4344",
"license": "bsd-3-clause",
"hash": 6216953964854711000,
"line_mean": 27.2077922078,
"line_max": 79,
"alpha_frac": 0.5877071823,
"autogenerated": false,
"ratio": 2.242643262777491,
"... |
from fractions import Fraction
##########
##########
#
# rational parameterization of a hyperbolic 3 dimensional sheet thing.
# take 2.
#
# equation:
#
# x^2 - y^2 - z^2 = 1
#
#########
#########
# this is the same theory used to make the paramterization of the unit sphere
# using four integers, m,n,m1,n1.
# Chromo... | {
"repo_name": "donbright/piliko",
"path": "experiment/ratparam3d/pythhypsheet2.py",
"copies": "1",
"size": "2004",
"license": "bsd-3-clause",
"hash": -8296609661365315000,
"line_mean": 20.3191489362,
"line_max": 77,
"alpha_frac": 0.5818363273,
"autogenerated": false,
"ratio": 2.049079754601227,
... |
from fractions import Fraction
##########
##########
#
# rational parameterization of the unit sphere
#
#########
#########
# consider a basic unit sphere
#
# x^2 + y^2 + z^2 = radius = 1^2
#
# x^2 + y^2 = l^2
# l^2 + z^2 = radius^2
# radius = 1, radius^2=1
#
# example: begin with very simple pythagorean triple... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythknotmaybe.py",
"copies": "1",
"size": "2989",
"license": "bsd-3-clause",
"hash": -1462187678143397000,
"line_mean": 28.0194174757,
"line_max": 80,
"alpha_frac": 0.5707594513,
"autogenerated": false,
"ratio": 2.2974634896233668,
"config_t... |
from fractions import Fraction
##########
##########
#
# rational parameterization of the unit sphere
#
#########
#########
# for basic theory see pythsphere and pythsphere2.py
#
# this version differs in that it limits distance between points to a minimum
def sqr(x): return x*x
def blueq(p1,p2): return sqr(p2[0]-p1... | {
"repo_name": "donbright/piliko",
"path": "experiment/pythsphere3.py",
"copies": "1",
"size": "1274",
"license": "bsd-3-clause",
"hash": -8968094350315552000,
"line_mean": 20.593220339,
"line_max": 77,
"alpha_frac": 0.5635792779,
"autogenerated": false,
"ratio": 2.159322033898305,
"config_test"... |
from fractions import Fraction
"""
We want to determine the optimum polynomial OP(k,n) for a given degree k-1:
OP(k,n) = a(0) + a(1) * n + a(2) * n^2 + ... + a(k-1) * n^(k-1)
Plugging values n = 1...k into OP(k, n) must generate the series u(n):
OP(k, 1) = u(1)
OP(k, 2) = u(2)
OP(k, 3) = u(3)
...
O... | {
"repo_name": "brunorijsman/euler-problems-python",
"path": "euler/problem101.py",
"copies": "1",
"size": "4006",
"license": "bsd-2-clause",
"hash": -7481112862446540000,
"line_mean": 31.048,
"line_max": 86,
"alpha_frac": 0.5539191213,
"autogenerated": false,
"ratio": 2.793584379358438,
"config... |
from fractions import Fraction
'''
Some builtin functions for bach's runtime
bach_add/bach_sub etc correspond to +/-...
see bach_ast for mapping(bach converts all those labels into valid python labels)
Most of those implementations don't feel pythonic, and that's intentional
Those functions would be used frequently, s... | {
"repo_name": "alehander42/bach",
"path": "bach/bach_stl/functions.py",
"copies": "1",
"size": "3457",
"license": "mit",
"hash": -1112258121155309400,
"line_mean": 24.992481203,
"line_max": 102,
"alpha_frac": 0.5253109633,
"autogenerated": false,
"ratio": 4.019767441860465,
"config_test": false... |
from fractions import Fraction
# polygon intersection.. doesnt work.
# assume - input polys are clockwise-ordered set of 3 or more points
# assume - points are using rational numbers for coordinates (Fractions)
# assume - polygons are simple
# design - dont use angles
# point = [x,y]
# line = [a,b,c] where ax+by+c ... | {
"repo_name": "donbright/piliko",
"path": "pmeet.py",
"copies": "1",
"size": "4347",
"license": "bsd-3-clause",
"hash": 6458302575557407000,
"line_mean": 27.4117647059,
"line_max": 94,
"alpha_frac": 0.6461927766,
"autogenerated": false,
"ratio": 2.3637846655791193,
"config_test": false,
"has_... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.