uid
stringlengths
24
24
split
stringclasses
1 value
category
stringclasses
2 values
content
stringlengths
5
482k
signature
stringlengths
1
14k
suffix
stringlengths
1
482k
prefix
stringlengths
9
14k
prefix_token_count
int64
3
5.01k
prefix_token_budget
int64
64
256
element_token_count
int64
1
292k
signature_token_count
int64
1
5.01k
prefix_context_token_count
int64
0
255
repo
stringlengths
7
112
path
stringlengths
4
208
language
stringclasses
1 value
name
stringlengths
1
218
qualname
stringlengths
1
218
start_line
int64
1
26.7k
end_line
int64
1
26.7k
signature_start_line
int64
1
26.7k
signature_end_line
int64
1
26.7k
source_hash
stringlengths
40
40
source_dataset
stringclasses
1 value
source_split
stringclasses
1 value
013dfb558603d44b8e54e5c9
train
class
class LineType(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ """ allowed enum values """ ENTRY = "entry" EXIT = "exit" BOTH = "both" NONE = "none" """ Attributes: swagger_types (dict): The...
class LineType(object):
"""NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually. """ """ allowed enum values """ ENTRY = "entry" EXIT = "exit" BOTH = "both" NONE = "none" """ Attributes: swagger_types (dict): The key is attribute name ...
# coding: utf-8 """ Engine api Engine APIs # noqa: E501 OpenAPI spec version: 1.0.6 Generated by: https://github.com/swagger-api/swagger-codegen.git """ import pprint import re # noqa: F401 import six class LineType(object):
71
142
474
5
65
vtpl1/videonetics_api
vtpl_api/models/line_type.py
Python
LineType
LineType
18
92
18
18
92b48aa2eb6571f3d473b5655d821a9a34ceb948
bigcode/the-stack
train
bff1cfb794e3c301cbed1224
train
class
class MovingAverage(Registrable): """ Tracks a moving average of model parameters. """ default_implementation = "exponential" def __init__(self, parameters: Iterable[NamedParameter]) -> None: self._parameters = list(parameters) self._shadows = {name: parameter.data.clone() for name...
class MovingAverage(Registrable):
""" Tracks a moving average of model parameters. """ default_implementation = "exponential" def __init__(self, parameters: Iterable[NamedParameter]) -> None: self._parameters = list(parameters) self._shadows = {name: parameter.data.clone() for name, parameter in self._parameters} ...
from typing import Iterable, Tuple, Optional, Any, Dict import torch from allennlp.common.registrable import Registrable NamedParameter = Tuple[str, torch.Tensor] class MovingAverage(Registrable):
44
101
339
7
37
MSLars/allennlp
allennlp/training/moving_average.py
Python
MovingAverage
MovingAverage
10
50
10
10
fc41f14a9c1097eee15b87281ed2edfcd334dc5e
bigcode/the-stack
train
17b023fc4f3fc72e4ad9037c
train
class
@MovingAverage.register("exponential") class ExponentialMovingAverage(MovingAverage): """ Create shadow variables and maintain exponential moving average for model parameters. Registered as a `MovingAverage` with name "exponential". # Parameters parameters : `Iterable[Tuple[str, Parameter]]`, req...
@MovingAverage.register("exponential") class ExponentialMovingAverage(MovingAverage):
""" Create shadow variables and maintain exponential moving average for model parameters. Registered as a `MovingAverage` with name "exponential". # Parameters parameters : `Iterable[Tuple[str, Parameter]]`, required The parameters whose averages we'll be tracking. In a typical AllenNLP c...
adows[name]) def restore(self) -> None: """ Restore the backed-up (non-average) parameter values. """ for name, parameter in self._parameters: parameter.data.copy_(self._backups[name]) def state_dict(self) -> Dict[str, Any]: return {"parameters": self._param...
156
157
525
17
139
MSLars/allennlp
allennlp/training/moving_average.py
Python
ExponentialMovingAverage
ExponentialMovingAverage
53
108
53
54
7486c886bfb783f7070614250f19a484e8dce433
bigcode/the-stack
train
9278e11a1fbec30609379334
train
class
class MathBinaryNet2(Cell): def __init__(self): super(MathBinaryNet2, self).__init__() self.less_equal = P.LessEqual() self.greater = P.Greater() self.logic_or = P.LogicalOr() self.logic_and = P.LogicalAnd() self.number = 3 self.flag = True def construct(...
class MathBinaryNet2(Cell):
def __init__(self): super(MathBinaryNet2, self).__init__() self.less_equal = P.LessEqual() self.greater = P.Greater() self.logic_or = P.LogicalOr() self.logic_and = P.LogicalAnd() self.number = 3 self.flag = True def construct(self, x): ret_less_e...
.TensorAdd() self.mul = P.Mul() self.max = P.Maximum() self.number = 3 def construct(self, x): return self.add(x, self.number) + self.mul(x, self.number) + self.max(x, self.number) class MathBinaryNet2(Cell):
64
64
135
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
MathBinaryNet2
MathBinaryNet2
193
206
193
193
5bd3f0063d39ed07234ef9bba6339eb7f1b7a82b
bigcode/the-stack
train
896853317306b1360f06001e
train
class
class ConfusionMatrixNet(Cell): def __init__(self): super(ConfusionMatrixNet, self).__init__() self.confusion_matrix = P.ConfusionMatrix(4, "int32") def construct(self, x, y): return self.confusion_matrix(x, y)
class ConfusionMatrixNet(Cell):
def __init__(self): super(ConfusionMatrixNet, self).__init__() self.confusion_matrix = P.ConfusionMatrix(4, "int32") def construct(self, x, y): return self.confusion_matrix(x, y)
= [2, 2] paddings = [[0, 0], [0, 0]] self.space_to_batch_nd = P.SpaceToBatchND(block_shape, paddings) def construct(self, x): return self.space_to_batch_nd(x) class ConfusionMatrixNet(Cell):
64
64
63
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
ConfusionMatrixNet
ConfusionMatrixNet
289
295
289
289
199b954b61fb83f7b6bafd6163fa1d31322e953b
bigcode/the-stack
train
6250f7ad5fb51c88964a30e9
train
class
class PackNet(Cell): def __init__(self): super(PackNet, self).__init__() self.pack = P.Pack() def construct(self, x): return self.pack((x, x))
class PackNet(Cell):
def __init__(self): super(PackNet, self).__init__() self.pack = P.Pack() def construct(self, x): return self.pack((x, x))
, self).__init__() block_size = 2 paddings = [[0, 0], [0, 0]] self.space_to_batch = P.SpaceToBatch(block_size, paddings) def construct(self, x): return self.space_to_batch(x) class PackNet(Cell):
64
64
46
5
59
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
PackNet
PackNet
231
237
231
231
6883e42b59fe062976fef564cbb754c6b67b303f
bigcode/the-stack
train
0c3276383eb359f4aff7a87b
train
class
class CustNet2(Cell): def __init__(self): super(CustNet2, self).__init__() self.op = CustomOP2() self.t1 = Tensor(np.ones([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.int1 = 3 def construct(self): return self.op(self.t1, self....
class CustNet2(Cell):
def __init__(self): super(CustNet2, self).__init__() self.op = CustomOP2() self.t1 = Tensor(np.ones([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.int1 = 3 def construct(self): return self.op(self.t1, self.t2, self.int1)
= 5.1 def construct(self): x = self.op(self.t1, self.t1, self.int1, self.float1, self.int1, self.float1, self.t2, self.t1, self.int1) return x class CustNet2(Cell):
64
64
101
6
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
CustNet2
CustNet2
157
166
157
157
12d3b708df61c3fb0c7c71221e222982e9bcde8c
bigcode/the-stack
train
119354f1bdc48d83fad3c5a9
train
function
def test_invert_permutation(): invert_permutation = P.InvertPermutation() x = (3, 4, 0, 2, 1) output = invert_permutation(x) expect = (2, 4, 3, 0, 1) assert np.all(output == expect)
def test_invert_permutation():
invert_permutation = P.InvertPermutation() x = (3, 4, 0, 2, 1) output = invert_permutation(x) expect = (2, 4, 3, 0, 1) assert np.all(output == expect)
numpy() == expect) def test_squeeze(): input_tensor = Tensor(np.ones(shape=[3, 2, 1])) squeeze = P.Squeeze(2) output = squeeze(input_tensor) assert output.asnumpy().shape == (3, 2) def test_invert_permutation():
64
64
69
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_invert_permutation
test_invert_permutation
82
87
82
82
ee5e58e7d219ac69508d024edfc97f7e192f4665
bigcode/the-stack
train
a098d160d1d9f5c59133d622
train
class
class CustNet1(Cell): def __init__(self): super(CustNet1, self).__init__() self.op = CustomOP() self.t1 = Tensor(np.ones([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.int1 = 3 self.float1 = 5.1 def construct(self): x = ...
class CustNet1(Cell):
def __init__(self): super(CustNet1, self).__init__() self.op = CustomOP() self.t1 = Tensor(np.ones([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.int1 = 3 self.float1 = 5.1 def construct(self): x = self.op(self.t1, self....
IND_POSITIONAL_KEYWORD, sig_kind.KIND_EMPTY_DEFAULT_VALUE, sig_dtype.T), ) @prim_attr_register def __init__(self): pass def __call__(self, p1, p2, p3): raise NotImplementedError class CustNet1(Cell):
64
64
141
6
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
CustNet1
CustNet1
141
154
141
141
e698a846337b61f6ad13f1b18cf7ec71acd824a8
bigcode/the-stack
train
a469cb9bb033cb2d95c32d2d
train
class
class CustNet3(Cell): def __init__(self): super(CustNet3, self).__init__() self.op = P.ReduceSum() self.t1 = Tensor(np.ones([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.t2 = 1 def construct(self): return self.op(self.t1, self....
class CustNet3(Cell):
def __init__(self): super(CustNet3, self).__init__() self.op = P.ReduceSum() self.t1 = Tensor(np.ones([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.t2 = 1 def construct(self): return self.op(self.t1, self.t2)
2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.int1 = 3 def construct(self): return self.op(self.t1, self.t2, self.int1) class CustNet3(Cell):
64
64
98
6
58
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
CustNet3
CustNet3
169
178
169
169
fb3a5461a4f5d8faa3d5115cd4b630bf68ba09c4
bigcode/the-stack
train
923d002ae09842824bf34088
train
function
@non_graph_engine @mindspore_test(pipeline_for_compile_forward_ge_graph_for_case_by_case_config) def test_exec(): context.set_context(mode=context.GRAPH_MODE) return test_exec_case
@non_graph_engine @mindspore_test(pipeline_for_compile_forward_ge_graph_for_case_by_case_config) def test_exec():
context.set_context(mode=context.GRAPH_MODE) return test_exec_case
y: x + y, test_case_lists) # use -k to select certain testcast # pytest tests/python/ops/test_ops.py::test_backward -k LayerNorm @non_graph_engine @mindspore_test(pipeline_for_compile_forward_ge_graph_for_case_by_case_config) def test_exec():
64
64
43
27
36
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_exec
test_exec
350
354
350
352
967a1444df9bc51782da3d5ef399be2dae76e8bb
bigcode/the-stack
train
ff94f1b2b7da222710e3a79e
train
class
class UnpackNet(Cell): def __init__(self): super(UnpackNet, self).__init__() self.unpack = P.Unpack() def construct(self, x): return self.unpack(x)
class UnpackNet(Cell):
def __init__(self): super(UnpackNet, self).__init__() self.unpack = P.Unpack() def construct(self, x): return self.unpack(x)
(self, x): return self.space_to_batch(x) class PackNet(Cell): def __init__(self): super(PackNet, self).__init__() self.pack = P.Pack() def construct(self, x): return self.pack((x, x)) class UnpackNet(Cell):
64
64
44
6
58
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
UnpackNet
UnpackNet
240
246
240
240
b4dc365ee519042ce959ed87672034593d824919
bigcode/the-stack
train
763d9a456a3dbc830cfd9ab8
train
function
def test_transpose(): input_tensor = Tensor(np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])) perm = (0, 2, 1) expect = np.array([[[1, 4], [2, 5], [3, 6]], [[7, 10], [8, 11], [9, 12]]]) transpose = P.Transpose() output = transpose(input_tensor, perm) assert np.all(output.asnumpy() ...
def test_transpose():
input_tensor = Tensor(np.array([[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]])) perm = (0, 2, 1) expect = np.array([[[1, 4], [2, 5], [3, 6]], [[7, 10], [8, 11], [9, 12]]]) transpose = P.Transpose() output = transpose(input_tensor, perm) assert np.all(output.asnumpy() == expect)
3.6], [0.4, 0.5, -3.2]])) shp = (3, 2) reshape = P.Reshape() output = reshape(input_tensor, shp) assert output.asnumpy().shape == (3, 2) def test_transpose():
64
64
132
5
59
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_transpose
test_transpose
65
72
65
65
b4be318910e2338a49210e3a66a5c947062b3cfd
bigcode/the-stack
train
00fc5464df5b63ffcc403584
train
class
class CustomOP2(PrimitiveWithInfer): __mindspore_signature__ = ( ('p1', sig_rw.RW_WRITE, sig_kind.KIND_POSITIONAL_KEYWORD, sig_kind.KIND_EMPTY_DEFAULT_VALUE, sig_dtype.T), ('p2', sig_rw.RW_READ, sig_kind.KIND_POSITIONAL_KEYWORD, sig_kind.KIND_EMPTY_DEFAULT_VALUE, sig_dtype.T), ('p3', sig_rw....
class CustomOP2(PrimitiveWithInfer):
__mindspore_signature__ = ( ('p1', sig_rw.RW_WRITE, sig_kind.KIND_POSITIONAL_KEYWORD, sig_kind.KIND_EMPTY_DEFAULT_VALUE, sig_dtype.T), ('p2', sig_rw.RW_READ, sig_kind.KIND_POSITIONAL_KEYWORD, sig_kind.KIND_EMPTY_DEFAULT_VALUE, sig_dtype.T), ('p3', sig_rw.RW_READ, sig_kind.KIND_POSITIONAL_KEY...
@prim_attr_register def __init__(self): pass def __call__(self, p1, p2, p3, p4, p5, p6, p7, p8, p9): raise NotImplementedError class CustomOP2(PrimitiveWithInfer):
64
64
154
9
54
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
CustomOP2
CustomOP2
126
138
126
126
0486617e8583cd7e72be1c919a71a5a0e9c8808c
bigcode/the-stack
train
20c0db6abb578cb24c333fa2
train
class
class MathBinaryNet1(Cell): def __init__(self): super(MathBinaryNet1, self).__init__() self.add = P.TensorAdd() self.mul = P.Mul() self.max = P.Maximum() self.number = 3 def construct(self, x): return self.add(x, self.number) + self.mul(x, self.number) + self.max...
class MathBinaryNet1(Cell):
def __init__(self): super(MathBinaryNet1, self).__init__() self.add = P.TensorAdd() self.mul = P.Mul() self.max = P.Maximum() self.number = 3 def construct(self, x): return self.add(x, self.number) + self.mul(x, self.number) + self.max(x, self.number)
([2, 2]), dtype=ms.int32) self.t2 = Tensor(np.ones([1, 5]), dtype=ms.float16) self.t2 = 1 def construct(self): return self.op(self.t1, self.t2) class MathBinaryNet1(Cell):
64
64
87
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
MathBinaryNet1
MathBinaryNet1
181
190
181
181
36a00181b9be663374ddc8629c14930a6afe2ae1
bigcode/the-stack
train
94d0d6045322415ed57fc09d
train
function
def test_expand_dims(): input_tensor = Tensor(np.array([[2, 2], [2, 2]])) expand_dims = P.ExpandDims() output = expand_dims(input_tensor, 0) assert output.asnumpy().shape == (1, 2, 2)
def test_expand_dims():
input_tensor = Tensor(np.array([[2, 2], [2, 2]])) expand_dims = P.ExpandDims() output = expand_dims(input_tensor, 0) assert output.asnumpy().shape == (1, 2, 2)
spore_test import mindspore_test from ....mindspore_test_framework.pipeline.forward.compile_forward \ import pipeline_for_compile_forward_ge_graph_for_case_by_case_config from ....mindspore_test_framework.pipeline.forward.verify_exception \ import pipeline_for_verify_exception_for_case_by_case_config def test_e...
64
64
62
5
58
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_expand_dims
test_expand_dims
39
43
39
39
fedaf42bced3e79fadaaeef527aeb7f7531d07d8
bigcode/the-stack
train
46d6a384c7ab16a55d0c8fb8
train
function
def test_squeeze(): input_tensor = Tensor(np.ones(shape=[3, 2, 1])) squeeze = P.Squeeze(2) output = squeeze(input_tensor) assert output.asnumpy().shape == (3, 2)
def test_squeeze():
input_tensor = Tensor(np.ones(shape=[3, 2, 1])) squeeze = P.Squeeze(2) output = squeeze(input_tensor) assert output.asnumpy().shape == (3, 2)
], [2, 5], [3, 6]], [[7, 10], [8, 11], [9, 12]]]) transpose = P.Transpose() output = transpose(input_tensor, perm) assert np.all(output.asnumpy() == expect) def test_squeeze():
64
64
52
5
59
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_squeeze
test_squeeze
75
79
75
75
67377f589541f6b4999708fbd551e0f92d9f994f
bigcode/the-stack
train
b058c73b638082e092bfe1f2
train
function
def test_argmin_invalid_output_type(): P.Argmin(-1, mstype.int64) P.Argmin(-1, mstype.int32) with pytest.raises(TypeError): P.Argmin(-1, mstype.float32) with pytest.raises(TypeError): P.Argmin(-1, mstype.float64) with pytest.raises(TypeError): P.Argmin(-1, mstype.uint8) w...
def test_argmin_invalid_output_type():
P.Argmin(-1, mstype.int64) P.Argmin(-1, mstype.int32) with pytest.raises(TypeError): P.Argmin(-1, mstype.float32) with pytest.raises(TypeError): P.Argmin(-1, mstype.float64) with pytest.raises(TypeError): P.Argmin(-1, mstype.uint8) with pytest.raises(TypeError): P...
9], [10, 11, 12]])) output = select(cond, x, y) expect = np.array([[1, 8, 9], [10, 5, 6]]) assert np.all(output.asnumpy() == expect) def test_argmin_invalid_output_type():
64
64
107
8
56
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_argmin_invalid_output_type
test_argmin_invalid_output_type
100
110
100
100
9510abc6cb2dcfd2ad5d463900e9973e46b4a49f
bigcode/the-stack
train
04ce5ae88c8781dba02b5356
train
function
@mindspore_test(pipeline_for_verify_exception_for_case_by_case_config) def test_check_exception(): return raise_set
@mindspore_test(pipeline_for_verify_exception_for_case_by_case_config) def test_check_exception():
return raise_set
': (lambda x: P.ReduceSum(keep_dims=1), {'exception': TypeError}), 'desc_inputs': [Tensor(np.ones(shape=[3, 1, 5]))]}), ] @mindspore_test(pipeline_for_verify_exception_for_case_by_case_config) def test_check_exception():
64
64
26
21
43
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_check_exception
test_check_exception
370
372
370
371
807dcd987900c466de308ee254d2402c8188d202
bigcode/the-stack
train
eb8814805269eae1bb283b96
train
class
class BatchToSpaceNDNet(Cell): def __init__(self): super(BatchToSpaceNDNet, self).__init__() block_shape = [2, 2] crops = [[0, 0], [0, 0]] self.batch_to_space_nd = P.BatchToSpaceND(block_shape, crops) def construct(self, x): return self.batch_to_space_nd(x)
class BatchToSpaceNDNet(Cell):
def __init__(self): super(BatchToSpaceNDNet, self).__init__() block_shape = [2, 2] crops = [[0, 0], [0, 0]] self.batch_to_space_nd = P.BatchToSpaceND(block_shape, crops) def construct(self, x): return self.batch_to_space_nd(x)
(Cell): def __init__(self): super(DepthToSpaceNet, self).__init__() block_size = 2 self.depth_to_space = P.DepthToSpace(block_size) def construct(self, x): return self.depth_to_space(x) class BatchToSpaceNDNet(Cell):
64
64
86
8
56
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
BatchToSpaceNDNet
BatchToSpaceNDNet
267
275
267
267
b2b9b66e9cf774fbf66d77f5876e59f3d6d637dd
bigcode/the-stack
train
2eba907d6ef3f22d295f3785
train
class
class CustomOP(PrimitiveWithInfer): __mindspore_signature__ = (sig_dtype.T, sig_dtype.T, sig_dtype.T1, sig_dtype.T1, sig_dtype.T2, sig_dtype.T2, sig_dtype.T2, sig_dtype.T3, sig_dtype.T4) @prim_attr_register def __init__(self): pass ...
class CustomOP(PrimitiveWithInfer):
__mindspore_signature__ = (sig_dtype.T, sig_dtype.T, sig_dtype.T1, sig_dtype.T1, sig_dtype.T2, sig_dtype.T2, sig_dtype.T2, sig_dtype.T3, sig_dtype.T4) @prim_attr_register def __init__(self): pass def __call__(self, p1, p2, p3, p4, p...
with pytest.raises(TypeError): P.Argmin(-1, mstype.float64) with pytest.raises(TypeError): P.Argmin(-1, mstype.uint8) with pytest.raises(TypeError): P.Argmin(-1, mstype.bool_) class CustomOP(PrimitiveWithInfer):
63
64
118
8
55
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
CustomOP
CustomOP
113
123
113
113
f98e65fe0d378d6f24628d680771bd61f77cae26
bigcode/the-stack
train
92d6cbb5692f00aeca0a5f4e
train
function
def test_select(): select = P.Select() cond = Tensor(np.array([[True, False, False], [False, True, True]])) x = Tensor(np.array([[1, 2, 3], [4, 5, 6]])) y = Tensor(np.array([[7, 8, 9], [10, 11, 12]])) output = select(cond, x, y) expect = np.array([[1, 8, 9], [10, 5, 6]]) assert np.all(output...
def test_select():
select = P.Select() cond = Tensor(np.array([[True, False, False], [False, True, True]])) x = Tensor(np.array([[1, 2, 3], [4, 5, 6]])) y = Tensor(np.array([[7, 8, 9], [10, 11, 12]])) output = select(cond, x, y) expect = np.array([[1, 8, 9], [10, 5, 6]]) assert np.all(output.asnumpy() == expec...
_permutation = P.InvertPermutation() x = (3, 4, 0, 2, 1) output = invert_permutation(x) expect = (2, 4, 3, 0, 1) assert np.all(output == expect) def test_select():
64
64
125
4
60
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_select
test_select
90
97
90
90
26e2d0ab8e523c198efbb13db092ab4e64644e25
bigcode/the-stack
train
850a4b7e804c8434e351add2
train
class
class BatchToSpaceNet(Cell): def __init__(self): super(BatchToSpaceNet, self).__init__() block_size = 2 crops = [[0, 0], [0, 0]] self.batch_to_space = P.BatchToSpace(block_size, crops) def construct(self, x): return self.batch_to_space(x)
class BatchToSpaceNet(Cell):
def __init__(self): super(BatchToSpaceNet, self).__init__() block_size = 2 crops = [[0, 0], [0, 0]] self.batch_to_space = P.BatchToSpace(block_size, crops) def construct(self, x): return self.batch_to_space(x)
def construct(self, x): ret_less_equal = self.logic_and(self.less_equal(x, self.number), self.flag) ret_greater = self.logic_or(self.greater(x, self.number), self.flag) return self.logic_or(ret_less_equal, ret_greater) class BatchToSpaceNet(Cell):
64
64
78
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
BatchToSpaceNet
BatchToSpaceNet
209
217
209
209
8a56090d2da73de4787c041c7245514024bfb3bf
bigcode/the-stack
train
6ab6dd12f3b4996d90add99b
train
class
class DepthToSpaceNet(Cell): def __init__(self): super(DepthToSpaceNet, self).__init__() block_size = 2 self.depth_to_space = P.DepthToSpace(block_size) def construct(self, x): return self.depth_to_space(x)
class DepthToSpaceNet(Cell):
def __init__(self): super(DepthToSpaceNet, self).__init__() block_size = 2 self.depth_to_space = P.DepthToSpace(block_size) def construct(self, x): return self.depth_to_space(x)
Net(Cell): def __init__(self): super(SpaceToDepthNet, self).__init__() block_size = 2 self.space_to_depth = P.SpaceToDepth(block_size) def construct(self, x): return self.space_to_depth(x) class DepthToSpaceNet(Cell):
64
64
61
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
DepthToSpaceNet
DepthToSpaceNet
257
264
257
257
45ce8d13d0468f03e0ef047da7806ae9ed356f18
bigcode/the-stack
train
ca3f2e3517336f51de3d05e4
train
class
class SpaceToBatchNet(Cell): def __init__(self): super(SpaceToBatchNet, self).__init__() block_size = 2 paddings = [[0, 0], [0, 0]] self.space_to_batch = P.SpaceToBatch(block_size, paddings) def construct(self, x): return self.space_to_batch(x)
class SpaceToBatchNet(Cell):
def __init__(self): super(SpaceToBatchNet, self).__init__() block_size = 2 paddings = [[0, 0], [0, 0]] self.space_to_batch = P.SpaceToBatch(block_size, paddings) def construct(self, x): return self.space_to_batch(x)
, self).__init__() block_size = 2 crops = [[0, 0], [0, 0]] self.batch_to_space = P.BatchToSpace(block_size, crops) def construct(self, x): return self.batch_to_space(x) class SpaceToBatchNet(Cell):
64
64
80
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
SpaceToBatchNet
SpaceToBatchNet
220
228
220
220
0abac559454c20db3d385bec9e374bc1659d6cac
bigcode/the-stack
train
15e5093002cfe3349e115e75
train
function
@non_graph_engine def test_reshape(): input_tensor = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]])) shp = (3, 2) reshape = P.Reshape() output = reshape(input_tensor, shp) assert output.asnumpy().shape == (3, 2)
@non_graph_engine def test_reshape():
input_tensor = Tensor(np.array([[-0.1, 0.3, 3.6], [0.4, 0.5, -3.2]])) shp = (3, 2) reshape = P.Reshape() output = reshape(input_tensor, shp) assert output.asnumpy().shape == (3, 2)
.float32) input_x = Tensor(input_np) td = ms.int32 cast = P.Cast() result = cast(input_x, td) expect = input_np.astype(np.int32) assert np.all(result.asnumpy() == expect) @non_graph_engine def test_reshape():
64
64
88
10
54
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_reshape
test_reshape
56
62
56
57
920511ca72acf73fd4b294f5339fade50dffbbd2
bigcode/the-stack
train
6ad42308c9b41b8c10e669b9
train
function
def test_cast(): input_np = np.random.randn(2, 3, 4, 5).astype(np.float32) input_x = Tensor(input_np) td = ms.int32 cast = P.Cast() result = cast(input_x, td) expect = input_np.astype(np.int32) assert np.all(result.asnumpy() == expect)
def test_cast():
input_np = np.random.randn(2, 3, 4, 5).astype(np.float32) input_x = Tensor(input_np) td = ms.int32 cast = P.Cast() result = cast(input_x, td) expect = input_np.astype(np.int32) assert np.all(result.asnumpy() == expect)
_expand_dims(): input_tensor = Tensor(np.array([[2, 2], [2, 2]])) expand_dims = P.ExpandDims() output = expand_dims(input_tensor, 0) assert output.asnumpy().shape == (1, 2, 2) def test_cast():
64
64
79
4
60
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
test_cast
test_cast
46
53
46
46
8e8f61ddb1251b8c9205c741b70c161f66a84881
bigcode/the-stack
train
b816b7c0ec8696422c3f78c2
train
class
class SpaceToBatchNDNet(Cell): def __init__(self): super(SpaceToBatchNDNet, self).__init__() block_shape = [2, 2] paddings = [[0, 0], [0, 0]] self.space_to_batch_nd = P.SpaceToBatchND(block_shape, paddings) def construct(self, x): return self.space_to_batch_nd(x)
class SpaceToBatchNDNet(Cell):
def __init__(self): super(SpaceToBatchNDNet, self).__init__() block_shape = [2, 2] paddings = [[0, 0], [0, 0]] self.space_to_batch_nd = P.SpaceToBatchND(block_shape, paddings) def construct(self, x): return self.space_to_batch_nd(x)
_shape = [2, 2] crops = [[0, 0], [0, 0]] self.batch_to_space_nd = P.BatchToSpaceND(block_shape, crops) def construct(self, x): return self.batch_to_space_nd(x) class SpaceToBatchNDNet(Cell):
64
64
88
8
56
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
SpaceToBatchNDNet
SpaceToBatchNDNet
278
286
278
278
b75b928becb793d65d1f19d715872b3c909d062c
bigcode/the-stack
train
a7e4bf6a61dc89655405df78
train
class
class SpaceToDepthNet(Cell): def __init__(self): super(SpaceToDepthNet, self).__init__() block_size = 2 self.space_to_depth = P.SpaceToDepth(block_size) def construct(self, x): return self.space_to_depth(x)
class SpaceToDepthNet(Cell):
def __init__(self): super(SpaceToDepthNet, self).__init__() block_size = 2 self.space_to_depth = P.SpaceToDepth(block_size) def construct(self, x): return self.space_to_depth(x)
(self, x): return self.pack((x, x)) class UnpackNet(Cell): def __init__(self): super(UnpackNet, self).__init__() self.unpack = P.Unpack() def construct(self, x): return self.unpack(x) class SpaceToDepthNet(Cell):
64
64
61
7
57
ZephyrChenzf/mindspore
tests/ut/python/ops/test_array_ops.py
Python
SpaceToDepthNet
SpaceToDepthNet
247
254
247
247
0bc8c60052196fd619e8713dcfaee85fe590e8ac
bigcode/the-stack
train
940ff1972d0038f068b6e928
train
class
class AnalysisListSchema(AutoSchema): def get_operation(self, path, method): operation = super().get_operation(path, method) if method == 'GET': operation['operationId'] = 'GetAnalysisList' elif method == 'POST': operation['operationId'] = 'CreateAnalysis' ope...
class AnalysisListSchema(AutoSchema):
def get_operation(self, path, method): operation = super().get_operation(path, method) if method == 'GET': operation['operationId'] = 'GetAnalysisList' elif method == 'POST': operation['operationId'] = 'CreateAnalysis' operation['tags'] = ['Tator'] ret...
from textwrap import dedent from rest_framework.schemas.openapi import AutoSchema from ._message import message_schema from ._errors import error_responses from .components.analysis import fields boilerplate = dedent("""\ Analysis objects are used to display information about filtered media lists and/or annotations...
92
168
562
8
84
kristianmk/tator
main/schema/analysis.py
Python
AnalysisListSchema
AnalysisListSchema
16
92
16
16
37037b72f5b2d86bf23055241a6114adc71fe5de
bigcode/the-stack
train
c333110718bcb7835b255780
train
class
class AnalysisDetailSchema(AutoSchema): def get_operation(self, path, method) -> dict: operation = super().get_operation(path, method) if method == 'GET': operation['operationId'] = 'GetAnalysis' elif method == 'PATCH': operation['operationId'] = 'UpdateAnalysis' ...
class AnalysisDetailSchema(AutoSchema):
def get_operation(self, path, method) -> dict: operation = super().get_operation(path, method) if method == 'GET': operation['operationId'] = 'GetAnalysis' elif method == 'PATCH': operation['operationId'] = 'UpdateAnalysis' elif method == 'DELETE': ...
400'] = {'description': 'Bad request.'} responses['200'] = { 'description': 'Successful retrieval of analyses.', 'content': {'application/json': {'schema': { 'type': 'array', 'items': {'$ref': '#/components/schemas/Analysis'}, ...
140
140
467
8
131
kristianmk/tator
main/schema/analysis.py
Python
AnalysisDetailSchema
AnalysisDetailSchema
94
158
94
95
088c9fb29411a8cf0be7ab04f20e9b2abcc3758c
bigcode/the-stack
train
d23e5f919695c91cc77e8353
train
function
def pytest_enter_pdb(config, pdb): """ called upon pdb.set_trace(), can be used by plugins to take special action just before the python debugger enters in interactive mode. :param _pytest.config.Config config: pytest config object :param pdb.Pdb pdb: Pdb instance """
def pytest_enter_pdb(config, pdb):
""" called upon pdb.set_trace(), can be used by plugins to take special action just before the python debugger enters in interactive mode. :param _pytest.config.Config config: pytest config object :param pdb.Pdb pdb: Pdb instance """
_exception_interact(node, call, report): """called when an exception was raised which can potentially be interactively handled. This hook is only called if an exception was raised that is not an internal exception like ``skip.Exception``. """ def pytest_enter_pdb(config, pdb):
63
64
65
9
54
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_enter_pdb
pytest_enter_pdb
726
732
726
726
c9274e9172199980cf0e6ab711ab7d8d8a405674
bigcode/the-stack
train
43ded405f46f2466204b59f7
train
function
@hookspec(firstresult=True) def pytest_make_collect_report(collector): """ perform ``collector.collect()`` and return a CollectReport. Stops at first non-None result, see :ref:`firstresult` """
@hookspec(firstresult=True) def pytest_make_collect_report(collector):
""" perform ``collector.collect()`` and return a CollectReport. Stops at first non-None result, see :ref:`firstresult` """
""" we just collected a test item. """ def pytest_collectreport(report): """ collector finished collecting. """ def pytest_deselected(items): """ called for test items deselected, e.g. by keyword. """ @hookspec(firstresult=True) def pytest_make_collect_report(collector):
63
64
46
15
48
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_make_collect_report
pytest_make_collect_report
268
272
268
269
d2ab3dc11f4ca339a8ee9d7f1ac1beb87d334123
bigcode/the-stack
train
d6ff167c074001bc5600b680
train
function
def pytest_assertrepr_compare(config, op, left, right): """return explanation for comparisons in failing assert expressions. Return None for no custom explanation, otherwise return a list of strings. The strings will be joined by newlines but any newlines *in* a string will be escaped. Note that all ...
def pytest_assertrepr_compare(config, op, left, right):
"""return explanation for comparisons in failing assert expressions. Return None for no custom explanation, otherwise return a list of strings. The strings will be joined by newlines but any newlines *in* a string will be escaped. Note that all but the first line will be indented slightly, the in...
system """ def pytest_unconfigure(config): """ called before test process is exited. :param _pytest.config.Config config: pytest config object """ # ------------------------------------------------------------------------- # hooks for customizing the assert methods # ------------------------------...
63
64
108
13
50
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_assertrepr_compare
pytest_assertrepr_compare
487
496
487
487
a08988db2a952db34e3ab8843da2113af03acc35
bigcode/the-stack
train
33495d16e2a33ccdf9f48221
train
function
def pytest_leave_pdb(config, pdb): """ called when leaving pdb (e.g. with continue after pdb.set_trace()). Can be used by plugins to take special action just after the python debugger leaves interactive mode. :param _pytest.config.Config config: pytest config object :param pdb.Pdb pdb: Pdb instanc...
def pytest_leave_pdb(config, pdb):
""" called when leaving pdb (e.g. with continue after pdb.set_trace()). Can be used by plugins to take special action just after the python debugger leaves interactive mode. :param _pytest.config.Config config: pytest config object :param pdb.Pdb pdb: Pdb instance """
called upon pdb.set_trace(), can be used by plugins to take special action just before the python debugger enters in interactive mode. :param _pytest.config.Config config: pytest config object :param pdb.Pdb pdb: Pdb instance """ def pytest_leave_pdb(config, pdb):
63
64
75
9
54
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_leave_pdb
pytest_leave_pdb
735
743
735
735
859ee4a14a3cef2b82f7c12809cc613deb6b3d37
bigcode/the-stack
train
ba5315b9aa2dad79dabbf3ea
train
function
@hookspec(firstresult=True) def pytest_runtest_protocol(item, nextitem): """ implements the runtest_setup/call/teardown protocol for the given test item, including capturing exceptions and calling reporting hooks. :arg item: test item for which the runtest protocol is performed. :arg nextitem: the...
@hookspec(firstresult=True) def pytest_runtest_protocol(item, nextitem):
""" implements the runtest_setup/call/teardown protocol for the given test item, including capturing exceptions and calling reporting hooks. :arg item: test item for which the runtest protocol is performed. :arg nextitem: the scheduled-to-be-next test item (or None if this is th...
performing the main runtest loop (after collection finished). Stops at first non-None result, see :ref:`firstresult` :param _pytest.main.Session session: the pytest session object """ @hookspec(firstresult=True) def pytest_runtest_protocol(item, nextitem):
63
64
144
18
45
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_protocol
pytest_runtest_protocol
341
356
341
342
1380d477bf5669550172c8728a515bb418d34793
bigcode/the-stack
train
620d55e3a741c198f931b4f4
train
function
@hookspec(historic=True) def pytest_plugin_registered(plugin, manager): """ a new pytest plugin got registered. :param plugin: the plugin module or instance :param _pytest.config.PytestPluginManager manager: pytest plugin manager .. note:: This hook is incompatible with ``hookwrapper=True``. ...
@hookspec(historic=True) def pytest_plugin_registered(plugin, manager):
""" a new pytest plugin got registered. :param plugin: the plugin module or instance :param _pytest.config.PytestPluginManager manager: pytest plugin manager .. note:: This hook is incompatible with ``hookwrapper=True``. """
_hookspecs(module_or_class, prefix)``. :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager .. note:: This hook is incompatible with ``hookwrapper=True``. """ @hookspec(historic=True) def pytest_plugin_registered(plugin, manager):
63
64
71
16
47
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_plugin_registered
pytest_plugin_registered
41
50
41
42
72810bb59fc8acb0e68fb1611bc48e4804a5269c
bigcode/the-stack
train
f71895fcce5483d5b24e30b3
train
function
def pytest_runtest_teardown(item, nextitem): """ called after ``pytest_runtest_call``. :arg nextitem: the scheduled-to-be-next test item (None if no further test item is scheduled). This argument can be used to perform exact teardowns, i.e. calling just enough finalizers ...
def pytest_runtest_teardown(item, nextitem):
""" called after ``pytest_runtest_call``. :arg nextitem: the scheduled-to-be-next test item (None if no further test item is scheduled). This argument can be used to perform exact teardowns, i.e. calling just enough finalizers so that nextitem only need...
testname)`` """ def pytest_runtest_setup(item): """ called before ``pytest_runtest_call(item)``. """ def pytest_runtest_call(item): """ called to execute the test ``item``. """ def pytest_runtest_teardown(item, nextitem):
63
64
86
12
51
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_teardown
pytest_runtest_teardown
389
396
389
389
cbf72fdbed3df9d56a5ef951ba0a44269afef4bd
bigcode/the-stack
train
29d7bc189d2df208d5159b02
train
function
def pytest_keyboard_interrupt(excinfo): """ called for keyboard interrupt. """
def pytest_keyboard_interrupt(excinfo):
""" called for keyboard interrupt. """
given doctest Stops at first non-None result, see :ref:`firstresult` """ # ------------------------------------------------------------------------- # error handling and internal debugging hooks # ------------------------------------------------------------------------- def pytest_internalerror(excrepr, excin...
63
64
15
7
56
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_keyboard_interrupt
pytest_keyboard_interrupt
713
714
713
713
2b10c761c2edffeec09ccb37876de120ba84162c
bigcode/the-stack
train
3797fd012e66a62b96bb97de
train
function
@hookspec(firstresult=True) def pytest_doctest_prepare_content(content): """ return processed content for a given doctest Stops at first non-None result, see :ref:`firstresult` """
@hookspec(firstresult=True) def pytest_doctest_prepare_content(content):
""" return processed content for a given doctest Stops at first non-None result, see :ref:`firstresult` """
umber, function). ``function`` evaluates to <module> when the execution context is at the module level. .. versionadded:: 6.0 """ # ------------------------------------------------------------------------- # doctest hooks # ------------------------------------------------------------------------- @ho...
63
64
44
16
47
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_doctest_prepare_content
pytest_doctest_prepare_content
697
701
697
698
7e1177500b759da43617292f814c174ff3fc4a79
bigcode/the-stack
train
edf239ee26c80ed130126daa
train
function
@hookspec(firstresult=True) def pytest_collection(session: "Session") -> Optional[Any]: """Perform the collection protocol for the given session. Stops at first non-None result, see :ref:`firstresult`. The return value is not used, but only stops further processing. The hook is meant to set `session.i...
@hookspec(firstresult=True) def pytest_collection(session: "Session") -> Optional[Any]:
"""Perform the collection protocol for the given session. Stops at first non-None result, see :ref:`firstresult`. The return value is not used, but only stops further processing. The hook is meant to set `session.items` to a sequence of items at least, but normally should follow this procedure: ...
[str] args: list of arguments passed on the command line :param _pytest.config.argparsing.Parser parser: to add command line options """ # ------------------------------------------------------------------------- # collection hooks # ------------------------------------------------------------------------- @h...
63
64
216
19
44
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collection
pytest_collection
176
198
176
177
5053c2bea2a1749fd13d70d8d1fdfa8de4a4b2e6
bigcode/the-stack
train
953ec73bc8a98a84321d6458
train
function
def pytest_terminal_summary(terminalreporter, exitstatus, config): """Add a section to terminal summary reporting. :param _pytest.terminal.TerminalReporter terminalreporter: the internal terminal reporter object :param int exitstatus: the exit status that will be reported back to the OS :param _pytest....
def pytest_terminal_summary(terminalreporter, exitstatus, config):
"""Add a section to terminal summary reporting. :param _pytest.terminal.TerminalReporter terminalreporter: the internal terminal reporter object :param int exitstatus: the exit status that will be reported back to the OS :param _pytest.config.Config config: pytest config object .. versionadded:: 4...
})``. :param report: The report object whose status is to be returned. :param _pytest.config.Config config: The pytest config object. Stops at first non-None result, see :ref:`firstresult`. """ def pytest_terminal_summary(terminalreporter, exitstatus, config):
63
64
95
14
49
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_terminal_summary
pytest_terminal_summary
613
622
613
613
c9e202c32d7d5525e32749e34344a76e7a5bea93
bigcode/the-stack
train
fb483c501ef933b6e809fe28
train
function
def pytest_collect_file(path, parent): """ return collection Node or None for the given path. Any new node needs to have the specified ``parent`` as a parent. :param path: a :py:class:`py.path.local` - the path to collect """
def pytest_collect_file(path, parent):
""" return collection Node or None for the given path. Any new node needs to have the specified ``parent`` as a parent. :param path: a :py:class:`py.path.local` - the path to collect """
(path, parent): """ called before traversing a directory for collection files. Stops at first non-None result, see :ref:`firstresult` :param path: a :py:class:`py.path.local` - the path to analyze """ def pytest_collect_file(path, parent):
63
64
60
8
55
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collect_file
pytest_collect_file
241
246
241
241
48590c2ec20f746721cef64d2908fce2e82ef10f
bigcode/the-stack
train
9d5c40bac036f5f1bbfcc723
train
function
@hookspec(firstresult=True) def pytest_pycollect_makemodule(path, parent): """ return a Module collector or None for the given path. This hook will be called for each matching test module path. The pytest_collect_file hook needs to be used if you want to create test modules for files that do not match a...
@hookspec(firstresult=True) def pytest_pycollect_makemodule(path, parent):
""" return a Module collector or None for the given path. This hook will be called for each matching test module path. The pytest_collect_file hook needs to be used if you want to create test modules for files that do not match as a test module. Stops at first non-None result, see :ref:`firstresult...
""" perform ``collector.collect()`` and return a CollectReport. Stops at first non-None result, see :ref:`firstresult` """ # ------------------------------------------------------------------------- # Python test function related hooks # ------------------------------------------------------------------------- ...
63
64
116
19
44
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_pycollect_makemodule
pytest_pycollect_makemodule
280
290
280
281
807666a07cbcd64eded37430ed22c7b1ccdd2f92
bigcode/the-stack
train
5b45bbb77b81d13b6e7cf108
train
function
def pytest_report_collectionfinish(config, startdir, items): """ .. versionadded:: 3.2 return a string or list of strings to be displayed after collection has finished successfully. These strings will be displayed after the standard "collected X items" message. :param _pytest.config.Config config...
def pytest_report_collectionfinish(config, startdir, items):
""" .. versionadded:: 3.2 return a string or list of strings to be displayed after collection has finished successfully. These strings will be displayed after the standard "collected X items" message. :param _pytest.config.Config config: pytest config object :param startdir: py.path object wi...
. .. note:: This function should be implemented only in plugins or ``conftest.py`` files situated at the tests root directory due to how pytest :ref:`discovers plugins during startup <pluginorder>`. """ def pytest_report_collectionfinish(config, startdir, items):
63
64
161
12
51
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_report_collectionfinish
pytest_report_collectionfinish
563
581
563
563
fd5054cd74067594fe33ef30abf8b67972f3022f
bigcode/the-stack
train
382f181310027776be0f1620
train
function
def pytest_load_initial_conftests(early_config, parser, args): """ implements the loading of initial conftest files ahead of command line option parsing. .. note:: This hook will not be called for ``conftest.py`` files, only for setuptools plugins. :param _pytest.config.Config early_config: py...
def pytest_load_initial_conftests(early_config, parser, args):
""" implements the loading of initial conftest files ahead of command line option parsing. .. note:: This hook will not be called for ``conftest.py`` files, only for setuptools plugins. :param _pytest.config.Config early_config: pytest config object :param list[str] args: list of arguments...
not be called for ``conftest.py`` files, only for setuptools plugins. Stops at first non-None result, see :ref:`firstresult` :param _pytest.config.Config config: pytest config object """ def pytest_load_initial_conftests(early_config, parser, args):
63
64
111
15
48
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_load_initial_conftests
pytest_load_initial_conftests
158
168
158
158
64eb75d0b1f4940f8df88e2f924b057fe656cb4c
bigcode/the-stack
train
1a04e8cc31e9a886aac2d685
train
function
def pytest_collectstart(collector): """ collector starts collecting. """
def pytest_collectstart(collector):
""" collector starts collecting. """
return collection Node or None for the given path. Any new node needs to have the specified ``parent`` as a parent. :param path: a :py:class:`py.path.local` - the path to collect """ # logging hooks for collection def pytest_collectstart(collector):
64
64
14
7
56
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collectstart
pytest_collectstart
252
253
252
252
5a880fa6c98fe4a64fa7dd7dca5ae427e4658535
bigcode/the-stack
train
a48eb4a460f993014a13518a
train
function
def pytest_runtest_call(item): """ called to execute the test ``item``. """
def pytest_runtest_call(item):
""" called to execute the test ``item``. """
str nodeid: full id of the item :param location: a triple of ``(filename, linenum, testname)`` """ def pytest_runtest_setup(item): """ called before ``pytest_runtest_call(item)``. """ def pytest_runtest_call(item):
63
64
20
8
55
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_call
pytest_runtest_call
385
386
385
385
2533c4f3322e6b19abe4e7522db605068b44b41d
bigcode/the-stack
train
47c4563e9b62c4f6766e9afb
train
function
def pytest_exception_interact(node, call, report): """called when an exception was raised which can potentially be interactively handled. This hook is only called if an exception was raised that is not an internal exception like ``skip.Exception``. """
def pytest_exception_interact(node, call, report):
"""called when an exception was raised which can potentially be interactively handled. This hook is only called if an exception was raised that is not an internal exception like ``skip.Exception``. """
""" # ------------------------------------------------------------------------- # error handling and internal debugging hooks # ------------------------------------------------------------------------- def pytest_internalerror(excrepr, excinfo): """ called for internal errors. """ def pytest_keyboard_interru...
63
64
56
11
52
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_exception_interact
pytest_exception_interact
717
723
717
717
685d4ec434169841967015eadfee4d94f4121ee3
bigcode/the-stack
train
35b30f9abacceaf004be4f83
train
function
@hookspec(firstresult=True) def pytest_runtest_makereport(item, call): """ return a :py:class:`_pytest.runner.TestReport` object for the given :py:class:`pytest.Item <_pytest.main.Item>` and :py:class:`_pytest.runner.CallInfo`. Stops at first non-None result, see :ref:`firstresult` """
@hookspec(firstresult=True) def pytest_runtest_makereport(item, call):
""" return a :py:class:`_pytest.runner.TestReport` object for the given :py:class:`pytest.Item <_pytest.main.Item>` and :py:class:`_pytest.runner.CallInfo`. Stops at first non-None result, see :ref:`firstresult` """
test item is scheduled). This argument can be used to perform exact teardowns, i.e. calling just enough finalizers so that nextitem only needs to call setup-functions. """ @hookspec(firstresult=True) def pytest_runtest_makereport(item, call):
63
64
85
20
43
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_makereport
pytest_runtest_makereport
399
405
399
400
78b2c4b03412f603e2c881af3173467778fcd1df
bigcode/the-stack
train
f75972f0f142677fb83bfb15
train
function
@hookspec(historic=True) def pytest_addoption(parser, pluginmanager): """register argparse-style options and ini-style config values, called once at the beginning of a test run. .. note:: This function should be implemented only in plugins or ``conftest.py`` files situated at the tests roo...
@hookspec(historic=True) def pytest_addoption(parser, pluginmanager):
"""register argparse-style options and ini-style config values, called once at the beginning of a test run. .. note:: This function should be implemented only in plugins or ``conftest.py`` files situated at the tests root directory due to how pytest :ref:`discovers plugins during s...
manager .. note:: This hook is incompatible with ``hookwrapper=True``. """ @hookspec(historic=True) def pytest_plugin_registered(plugin, manager): """ a new pytest plugin got registered. :param plugin: the plugin module or instance :param _pytest.config.PytestPluginManager manager: pyte...
109
110
369
17
92
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_addoption
pytest_addoption
53
88
53
54
9d816b16d2ce972a3ad752f5977c9707b5b3c294
bigcode/the-stack
train
3de20cf262960945e56906ef
train
function
@hookspec(firstresult=True) def pytest_ignore_collect(path, config): """ return True to prevent considering this path for collection. This hook is consulted for all files and directories prior to calling more specific hooks. Stops at first non-None result, see :ref:`firstresult` :param path: a :py...
@hookspec(firstresult=True) def pytest_ignore_collect(path, config):
""" return True to prevent considering this path for collection. This hook is consulted for all files and directories prior to calling more specific hooks. Stops at first non-None result, see :ref:`firstresult` :param path: a :py:class:`py.path.local` - the path to analyze :param _pytest.confi...
[_pytest.nodes.Item] items: list of item objects """ def pytest_collection_finish(session): """ called after collection has been performed and modified. :param _pytest.main.Session session: the pytest session object """ @hookspec(firstresult=True) def pytest_ignore_collect(path, config):
63
64
98
15
48
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_ignore_collect
pytest_ignore_collect
218
228
218
219
ee5d987d86fb7214ac451e34b51bd6aacb9c3626
bigcode/the-stack
train
588ce65cb06182e68e32c5b4
train
function
def pytest_runtest_setup(item): """ called before ``pytest_runtest_call(item)``. """
def pytest_runtest_setup(item):
""" called before ``pytest_runtest_call(item)``. """
pytest_runtest_call` and :func:`pytest_runtest_teardown` hooks. :param str nodeid: full id of the item :param location: a triple of ``(filename, linenum, testname)`` """ def pytest_runtest_setup(item):
63
64
23
8
55
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_setup
pytest_runtest_setup
381
382
381
381
64112d6a802b50f8d3d56db9f9ac9062f53ee157
bigcode/the-stack
train
d3dcfcd86dd8e545b1af7ac4
train
function
@hookspec(firstresult=True) def pytest_runtestloop(session): """ called for performing the main runtest loop (after collection finished). Stops at first non-None result, see :ref:`firstresult` :param _pytest.main.Session session: the pytest session object """
@hookspec(firstresult=True) def pytest_runtestloop(session):
""" called for performing the main runtest loop (after collection finished). Stops at first non-None result, see :ref:`firstresult` :param _pytest.main.Session session: the pytest session object """
.Config config: pytest config object :param val: the parametrized value :param str argname: the automatic parameter name produced by pytest """ # ------------------------------------------------------------------------- # generic runtest related hooks # ----------------------------------------------------...
63
64
64
15
48
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtestloop
pytest_runtestloop
330
338
330
331
3c8eeaae0403d2d92b2d55e651f6dea808f2cbfe
bigcode/the-stack
train
d77b05c5272da33523fd3070
train
function
@hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK) def pytest_warning_captured( warning_message: "warnings.WarningMessage", when: str, item, location: Optional[Tuple[str, int, str]], ) -> None: """(**Deprecated**) Process a warning captured by the internal pytest warnings plugin. .. d...
@hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK) def pytest_warning_captured( warning_message: "warnings.WarningMessage", when: str, item, location: Optional[Tuple[str, int, str]], ) -> None:
"""(**Deprecated**) Process a warning captured by the internal pytest warnings plugin. .. deprecated:: 6.0 This hook is considered deprecated and will be removed in a future pytest version. Use :func:`pytest_warning_recorded` instead. :param warnings.WarningMessage warning_message: The ca...
:param _pytest.config.Config config: pytest config object .. versionadded:: 4.2 The ``config`` parameter. """ @hookspec(historic=True, warn_on_impl=WARNING_CAPTURED_HOOK) def pytest_warning_captured( warning_message: "warnings.WarningMessage", when: str, item, location: Optional[Tup...
89
90
301
57
32
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_warning_captured
pytest_warning_captured
625
657
625
631
2e66716aa2ab6040ac7c437f5b46a1ae7017ffa5
bigcode/the-stack
train
0684097bc3864a906841db57
train
function
@hookspec(firstresult=True) def pytest_report_teststatus( report: "BaseReport", config: "Config" ) -> Tuple[ str, str, Union[str, Mapping[str, bool]], ]: """Return result-category, shortletter and verbose word for status reporting. The result-category is a category in which to count the result, for...
@hookspec(firstresult=True) def pytest_report_teststatus( report: "BaseReport", config: "Config" ) -> Tuple[ str, str, Union[str, Mapping[str, bool]], ]:
"""Return result-category, shortletter and verbose word for status reporting. The result-category is a category in which to count the result, for example "passed", "skipped", "error" or the empty string. The shortletter is shown as testing progresses, for example ".", "s", "E" or the empty str...
If you want to have your line(s) displayed first, use :ref:`trylast=True <plugin-hookorder>`. """ @hookspec(firstresult=True) def pytest_report_teststatus( report: "BaseReport", config: "Config" ) -> Tuple[ str, str, Union[str, Mapping[str, bool]], ]:
73
74
247
43
30
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_report_teststatus
pytest_report_teststatus
584
610
584
589
cc8af82de88ecc39bc8dc412f9999f11e309c7a8
bigcode/the-stack
train
70491769f61440dd7b96f5ed
train
function
@hookspec(firstresult=True) def pytest_pycollect_makeitem(collector, name, obj): """ return custom item/collector for a python object in a module, or None. Stops at first non-None result, see :ref:`firstresult` """
@hookspec(firstresult=True) def pytest_pycollect_makeitem(collector, name, obj):
""" return custom item/collector for a python object in a module, or None. Stops at first non-None result, see :ref:`firstresult` """
module. Stops at first non-None result, see :ref:`firstresult` :param path: a :py:class:`py.path.local` - the path of module to collect """ @hookspec(firstresult=True) def pytest_pycollect_makeitem(collector, name, obj):
63
64
55
20
43
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_pycollect_makeitem
pytest_pycollect_makeitem
293
297
293
294
22a198dffb27f7f12215760ab564a53d4719860a
bigcode/the-stack
train
9c3e392444e90ea853a2b62c
train
function
@hookspec(firstresult=True) def pytest_cmdline_main(config): """ called for performing the main command line action. The default implementation will invoke the configure hooks and runtest_mainloop. .. note:: This hook will not be called for ``conftest.py`` files, only for setuptools plugins. S...
@hookspec(firstresult=True) def pytest_cmdline_main(config):
""" called for performing the main command line action. The default implementation will invoke the configure hooks and runtest_mainloop. .. note:: This hook will not be called for ``conftest.py`` files, only for setuptools plugins. Stops at first non-None result, see :ref:`firstresult` :p...
not be called for ``conftest.py`` files, only for setuptools plugins. :param _pytest.config.Config config: pytest config object :param list[str] args: list of arguments passed on the command line """ @hookspec(firstresult=True) def pytest_cmdline_main(config):
63
64
97
14
49
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_cmdline_main
pytest_cmdline_main
144
155
144
145
e2208645e6f96ae2c90e9ba9affb20aa6bfd791e
bigcode/the-stack
train
6a67697e3604d96a8788b337
train
function
@hookspec(firstresult=True) def pytest_cmdline_parse(pluginmanager, args): """return initialized config object, parsing the specified args. Stops at first non-None result, see :ref:`firstresult` .. note:: This hook will only be called for plugin classes passed to the ``plugins`` arg when using `py...
@hookspec(firstresult=True) def pytest_cmdline_parse(pluginmanager, args):
"""return initialized config object, parsing the specified args. Stops at first non-None result, see :ref:`firstresult` .. note:: This hook will only be called for plugin classes passed to the ``plugins`` arg when using `pytest.main`_ to perform an in-process test run. :param _pytest....
wrapper=True``. :arg _pytest.config.Config config: pytest config object """ # ------------------------------------------------------------------------- # Bootstrapping hooks called for plugins registered early enough: # internal and 3rd party plugins. # -------------------------------------------------------...
63
64
120
17
46
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_cmdline_parse
pytest_cmdline_parse
115
127
115
116
a8bf9d1ce71c9881dd89e4693b48a8079babdce3
bigcode/the-stack
train
5660cb40d0928e8ef97e10d7
train
function
@hookspec(historic=True) def pytest_warning_recorded( warning_message: "warnings.WarningMessage", when: str, nodeid: str, location: Optional[Tuple[str, int, str]], ) -> None: """ Process a warning captured by the internal pytest warnings plugin. :param warnings.WarningMessage warning_messag...
@hookspec(historic=True) def pytest_warning_recorded( warning_message: "warnings.WarningMessage", when: str, nodeid: str, location: Optional[Tuple[str, int, str]], ) -> None:
""" Process a warning captured by the internal pytest warnings plugin. :param warnings.WarningMessage warning_message: The captured warning. This is the same object produced by :py:func:`warnings.catch_warnings`, and contains the same attributes as the parameters of :py:func:`warnings.showw...
, function). ``function`` evaluates to <module> when the execution context is at the module level. """ @hookspec(historic=True) def pytest_warning_recorded( warning_message: "warnings.WarningMessage", when: str, nodeid: str, location: Optional[Tuple[str, int, str]], ) -> None:
74
75
250
50
24
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_warning_recorded
pytest_warning_recorded
660
689
660
666
5a5f4d279978c35698727ec09dc7f50ef66621d1
bigcode/the-stack
train
32ef1967090f64a9a6b9f8b9
train
function
@hookspec(firstresult=True) def pytest_report_to_serializable(config, report): """ Serializes the given report object into a data structure suitable for sending over the wire, e.g. converted to JSON. """
@hookspec(firstresult=True) def pytest_report_to_serializable(config, report):
""" Serializes the given report object into a data structure suitable for sending over the wire, e.g. converted to JSON. """
None result, see :ref:`firstresult` """ def pytest_runtest_logreport(report): """ process a test setup/call/teardown report relating to the respective phase of executing a test. """ @hookspec(firstresult=True) def pytest_report_to_serializable(config, report):
63
64
48
17
46
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_report_to_serializable
pytest_report_to_serializable
413
418
413
414
3a8929d96a1cdc60d15e39ce28c4dae812213ebb
bigcode/the-stack
train
b8d02df702abc512b259b92b
train
function
def pytest_sessionstart(session): """ called after the ``Session`` object has been created and before performing collection and entering the run test loop. :param _pytest.main.Session session: the pytest session object """
def pytest_sessionstart(session):
""" called after the ``Session`` object has been created and before performing collection and entering the run test loop. :param _pytest.main.Session session: the pytest session object """
izer(fixturedef, request): """Called after fixture teardown, but before the cache is cleared, so the fixture result ``fixturedef.cached_result`` is still available (not ``None``).""" # ------------------------------------------------------------------------- # test session related hooks # ----------------...
63
64
47
6
57
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_sessionstart
pytest_sessionstart
459
464
459
459
8df5f83a63fe7d30721271ef71c6b3b8d19471d5
bigcode/the-stack
train
662915ccf159368853a91a91
train
function
@hookspec(firstresult=True, warn_on_impl=COLLECT_DIRECTORY_HOOK) def pytest_collect_directory(path, parent): """ called before traversing a directory for collection files. Stops at first non-None result, see :ref:`firstresult` :param path: a :py:class:`py.path.local` - the path to analyze """
@hookspec(firstresult=True, warn_on_impl=COLLECT_DIRECTORY_HOOK) def pytest_collect_directory(path, parent):
""" called before traversing a directory for collection files. Stops at first non-None result, see :ref:`firstresult` :param path: a :py:class:`py.path.local` - the path to analyze """
result` :param path: a :py:class:`py.path.local` - the path to analyze :param _pytest.config.Config config: pytest config object """ @hookspec(firstresult=True, warn_on_impl=COLLECT_DIRECTORY_HOOK) def pytest_collect_directory(path, parent):
63
64
76
25
38
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collect_directory
pytest_collect_directory
231
238
231
232
b405480f9b12ba56ef7cca0b91710b059e830ded
bigcode/the-stack
train
52f719062d055e9de6688c59
train
function
def pytest_internalerror(excrepr, excinfo): """ called for internal errors. """
def pytest_internalerror(excrepr, excinfo):
""" called for internal errors. """
def pytest_doctest_prepare_content(content): """ return processed content for a given doctest Stops at first non-None result, see :ref:`firstresult` """ # ------------------------------------------------------------------------- # error handling and internal debugging hooks # --------------------------------...
63
64
19
11
52
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_internalerror
pytest_internalerror
709
710
709
709
60d7d374600f1f80fd6c81788a36fb88413392da
bigcode/the-stack
train
74e392bccf547c1dd4a5a84a
train
function
@hookspec(firstresult=True) def pytest_make_parametrize_id(config, val, argname): """Return a user-friendly string representation of the given ``val`` that will be used by @pytest.mark.parametrize calls. Return None if the hook doesn't know about ``val``. The parameter name is available as ``argname``, if r...
@hookspec(firstresult=True) def pytest_make_parametrize_id(config, val, argname):
"""Return a user-friendly string representation of the given ``val`` that will be used by @pytest.mark.parametrize calls. Return None if the hook doesn't know about ``val``. The parameter name is available as ``argname``, if required. Stops at first non-None result, see :ref:`firstresult` :param _...
function. Stops at first non-None result, see :ref:`firstresult` """ def pytest_generate_tests(metafunc): """ generate (multiple) parametrized calls to a test function.""" @hookspec(firstresult=True) def pytest_make_parametrize_id(config, val, argname):
63
64
130
20
43
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_make_parametrize_id
pytest_make_parametrize_id
311
322
311
312
1a20206444dce496c5bc8c6cef6f6efd33d49e42
bigcode/the-stack
train
d4b64e0360f5b750f87e3146
train
function
def pytest_sessionfinish(session, exitstatus): """ called after whole test run finished, right before returning the exit status to the system. :param _pytest.main.Session session: the pytest session object :param int exitstatus: the status which pytest will return to the system """
def pytest_sessionfinish(session, exitstatus):
""" called after whole test run finished, right before returning the exit status to the system. :param _pytest.main.Session session: the pytest session object :param int exitstatus: the status which pytest will return to the system """
related hooks # ------------------------------------------------------------------------- def pytest_sessionstart(session): """ called after the ``Session`` object has been created and before performing collection and entering the run test loop. :param _pytest.main.Session session: the pytest session ob...
63
64
61
9
54
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_sessionfinish
pytest_sessionfinish
467
472
467
467
c3e1903c3d68a6874158b54b2d49ccf3f12833bf
bigcode/the-stack
train
5b4e45014157bb22fe8422bb
train
function
def pytest_collection_modifyitems(session, config, items): """ called after collection has been performed, may filter or re-order the items in-place. :param _pytest.main.Session session: the pytest session object :param _pytest.config.Config config: pytest config object :param List[_pytest.nodes.It...
def pytest_collection_modifyitems(session, config, items):
""" called after collection has been performed, may filter or re-order the items in-place. :param _pytest.main.Session session: the pytest session object :param _pytest.config.Config config: pytest config object :param List[_pytest.nodes.Item] items: list of item objects """
You can implement this hook to only perform some action before collection, for example the terminal plugin uses it to start displaying the collection counter (and returns `None`). :param _pytest.main.Session session: the pytest session object """ def pytest_collection_modifyitems(session, config, item...
63
64
77
11
52
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collection_modifyitems
pytest_collection_modifyitems
201
208
201
201
54fbfb83b0112ae1104f721642db9afe8416a891
bigcode/the-stack
train
39413897a8339522cdf4b3c4
train
function
def pytest_cmdline_preparse(config, args): """(**Deprecated**) modify command line arguments before option parsing. This hook is considered deprecated and will be removed in a future pytest version. Consider using :func:`pytest_load_initial_conftests` instead. .. note:: This hook will not be c...
def pytest_cmdline_preparse(config, args):
"""(**Deprecated**) modify command line arguments before option parsing. This hook is considered deprecated and will be removed in a future pytest version. Consider using :func:`pytest_load_initial_conftests` instead. .. note:: This hook will not be called for ``conftest.py`` files, only for s...
using `pytest.main`_ to perform an in-process test run. :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager :param list[str] args: list of arguments passed on the command line """ def pytest_cmdline_preparse(config, args):
63
64
112
10
53
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_cmdline_preparse
pytest_cmdline_preparse
130
141
130
130
d2f11ea2423c4dc39f10fbe66d146e67c47b082d
bigcode/the-stack
train
c7fa210f337e13820facbf2e
train
function
def pytest_runtest_logreport(report): """ process a test setup/call/teardown report relating to the respective phase of executing a test. """
def pytest_runtest_logreport(report):
""" process a test setup/call/teardown report relating to the respective phase of executing a test. """
.runner.TestReport` object for the given :py:class:`pytest.Item <_pytest.main.Item>` and :py:class:`_pytest.runner.CallInfo`. Stops at first non-None result, see :ref:`firstresult` """ def pytest_runtest_logreport(report):
63
64
34
9
54
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_logreport
pytest_runtest_logreport
408
410
408
408
c25105aa69f52544c0d39ce8f4ce9109ebf57321
bigcode/the-stack
train
557f6f1731e7aabe99a5df6c
train
function
def pytest_deselected(items): """ called for test items deselected, e.g. by keyword. """
def pytest_deselected(items):
""" called for test items deselected, e.g. by keyword. """
""" # logging hooks for collection def pytest_collectstart(collector): """ collector starts collecting. """ def pytest_itemcollected(item): """ we just collected a test item. """ def pytest_collectreport(report): """ collector finished collecting. """ def pytest_deselected(items):
63
64
23
7
56
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_deselected
pytest_deselected
264
265
264
264
9d55e73f71b0256b8ba110e3eb98636d6075825c
bigcode/the-stack
train
dfae43eee291fa3b93fb1faa
train
function
def pytest_fixture_post_finalizer(fixturedef, request): """Called after fixture teardown, but before the cache is cleared, so the fixture result ``fixturedef.cached_result`` is still available (not ``None``)."""
def pytest_fixture_post_finalizer(fixturedef, request):
"""Called after fixture teardown, but before the cache is cleared, so the fixture result ``fixturedef.cached_result`` is still available (not ``None``)."""
see :ref:`firstresult` .. note:: If the fixture function returns None, other implementations of this hook function will continue to be called, according to the behavior of the :ref:`firstresult` option. """ def pytest_fixture_post_finalizer(fixturedef, request):
63
64
50
12
51
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_fixture_post_finalizer
pytest_fixture_post_finalizer
448
451
448
448
5457cbf294019dff3847a3b7ff1cb332f3ba4517
bigcode/the-stack
train
d4b7cbb1136da5cb69c8199d
train
function
def pytest_runtest_logstart(nodeid, location): """ signal the start of running a single test item. This hook will be called **before** :func:`pytest_runtest_setup`, :func:`pytest_runtest_call` and :func:`pytest_runtest_teardown` hooks. :param str nodeid: full id of the item :param location: a trip...
def pytest_runtest_logstart(nodeid, location):
""" signal the start of running a single test item. This hook will be called **before** :func:`pytest_runtest_setup`, :func:`pytest_runtest_call` and :func:`pytest_runtest_teardown` hooks. :param str nodeid: full id of the item :param location: a triple of ``(filename, linenum, testname)`` """...
argument is passed on to :py:func:`pytest_runtest_teardown`. :return boolean: True if no further hook implementations should be invoked. Stops at first non-None result, see :ref:`firstresult` """ def pytest_runtest_logstart(nodeid, location):
63
64
100
12
51
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_logstart
pytest_runtest_logstart
359
367
359
359
b40f83e527f1a6451b4569bc970c5d86c2bb1a2f
bigcode/the-stack
train
9069be57ae6ac49f184e90ec
train
function
def pytest_generate_tests(metafunc): """ generate (multiple) parametrized calls to a test function."""
def pytest_generate_tests(metafunc):
""" generate (multiple) parametrized calls to a test function."""
non-None result, see :ref:`firstresult` """ @hookspec(firstresult=True) def pytest_pyfunc_call(pyfuncitem): """ call underlying test function. Stops at first non-None result, see :ref:`firstresult` """ def pytest_generate_tests(metafunc):
63
64
23
9
54
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_generate_tests
pytest_generate_tests
307
308
307
307
551f103e67178eb406a01dfbb97c6f02d8dbd08b
bigcode/the-stack
train
8d27fc20324430e2c9c436c6
train
function
def pytest_collection_finish(session): """ called after collection has been performed and modified. :param _pytest.main.Session session: the pytest session object """
def pytest_collection_finish(session):
""" called after collection has been performed and modified. :param _pytest.main.Session session: the pytest session object """
may filter or re-order the items in-place. :param _pytest.main.Session session: the pytest session object :param _pytest.config.Config config: pytest config object :param List[_pytest.nodes.Item] items: list of item objects """ def pytest_collection_finish(session):
63
64
33
6
57
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collection_finish
pytest_collection_finish
211
215
211
211
ee1a794e15528f093b670c7a4b7414423f1f58e6
bigcode/the-stack
train
d4999430050d21337aed1af7
train
function
def pytest_runtest_logfinish(nodeid, location): """ signal the complete finish of running a single test item. This hook will be called **after** :func:`pytest_runtest_setup`, :func:`pytest_runtest_call` and :func:`pytest_runtest_teardown` hooks. :param str nodeid: full id of the item :param locati...
def pytest_runtest_logfinish(nodeid, location):
""" signal the complete finish of running a single test item. This hook will be called **after** :func:`pytest_runtest_setup`, :func:`pytest_runtest_call` and :func:`pytest_runtest_teardown` hooks. :param str nodeid: full id of the item :param location: a triple of ``(filename, linenum, testname)`...
_call` and :func:`pytest_runtest_teardown` hooks. :param str nodeid: full id of the item :param location: a triple of ``(filename, linenum, testname)`` """ def pytest_runtest_logfinish(nodeid, location):
63
64
101
12
51
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_runtest_logfinish
pytest_runtest_logfinish
370
378
370
370
d6280fafa096cad1b5aafb60f35717d5725eff7c
bigcode/the-stack
train
6a00b52186cc43f53e91f0bd
train
function
@hookspec(firstresult=True) def pytest_report_from_serializable(config, data): """ Restores a report object previously serialized with pytest_report_to_serializable(). """
@hookspec(firstresult=True) def pytest_report_from_serializable(config, data):
""" Restores a report object previously serialized with pytest_report_to_serializable(). """
pec(firstresult=True) def pytest_report_to_serializable(config, report): """ Serializes the given report object into a data structure suitable for sending over the wire, e.g. converted to JSON. """ @hookspec(firstresult=True) def pytest_report_from_serializable(config, data):
63
64
36
17
46
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_report_from_serializable
pytest_report_from_serializable
421
425
421
422
c12a641dae67efb419bb15593ea1164ee3406640
bigcode/the-stack
train
4aff4a85314cf863fa041d65
train
function
@hookspec(historic=True) def pytest_addhooks(pluginmanager): """called at plugin registration time to allow adding new hooks via a call to ``pluginmanager.add_hookspecs(module_or_class, prefix)``. :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager .. note:: This ho...
@hookspec(historic=True) def pytest_addhooks(pluginmanager):
"""called at plugin registration time to allow adding new hooks via a call to ``pluginmanager.add_hookspecs(module_or_class, prefix)``. :param _pytest.config.PytestPluginManager pluginmanager: pytest plugin manager .. note:: This hook is incompatible with ``hookwrapper=True``. """
from _pytest.config import Config from _pytest.main import Session from _pytest.reports import BaseReport hookspec = HookspecMarker("pytest") # ------------------------------------------------------------------------- # Initialization hooks called for every plugin # -----------------------------------------...
63
64
84
15
48
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_addhooks
pytest_addhooks
28
38
28
29
e49fd1513b9a72afba99ddc5a4bdcf01797c4cda
bigcode/the-stack
train
0e9df2c6330994c8f7389119
train
function
@hookspec(historic=True) def pytest_configure(config): """ Allows plugins and conftest files to perform initial configuration. This hook is called for every plugin and initial conftest file after command line options have been parsed. After that, the hook is called for other conftest files as they...
@hookspec(historic=True) def pytest_configure(config):
""" Allows plugins and conftest files to perform initial configuration. This hook is called for every plugin and initial conftest file after command line options have been parsed. After that, the hook is called for other conftest files as they are imported. .. note:: This hook is ...
The config object is passed around on many internal objects via the ``.config`` attribute or can be retrieved as the ``pytestconfig`` fixture. .. note:: This hook is incompatible with ``hookwrapper=True``. """ @hookspec(historic=True) def pytest_configure(config):
63
64
104
14
49
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_configure
pytest_configure
91
106
91
92
835ce600d5b65dc97c10b2796892f2f87e136604
bigcode/the-stack
train
0988b25abcca34d3087b7862
train
function
def pytest_itemcollected(item): """ we just collected a test item. """
def pytest_itemcollected(item):
""" we just collected a test item. """
needs to have the specified ``parent`` as a parent. :param path: a :py:class:`py.path.local` - the path to collect """ # logging hooks for collection def pytest_collectstart(collector): """ collector starts collecting. """ def pytest_itemcollected(item):
63
64
17
7
56
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_itemcollected
pytest_itemcollected
256
257
256
256
5709904b691af9d027afec3fe766656018050f0e
bigcode/the-stack
train
4e406973569490832ab06fb2
train
function
def pytest_unconfigure(config): """ called before test process is exited. :param _pytest.config.Config config: pytest config object """
def pytest_unconfigure(config):
""" called before test process is exited. :param _pytest.config.Config config: pytest config object """
(session, exitstatus): """ called after whole test run finished, right before returning the exit status to the system. :param _pytest.main.Session session: the pytest session object :param int exitstatus: the status which pytest will return to the system """ def pytest_unconfigure(config):
63
64
30
6
57
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_unconfigure
pytest_unconfigure
475
479
475
475
3b2e698224bb2b20481945a2f8f6ac8bce1f2470
bigcode/the-stack
train
08141a0753bc0eaeea8d8466
train
function
def pytest_report_header(config, startdir): """ return a string or list of strings to be displayed as header info for terminal reporting. :param _pytest.config.Config config: pytest config object :param startdir: py.path object with the starting dir .. note:: Lines returned by a plugin are di...
def pytest_report_header(config, startdir):
""" return a string or list of strings to be displayed as header info for terminal reporting. :param _pytest.config.Config config: pytest config object :param startdir: py.path object with the starting dir .. note:: Lines returned by a plugin are displayed before those of plugins which ...
itself might be changed/removed without warning in any future pytest release. If you find this hook useful, please share your feedback opening an issue. """ # ------------------------------------------------------------------------- # hooks for influencing reporting (invoked from _pytest_termina...
63
64
156
9
54
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_report_header
pytest_report_header
542
560
542
542
1104d9b36d0c04c554c561be9c53f9591e480f8c
bigcode/the-stack
train
a5baf42a8c577751ea9e600f
train
function
@hookspec(firstresult=True) def pytest_pyfunc_call(pyfuncitem): """ call underlying test function. Stops at first non-None result, see :ref:`firstresult` """
@hookspec(firstresult=True) def pytest_pyfunc_call(pyfuncitem):
""" call underlying test function. Stops at first non-None result, see :ref:`firstresult` """
pytest_pycollect_makeitem(collector, name, obj): """ return custom item/collector for a python object in a module, or None. Stops at first non-None result, see :ref:`firstresult` """ @hookspec(firstresult=True) def pytest_pyfunc_call(pyfuncitem):
63
64
40
16
47
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_pyfunc_call
pytest_pyfunc_call
300
304
300
301
adfa9d01cbe9f6f5ffce709b21a596c0131dd05b
bigcode/the-stack
train
53f52fc8136a78bec7b78e33
train
function
@hookspec(firstresult=True) def pytest_fixture_setup(fixturedef, request): """ performs fixture setup execution. :return: The return value of the call to the fixture function Stops at first non-None result, see :ref:`firstresult` .. note:: If the fixture function returns None, other implement...
@hookspec(firstresult=True) def pytest_fixture_setup(fixturedef, request):
""" performs fixture setup execution. :return: The return value of the call to the fixture function Stops at first non-None result, see :ref:`firstresult` .. note:: If the fixture function returns None, other implementations of this hook function will continue to be called, according ...
pec(firstresult=True) def pytest_report_from_serializable(config, data): """ Restores a report object previously serialized with pytest_report_to_serializable(). """ # ------------------------------------------------------------------------- # Fixture related hooks # --------------------------------------...
63
64
99
17
46
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_fixture_setup
pytest_fixture_setup
433
445
433
434
f9ee9d4fd834fd87f3242bae47ed3f9b7a2347e2
bigcode/the-stack
train
462480f90e1eca5e7c80b2d2
train
function
def pytest_collectreport(report): """ collector finished collecting. """
def pytest_collectreport(report):
""" collector finished collecting. """
a :py:class:`py.path.local` - the path to collect """ # logging hooks for collection def pytest_collectstart(collector): """ collector starts collecting. """ def pytest_itemcollected(item): """ we just collected a test item. """ def pytest_collectreport(report):
63
64
13
6
57
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_collectreport
pytest_collectreport
260
261
260
260
3c2530914c1347aaea74eaaae76f8c724c8b910a
bigcode/the-stack
train
d39f19245a06c0aa40213ce1
train
function
def pytest_assertion_pass(item, lineno, orig, expl): """ **(Experimental)** .. versionadded:: 5.0 Hook called whenever an assertion *passes*. Use this hook to do some processing after a passing assertion. The original assertion information is available in the `orig` string and the pytest ...
def pytest_assertion_pass(item, lineno, orig, expl):
""" **(Experimental)** .. versionadded:: 5.0 Hook called whenever an assertion *passes*. Use this hook to do some processing after a passing assertion. The original assertion information is available in the `orig` string and the pytest introspected assertion information is available in th...
strings will be joined by newlines but any newlines *in* a string will be escaped. Note that all but the first line will be indented slightly, the intention is for the first line to be a summary. :param _pytest.config.Config config: pytest config object """ def pytest_assertion_pass(item, lineno, ori...
79
80
268
14
65
xinbinhuang/pytest
src/_pytest/hookspec.py
Python
pytest_assertion_pass
pytest_assertion_pass
499
534
499
499
61cad70b4e220804f8668686d90d5c00af7ebe9b
bigcode/the-stack
train
b1c5d86df7ecbb94ba476479
train
class
class TestRotClass: def test_rot_n(self): with pytest.raises(ValueError): rotN(-26, '') def test_rot_value(self): assert rotN(1, 'ABC xyz') == 'BCD yza'
class TestRotClass:
def test_rot_n(self): with pytest.raises(ValueError): rotN(-26, '') def test_rot_value(self): assert rotN(1, 'ABC xyz') == 'BCD yza'
#!/usr/bin/env python import pytest from stegolib.main import * class TestRotClass:
21
64
51
5
16
oleyka/stegolib
tests/test_rot.py
Python
TestRotClass
TestRotClass
7
13
7
7
d19672fa5732b46ee38049d03d448cc8f1817782
bigcode/the-stack
train
2b418d79cf53f8a70e04e4d3
train
class
@type_checked class StellarValueExt: """ XDR Source Code:: union switch (StellarValueType v) { case STELLAR_VALUE_BASIC: void; case STELLAR_VALUE_SIGNED: LedgerCloseValueSignature lcValueSignature; } """ def __init...
@type_checked class StellarValueExt:
""" XDR Source Code:: union switch (StellarValueType v) { case STELLAR_VALUE_BASIC: void; case STELLAR_VALUE_SIGNED: LedgerCloseValueSignature lcValueSignature; } """ def __init__( self, v: StellarV...
# This is an automatically generated file. # DO NOT EDIT or your changes may be overwritten import base64 from xdrlib import Packer, Unpacker from ..type_checked import type_checked from .ledger_close_value_signature import LedgerCloseValueSignature from .stellar_value_type import StellarValueType __all__ = ["Stellar...
83
169
566
9
74
Shaptic/py-stellar-base
stellar_sdk/xdr/stellar_value_ext.py
Python
StellarValueExt
StellarValueExt
13
85
13
14
2326cbe11726ab2fd9430a99f6482f0bf37d6158
bigcode/the-stack
train
fdd9559960f594d9e0a3834e
train
class
class Solution: def searchRange(self, nums: List[int], target: int) -> List[int]: if len(nums)==1 and nums[0]==target: return [0,0] low=0 high=len(nums)-1 temp=None while low<=high: mid=(high+low)//2 ...
class Solution:
def searchRange(self, nums: List[int], target: int) -> List[int]: if len(nums)==1 and nums[0]==target: return [0,0] low=0 high=len(nums)-1 temp=None while low<=high: mid=(high+low)//2 if target...
# -*- coding: utf-8 -*- """ Created on Fri Aug 7 19:06:01 2020 @author: abhi0 """ class Solution:
37
75
252
3
34
amukher3/Problem_solutions
LeetCode_FirstAndLastPositionInSortedArray.py
Python
Solution
Solution
8
53
8
8
6cd33cd0638a70cb5772e9576b3ca06d97d8b990
bigcode/the-stack
train
f0c0b72460309e0c3461e894
train
function
def ll_deepcopy(root): node_map = {} cur_node = root ret = id(root) # generate and store deepcopies and links of each node while cur_node: cur_id = id(cur_node) node_map[cur_id] = (cur_node.deepcopy(), id(cur_node.next), id(cur_node.rand_link)) cur_node = cur_node.next n...
def ll_deepcopy(root):
node_map = {} cur_node = root ret = id(root) # generate and store deepcopies and links of each node while cur_node: cur_id = id(cur_node) node_map[cur_id] = (cur_node.deepcopy(), id(cur_node.next), id(cur_node.rand_link)) cur_node = cur_node.next node_map[id(None)] = (No...
def describe_list(root): while root: print("{} || val: {} | next: {} | rand: {}".format(id(root), root.val, id(root.next), id(root.rand_link))) root = root.next print("{} || None".format(id(None))) #### def ll_deepcopy(root):
64
64
160
7
57
whoophee/DCP
131.py
Python
ll_deepcopy
ll_deepcopy
38
56
38
38
fae8612957de2c1b68a866b6d53c1bfbc6e20c8d
bigcode/the-stack
train
58a1804df2fd44c96f4a8691
train
class
class LinkedList: def deepcopy(self): return LinkedList(self.val) def __init__(self, val = None, next = None, rand_link = None): self.val = val self.next = next self.rand_link = rand_link
class LinkedList:
def deepcopy(self): return LinkedList(self.val) def __init__(self, val = None, next = None, rand_link = None): self.val = val self.next = next self.rand_link = rand_link
# memory address to uniquely identify objects or write a hash function specific # to the object. # # Sample linked list: # a -> b -> c # Random links: # a -> c # b -> a # c -> b #### # Makeshift class for this problem class LinkedList:
64
64
56
4
59
whoophee/DCP
131.py
Python
LinkedList
LinkedList
18
24
18
18
6b942f1be42de792419fb932f522e3c436ed92d8
bigcode/the-stack
train
17f80a89288dd64352ad8b24
train
function
def describe_list(root): while root: print("{} || val: {} | next: {} | rand: {}".format(id(root), root.val, id(root.next), id(root.rand_link))) root = root.next print("{} || None".format(id(None)))
def describe_list(root):
while root: print("{} || val: {} | next: {} | rand: {}".format(id(root), root.val, id(root.next), id(root.rand_link))) root = root.next print("{} || None".format(id(None)))
self.val = val self.next = next self.rand_link = rand_link c = LinkedList(5) b = LinkedList(4, c) a = LinkedList(3, b, c) c.rand_link = b b.rand_link = a def describe_list(root):
64
64
56
5
58
whoophee/DCP
131.py
Python
describe_list
describe_list
32
36
32
32
d5e30abb7d0fd670564a917ba10d49aeeaac01c8
bigcode/the-stack
train
c03145d6509c114c3ea1c189
train
class
class ImageFileDescriptor(FileDescriptor): """ Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate. """ def __set__(self, instance, value): previous_file = instance.__dict__.get(self.field....
class ImageFileDescriptor(FileDescriptor):
""" Just like the FileDescriptor, but for ImageFields. The only difference is assigning the width/height to the width_field/height_field, if appropriate. """ def __set__(self, instance, value): previous_file = instance.__dict__.get(self.field.name) super(ImageFileDescriptor, se...
, but can probably be removed once form_for_instance # is gone. ModelForm uses a different method to check for an existing file. if 'initial' in kwargs: defaults['required'] = False defaults.update(kwargs) return super(FileField, self).formfield(**defaults) class ImageFi...
70
70
236
7
63
sainjusajan/django-oscar
oscar/lib/python2.7/site-packages/django/db/models/fields/files.py
Python
ImageFileDescriptor
ImageFileDescriptor
358
377
358
358
1d189a3cee137cfac9ed3b23eab2195aba4c1b74
bigcode/the-stack
train
2796b36d2d3715dbd517bc19
train
class
class FieldFile(File): def __init__(self, instance, field, name): super(FieldFile, self).__init__(None, name) self.instance = instance self.field = field self.storage = field.storage self._committed = True def __eq__(self, other): # Older code may be exp...
class FieldFile(File):
def __init__(self, instance, field, name): super(FieldFile, self).__init__(None, name) self.instance = instance self.field = field self.storage = field.storage self._committed = True def __eq__(self, other): # Older code may be expecting FileField values ...
import datetime import os import posixpath import warnings from django import forms from django.core import checks from django.core.files.base import File from django.core.files.images import ImageFile from django.core.files.storage import default_storage from django.db.models import signals from django.db....
111
256
863
5
106
sainjusajan/django-oscar
oscar/lib/python2.7/site-packages/django/db/models/fields/files.py
Python
FieldFile
FieldFile
19
137
19
19
9a1f49d55d0d403fdb15be92273a284db3fd9c21
bigcode/the-stack
train
e9bee82dd198436d58869ec6
train
class
class FileDescriptor(object): """ The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:: >>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size Assigns a fi...
class FileDescriptor(object):
""" The descriptor for the file attribute on the model instance. Returns a FieldFile when accessed so you can do stuff like:: >>> from myapp.models import MyModel >>> instance = MyModel.objects.get(pk=1) >>> instance.file.size Assigns a file object on assignment so you ...
# presence of self._file if hasattr(self, '_file'): self.close() del self.file self.storage.delete(self.name) self.name = None setattr(self.instance, self.field.name, self.name) self._committed = False if save: se...
228
228
762
5
223
sainjusajan/django-oscar
oscar/lib/python2.7/site-packages/django/db/models/fields/files.py
Python
FileDescriptor
FileDescriptor
140
216
140
140
0e60f75dfd623a2f6eaebc461e98b9e4c51ba7c4
bigcode/the-stack
train
4cb23882fd80040c033103c7
train
class
class FileField(Field): # The class to wrap instance attributes in. Accessing the file object off # the instance will always return an instance of attr_class. attr_class = FieldFile # The descriptor to use for accessing the attribute off of the class. descriptor_class = FileDescriptor ...
class FileField(Field): # The class to wrap instance attributes in. Accessing the file object off # the instance will always return an instance of attr_class.
attr_class = FieldFile # The descriptor to use for accessing the attribute off of the class. descriptor_class = FileDescriptor description = _("File") def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs): self._primary_key_set_explicitly = 'primar...
elif isinstance(file, File) and not isinstance(file, FieldFile): file_copy = self.field.attr_class(instance, self.field, file.name) file_copy.file = file file_copy._committed = False instance.__dict__[self.field.name] = file_copy # Finally, because ...
256
256
1,202
35
220
sainjusajan/django-oscar
oscar/lib/python2.7/site-packages/django/db/models/fields/files.py
Python
FileField
FileField
219
355
219
222
946744c8d0889cb82b753dd753f39e75fa429cff
bigcode/the-stack
train
bc6807b547dbba5d2147a9d7
train
class
class ImageFieldFile(ImageFile, FieldFile): def delete(self, save=True): # Clear the image dimensions cache if hasattr(self, '_dimensions_cache'): del self._dimensions_cache super(ImageFieldFile, self).delete(save)
class ImageFieldFile(ImageFile, FieldFile):
def delete(self, save=True): # Clear the image dimensions cache if hasattr(self, '_dimensions_cache'): del self._dimensions_cache super(ImageFieldFile, self).delete(save)
to the post_init signal handles the Model.__init__() cases. # Assignment happening outside of Model.__init__() will trigger the # update right here. if previous_file is not None: self.field.update_dimension_fields(instance, force=True) class ImageFieldFile(ImageFile, FieldFile):...
64
64
53
10
54
sainjusajan/django-oscar
oscar/lib/python2.7/site-packages/django/db/models/fields/files.py
Python
ImageFieldFile
ImageFieldFile
380
385
380
380
3e4c783286d08c12c25c0e3c0f0b818c55c0005d
bigcode/the-stack
train
2667bc026843f4e296c31140
train
class
class ImageField(FileField): attr_class = ImageFieldFile descriptor_class = ImageFileDescriptor description = _("Image") def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, **kwargs): self.width_field, self.height_field = width_field, height_field ...
class ImageField(FileField):
attr_class = ImageFieldFile descriptor_class = ImageFileDescriptor description = _("Image") def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, **kwargs): self.width_field, self.height_field = width_field, height_field super(ImageField, self).__in...
, if appropriate. """ def __set__(self, instance, value): previous_file = instance.__dict__.get(self.field.name) super(ImageFileDescriptor, self).__set__(instance, value) # To prevent recalculating image dimensions when we are instantiating # an object from the database (...
256
256
946
6
250
sainjusajan/django-oscar
oscar/lib/python2.7/site-packages/django/db/models/fields/files.py
Python
ImageField
ImageField
388
495
388
388
d77c3e76ddf2d0f8f0e27fbe5cdcca99791bd18b
bigcode/the-stack
train
be2751ee74370e211e73c6c1
train
class
class DatahubRestHook(BaseHook): conn_name_attr = "datahub_rest_conn_id" default_conn_name = "datahub_rest_default" conn_type = "datahub_rest" hook_name = "DataHub REST Server" def __init__(self, datahub_rest_conn_id: str = default_conn_name) -> None: super().__init__() self.datahub...
class DatahubRestHook(BaseHook):
conn_name_attr = "datahub_rest_conn_id" default_conn_name = "datahub_rest_default" conn_type = "datahub_rest" hook_name = "DataHub REST Server" def __init__(self, datahub_rest_conn_id: str = default_conn_name) -> None: super().__init__() self.datahub_rest_conn_id = datahub_rest_conn...
.exceptions import AirflowException from airflow.hooks.base import BaseHook from datahub.emitter.kafka_emitter import DatahubKafkaEmitter from datahub.emitter.rest_emitter import DatahubRestEmitter from datahub.ingestion.sink.datahub_kafka import KafkaSinkConfig from datahub.metadata.com.linkedin.pegasus2avro.mxe impo...
86
86
288
8
77
OddCN/datahub
metadata-ingestion/src/datahub/integrations/airflow/hooks.py
Python
DatahubRestHook
DatahubRestHook
12
50
12
12
181f6a8add04fc9820be0b31d887774e90c9d74e
bigcode/the-stack
train
dc3923b40fa0dd5fee15bb56
train
class
class DatahubKafkaHook(BaseHook): conn_name_attr = "datahub_kafka_conn_id" default_conn_name = "datahub_kafka_default" conn_type = "datahub_kafka" hook_name = "DataHub Kafka Sink" def __init__(self, datahub_kafka_conn_id: str = default_conn_name) -> None: super().__init__() self.dat...
class DatahubKafkaHook(BaseHook):
conn_name_attr = "datahub_kafka_conn_id" default_conn_name = "datahub_kafka_default" conn_type = "datahub_kafka" hook_name = "DataHub Kafka Sink" def __init__(self, datahub_kafka_conn_id: str = default_conn_name) -> None: super().__init__() self.datahub_kafka_conn_id = datahub_kafka...
_endpoint(self) -> str: conn = self.get_connection(self.datahub_rest_conn_id) host = conn.host if host is None: raise AirflowException("host parameter is required") return host def make_emitter(self) -> DatahubRestEmitter: return DatahubRestEmitter(self._gms_endp...
122
122
407
8
114
OddCN/datahub
metadata-ingestion/src/datahub/integrations/airflow/hooks.py
Python
DatahubKafkaHook
DatahubKafkaHook
53
108
53
53
a737097d7516c60769a297abb085699745812d63
bigcode/the-stack
train
7cd836f79268aab26eac57a8
train
function
def rotateAll(degrees): for s in app.group: s.rotateAngle += degrees
def rotateAll(degrees):
for s in app.group: s.rotateAngle += degrees
def rotateAll(degrees):
6
64
20
6
0
cmu-cs-academy/cpython-cmu-graphics
tests/image_gen/rotated_gradients.py
Python
rotateAll
rotateAll
1
3
1
1
faa5bf061d5b77dbd3c2b400f4c966b29ef2f843
bigcode/the-stack
train