function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def _makeOne(self):
path = "/" + uuid.uuid4().hex
return self.client.Queue(path) | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def test_empty_queue(self):
queue = self._makeOne()
assert len(queue) == 0
assert queue.get() is None
assert len(queue) == 0 | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def test_priority(self):
queue = self._makeOne()
queue.put(b"four", priority=101)
queue.put(b"one", priority=0)
queue.put(b"two", priority=0)
queue.put(b"three", priority=10)
assert queue.get() == b"one"
assert queue.get() == b"two"
assert queue.get() == ... | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def setUp(self):
KazooTestCase.setUp(self)
skip = False
if CI_ZK_VERSION and CI_ZK_VERSION < (3, 4):
skip = True
elif CI_ZK_VERSION and CI_ZK_VERSION >= (3, 4):
skip = False
else:
ver = self.client.server_version()
if ver[1] < 4:
... | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def test_queue_validation(self):
queue = self._makeOne()
with pytest.raises(TypeError):
queue.put({})
with pytest.raises(TypeError):
queue.put(b"one", b"100")
with pytest.raises(TypeError):
queue.put(b"one", 10.0)
with pytest.raises(ValueError)... | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def test_queue(self):
queue = self._makeOne()
queue.put(b"one")
queue.put_all([b"two", b"three"])
assert len(queue) == 3
assert not queue.consume()
assert not queue.holds_lock()
assert queue.get(1) == b"one"
assert queue.holds_lock()
# Without con... | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def test_release(self):
queue = self._makeOne()
queue.put(b"one")
assert queue.get(1) == b"one"
assert queue.holds_lock()
assert queue.release()
assert not queue.holds_lock()
assert queue.get(1) == b"one"
assert queue.consume()
assert not queue.re... | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def test_priority(self):
queue = self._makeOne()
queue.put(b"four", priority=101)
queue.put(b"one", priority=0)
queue.put(b"two", priority=0)
queue.put(b"three", priority=10)
assert queue.get(1) == b"one"
assert queue.consume()
assert queue.get(1) == b"tw... | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def get_concurrently(value, event):
q = self.client.LockingQueue(queue.path)
value.append(q.get(0.1))
event.set() | python-zk/kazoo | [
1240,
379,
1240,
117,
1337816802
] |
def __init__(self, error):
super().__init__(error['message'])
self.status = error['status']
self.code = error['code'] | QISKit/qiskit-sdk-py | [
3515,
1875,
3515,
1061,
1488560562
] |
def buildTree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
def helper(inorderL, inorderR):
# base case
if inorderL >= inorderR:
return None
nonlocal postorder
curr = postorder.pop()
root = TreeNode(curr)
curr... | saisankargochhayat/algo_quest | [
2,
1,
2,
1,
1473454289
] |
def __init__(self, max_age=None, success=None, job_id=None,
sequential_mode=None, previous_job_id=None, component=None):
"""Params - a model defined in Swagger
:param dict swaggerTypes: The key is attribute name
and the value is attribute type.
... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def max_age(self):
"""Gets the max_age of this Params.
Maximum age (in hours) for the repo to be considered.
Any repo tested or being tested after \"now - max_age\" will be taken
into account. If set to 0, all repos will be considered.
:return: The max_age of this Params.
... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def max_age(self, max_age):
"""Sets the max_age of this Params.
Maximum age (in hours) for the repo to be considered.
Any repo tested or being tested after \"now - max_age\" will be taken
into account. If set to 0, all repos will be considered.
:param max_age: The max_age of th... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def success(self):
"""Gets the success of this Params.
If set to a value, find repos with a successful/unsuccessful vote
(as specified). If not set, any tested repo will be considered.
:return: The success of this Params.
:rtype: bool
"""
return self._success | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def success(self, success):
"""Sets the success of this Params.
If set to a value, find repos with a successful/unsuccessful vote
(as specified). If not set, any tested repo will be considered.
:param success: The success of this Params.
:type: bool
"""
self._s... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def job_id(self):
"""Gets the job_id of this Params.
Name of the CI that sent the vote. If not set, no filter will be set
on CI.
:return: The job_id of this Params.
:rtype: str
"""
return self._job_id | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def job_id(self, job_id):
"""Sets the job_id of this Params.
Name of the CI that sent the vote. If not set, no filter will be set
on CI.
:param job_id: The job_id of this Params.
:type: str
"""
self._job_id = job_id | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def sequential_mode(self):
"""Gets the sequential_mode of this Params.
Use the sequential mode algorithm. In this case, return the last tested
repo within that timeframe for the CI job described by previous_job_id.
Defaults to false.
:return: The sequential_mode of this Params.... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def sequential_mode(self, sequential_mode):
"""Sets the sequential_mode of this Params.
Use the sequential mode algorithm. In this case, return the last tested
repo within that timeframe for the CI job described by previous_job_id.
Defaults to false.
:param sequential_mode: The... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def previous_job_id(self):
"""Gets the previous_job_id of this Params.
If sequential_mode is set to true, look for jobs tested by the CI
identified by previous_job_id.
:return: The previous_job_id of this Params.
:rtype: str
"""
return self._previous_job_id | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def previous_job_id(self, previous_job_id):
"""Sets the previous_job_id of this Params.
If sequential_mode is set to true, look for jobs tested by the CI
identified by previous_job_id.
:param previous_job_id: The previous_job_id of this Params.
:type: str
"""
s... | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def component(self):
"""Gets the component of this Params.
additional notes
:return: The component of this Params.
:rtype: str
"""
return self._component | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def component(self, component):
"""Sets the component of this Params.
additional notes
:param component: The component of this Params.
:type: str
"""
self._component = component | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def to_str(self):
"""Returns the string representation of the model """
return pformat(self.to_dict()) | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def __eq__(self, other):
"""Returns true if both objects are equal """
if not isinstance(other, Params):
return False
return self.__dict__ == other.__dict__ | javierpena/dlrnapi_client | [
1,
3,
1,
3,
1488890089
] |
def get_user_status(self, user: Optional['User'] = None) -> 'TermsOfServiceUserStatus':
"""
Get the terms of service user status.
:param user:
This is the user to get the status of the terms of service for. This defaults to current
user.
:returns:
A :... | box/box-python-sdk | [
375,
216,
375,
21,
1423182655
] |
def reject(self, user: Optional['User'] = None) -> 'TermsOfServiceUserStatus':
"""
Reject a terms of service.
:param user:
The :class:`User` to assign the terms of service to.
:returns:
A newly created :class:`TermsOfServiceUserStatus` object
"""
... | box/box-python-sdk | [
375,
216,
375,
21,
1423182655
] |
def usage():
return """
Usage: python runtests.py [UnitTestClass].[method]
You can pass the Class name of the `UnitTestClass` you want to test.
Append a method name if you only want to test a specific method of that class.
""" | alanjds/drf-nested-routers | [
1458,
147,
1458,
48,
1380573232
] |
def main(_):
if FLAGS.eager:
tf.config.experimental_run_functions_eagerly(FLAGS.eager)
tf.random.set_seed(FLAGS.seed)
np.random.seed(FLAGS.seed)
random.seed(FLAGS.seed)
action_repeat = FLAGS.action_repeat
_, _, domain_name, _ = FLAGS.env_name.split('-')
if domain_name in ['cartpole']:
FLAGS.set... | google-research/google-research | [
27788,
6881,
27788,
944,
1538678568
] |
def __init__(self, sc, estimator, param_distributions, n_iter=10, scoring=None,
fit_params=None, n_jobs=1, iid=True, refit=True, cv=None,
verbose=0, pre_dispatch='2*n_jobs', random_state=None,
error_score='raise'):
self.param_distributions = param_distribution... | databricks/spark-sklearn | [
1075,
234,
1075,
15,
1441219491
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __add__(self, other): return self.value + other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __mul__(self, other): return self.value * other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __floordiv__(self, other): return self.value // other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __divmod__(self, other): return divmod(self.value, other) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __lshift__(self, other): return self.value << other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __and__(self, other): return self.value & other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __or__(self, other): return self.value | other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __radd__(self, other): return other + self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rmul__(self, other):
print("\toldstyle_reflect.__rmul__")
return other * self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rfloordiv__(self, other): return other // self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rdivmod__(self, other): return divmod(other, self.value) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rlshift__(self, other): return other << self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rand__(self, other): return self.value & other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ror__(self, other): return self.value | other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __iadd__(self, other): return self.value + other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __imul__(self, other): return self.value * other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ifloordiv__(self, other): return self.value // other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __idivmod__(self, other): return divmod(self.value, other) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ilshift__(self, other): return self.value << other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __iand__(self, other): return self.value & other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ior__(self, other): return self.value | other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __add__(self, other): return self.value + other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __mul__(self, other): return self.value * other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __floordiv__(self, other): return self.value // other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __divmod__(self, other): return divmod(self.value, other) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __lshift__(self, other): return self.value << other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __and__(self, other): return self.value & other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __or__(self, other): return self.value | other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __radd__(self, other): return other + self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rmul__(self, other):
print("\tnewstyle_reflect.__rmul__")
return other * self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rfloordiv__(self, other): return other // self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rdivmod__(self, other): return divmod(other, self.value) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rlshift__(self, other): return other << self.value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __rand__(self, other): return self.value & other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ror__(self, other): return self.value | other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __iadd__(self, other): return self.value + other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __imul__(self, other): return self.value * other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ifloordiv__(self, other): return self.value // other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __idivmod__(self, other): return divmod(self.value, other) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ilshift__(self, other): return self.value << other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __iand__(self, other): return self.value & other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __ior__(self, other): return self.value | other | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self, value): self.value = value | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def normal(self, leftc, rightc):
for a in leftc:
for b in rightc:
try:
printwith("case", a, "+", b, type(a), type(b))
printwithtype(a + b)
except:
printwith("same", sys.exc_info()[0])
try:
... | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def clone_list(self, l):
l2 = []
for x in l:
if x is newstyle_inplace:
l2.append(newstyle_inplace(x.value))
elif x is oldstyle_inplace:
l2.append(oldstyle_inplace(x.value))
else :
l2.append(x)
return l2 | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def __init__(self):
self.collection = testdata.merge_lists(
[None],
testdata.list_bool,
testdata.list_int,
testdata.list_float,
testdata.list_long[:-1], # the last number is very long
testdata.list_complex,
... | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_normal_oc_left(self): super(ops_simple, self).normal(self.collection_oldstyle, self.collection) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_normal_nc_left(self): super(ops_simple, self).normal(self.collection_newstyle, self.collection) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_reflect_oc_right(self): super(ops_simple, self).normal(self.collection, self.collection_oldstyle_reflect) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_oc_notdefined(self): super(ops_simple, self).normal(self.collection_oldstyle_notdefined, self.collection) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_oc_notdefined_oc_reflect(self): super(ops_simple, self).normal(self.collection_oldstyle_notdefined, self.collection_oldstyle_reflect) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_inplace(self): super(ops_simple, self).inplace(self.collection, self.collection) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def test_inplace_nl(self): super(ops_simple, self).inplace(self.collection_newstyle_inplace, self.collection) | IronLanguages/ironpython3 | [
2070,
249,
2070,
270,
1393537849
] |
def forwards_func(apps, schema_editor):
Language = apps.get_model("lexicon", "Language")
languages = Language.objects.filter(
id__in=set(idDistributionMap.keys())).all()
for language in languages:
for k, v in idDistributionMap[language.id].items():
setattr(language, k, v)
... | lingdb/CoBL-public | [
3,
3,
3,
1,
1483699154
] |
def Solver(mats):
"""Return appropriate solver for `mats`
Parameters
----------
mats : SparseMatrix or list of SparseMatrices
Returns
-------
Matrix solver (:class:`.SparseMatrixSolver`)
Note
----
The list of matrices may include boundary matrices. The returned solver
will... | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def __init__(self, mat):
assert isinstance(mat, (SparseMatrix, list))
self.bc_mats = []
if isinstance(mat, list):
bc_mats = extract_bc_matrices([mat])
mat = sum(mat[1:], mat[0])
self.bc_mats = bc_mats
self.mat = mat
self._lu = None
self... | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def apply_constraints(self, b, constraints, axis=0):
"""Apply constraints to matrix `self.mat` and rhs vector `b`
Parameters
----------
b : array
constraints : tuple of 2-tuples
The 2-tuples represent (row, val)
The constraint indents the matrix row and s... | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def solve(self, b, u, axis, lu):
"""Solve Au=b
Solve along axis if b and u are multidimensional arrays.
Parameters
----------
b, u : arrays of rhs and output
Both can be multidimensional
axis : int
The axis we are solving over
lu : LU-dec... | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def inner_solve(u, lu):
"""Solve Au=b for one-dimensional u
On entry u is the rhs b, on exit it contains the solution.
Parameters
----------
u : array 1D
rhs on entry and solution on exit
lu : LU-decomposition
Can be either a 2-tuple with (output... | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def __init__(self, mat):
SparseMatrixSolver.__init__(self, mat)
self._lu = self.mat.diags('dia') | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def LU(data):
"""LU-decomposition using either Cython or Numba
Parameters
----------
data : 2D-array
Storage for dia-matrix on entry and L and U matrices
on exit.
"""
raise NotImplementedError | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
def Solve(u, data, axis=0):
"""Fast solve using either Cython or Numba
Parameters
----------
u : array
rhs on entry, solution on exit
data : 2D-array
Storage for dia-matrix containing L and U matrices
axis : int, optional
The axis we a... | spectralDNS/shenfun | [
148,
38,
148,
24,
1485264542
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.