function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute("INSERT INTO auth_type VALUES ('webauthn_auth')")
op.drop_constraint('ck_users_mobile_or_email_auth', 'users', type_=None, schema=None)
op.execute("""
ALTER TABLE users ADD CONSTRAINT "ck_user_has_mobile_or_... | alphagov/notifications-api | [
56,
23,
56,
6,
1447855037
] |
def post_install(install_path):
"""
Post install script for pyCUDA applications to warm the cubin cache
"""
import pycuda.autoinit
from pycuda.compiler import SourceModule
CACHE_DIR = os.path.join(install_path, 'cache')
if not os.path.exists(CACHE_DIR):
os.mkdir(CACHE_DIR)
for k... | Captricity/sciguppy | [
1,
1,
1,
5,
1416963903
] |
def run(self):
install.run(self)
post_install(os.path.join(self.install_lib, 'sciguppy')) | Captricity/sciguppy | [
1,
1,
1,
5,
1416963903
] |
def DescribeMesh(self, request):
"""查询网格详情
:param request: Request instance for DescribeMesh.
:type request: :class:`tencentcloud.tcm.v20210413.models.DescribeMeshRequest`
:rtype: :class:`tencentcloud.tcm.v20210413.models.DescribeMeshResponse`
"""
try:
param... | tzpBingo/github-trending | [
42,
20,
42,
1,
1504755582
] |
def __init__(self, scores):
self.scores = scores | N-Parsons/exercism-python | [
1,
1,
1,
3,
1506170251
] |
def personal_best(self):
return max(self.scores) | N-Parsons/exercism-python | [
1,
1,
1,
3,
1506170251
] |
def main(argv=None):
"""
Make a confidence report and save it to disk.
"""
assert len(argv) >= 3
_name_of_script = argv[0]
model_filepath = argv[1]
adv_x_filepaths = argv[2:]
sess = tf.Session()
with sess.as_default():
model = serial.load(model_filepath)
factory = model.dataset_factory
facto... | openai/cleverhans | [
5732,
1384,
5732,
39,
1473899284
] |
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
if cls:
return cls(pipeline_response, None, {}) | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('RouteFilterRule', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def get_long_running_output(pipeline_response):
deserialized = self._deserialize('RouteFilterRule', pipeline_response)
if cls:
return cls(pipeline_response, deserialized, {})
return deserialized | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def list_by_route_filter(
self,
resource_group_name: str,
route_filter_name: str,
**kwargs: Any | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_rout... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def setup_parser(self, parser):
parser.add_argument(
'where',
help='Path to new module',
) | cpenv/cpenv | [
22,
6,
22,
14,
1441120492
] |
def __init__(self, data):
self.data = data
self.left = None
self.right = None | anubhavshrimal/Data_Structures_Algorithms_In_Python | [
312,
131,
312,
1,
1474914708
] |
def __init__(self):
self.root = None | anubhavshrimal/Data_Structures_Algorithms_In_Python | [
312,
131,
312,
1,
1474914708
] |
def _insert(self, data, current_node):
if data <= current_node.data:
if current_node.left is not None:
self._insert(data, current_node.left)
else:
current_node.left = Node(data)
else:
if current_node.right is not None:
s... | anubhavshrimal/Data_Structures_Algorithms_In_Python | [
312,
131,
312,
1,
1474914708
] |
def _inorder(self, current_node):
if current_node is None:
return
self._inorder(current_node.left)
print(current_node.data, " -> ", end='')
self._inorder(current_node.right) | anubhavshrimal/Data_Structures_Algorithms_In_Python | [
312,
131,
312,
1,
1474914708
] |
def lca_bst(root, value1, value2):
while root is not None:
if value2 > root.data < value1:
root = root.right
elif value2 < root.data > value1:
root = root.left
else:
return root.data | anubhavshrimal/Data_Structures_Algorithms_In_Python | [
312,
131,
312,
1,
1474914708
] |
def assertTrue(self, expr, msg=None):
self.failUnless(expr,msg=msg) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def setUp(self):
if verbose:
dbutils._deadlock_VerboseFile = sys.stdout | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def tearDown(self):
self.d.close()
self.env.close()
test_support.rmtree(self.homeDir) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def setEnvOpts(self):
pass | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def makeData(self, key):
return DASH.join([key] * 5) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test01_1WriterMultiReaders(self):
if verbose:
print '\n', '-=' * 30
print "Running %s.test01_1WriterMultiReaders..." % \
self.__class__.__name__ | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def writerThread(self, d, keys, readers):
import sys
if sys.version_info[0] < 3 :
name = currentThread().getName()
else :
name = currentThread().name | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def readerThread(self, d, readerNum):
import sys
if sys.version_info[0] < 3 :
name = currentThread().getName()
else :
name = currentThread().name | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def setEnvOpts(self):
self.env.set_lk_detect(db.DB_LOCK_DEFAULT) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test02_SimpleLocks(self):
if verbose:
print '\n', '-=' * 30
print "Running %s.test02_SimpleLocks..." % self.__class__.__name__ | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def writerThread(self, d, keys, readers):
import sys
if sys.version_info[0] < 3 :
name = currentThread().getName()
else :
name = currentThread().name
if verbose:
print "%s: creating records %d - %d" % (name, start, stop) | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def readerThread(self, d, readerNum):
import sys
if sys.version_info[0] < 3 :
name = currentThread().getName()
else :
name = currentThread().name | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def setEnvOpts(self):
#self.env.set_lk_detect(db.DB_LOCK_DEFAULT)
pass | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test03_ThreadedTransactions(self):
if verbose:
print '\n', '-=' * 30
print "Running %s.test03_ThreadedTransactions..." % \
self.__class__.__name__ | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def writerThread(self, d, keys, readers):
import sys
if sys.version_info[0] < 3 :
name = currentThread().getName()
else :
name = currentThread().name | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def readerThread(self, d, readerNum):
import sys
if sys.version_info[0] < 3 :
name = currentThread().getName()
else :
name = currentThread().name | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def deadlockThread(self):
self.doLockDetect = True
while self.doLockDetect:
time.sleep(0.05)
try:
aborted = self.env.lock_detect(
db.DB_LOCK_RANDOM, db.DB_LOCK_CONFLICT)
if verbose and aborted:
print ... | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def test_suite():
suite = unittest.TestSuite() | babyliynfg/cross | [
75,
39,
75,
4,
1489383147
] |
def getlines():
try:
f = open(os.path.join(os.path.dirname(cffi.__file__),
'..', 'c', 'commontypes.c'))
except IOError:
py.test.skip("cannot find ../c/commontypes.c")
lines = [line for line in f.readlines() if line.strip().startswith('EQ(')]
f.close()
re... | johncsnyder/SwiftKitten | [
142,
18,
142,
10,
1458321581
] |
def test_dependencies():
r = re.compile(r'EQ[(]"([^"]+)",(?:\s*"([A-Z0-9_]+)\s*[*]*"[)])?')
lines = getlines()
d = {}
for line in lines:
match = r.search(line)
if match is not None:
d[match.group(1)] = match.group(2)
for value in d.values():
if value:
... | johncsnyder/SwiftKitten | [
142,
18,
142,
10,
1458321581
] |
def format_msg(message, headline):
msg = "Line {0}:\n {1}\n{2}:\n{3}"\
.format(PARAMS["lineno"], PARAMS["source"], headline, message)
return msg | sjdv1982/seamless | [
19,
6,
19,
76,
1465852536
] |
def jaccard_similariy(setA, setB, alternativeUnion=False):
"""
Finds the jaccard similarity between two sets.
Essentially, its intersection over union.
The alternative way to calculate this is to take union as sum of the
number of items in the two sets. This will lead to jaccard similarity
of a... | TheAlgorithms/Python | [
154959,
39275,
154959,
147,
1468662241
] |
def test_set(self):
sieve = '''
require "variables";
set "honorific" "Mr";
'''
self.assertFalse(checksieve.parse_string(sieve, False)) | dburkart/check-sieve | [
24,
4,
24,
6,
1434172648
] |
def test_wrong_tag(self):
sieve = '''
require "variables";
set :mime "b" "c";
'''
self.assertTrue(checksieve.parse_string(sieve, True)) | dburkart/check-sieve | [
24,
4,
24,
6,
1434172648
] |
def test_too_many_args(self):
sieve = '''
require "variables";
set "a" "b" "c" "d";
'''
self.assertTrue(checksieve.parse_string(sieve, True)) | dburkart/check-sieve | [
24,
4,
24,
6,
1434172648
] |
def test_numeral_varname(self):
sieve = '''
require "variables";
set "1" "${state} pending";
'''
self.assertFalse(checksieve.parse_string(sieve, False)) | dburkart/check-sieve | [
24,
4,
24,
6,
1434172648
] |
def test_suggest_filename(self):
"""
Testing some files. Not testing recursion in filenames. It is situation
if there exist file0, file1, file2 and input file is file
"""
filename = "mujsoubor"
# import ipdb; ipdb.set_trace() # BREAKPOINT
new_filename = misc.sugge... | mjirik/imtools | [
7,
1,
7,
1,
1445161284
] |
def test_getVersionString(self):
"""
getVersionString is not used anymore
"""
vfn = "../__VERSION__"
existed = False
if not os.path.exists(vfn):
with open(vfn, 'a') as the_file:
the_file.write('1.1.1\n')
existed = False
ve... | mjirik/imtools | [
7,
1,
7,
1,
1445161284
] |
def test_obj_to_and_from_file_pickle(self):
testdata = np.random.random([4, 4, 3])
test_object = {'a': 1, 'data': testdata}
filename = 'test_obj_to_and_from_file.pkl'
misc.obj_to_file(test_object, filename, 'pickle')
saved_object = misc.obj_from_file(filename, 'pickle')
... | mjirik/imtools | [
7,
1,
7,
1,
1445161284
] |
def test_obj_to_and_from_file_with_directories(self):
import shutil
testdata = np.random.random([4, 4, 3])
test_object = {'a': 1, 'data': testdata}
dirname = '__test_write_and_read'
filename = '__test_write_and_read/test_obj_to_and_from_file.pkl'
misc.obj_to_file(test_o... | mjirik/imtools | [
7,
1,
7,
1,
1445161284
] |
def simple_extract_stack(f=None, limit=None, skips=[]):
"""This is traceback.extract_stack from python 2.7 with this change:
- Comment the update of the cache.
- Skip internal stack trace level.
The update of the cache call os.stat to verify is the cache is up
to date. This take too much time on ... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def add_tag_trace(thing, user_line=None):
"""
Add tag.trace to an node or variable.
The argument is returned after being affected (inplace).
Parameters
----------
thing
The object where we add .tag.trace.
user_line
The max number of user line to keep.
Notes
-----
... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __hash__(self):
# this fixes silent-error-prone new-style class behavior
if hasattr(self, '__eq__') or hasattr(self, '__cmp__'):
raise TypeError("unhashable object: %s" % self)
return id(self) | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def clear(self):
self.__dict__.clear() | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __str__(self):
return "scratchpad" + str(self.__dict__) | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def info(self):
print("<theano.gof.utils.scratchpad instance at %i>" % id(self))
for k, v in iteritems(self.__dict__):
print(" %s: %s" % (k, v)) | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __init__(self, **d):
self.__dict__.update(d) | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def rval(*args, **kwargs):
kwtup = tuple(kwargs.items())
key = (args, kwtup)
if key not in cache:
val = f(*args, **kwargs)
cache[key] = val
else:
val = cache[key]
return val | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def deprecated(filename, msg=''):
"""
Decorator which will print a warning message on the first call.
Use it like this::
@deprecated('myfile', 'do something different...')
def fn_name(...)
...
And it will print::
WARNING myfile.fn_name deprecated. do something different..... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def difference(seq1, seq2):
"""
Returns all elements in seq1 which are not in seq2: i.e ``seq1\seq2``.
"""
try:
# try to use O(const * len(seq1)) algo
if len(seq2) < 4: # I'm guessing this threshold -JB
raise Exception('not worth it')
set2 = set(seq2)
return... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def from_return_values(values):
if isinstance(values, (list, tuple)):
return values
else:
return [values] | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __init__(self, name, nonzero=True):
self.name = name
self.nonzero = nonzero | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __bool__(self):
# Python 3.x
return self.nonzero | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __repr__(self):
return "<%s>" % self.name | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def comm_guard(type1, type2):
def wrap(f):
old_f = f.__globals__[f.__name__]
def new_f(arg1, arg2, *rest):
if ((type1 is ANY_TYPE or isinstance(arg1, type1)) and
(type2 is ANY_TYPE or isinstance(arg2, type2))):
pass
elif ((type1 is ANY_TYP... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def wrap(f):
old_f = f.__globals__[f.__name__]
def new_f(arg1, *rest):
if (type1 is ANY_TYPE or isinstance(arg1, type1)):
variable = f(arg1, *rest)
if variable is FALL_THROUGH:
return old_f(arg1, *rest)
else:
... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def flatten(a):
"""
Recursively flatten tuple, list and set in a list.
"""
if isinstance(a, (tuple, list, set)):
l = []
for item in a:
l.extend(flatten(item))
return l
else:
return [a] | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def hist(coll):
counts = {}
for elem in coll:
counts[elem] = counts.get(elem, 0) + 1
return counts | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def bad_var(var):
return not var.name or h[var.name] > 1 | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def remove(predicate, coll):
"""
Return those items of collection for which predicate(item) is true.
Examples
--------
>>> def even(x):
... return x % 2 == 0
>>> remove(even, [1, 2, 3, 4])
[1, 3]
"""
return [x for x in coll if not predicate(x)] | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def hash_from_code(msg):
# hashlib.md5() requires an object that supports buffer interface,
# but Python 3 (unicode) strings don't.
if isinstance(msg, str):
msg = msg.encode()
# Python 3 does not like module names that start with
# a digit.
return 'm' + hashli... | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def hash_from_code(msg):
try:
return hashlib.md5(msg).hexdigest()
except TypeError:
assert isinstance(msg, numpy.ndarray)
return hashlib.md5(numpy.getbuffer(msg)).hexdigest() | rizar/attention-lvcsr | [
259,
103,
259,
11,
1443211188
] |
def __init__(self, client, config, serializer, deserializer) -> None:
self._client = client
self._serialize = serializer
self._deserialize = deserializer
self._config = config | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def prepare_request(next_link=None):
# Construct headers
header_parameters = {} # type: Dict[str, Any]
header_parameters['Accept'] = self._serialize.header("accept", accept, 'str')
if not next_link:
# Construct URL
url = self.list_by_vpn_... | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self, plotly_name="smoothing", parent_name="contourcarpet.line", **kwargs | plotly/plotly.py | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, fileDir):
self.fileDir = fileDir
self.console = sys.stdout | littlecodersh/EasierLife | [
181,
138,
181,
1,
1453081737
] |
def flush(self):
self.console.flush() | littlecodersh/EasierLife | [
181,
138,
181,
1,
1453081737
] |
def inPip(fileDir):
def _input(hint):
s = new_input(hint)
with open(fileDir, 'a') as f: f.write(s)
return s
return _input | littlecodersh/EasierLife | [
181,
138,
181,
1,
1453081737
] |
def problem_sinsin():
"""cosine example.
"""
def mesh_generator(n):
return UnitSquareMesh(n, n, "left/right")
x = sympy.DeferredVector("x")
# Choose the solution such that the boundary conditions are fulfilled
# exactly. Also, multiply with x**2 to make sure that the right-hand side
... | nschloe/maelstrom | [
28,
7,
28,
2,
1400013996
] |
def test_order(problem, stabilization):
"""Assert the correct discretization order.
"""
mesh_sizes = [16, 32, 64]
errors, hmax = _compute_errors(problem, mesh_sizes, stabilization)
# Compute the numerical order of convergence.
order = helpers.compute_numerical_order_of_convergence(hmax, errors)... | nschloe/maelstrom | [
28,
7,
28,
2,
1400013996
] |
def _show_order_info(problem, mesh_sizes, stabilization):
"""Performs consistency check for the given problem/method combination and
show some information about it. Useful for debugging.
"""
errors, hmax = _compute_errors(problem, mesh_sizes, stabilization)
order = helpers.compute_numerical_order_of... | nschloe/maelstrom | [
28,
7,
28,
2,
1400013996
] |
def __init__(self, links=None, delimiter=' | ', **kwargs):
super(ActionsColumn, self).__init__(**kwargs)
self.orderable = False
self.delimiter = delimiter
if links is not None:
self.links = links | naphthalene/hubcave | [
6,
3,
6,
3,
1412887181
] |
def __init__(self, *args, **kwargs):
super(PaginateTable, self).__init__(*args, **kwargs)
self.template = kwargs.get('template', 'fancy_paged_tables/table.html') | naphthalene/hubcave | [
6,
3,
6,
3,
1412887181
] |
def tokenize(stream):
def is_delimiter(char):
return char.isspace() or char in "{}[]:,"
token = []
charcode = 0
completed = False
now_token = ""
def process_char(char, charcode):
nonlocal token, completed, now_token
advance = True
add_char = False
next_s... | danielyule/naya | [
59,
13,
59,
4,
1416428638
] |
def parse(file):
token_stream = tokenize(file)
val, token_type, token = __parse(token_stream, next(token_stream))
if token is not None:
raise ValueError("Improperly closed JSON object")
try:
next(token_stream)
except StopIteration:
return val
raise ValueError("Additional ... | danielyule/naya | [
59,
13,
59,
4,
1416428638
] |
def __parse(token_stream, first_token):
class KVP:
def __init__(self, key):
self.key = key
self.value = None
self.set = False
def __str__(self):
if self.set:
return "{}: {}".format(self.key, self.value)
else:
... | danielyule/naya | [
59,
13,
59,
4,
1416428638
] |
def process_token(token_type, token):
if token_type == TOKEN_TYPE.OPERATOR:
if token == ']':
return None, None, None
elif token == ",":
token_type, token = next(token_stream)
if token_type == TOKEN_TYPE.OPERATOR:
if toke... | danielyule/naya | [
59,
13,
59,
4,
1416428638
] |
def run(ds):
pw.plot(data, clear=True)
for m, c in zip(methods, colors):
d1 = data.copy()
t = time.clock()
d2 = NiDAQ.downsample(d1, ds, method=m)
print("Method %d: %f" % (m, time.clock()-t))
p = pw.plot(y=d2, x=np.linspace(0, len(d2)*ds, len(d2)), pen=mkPen(c))
p... | acq4/acq4 | [
51,
39,
51,
31,
1385049034
] |
def showDownsample(**kwargs):
d1 = data.copy()
d2 = NiDAQ.downsample(d1, **kwargs)
xv2 = xVals[::kwargs['ds']][:len(d2)]
pw.plot(y=d1, x=xVals, clear=True)
pw.plot(y=d2[:len(xv2)], x=xv2, pen=mkPen((255, 0, 0))) | acq4/acq4 | [
51,
39,
51,
31,
1385049034
] |
def showTransfer(**kwargs):
xVals = np.linspace(0, dur, sr*dur)
#data = sin(xVals* linspace(0, sampr*2, sampr*dur))
data = np.random.normal(size=sr*dur) | acq4/acq4 | [
51,
39,
51,
31,
1385049034
] |
def test_repeatable_zero_or_more():
"""
Tests zero or more repeatable operator.
"""
grammar = """
S: "2" b* "3";
terminals
b: "1";
"""
g = Grammar.from_string(grammar)
assert g.get_nonterminal('b_0')
assert g.get_nonterminal('b_1')
p = Parser(g)
input_str = '2 1 ... | igordejanovic/parglare | [
118,
29,
118,
49,
1481999547
] |
def test_repeatable_one_or_more():
"""
Tests one or more repeatable operator.
"""
grammar = """
S: "2" b+ "3";
terminals
b: "1";
"""
g = Grammar.from_string(grammar)
assert g.get_nonterminal('b_1')
p = Parser(g)
input_str = '2 1 1 1 3'
result = p.parse(input_str)... | igordejanovic/parglare | [
118,
29,
118,
49,
1481999547
] |
def test_optional():
"""
Tests optional operator.
"""
grammar = """
S: "2" b? "3"?;
terminals
b: "1";
"""
g = Grammar.from_string(grammar)
assert g.get_nonterminal('b_opt')
p = Parser(g)
input_str = '2 1 3'
result = p.parse(input_str)
assert result == ["2", "... | igordejanovic/parglare | [
118,
29,
118,
49,
1481999547
] |
def test_multiple_repetition_operators():
"""
Test using of multiple repetition operators.
"""
grammar = """
S: "2" b*[comma] c+ "3"?;
terminals
b: "b";
c: "c";
comma: ",";
"""
g = Grammar.from_string(grammar)
assert g.get_nonterminal('b_0_comma')
assert g.get_nonte... | igordejanovic/parglare | [
118,
29,
118,
49,
1481999547
] |
def test_live_customer(self):
# Create customers
result = Customer.create()
Customer.create(FULL_CUSTOMER)
Customer.create(CUSTOMER_WITH_CARD)
# Read customer information. This returns the payment profile IDs
# address IDs for the user
customer_id = result.custom... | vcatalano/py-authorize | [
41,
38,
41,
8,
1366675320
] |
def __init__(self, default_factory=None, *a, **kw):
if (default_factory is not None and
not hasattr(default_factory, '__call__')):
raise TypeError('first argument must be callable')
dict.__init__(self, *a, **kw)
self.default_factory = default_factory | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def __missing__(self, key):
if self.default_factory is None:
raise KeyError(key)
self[key] = value = self.default_factory()
return value | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def copy(self):
return self.__copy__() | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def __deepcopy__(self, memo):
import copy
return type(self)(self.default_factory,
copy.deepcopy(self.items())) | ActiveState/code | [
1884,
686,
1884,
41,
1500923597
] |
def __init__(self, feat_extractor,num_classes=None):
super(Classifier,self).__init__()
self.feat_extractor = feat_extractor
self.class_fc = nn.Linear(feat_extractor.fc.in_features, num_classes) | sankit1/cv-tricks.com | [
463,
598,
463,
10,
1487404894
] |
def orchestrate_services(self):
return Mock() | sigopt/sigopt-python | [
66,
20,
66,
4,
1418876174
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.