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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1646998ed329d774610de078 | train | function | def hypot(x1, x2):
"""Equivalent to sqrt(x1**2 + x2**2), element-wise.
Parameters
----------
x1 : PrimExpr
Input argument.
x2 : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x1.dtype, "tir.hypot", x1, x2) # ty... | def hypot(x1, x2):
| """Equivalent to sqrt(x1**2 + x2**2), element-wise.
Parameters
----------
x1 : PrimExpr
Input argument.
x2 : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x1.dtype, "tir.hypot", x1, x2) # type: ignore
| argument.
x2 : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x1.dtype, "tir.nextafter", x1, x2) # type: ignore
def hypot(x1, x2):
| 64 | 64 | 97 | 8 | 55 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | hypot | hypot | 917 | 933 | 917 | 917 | 44fd8d4cc253e52553c0fc92528c0edc6978458a | bigcode/the-stack | train |
e2f085246083624d061aecda | train | function | def log2(x):
"""Take log2 of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log2", x)
| def log2(x):
| """Take log2 of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log2", x)
| )
def log(x):
"""Take log of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log", x)
def log2(x):
| 64 | 64 | 61 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | log2 | log2 | 482 | 495 | 482 | 482 | b66e7909c63bd283574939b52bfe7aea733e49f6 | bigcode/the-stack | train |
e3f0d747fe6ba2824a477c2d | train | function | def isfinite(x, span=None):
"""Check if input value is finite.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.isfini... | def isfinite(x, span=None):
| """Check if input value is finite.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.isfinite(x, span) # type: ignore
|
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.isnan(x, span) # type: ignore
def isfinite(x, span=None):
| 64 | 64 | 84 | 8 | 55 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | isfinite | isfinite | 993 | 1,009 | 993 | 993 | 311669eb46ffe9c9f73455241ea396b4875675f5 | bigcode/the-stack | train |
ef9a44153e5e22a0e82b91f2 | train | function | def call_packed(*args, span=None):
"""Build expression by call an external packed function.
The argument to packed function can be Expr or Buffer.
The argument is the corresponding POD type when Expr is presented.
When the argument is Buffer, the corresponding PackedFunc
will recieve an TVMArrayHa... | def call_packed(*args, span=None):
| """Build expression by call an external packed function.
The argument to packed function can be Expr or Buffer.
The argument is the corresponding POD type when Expr is presented.
When the argument is Buffer, the corresponding PackedFunc
will recieve an TVMArrayHandle whose content is valid during ... | [
buf.data,
shape,
strides,
len(buf.shape),
const(0, dtype=buf.dtype),
buf.elem_offset,
]
return Call("handle", Op.get("tir.tvm_stack_make_array"), pack_args, span)
def call_packed(*args, span=None):
| 64 | 64 | 210 | 10 | 54 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | call_packed | call_packed | 45 | 73 | 45 | 45 | c2d46ef365b7b9ed56b0dcdb743208398054fabb | bigcode/the-stack | train |
7a29745614850a4f4da73ddf | train | function | def trunc(x, span=None):
"""Get truncated value of the input.
The truncated value of the scalar x is the
nearest integer i which is closer to zero than x is.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the sourc... | def trunc(x, span=None):
| """Get truncated value of the input.
The truncated value of the scalar x is the
nearest integer i which is closer to zero than x is.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
... | Expr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.ceil(x, span) # type: ignore
def trunc(x, span=None):
| 64 | 64 | 107 | 7 | 56 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | trunc | trunc | 812 | 831 | 812 | 812 | fc6c25c2d82131d4491981e5f3eb6bb8c59ab31a | bigcode/the-stack | train |
d5f2c4a05a071c0d7e2f256c | train | function | def div(a, b, span=None):
"""Compute a / b as in C/C++ semantics.
Parameters
----------
a : PrimExpr
The left hand operand, known to be non-negative.
b : PrimExpr
The right hand operand, known to be non-negative.
span : Optional[Span]
The location of this operator in t... | def div(a, b, span=None):
| """Compute a / b as in C/C++ semantics.
Parameters
----------
a : PrimExpr
The left hand operand, known to be non-negative.
b : PrimExpr
The right hand operand, known to be non-negative.
span : Optional[Span]
The location of this operator in the source.
Returns
... | bound access.
Unlike Select, if_then_else cannot be vectorized
if some lanes in the vector have different conditions.
"""
return _ffi_api._OpIfThenElse(convert(cond), convert(t), convert(f), span) # type: ignore
def div(a, b, span=None):
| 64 | 64 | 139 | 9 | 54 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | div | div | 1,149 | 1,171 | 1,149 | 1,149 | 2f0dea81f0ec5395186bb042b4d0a165d0eb275a | bigcode/the-stack | train |
4b91b32e3fc4116840391170 | train | function | def call_llvm_intrin(dtype, name, *args, span=None):
"""Build expression by calling a llvm intrinsic function
Parameters
----------
dtype : str
The data type of the result.
name : str
The name of the llvm intrinsic function.
args : list
Poistional arguments.
span : O... | def call_llvm_intrin(dtype, name, *args, span=None):
| """Build expression by calling a llvm intrinsic function
Parameters
----------
dtype : str
The data type of the result.
name : str
The name of the llvm intrinsic function.
args : list
Poistional arguments.
span : Optional[Span]
The location of this operator i... |
-------
call : PrimExpr
The call expression.
"""
return Call(
dtype, Op.get("tir.call_extern"), convert((StringImm(func_name),) + args), span=span
)
def call_llvm_intrin(dtype, name, *args, span=None):
| 64 | 64 | 201 | 16 | 48 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | call_llvm_intrin | call_llvm_intrin | 158 | 187 | 158 | 158 | 8497d86de6c6a9abffbaca9eeac34f9ec07ce7c6 | bigcode/the-stack | train |
9e217fbb08c78022e7b100ef | train | function | def indexmod(a, b, span=None):
"""Compute the remainder of indexdiv. a and b are non-negative.
Parameters
----------
a : PrimExpr
The left hand operand, known to be non-negative.
b : PrimExpr
The right hand operand, known to be non-negative.
span : Optional[Span]
The l... | def indexmod(a, b, span=None):
| """Compute the remainder of indexdiv. a and b are non-negative.
Parameters
----------
a : PrimExpr
The left hand operand, known to be non-negative.
b : PrimExpr
The right hand operand, known to be non-negative.
span : Optional[Span]
The location of this operator in the... | Note
----
Use this function to split non-negative indices.
This function may take advantage of operands'
non-negativeness.
"""
return _ffi_api._OpIndexDiv(a, b, span) # type: ignore
def indexmod(a, b, span=None):
| 64 | 64 | 154 | 10 | 53 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | indexmod | indexmod | 1,202 | 1,227 | 1,202 | 1,202 | c02dc955ff65261de9641e1e4d18847025f05939 | bigcode/the-stack | train |
ef995e1d6334ddc4a83aeee0 | train | function | def atan(x):
"""Take atan of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.atan", x)
| def atan(x):
| """Take atan of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.atan", x)
| asinh(x):
"""Take asinh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.asinh", x)
def atan(x):
| 64 | 64 | 58 | 4 | 60 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | atan | atan | 674 | 687 | 674 | 674 | 6c3a612480838979448c58ad00cf27817f290568 | bigcode/the-stack | train |
da8b28d7eb3536758f71e7c5 | train | function | def asinh(x):
"""Take asinh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.asinh", x)
| def asinh(x):
| """Take asinh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.asinh", x)
| def asin(x):
"""Take asin of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.asin", x)
def asinh(x):
| 64 | 64 | 61 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | asinh | asinh | 658 | 671 | 658 | 658 | 1da57d6909dd10e77de5166d5dce1b747bb8b05b | bigcode/the-stack | train |
3984ca4bc92adc5d2efe92a2 | train | function | def ceil(x, span=None):
"""Take ceil of float input x.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.ceil(x, span) ... | def ceil(x, span=None):
| """Take ceil of float input x.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.ceil(x, span) # type: ignore
| Expr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.floor(x, span) # type: ignore
def ceil(x, span=None):
| 64 | 64 | 82 | 7 | 56 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | ceil | ceil | 793 | 809 | 793 | 793 | 3eccd34526b2b2383c885b81363a73185d7ec72e | bigcode/the-stack | train |
b7aa88f409f34295fee1fed2 | train | function | def tanh(x):
"""Take hyperbolic tanh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.tanh", x)
| def tanh(x):
| """Take hyperbolic tanh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.tanh", x)
| """Take gauss error function of the input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.erf", x)
def tanh(x):
| 64 | 64 | 64 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | tanh | tanh | 434 | 447 | 434 | 434 | 8dc6d319467326b62d8d96e654cb94d59e4e5c27 | bigcode/the-stack | train |
047664528d4ec2e2a6c7c9d0 | train | function | def acos(x):
"""Take acos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.acos", x)
| def acos(x):
| """Take acos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.acos", x)
| cosh(x):
"""Take cosh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.cosh", x)
def acos(x):
| 64 | 64 | 59 | 4 | 60 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | acos | acos | 578 | 591 | 578 | 578 | 37b86e5ad0598c63d19035553def80b95334841e | bigcode/the-stack | train |
d5a445eabc963e6e26b37ab1 | train | function | def fmod(x, y):
"""Return the remainder of x divided by y with the same sign as x.
Parameters
----------
x : PrimExpr
Input argument.
y : PrimExpr
Input argument.
Returns
-------
z : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.fmod", x, y)
| def fmod(x, y):
| """Return the remainder of x divided by y with the same sign as x.
Parameters
----------
x : PrimExpr
Input argument.
y : PrimExpr
Input argument.
Returns
-------
z : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.fmod", x, y)
| to be > 0
s : PrimExpr
Integer shift
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin("int32", "tir.q_multiply_shift", x, y, q, s)
def fmod(x, y):
| 64 | 64 | 83 | 7 | 57 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | fmod | fmod | 1,098 | 1,113 | 1,098 | 1,098 | 21bf9d1c5559d34e8ffc5f6d0dd33314edb6b39e | bigcode/the-stack | train |
064dc22d7a54afe85554fa06 | train | function | def rsqrt(x):
"""Take reciprocal of square root of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.rsqrt", x)
| def rsqrt(x):
| """Take reciprocal of square root of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.rsqrt", x)
| def sqrt(x):
"""Take square root of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.sqrt", x)
def rsqrt(x):
| 64 | 64 | 63 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | rsqrt | rsqrt | 741 | 754 | 741 | 741 | ff7b3ef93a1f64a9e3bb1fddd7b158382682bc08 | bigcode/the-stack | train |
cc795d7486278bd55d7a0c22 | train | function | def abs(x, span=None):
"""Get absolute value of the input element-wise.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_a... | def abs(x, span=None):
| """Get absolute value of the input element-wise.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.abs(x, span) # type... |
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.trunc(x, span) # type: ignore
def abs(x, span=None):
| 64 | 64 | 84 | 7 | 56 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | abs | abs | 834 | 850 | 834 | 834 | 4b933d9179bd89f6d5f853417a28e7e410060814 | bigcode/the-stack | train |
0df76933aa22cd62dd3f9bd3 | train | function | def indexdiv(a, b, span=None):
"""Compute floor(a / b) where a and b are non-negative.
Parameters
----------
a : PrimExpr
The left hand operand, known to be non-negative.
b : PrimExpr
The right hand operand, known to be non-negative.
span : Optional[Span]
The location ... | def indexdiv(a, b, span=None):
| """Compute floor(a / b) where a and b are non-negative.
Parameters
----------
a : PrimExpr
The left hand operand, known to be non-negative.
b : PrimExpr
The right hand operand, known to be non-negative.
span : Optional[Span]
The location of this operator in the source.... | res : PrimExpr
The result expression.
Note
----
When operands are integers, returns truncdiv(a, b, span).
"""
return _ffi_api._OpDiv(a, b, span) # type: ignore
def indexdiv(a, b, span=None):
| 64 | 64 | 154 | 10 | 53 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | indexdiv | indexdiv | 1,174 | 1,199 | 1,174 | 1,174 | daab6b195eb06c69212a3ced260e73ac22d8c32f | bigcode/the-stack | train |
340ae795bb62ed4c070b5f93 | train | function | def sin(x):
"""Take sin of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.sin", x)
| def sin(x):
| """Take sin of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.sin", x)
| def acosh(x):
"""Take acos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.acosh", x)
def sin(x):
| 64 | 64 | 58 | 4 | 60 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | sin | sin | 610 | 623 | 610 | 610 | c4dcb8849497be2450419716772c46237f9b2e21 | bigcode/the-stack | train |
783a78962c1cefbab0e71c85 | train | function | def call_extern(dtype, func_name, *args, span=None):
"""Build expression by calling a extern function.
Parameters
----------
dtype : str
The data type of the result.
func_name: str
The extern function name.
args : list
Positional arguments.
span : Optional[Span]
... | def call_extern(dtype, func_name, *args, span=None):
| """Build expression by calling a extern function.
Parameters
----------
dtype : str
The data type of the result.
func_name: str
The extern function name.
args : list
Positional arguments.
span : Optional[Span]
The location of this operator in the source co... | Returns
-------
call : PrimExpr
The call expression.
"""
return Call(
dtype, Op.get("tir.call_pure_extern"), convert((StringImm(func_name),) + args), span
)
def call_extern(dtype, func_name, *args, span=None):
| 64 | 64 | 133 | 15 | 49 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | call_extern | call_extern | 131 | 155 | 131 | 131 | eda6e261b6fc715d96b1fd7a96f354c099e2e000 | bigcode/the-stack | train |
b5724710e86350839b045ce6 | train | function | def call_intrin(dtype, func_name, *args, span=None):
"""Build expression by calling an intrinsic function.
Intrinsics can be overloaded with multiple data types via
the intrinsic translation rule.
Parameters
----------
dtype : str
The data type of the result.
func_name: str
... | def call_intrin(dtype, func_name, *args, span=None):
| """Build expression by calling an intrinsic function.
Intrinsics can be overloaded with multiple data types via
the intrinsic translation rule.
Parameters
----------
dtype : str
The data type of the result.
func_name: str
The intrinsic function name.
args : list
... | function call.
"""
call_args = [_pack_buffer(x) if isinstance(x, Buffer) else x for x in args]
return Call("int32", Op.get("tir.tvm_call_packed"), call_args, span)
def call_intrin(dtype, func_name, *args, span=None):
| 64 | 64 | 132 | 15 | 49 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | call_intrin | call_intrin | 76 | 101 | 76 | 76 | 7558ce73c12da352e31ecb12c99d78761178ce6d | bigcode/the-stack | train |
61efc05b1d340c7639f8efd2 | train | function | def asin(x):
"""Take asin of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.asin", x)
| def asin(x):
| """Take asin of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.asin", x)
| )
def sinh(x):
"""Take sinh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.sinh", x)
def asin(x):
| 64 | 64 | 59 | 4 | 60 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | asin | asin | 642 | 655 | 642 | 642 | bb6561a982e946317c0fe27890277fd0c1bc9533 | bigcode/the-stack | train |
cbe95933018c3cef404f3864 | train | function | def comm_reducer(fcombine, fidentity, name="reduce"):
"""Create a commutative reducer for reduction.
Parameters
----------
fcombine : function(Expr -> Expr -> Expr)
A binary function which takes two Expr as input to return a Expr.
fidentity : function(str -> Expr)
A function which ... | def comm_reducer(fcombine, fidentity, name="reduce"):
| """Create a commutative reducer for reduction.
Parameters
----------
fcombine : function(Expr -> Expr -> Expr)
A binary function which takes two Expr as input to return a Expr.
fidentity : function(str -> Expr)
A function which takes a type string as input to return a const Expr.
... | behavior in C.
"""
return _ffi_api._OpTruncMod(a, b, span) # type: ignore
def floordiv(a, b, span=None):
"""Compute the floordiv of two expressions.
Parameters
----------
a : PrimExpr
The left hand operand
b : PrimExpr
The right hand operand
span : Optional[Span]
... | 256 | 256 | 1,275 | 14 | 241 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | comm_reducer | comm_reducer | 1,326 | 1,476 | 1,326 | 1,326 | 881aac03f1d2cd70846cada7b333a80bd0d22bd5 | bigcode/the-stack | train |
73d5be6e9650f0c91d2b3e24 | train | function | def log10(x):
"""Take log10 of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log10", x)
| def log10(x):
| """Take log10 of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log10", x)
| 2(x):
"""Take log2 of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log2", x)
def log10(x):
| 64 | 64 | 61 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | log10 | log10 | 498 | 511 | 498 | 498 | c8787bdfa920d06eecbe817004527152f1ef0bee | bigcode/the-stack | train |
76837c863cb900c1b5b5c14e | train | function | def floor(x: PrimExprWithOp, span=None):
"""Take floor of float input x.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_... | def floor(x: PrimExprWithOp, span=None):
| """Take floor of float input x.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.floor(x, span) # type: ignore
| 32 or 64 bit integer.
The result is undefined if the input is 0.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin("int32", "tir.clz", x)
def floor(x: PrimExprWithOp, span=None):
| 64 | 64 | 87 | 12 | 52 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | floor | floor | 774 | 790 | 774 | 774 | 9e9216b042c2c04b1a9c62bc59ff4565e4b5c92c | bigcode/the-stack | train |
9bb23974b8793876a13ac22c | train | function | def any(*args, span=None):
"""Create a new experssion of the union of all conditions in the arguments
Parameters
----------
args : list
List of symbolic boolean expressions
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
expr: Ex... | def any(*args, span=None):
| """Create a new experssion of the union of all conditions in the arguments
Parameters
----------
args : list
List of symbolic boolean expressions
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
expr: Expr
Expression
"... | ----------
val : Expr
The returned tir expression, whose data type is int, float or void pointer.
Returns
-------
ret : PrimExpr
The return expression
"""
return call_intrin(val.dtype, "tir.ret", val)
def any(*args, span=None):
| 64 | 64 | 173 | 8 | 56 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | any | any | 242 | 265 | 242 | 242 | 5149f1e80df3c780c1a6bf83c97cbea49dcdb12f | bigcode/the-stack | train |
0742cc9fd6990b3627c5b0c0 | train | function | @tvm._ffi.register_func("tvm.default_trace_action")
def _tvm_default_trace_action(*args):
print(list(args))
| @tvm._ffi.register_func("tvm.default_trace_action")
def _tvm_default_trace_action(*args):
| print(list(args))
| : ignore
for i in range(2, len(args)):
val = _ffi_api._OpAnd(val, args[i], span) # type: ignore
return val
@tvm._ffi.register_func("tvm.default_trace_action")
def _tvm_default_trace_action(*args):
| 64 | 64 | 29 | 24 | 39 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | _tvm_default_trace_action | _tvm_default_trace_action | 295 | 297 | 295 | 296 | 8e230d95d341c5cd58e323b2285d368505fecc5b | bigcode/the-stack | train |
87b492269473dead459850a1 | train | function | def all(*args, span=None):
"""Create a new expression of the intersection of all conditions in the
arguments
Parameters
----------
args : list
List of symbolic boolean expressions
span : Optional[Span]
The location of this operator in the source code.
Returns
-------... | def all(*args, span=None):
| """Create a new expression of the intersection of all conditions in the
arguments
Parameters
----------
args : list
List of symbolic boolean expressions
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
expr: Expr
Exp... | ._OpOr(args[0], args[1], span) # type: ignore
for i in range(2, len(args)):
val = _ffi_api._OpOr(val, args[i], span) # type: ignore
return val
def all(*args, span=None):
| 64 | 64 | 172 | 8 | 55 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | all | all | 268 | 292 | 268 | 268 | a42c752bf0abdb5ccd2a1780d1652f523afed6f1 | bigcode/the-stack | train |
89a4e7282e32c1c964d21c93 | train | function | def tan(x):
"""Take tan of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.tan", x)
| def tan(x):
| """Take tan of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.tan", x)
| log(x + 1) with respect to input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.log1p", x)
def tan(x):
| 64 | 64 | 59 | 4 | 60 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | tan | tan | 530 | 543 | 530 | 530 | 865b41858697d59a30fdd3217c15baaae317d854 | bigcode/the-stack | train |
aecb7c502ebbf61f3ec3fc6e | train | function | def atan2(x1, x2):
"""Take arctan2(x1, x2).
Parameters
----------
x1 : PrimExpr
Input argument.
x2 : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x1.dtype, "tir.atan2", x1, x2)
| def atan2(x1, x2):
| """Take arctan2(x1, x2).
Parameters
----------
x1 : PrimExpr
Input argument.
x2 : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x1.dtype, "tir.atan2", x1, x2)
| """Take atanh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.atanh", x)
def atan2(x1, x2):
| 64 | 64 | 86 | 9 | 55 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | atan2 | atan2 | 706 | 722 | 706 | 706 | aebf0bed2035ff3270fe89cdfdf993c7aaaea57f | bigcode/the-stack | train |
1a3bff9325b8706f669f9be4 | train | function | def popcount(x):
"""Count the number of set bits in input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.popcount", x)
| def popcount(x):
| """Count the number of set bits in input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.popcount", x)
| exponent
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
z : PrimExpr
The result.
"""
return _ffi_api._OpPow(convert(x), convert(y), span) # type: ignore
def popcount(x):
| 64 | 64 | 64 | 5 | 58 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | popcount | popcount | 1,053 | 1,066 | 1,053 | 1,053 | f516d39bff5480e189d8080e1cab54f1cf2f654d | bigcode/the-stack | train |
8f2abba12c5995dbcfdc26c7 | train | function | def nearbyint(x, span=None):
"""Round elements of the array to the nearest integer.
This intrinsic uses llvm.nearbyint instead of llvm.round
which is faster but will results different from te.round.
Notably nearbyint rounds according to the rounding mode,
whereas te.round (llvm.round) ignores that.
... | def nearbyint(x, span=None):
| """Round elements of the array to the nearest integer.
This intrinsic uses llvm.nearbyint instead of llvm.round
which is faster but will results different from te.round.
Notably nearbyint rounds according to the rounding mode,
whereas te.round (llvm.round) ignores that.
For differences between t... |
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.round(x, span) # type: ignore
def nearbyint(x, span=None):
| 64 | 64 | 180 | 8 | 55 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | nearbyint | nearbyint | 872 | 895 | 872 | 872 | 0df3b7526967b7d10f30000566456b446870f476 | bigcode/the-stack | train |
d9f27d1aba63d2ce98916682 | train | function | def acosh(x):
"""Take acos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.acosh", x)
| def acosh(x):
| """Take acos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.acosh", x)
| def acos(x):
"""Take acos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.acos", x)
def acosh(x):
| 64 | 64 | 60 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | acosh | acosh | 594 | 607 | 594 | 594 | 1abd79fe6e0d8b7b1b1a19c24545dd0c977dafa7 | bigcode/the-stack | train |
37fd867c1ee0ae72eb466caf | train | function | def trace(args, trace_action="tvm.default_trace_action"):
"""Trace tensor data at the runtime.
The trace function allows to trace specific tensor at the
runtime. The tracing value should come as last argument.
The trace action should be specified, by default
tvm.default_trace_action is used.
P... | def trace(args, trace_action="tvm.default_trace_action"):
| """Trace tensor data at the runtime.
The trace function allows to trace specific tensor at the
runtime. The tracing value should come as last argument.
The trace action should be specified, by default
tvm.default_trace_action is used.
Parameters
----------
args : list of Expr or Buffer... | = _ffi_api._OpAnd(val, args[i], span) # type: ignore
return val
@tvm._ffi.register_func("tvm.default_trace_action")
def _tvm_default_trace_action(*args):
print(list(args))
def trace(args, trace_action="tvm.default_trace_action"):
| 66 | 66 | 221 | 13 | 53 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | trace | trace | 300 | 329 | 300 | 300 | 3d4467999fd2b1042c2a82684bc818761e625ffa | bigcode/the-stack | train |
e084a4660e59b6a9e129e15e | train | function | def _pack_buffer(buf, span=None):
"""Build intrinsics that packs the buffer."""
shape = Call("handle", "tir.tvm_stack_make_shape", buf.shape, span)
strides = Call("handle", "tir.tvm_stack_make_shape", buf.strides, span) if buf.strides else 0
pack_args = [
buf.data,
shape,
strides... | def _pack_buffer(buf, span=None):
| """Build intrinsics that packs the buffer."""
shape = Call("handle", "tir.tvm_stack_make_shape", buf.shape, span)
strides = Call("handle", "tir.tvm_stack_make_shape", buf.strides, span) if buf.strides else 0
pack_args = [
buf.data,
shape,
strides,
len(buf.shape),
... | .ir.base import Span
from tvm.runtime import convert, const
from tvm.ir import Array, Op
from .buffer import Buffer
from .expr import Call, PrimExprWithOp, StringImm, Var, CommReducer
from . import _ffi_api
def _pack_buffer(buf, span=None):
| 64 | 64 | 126 | 9 | 54 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | _pack_buffer | _pack_buffer | 30 | 42 | 30 | 30 | dfc1278a520838ab7c2cfa517ca6310836c30a39 | bigcode/the-stack | train |
dbab8fa02245cb5868b43734 | train | function | def exp2(x):
"""Calculate 2**x
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.exp2", x)
| def exp2(x):
| """Calculate 2**x
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.exp2", x)
|
def exp(x):
"""Take exponential of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.exp", x)
def exp2(x):
| 64 | 64 | 60 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | exp2 | exp2 | 386 | 399 | 386 | 386 | bc699729cffbd53db1c511c2fcb0958438019a14 | bigcode/the-stack | train |
4512c105f8a05fb89f940c52 | train | function | def cosh(x):
"""Take cosh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.cosh", x)
| def cosh(x):
| """Take cosh of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.cosh", x)
| )
def cos(x):
"""Take cos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.cos", x)
def cosh(x):
| 64 | 64 | 61 | 5 | 59 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | cosh | cosh | 562 | 575 | 562 | 562 | f4c8f282ffdd33c840ff7c669bdb7ffe79e34613 | bigcode/the-stack | train |
3e7091a317964233a650d3ae | train | function | def cos(x):
"""Take cos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.cos", x)
| def cos(x):
| """Take cos of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.cos", x)
| )
def tan(x):
"""Take tan of input x.
Parameters
----------
x : PrimExpr
Input argument.
Returns
-------
y : PrimExpr
The result.
"""
return call_intrin(x.dtype, "tir.tan", x)
def cos(x):
| 64 | 64 | 58 | 4 | 60 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | cos | cos | 546 | 559 | 546 | 546 | 5db83bc980c3f93de2d8cb3d5ea1a4c8aa5a98f2 | bigcode/the-stack | train |
6088c31c97421c9f7453f6d8 | train | function | def min_value(dtype, span=None):
"""minimum value of dtype
Parameters
----------
dtype : str
The data type.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
value : tvm.Expr
The minimum value of dtype.
"""
return _... | def min_value(dtype, span=None):
| """minimum value of dtype
Parameters
----------
dtype : str
The data type.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
value : tvm.Expr
The minimum value of dtype.
"""
return _ffi_api.min_value(dtype, span) #... | = [_pack_buffer(x) if isinstance(x, Buffer) else x for x in args]
call_args.insert(0, trace_action)
return tvm.tir.Call(args[-1].dtype, Op.get("tir.tvm_call_trace_packed"), call_args)
def min_value(dtype, span=None):
| 64 | 64 | 86 | 8 | 56 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | min_value | min_value | 332 | 348 | 332 | 332 | fc50048ccd5ae8f600c39ce4842a1d780d32680b | bigcode/the-stack | train |
b48f96af767ceca580c5a0da | train | function | def floormod(a, b, span=None):
"""Compute the floormod of two expressions.
Parameters
----------
a : PrimExpr
The left hand operand
b : PrimExpr
The right hand operand
span : Optional[Span]
The location of this operator in the source.
Returns
-------
res :... | def floormod(a, b, span=None):
| """Compute the floormod of two expressions.
Parameters
----------
a : PrimExpr
The left hand operand
b : PrimExpr
The right hand operand
span : Optional[Span]
The location of this operator in the source.
Returns
-------
res : PrimExpr
The result ex... | Optional[Span]
The location of this operator in the source.
Returns
-------
res : PrimExpr
The result expression.
"""
return _ffi_api._OpFloorDiv(a, b, span) # type: ignore
def floormod(a, b, span=None):
| 64 | 64 | 107 | 11 | 52 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | floormod | floormod | 1,304 | 1,323 | 1,304 | 1,304 | f72ba27638e4aeada6cc9de9ffceefba7f6be740 | bigcode/the-stack | train |
7ef2230f647fa28a1c625c22 | train | function | def power(x, y, span=None):
"""x power y
Parameters
----------
x : PrimExpr
Input argument.
y : PrimExpr
The exponent
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
z : PrimExpr
The result.
"""
retur... | def power(x, y, span=None):
| """x power y
Parameters
----------
x : PrimExpr
Input argument.
y : PrimExpr
The exponent
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
z : PrimExpr
The result.
"""
return _ffi_api._OpPow(convert(x)... | Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.isinf(x, span) # type: ignore
def power(x, y, span=None):
| 64 | 64 | 97 | 9 | 54 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | power | power | 1,031 | 1,050 | 1,031 | 1,031 | 821f795bb15f1d2ef3ce1aa9deae820fdacc354a | bigcode/the-stack | train |
13bd082e5a3ec19078602118 | train | function | def truncdiv(a, b, span=None):
"""Compute the truncdiv of two expressions.
Parameters
----------
a : PrimExpr
The left hand operand
b : PrimExpr
The right hand operand
span : Optional[Span]
The location of this operator in the source.
Returns
-------
res :... | def truncdiv(a, b, span=None):
| """Compute the truncdiv of two expressions.
Parameters
----------
a : PrimExpr
The left hand operand
b : PrimExpr
The right hand operand
span : Optional[Span]
The location of this operator in the source.
Returns
-------
res : PrimExpr
The result ex... | Note
----
Use this function to split non-negative indices.
This function may take advantage of operands'
non-negativeness.
"""
return _ffi_api._OpIndexMod(a, b, span) # type: ignore
def truncdiv(a, b, span=None):
| 64 | 64 | 123 | 10 | 53 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | truncdiv | truncdiv | 1,230 | 1,253 | 1,230 | 1,230 | f13eb5077aa6df36b605193a69789b15efd32d13 | bigcode/the-stack | train |
0b98acdd17d06c6dba8c5288 | train | function | def round(x, span=None):
"""Round elements of the array to the nearest integer.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
retur... | def round(x, span=None):
| """Round elements of the array to the nearest integer.
Parameters
----------
x : PrimExpr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.round(x, span)... | Expr
Input argument.
span : Optional[Span]
The location of this operator in the source code.
Returns
-------
y : PrimExpr
The result.
"""
return _ffi_api.abs(x, span) # type: ignore
def round(x, span=None):
| 64 | 64 | 85 | 7 | 56 | XiaoSong9905/tvm | python/tvm/tir/op.py | Python | round | round | 853 | 869 | 853 | 853 | bbc575118c95970e924d3cdf5ecbc70628c90b65 | bigcode/the-stack | train |
5a799b233730894d2ad9406b | train | function | def GenTests(api):
builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug'
yield (
api.test('normal_bot') +
api.properties(buildername=builder,
revision='abc123',
path_config='kitchen')
)
builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot'
yield (
api.... | def GenTests(api):
| builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug'
yield (
api.test('normal_bot') +
api.properties(buildername=builder,
revision='abc123',
path_config='kitchen')
)
builder = 'Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Debug-Trybot'
yield (
api.test('trybot') +
... | _path, issue, patchset))
dst = '/'.join(('gs://skia-perf', gs_path, basename))
api.step('upload',
cmd=['gsutil', 'cp', '-a', 'public-read', '-z', 'json', src, dst],
infra_step=True)
def GenTests(api):
| 68 | 68 | 228 | 5 | 63 | jrmuizel/skia-wr | infra/bots/recipes/upload_nano_results.py | Python | GenTests | GenTests | 56 | 87 | 56 | 56 | 55dc8e30fbe9fe8a25a962ac0688e669b5cc380c | bigcode/the-stack | train |
f3a47c36939218d3f78e0195 | train | function | def RunSteps(api):
# Upload the nanobench resuls.
builder_name = api.properties['buildername']
now = api.time.utcnow()
src_path = api.path['cwd'].join(
'perfdata', builder_name, 'data')
results = api.file.glob(
'find results',
'*.json',
cwd=src_path,
test_data=['nanobench_abc123... | def RunSteps(api):
# Upload the nanobench resuls.
| builder_name = api.properties['buildername']
now = api.time.utcnow()
src_path = api.path['cwd'].join(
'perfdata', builder_name, 'data')
results = api.file.glob(
'find results',
'*.json',
cwd=src_path,
test_data=['nanobench_abc123.json'],
infra_step=True)
if len(results) !=... | # Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Recipe for uploading nanobench results.
DEPS = [
'build/file',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/step',
'recipe... | 97 | 104 | 347 | 15 | 82 | jrmuizel/skia-wr | infra/bots/recipes/upload_nano_results.py | Python | RunSteps | RunSteps | 18 | 53 | 18 | 19 | d85fc1e93fa4ee803e197a48f27fc2cb697d55f1 | bigcode/the-stack | train |
457b6999c66e3b33633bc4b4 | train | function | def load_cifar10():
# dataset_url='https://s3.amazonaws.com/fast-ai-imageclas/cifar10.tgz'
# download_url(dataset_url,'.')
# with tarfile.open('./cifar10.tgz', 'r:gz') as tar:
# tar.extractall(path='./data')
# dataset is opened in the folder format in order to understand the distribution by p... | def load_cifar10():
# dataset_url='https://s3.amazonaws.com/fast-ai-imageclas/cifar10.tgz'
# download_url(dataset_url,'.')
# with tarfile.open('./cifar10.tgz', 'r:gz') as tar:
# tar.extractall(path='./data')
# dataset is opened in the folder format in order to understand the distribution by p... | url = "https://s3.amazonaws.com/fast-ai-imageclas/cifar10.tgz"
response = requests.get(url, stream=True)
file = tarfile.open(fileobj=response.raw, mode="r|gz")
file.extractall(path=".")
# ? prints a barplot showing the distribution of training data.
data_url = "cifar10" # dadaset directory
... | folder consists of 50000 images and labels for training and the 'test' folder contains 10000 images and labels for testing.
# ? Normalisation applied to the arrays to help the network to learn properly since all the pixel values are scaled down in such a way that
# ? the overall mean is 1 and standard deviation is 0.... | 176 | 176 | 589 | 92 | 84 | pclubiitk/model-zoo | classification/Xception_TF/dataloader.py | Python | load_cifar10 | load_cifar10 | 18 | 73 | 18 | 23 | 1ad14d4d73f67513d4247b5a0f63484f11032886 | bigcode/the-stack | train |
91d557501c93943cdfad3789 | train | class | class AddStorageProviderResult:
"""
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually."""
def __init__(self):
self.swaggerTypes = {
}
| class AddStorageProviderResult:
| """
NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually."""
def __init__(self):
self.swaggerTypes = {
}
| applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
class AddSto... | 64 | 64 | 49 | 6 | 58 | groupdocs-legacy-sdk/python | groupdocs/models/AddStorageProviderResult.py | Python | AddStorageProviderResult | AddStorageProviderResult | 17 | 28 | 17 | 17 | 067492bdbd6967c493fa5ce845aeef5f85793ef2 | bigcode/the-stack | train |
1670c0cdc05326274e50d85c | train | function | def arg_fixup(s):
if not isinstance(s, str):
return s
try:
import ast
s2 = ast.literal_eval(s)
if isinstance(s2, int):
return s2
except:
pass
try:
s2 = pwn.clookup(s, eval = True)
if isinstance(s2, list) and len(s2) == 1 and isinstance(... | def arg_fixup(s):
| if not isinstance(s, str):
return s
try:
import ast
s2 = ast.literal_eval(s)
if isinstance(s2, int):
return s2
except:
pass
try:
s2 = pwn.clookup(s, eval = True)
if isinstance(s2, list) and len(s2) == 1 and isinstance(s2[0], int):
... | **kwargs)
else:
return AssemblerBlob(r, **kwargs)
if not hidden:
# we need the undecorated function to look up argcount and such
registered[f.func_name] = (f, wrapper)
return wrapper
return deco
def arg_fixup(s):
| 64 | 64 | 113 | 6 | 57 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | arg_fixup | arg_fixup | 147 | 163 | 147 | 147 | 774df4ff1d8fb4ecbceb808c5f985a2c93041160 | bigcode/the-stack | train |
9852df9aad929aba5d87aff8 | train | class | class AssemblerContainer(AssemblerBlock):
def __init__(self, *blocks, **kwargs):
self.arch = kwargs.get('arch')
self.os = kwargs.get('os')
self.blocks = []
for b in pwn.concat_all(list(blocks)):
if isinstance(b, AssemblerBlock):
if self.os == None... | class AssemblerContainer(AssemblerBlock):
| def __init__(self, *blocks, **kwargs):
self.arch = kwargs.get('arch')
self.os = kwargs.get('os')
self.blocks = []
for b in pwn.concat_all(list(blocks)):
if isinstance(b, AssemblerBlock):
if self.os == None: self.os = b.os
if self... | isinstance(text, str):
pwn.die('Trying to create an AssemblerText class, but the text does not have type str.\nThe type is ' + str(type(text)) + ' with the value:\n' + repr(text)[:100])
def __hash__(self):
return hash((self.arch, self.os, self.text))
def __repr__(self):
return 'As... | 111 | 111 | 372 | 8 | 103 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | AssemblerContainer | AssemblerContainer | 56 | 92 | 56 | 56 | 07f73ca782a0e3d0ed1af23c450d179d06cb1fdc | bigcode/the-stack | train |
44715eea4298d96836cf2f81 | train | function | def shellcode_wrapper(f, args, kwargs, avoider):
kwargs = pwn.with_context(**kwargs)
kwargs = pwn.decoutils.kwargs_remover(f, kwargs, pwn.possible_contexts.keys() + ['raw'])
if avoider:
return pwn.avoider(f)(*args, **kwargs)
else:
return f(*args, **kwargs)
| def shellcode_wrapper(f, args, kwargs, avoider):
| kwargs = pwn.with_context(**kwargs)
kwargs = pwn.decoutils.kwargs_remover(f, kwargs, pwn.possible_contexts.keys() + ['raw'])
if avoider:
return pwn.avoider(f)(*args, **kwargs)
else:
return f(*args, **kwargs)
| def __hash__(self):
return hash((self.arch, self.os, tuple(self.blocks)))
def __repr__(self):
return 'AssemblerContainer( %s )' % ', '.join(repr(b) for b in self.blocks)
def shellcode_wrapper(f, args, kwargs, avoider):
| 64 | 64 | 83 | 13 | 51 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | shellcode_wrapper | shellcode_wrapper | 94 | 100 | 94 | 94 | 1f93beadbcdc46c2933c665aea1379bd31dbe5ba | bigcode/the-stack | train |
65bc340c0020ae90fc742bd0 | train | function | def shellcode_reqs(blob = False, hidden = False, avoider = False, **supported_context):
'''A decorator for shellcode functions, which registers the function
with shellcraft and validates the context when the function is called.
Example usage:
@shellcode_reqs(os = ['linux', 'freebsd'], arch = 'i386')
... | def shellcode_reqs(blob = False, hidden = False, avoider = False, **supported_context):
| '''A decorator for shellcode functions, which registers the function
with shellcraft and validates the context when the function is called.
Example usage:
@shellcode_reqs(os = ['linux', 'freebsd'], arch = 'i386')
def sh(os = None):
...
Notice that in this example the decorator will gua... | ( %s )' % ', '.join(repr(b) for b in self.blocks)
def shellcode_wrapper(f, args, kwargs, avoider):
kwargs = pwn.with_context(**kwargs)
kwargs = pwn.decoutils.kwargs_remover(f, kwargs, pwn.possible_contexts.keys() + ['raw'])
if avoider:
return pwn.avoider(f)(*args, **kwargs)
else:
return... | 124 | 124 | 415 | 22 | 102 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | shellcode_reqs | shellcode_reqs | 102 | 145 | 102 | 102 | bbb4c1ad1e56ee3710beaf68309c12b5b2a57554 | bigcode/the-stack | train |
736c7a551c7bb38a2acbcbbd | train | class | class AssemblerText(AssemblerBlock):
def __init__(self, text, **kwargs):
self.arch = kwargs.get('arch')
self.os = kwargs.get('os')
self.text = text
if not isinstance(text, str):
pwn.die('Trying to create an AssemblerText class, but the text does not have type str.\nThe... | class AssemblerText(AssemblerBlock):
| def __init__(self, text, **kwargs):
self.arch = kwargs.get('arch')
self.os = kwargs.get('os')
self.text = text
if not isinstance(text, str):
pwn.die('Trying to create an AssemblerText class, but the text does not have type str.\nThe type is ' + str(type(text)) + ' with... | ' with the value:\n' + repr(blob)[:100])
def __hash__(self):
return hash((self.arch, self.os, self.blob))
def __repr__(self):
return 'AssemberBlob(%d)' % len(self)
class AssemblerText(AssemblerBlock):
| 64 | 64 | 151 | 8 | 56 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | AssemblerText | AssemblerText | 40 | 53 | 40 | 40 | f5e21473b8d561dcc8119a7bab5f05a9fdec1f2a | bigcode/the-stack | train |
c07c15dc35b6917e746e6130 | train | function | def no_support(name, os, arch):
pwn.bug("OS/arch combination (%s, %s) is not supported for %s" % (os, arch, name))
| def no_support(name, os, arch):
| pwn.bug("OS/arch combination (%s, %s) is not supported for %s" % (os, arch, name))
| 2 = pwn.clookup(s, eval = True)
if isinstance(s2, list) and len(s2) == 1 and isinstance(s2[0], int):
return s2[0]
except:
pass
return s
def no_support(name, os, arch):
| 64 | 64 | 40 | 9 | 54 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | no_support | no_support | 165 | 166 | 165 | 165 | b4b32650144a7483b1be027908d068d375ebcd50 | bigcode/the-stack | train |
469ff45e3aa00b2af08074cc | train | function | def indent_shellcode(shellcode):
if isinstance(shellcode, list):
shellcode = '\n'.join(shellcode)
shellcode = [s.strip() for s in shellcode.split('\n')]
shellcode = [(' ' + s if s and s[-1] != ':' else s) for s in shellcode]
return '\n'.join(shellcode)
| def indent_shellcode(shellcode):
| if isinstance(shellcode, list):
shellcode = '\n'.join(shellcode)
shellcode = [s.strip() for s in shellcode.split('\n')]
shellcode = [(' ' + s if s and s[-1] != ':' else s) for s in shellcode]
return '\n'.join(shellcode)
| return s2[0]
except:
pass
return s
def no_support(name, os, arch):
pwn.bug("OS/arch combination (%s, %s) is not supported for %s" % (os, arch, name))
def indent_shellcode(shellcode):
| 64 | 64 | 79 | 7 | 57 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | indent_shellcode | indent_shellcode | 168 | 175 | 168 | 168 | 644b63e14fc536f76cc38f45066636267af4442d | bigcode/the-stack | train |
36c5b5e3a8e7752ba903e532 | train | class | class AssemblerBlock:
def __add__(self, other):
return AssemblerContainer(self, other)
def __radd__(self, other):
return AssemblerContainer(other, self)
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __flat__(self):
return pwn.asm(self)
def __... | class AssemblerBlock:
| def __add__(self, other):
return AssemblerContainer(self, other)
def __radd__(self, other):
return AssemblerContainer(other, self)
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __flat__(self):
return pwn.asm(self)
def __len__(self):
r... | import pwn
registered = {}
# For the benefit of the shellcodes
from pwn import *
from socket import htons
class AssemblerBlock:
| 31 | 64 | 91 | 5 | 25 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | AssemblerBlock | AssemblerBlock | 9 | 23 | 9 | 9 | 20b397a9adb43359bf6e8b820a276995d2454332 | bigcode/the-stack | train |
1e07afddadacefd6d8776441 | train | class | class AssemblerBlob(AssemblerBlock):
def __init__(self, blob, **kwargs):
self.arch = kwargs.get('arch')
self.os = kwargs.get('os')
self.blob = blob
if not isinstance(blob, str):
pwn.die('Trying to create an AssemblerBlob class, but the blob does not have type str.\nThe... | class AssemblerBlob(AssemblerBlock):
| def __init__(self, blob, **kwargs):
self.arch = kwargs.get('arch')
self.os = kwargs.get('os')
self.blob = blob
if not isinstance(blob, str):
pwn.die('Trying to create an AssemblerBlob class, but the blob does not have type str.\nThe type is ' + str(type(blob)) + ' with... | AssemblerContainer(other, self)
def __eq__(self, other):
return self.__dict__ == other.__dict__
def __flat__(self):
return pwn.asm(self)
def __len__(self):
return len(pwn.flat(self))
class AssemblerBlob(AssemblerBlock):
| 64 | 64 | 145 | 8 | 56 | Haabb/pwnfork | pwn/internal/shellcode_helper.py | Python | AssemblerBlob | AssemblerBlob | 25 | 38 | 25 | 25 | 4624627bb62ad7429180233faa69e29284a6744b | bigcode/the-stack | train |
28dafd59d885edd45df665d0 | train | function | def distance_wb(gwr, gws):
shape = gwr.shape
if len(shape) == 4: # conv, out*in*h*w
gwr = gwr.reshape(shape[0], shape[1] * shape[2] * shape[3])
gws = gws.reshape(shape[0], shape[1] * shape[2] * shape[3])
elif len(shape) == 3: # layernorm, C*h*w
gwr = gwr.reshape(shape[0], shape[1] *... | def distance_wb(gwr, gws):
| shape = gwr.shape
if len(shape) == 4: # conv, out*in*h*w
gwr = gwr.reshape(shape[0], shape[1] * shape[2] * shape[3])
gws = gws.reshape(shape[0], shape[1] * shape[2] * shape[3])
elif len(shape) == 3: # layernorm, C*h*w
gwr = gwr.reshape(shape[0], shape[1] * shape[2])
gws = gw... | gw_syn_vec = torch.cat(gw_syn_vec, dim=0)
dis = 1 - torch.sum(gw_real_vec * gw_syn_vec, dim=-1) / (torch.norm(gw_real_vec, dim=-1) * torch.norm(gw_syn_vec, dim=-1) + 0.000001)
return dis
def distance_wb(gwr, gws):
| 82 | 82 | 276 | 10 | 71 | bigdata-inha/FedDC | test_scaffold_.py | Python | distance_wb | distance_wb | 637 | 654 | 637 | 637 | 9564d309a2fa00eeb2214c4da77cc99c0e094307 | bigcode/the-stack | train |
696b489a165ffee081170b8d | train | function | def update_locals(global_model, local_weights, syn_round_dataset,output_clients,device,test_dataset):
last_global = copy.deepcopy(global_model)
criterion = torch.nn.CrossEntropyLoss()
#optimizer = torch.optim.SGD(last_global.parameters(), lr= 0.01, weight_decay=1e-3)
'''
optimizer = torch.opti... | def update_locals(global_model, local_weights, syn_round_dataset,output_clients,device,test_dataset):
| last_global = copy.deepcopy(global_model)
criterion = torch.nn.CrossEntropyLoss()
#optimizer = torch.optim.SGD(last_global.parameters(), lr= 0.01, weight_decay=1e-3)
'''
optimizer = torch.optim.SGD([
{'params': base_params},
{'params': global_model.classifier.parameters(), 'lr':... |
gwr = gwr.reshape(shape[0], shape[1] * shape[2])
gws = gws.reshape(shape[0], shape[1] * shape[2])
elif len(shape) == 2: # linear, out*in
tmp = 'do nothing'
elif len(shape) == 1: # batchnorm/instancenorm, C; groupnorm x, bias
gwr = gwr.reshape(1, shape[0])
gws = gws.resha... | 198 | 198 | 662 | 21 | 176 | bigdata-inha/FedDC | test_scaffold_.py | Python | update_locals | update_locals | 656 | 720 | 656 | 657 | afed1029d91d1a1c43fd623b971dfeab724f614f | bigcode/the-stack | train |
7f6cd8fd72719e3fe427ee5b | train | function | def aggregate_scaffold(global_model,server_controls,total_delta_model, total_delta_controls, num_users,idxs_users):
num_of_selected_users = len(idxs_users)
for delta_controls, delta_models in zip(total_delta_controls,total_delta_model):
for param, control, del_control, del_model in zip(global_model... | def aggregate_scaffold(global_model,server_controls,total_delta_model, total_delta_controls, num_users,idxs_users):
| num_of_selected_users = len(idxs_users)
for delta_controls, delta_models in zip(total_delta_controls,total_delta_model):
for param, control, del_control, del_model in zip(global_model.parameters(), server_controls,
delta_controls, delta_models)... | [train_loss, total_grad,test_class_acc_list,round_indicate_class,accumlate_indicate_class]
#total_list =[]
return total_list,client_indicate_class
def aggregate_scaffold(global_model,server_controls,total_delta_model, total_delta_controls, num_users,idxs_users):
| 64 | 64 | 138 | 25 | 38 | bigdata-inha/FedDC | test_scaffold_.py | Python | aggregate_scaffold | aggregate_scaffold | 593 | 603 | 593 | 594 | ea505055f99f4650b26d0ba60c5d2be8108c97cc | bigcode/the-stack | train |
9c59de7bd9c6abfc9ba6f2fd | train | function | def main_test(args):
start_time = time.time()
now = datetime.datetime.now().strftime('%Y-%m-%d-%H%M%S')
# define paths
logger = SummaryWriter('../logs')
# easydict 사용하는 경우 주석처리
# args = args_parser()
# checkpoint 생성위치
args.save_path = os.path.join(args.save_path, args.exp_folder)
... | def main_test(args):
| start_time = time.time()
now = datetime.datetime.now().strftime('%Y-%m-%d-%H%M%S')
# define paths
logger = SummaryWriter('../logs')
# easydict 사용하는 경우 주석처리
# args = args_parser()
# checkpoint 생성위치
args.save_path = os.path.join(args.save_path, args.exp_folder)
if not os.path.exists... | args_parser
from update_scaffold_ import LocalUpdate, test_inference,test_inference_tsne
from networks import MLP, CNNMnist, CNNFashion_Mnist, CNNCifar, CNNCifar_fedVC, CNNCifar_WS, AlexNet, ConvNet
from utils import aggregate, average_weights_class_normalize, get_dataset, average_weights, eval_smooth, average, exp_de... | 256 | 256 | 5,861 | 5 | 251 | bigdata-inha/FedDC | test_scaffold_.py | Python | main_test | main_test | 43 | 590 | 43 | 43 | 05b3efac46def37388921b4ddbf912327365b164 | bigcode/the-stack | train |
8038ebd07065a2a9f5be4273 | train | function | def match_loss(gw_syn, gw_real, device):
dis = torch.tensor(0.0).to(device)
"""
#if args.dis_metric == 'ours':
for ig in range(len(gw_real)):
gwr = gw_real[ig]
gws = gw_syn[ig]
dis += distance_wb(gwr, gws)
elif args.dis_metric == 'mse':
gw_real_vec = []
g... | def match_loss(gw_syn, gw_real, device):
| dis = torch.tensor(0.0).to(device)
"""
#if args.dis_metric == 'ours':
for ig in range(len(gw_real)):
gwr = gw_real[ig]
gws = gw_syn[ig]
dis += distance_wb(gwr, gws)
elif args.dis_metric == 'mse':
gw_real_vec = []
gw_syn_vec = []
for ig in range(le... | ,total_delta_model):
for param, control, del_control, del_model in zip(global_model.parameters(), server_controls,
delta_controls, delta_models):
# param.data = param.data + del_model.data * num_of_samples / total_samples / num_of_selected_... | 102 | 102 | 340 | 12 | 89 | bigdata-inha/FedDC | test_scaffold_.py | Python | match_loss | match_loss | 604 | 633 | 604 | 604 | a6bd42b8bd91cd8cb8e692c56a4156ba68fe2860 | bigcode/the-stack | train |
6f4c17decd1a11d10f60a51e | train | function | def test_streaming_output_changed() -> None:
changed_digest = Digest(EMPTY_DIGEST.fingerprint, 2)
result = FmtResult(
input=EMPTY_DIGEST,
output=changed_digest,
stdout="stdout",
stderr="stderr",
formatter_name="formatter",
)
assert result.level() == LogLevel.WARN
... | def test_streaming_output_changed() -> None:
| changed_digest = Digest(EMPTY_DIGEST.fingerprint, 2)
result = FmtResult(
input=EMPTY_DIGEST,
output=changed_digest,
stdout="stdout",
stderr="stderr",
formatter_name="formatter",
)
assert result.level() == LogLevel.WARN
assert result.message() == dedent(
... | =False)
assert_expected(per_file_caching=True)
def test_streaming_output_skip() -> None:
result = FmtResult.skip(formatter_name="formatter")
assert result.level() == LogLevel.DEBUG
assert result.message() == "formatter skipped."
def test_streaming_output_changed() -> None:
| 64 | 64 | 101 | 10 | 54 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | test_streaming_output_changed | test_streaming_output_changed | 268 | 285 | 268 | 268 | 78542016ff38c200f635a0d059b4b5517f0adfba | bigcode/the-stack | train |
f1666b9dcaccf00050749247 | train | function | def test_summary(rule_runner: RuleRunner) -> None:
"""Tests that the final summary is correct.
This checks that we:
* Merge multiple results for the same formatter together (when you use
`--per-file-caching`).
* Correctly distinguish between skipped, changed, and did not change.
"""
for... | def test_summary(rule_runner: RuleRunner) -> None:
| """Tests that the final summary is correct.
This checks that we:
* Merge multiple results for the same formatter together (when you use
`--per-file-caching`).
* Correctly distinguish between skipped, changed, and did not change.
"""
fortran_addresses = [
Address("", target_name=... | _runner,
language_target_collection_types=[InvalidTargets],
targets=[make_target()],
result_digest=fortran_digest(rule_runner),
per_file_caching=per_file_caching,
)
assert stderr.strip() == ""
assert_workspace_modified(rule_runner, fortran_formatte... | 98 | 98 | 327 | 12 | 86 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | test_summary | test_summary | 221 | 259 | 221 | 221 | 5da9afc149db85d9619417104dcc08a6ce219764 | bigcode/the-stack | train |
2335a12680dfddbd3aa9e2dc | train | class | class SmalltalkSources(MultipleSourcesField):
pass
| class SmalltalkSources(MultipleSourcesField):
| pass
| RuleRunner, mock_console, run_rule_with_mocks
from pants.util.logging import LogLevel
class FortranSources(MultipleSourcesField):
pass
class FortranTarget(Target):
alias = "fortran"
core_fields = (FortranSources,)
class SmalltalkSources(MultipleSourcesField):
| 63 | 64 | 12 | 9 | 54 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | SmalltalkSources | SmalltalkSources | 37 | 38 | 37 | 37 | ef0ac7542cffb4ce6ff8d3f1dd2404089e370cc2 | bigcode/the-stack | train |
3fabc9435b7a6fa3d3090b0b | train | function | def test_invalid_target_noops(rule_runner: RuleRunner) -> None:
def assert_noops(*, per_file_caching: bool) -> None:
stderr = run_fmt_rule(
rule_runner,
language_target_collection_types=[InvalidTargets],
targets=[make_target()],
result_digest=fortran_digest(ru... | def test_invalid_target_noops(rule_runner: RuleRunner) -> None:
| def assert_noops(*, per_file_caching: bool) -> None:
stderr = run_fmt_rule(
rule_runner,
language_target_collection_types=[InvalidTargets],
targets=[make_target()],
result_digest=fortran_digest(rule_runner),
per_file_caching=per_file_caching,
... | .is_file()
assert fortran_file.read_text() == FORTRAN_FILE.content.decode()
if smalltalk_formatted:
assert smalltalk_file.is_file()
assert smalltalk_file.read_text() == SMALLTALK_FILE.content.decode()
def test_invalid_target_noops(rule_runner: RuleRunner) -> None:
| 64 | 64 | 127 | 15 | 49 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | test_invalid_target_noops | test_invalid_target_noops | 205 | 218 | 205 | 205 | f5521411d949a3bf08504e803669a67937cc2bdc | bigcode/the-stack | train |
d6c59bce81e7c6bb0415fa1e | train | function | def merged_digest(rule_runner: RuleRunner) -> Digest:
return rule_runner.make_snapshot(
{fc.path: fc.content.decode() for fc in (FORTRAN_FILE, SMALLTALK_FILE)}
).digest
| def merged_digest(rule_runner: RuleRunner) -> Digest:
| return rule_runner.make_snapshot(
{fc.path: fc.content.decode() for fc in (FORTRAN_FILE, SMALLTALK_FILE)}
).digest
| `, we still need an
# instance of a Scheduler.
return RuleRunner()
def fortran_digest(rule_runner: RuleRunner) -> Digest:
return rule_runner.make_snapshot({FORTRAN_FILE.path: FORTRAN_FILE.content.decode()}).digest
def merged_digest(rule_runner: RuleRunner) -> Digest:
| 64 | 64 | 45 | 12 | 51 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | merged_digest | merged_digest | 138 | 141 | 138 | 138 | 8c3bd4e47b92c4228440773be88a8718995e33d8 | bigcode/the-stack | train |
cf8be89ae7a0a2ef0eae3308 | train | class | class SmalltalkTargets(MockLanguageTargets):
required_fields = (SmalltalkSources,)
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
return LanguageFmtResults(
(
FmtResult(
input=result_digest,
output=result_... | class SmalltalkTargets(MockLanguageTargets):
| required_fields = (SmalltalkSources,)
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
return LanguageFmtResults(
(
FmtResult(
input=result_digest,
output=result_digest,
stdout="",
... | (
FmtResult(
input=EMPTY_DIGEST,
output=output,
stdout="",
stderr="",
formatter_name="FortranConditionallyDidChange",
),
),
input=EMPTY_DIGEST,
... | 64 | 64 | 107 | 8 | 56 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | SmalltalkTargets | SmalltalkTargets | 82 | 99 | 82 | 82 | 0b65c47f9cdaa493adb87813aecf5a384d222c9c | bigcode/the-stack | train |
7da1c42cf4425d8af9733e0f | train | function | def test_streaming_output_not_changed() -> None:
result = FmtResult(
input=EMPTY_DIGEST,
output=EMPTY_DIGEST,
stdout="stdout",
stderr="stderr",
formatter_name="formatter",
)
assert result.level() == LogLevel.INFO
assert result.message() == dedent(
"""\
... | def test_streaming_output_not_changed() -> None:
| result = FmtResult(
input=EMPTY_DIGEST,
output=EMPTY_DIGEST,
stdout="stdout",
stderr="stderr",
formatter_name="formatter",
)
assert result.level() == LogLevel.INFO
assert result.message() == dedent(
"""\
formatter made no changes.
stdout
... | stdout",
stderr="stderr",
formatter_name="formatter",
)
assert result.level() == LogLevel.WARN
assert result.message() == dedent(
"""\
formatter made changes.
stdout
stderr
"""
)
def test_streaming_output_not_changed() -> None:
| 64 | 64 | 88 | 11 | 53 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | test_streaming_output_not_changed | test_streaming_output_not_changed | 288 | 304 | 288 | 288 | 65adbd53f915199a6e0adcdad16ce29c25ed0003 | bigcode/the-stack | train |
1ed3d6096152323e063b3172 | train | class | class MockLanguageTargets(LanguageFmtTargets, metaclass=ABCMeta):
formatter_name: ClassVar[str]
@abstractmethod
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
pass
| class MockLanguageTargets(LanguageFmtTargets, metaclass=ABCMeta):
| formatter_name: ClassVar[str]
@abstractmethod
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
pass
| tranSources,)
class SmalltalkSources(MultipleSourcesField):
pass
class SmalltalkTarget(Target):
alias = "smalltalk"
core_fields = (SmalltalkSources,)
class InvalidSources(MultipleSourcesField):
pass
class MockLanguageTargets(LanguageFmtTargets, metaclass=ABCMeta):
| 64 | 64 | 47 | 14 | 49 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | MockLanguageTargets | MockLanguageTargets | 50 | 55 | 50 | 50 | 8b548e8a216f8517873913b810636b85415d080f | bigcode/the-stack | train |
8824b31e064fc58dae4baba3 | train | class | class FortranTargets(MockLanguageTargets):
required_fields = (FortranSources,)
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
output = (
result_digest
if any(tgt.address.target_name == "needs_formatting" for tgt in self.targets)
else EMP... | class FortranTargets(MockLanguageTargets):
| required_fields = (FortranSources,)
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
output = (
result_digest
if any(tgt.address.target_name == "needs_formatting" for tgt in self.targets)
else EMPTY_DIGEST
)
return Language... | Sources(MultipleSourcesField):
pass
class MockLanguageTargets(LanguageFmtTargets, metaclass=ABCMeta):
formatter_name: ClassVar[str]
@abstractmethod
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
pass
class FortranTargets(MockLanguageTargets):
| 64 | 64 | 133 | 8 | 55 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | FortranTargets | FortranTargets | 58 | 79 | 58 | 58 | b9ae04a8d627579bc4be41d74e1b10722e0e6300 | bigcode/the-stack | train |
67fad34c3ed2b8c5a3edd1b0 | train | class | class InvalidTargets(MockLanguageTargets):
required_fields = (InvalidSources,)
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
# Note: we return a result that would result in a change so that we can validate that this
# result is not actually returned.
retur... | class InvalidTargets(MockLanguageTargets):
| required_fields = (InvalidSources,)
def language_fmt_results(self, result_digest: Digest) -> LanguageFmtResults:
# Note: we return a result that would result in a change so that we can validate that this
# result is not actually returned.
return LanguageFmtResults(
(
... | =result_digest,
output=result_digest,
stdout="",
stderr="",
formatter_name="SmalltalkDidNotChange",
),
FmtResult.skip(formatter_name="SmalltalkSkipped"),
),
input=EMPTY_DIGEST,
... | 64 | 64 | 121 | 7 | 57 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | InvalidTargets | InvalidTargets | 102 | 120 | 102 | 102 | eb04abd067f6cc728a0068c5b36475d65eb220c3 | bigcode/the-stack | train |
1c439485f60a7aaa8baa64ee | train | function | def run_fmt_rule(
rule_runner: RuleRunner,
*,
language_target_collection_types: List[Type[LanguageFmtTargets]],
targets: List[Target],
result_digest: Digest,
per_file_caching: bool,
) -> str:
with mock_console(rule_runner.options_bootstrapper) as (console, stdio_reader):
union_member... | def run_fmt_rule(
rule_runner: RuleRunner,
*,
language_target_collection_types: List[Type[LanguageFmtTargets]],
targets: List[Target],
result_digest: Digest,
per_file_caching: bool,
) -> str:
| with mock_console(rule_runner.options_bootstrapper) as (console, stdio_reader):
union_membership = UnionMembership({LanguageFmtTargets: language_target_collection_types})
result: Fmt = run_rule_with_mocks(
fmt,
rule_args=[
console,
Targets(targ... | _cls: Type[Target] = FortranTarget
) -> Target:
return target_cls({}, address or Address("", target_name="tests"))
def run_fmt_rule(
rule_runner: RuleRunner,
*,
language_target_collection_types: List[Type[LanguageFmtTargets]],
targets: List[Target],
result_digest: Digest,
per_file_caching: b... | 82 | 83 | 279 | 53 | 29 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | run_fmt_rule | run_fmt_rule | 150 | 189 | 150 | 157 | 20ee45af6e338869ffa4265729fdc5a18d4b0145 | bigcode/the-stack | train |
2a7cb6ce2af230880526eb37 | train | function | def assert_workspace_modified(
rule_runner: RuleRunner, *, fortran_formatted: bool, smalltalk_formatted: bool
) -> None:
fortran_file = Path(rule_runner.build_root, FORTRAN_FILE.path)
smalltalk_file = Path(rule_runner.build_root, SMALLTALK_FILE.path)
if fortran_formatted:
assert fortran_file.is_... | def assert_workspace_modified(
rule_runner: RuleRunner, *, fortran_formatted: bool, smalltalk_formatted: bool
) -> None:
| fortran_file = Path(rule_runner.build_root, FORTRAN_FILE.path)
smalltalk_file = Path(rule_runner.build_root, SMALLTALK_FILE.path)
if fortran_formatted:
assert fortran_file.is_file()
assert fortran_file.read_text() == FORTRAN_FILE.content.decode()
if smalltalk_formatted:
assert sm... | union_membership,
)
assert result.exit_code == 0
assert not stdio_reader.get_stdout()
return stdio_reader.get_stderr()
def assert_workspace_modified(
rule_runner: RuleRunner, *, fortran_formatted: bool, smalltalk_formatted: bool
) -> None:
| 64 | 64 | 125 | 31 | 33 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | assert_workspace_modified | assert_workspace_modified | 192 | 202 | 192 | 194 | ab123795447ed1a331d4a122a90ea6645177364a | bigcode/the-stack | train |
c0873678caa8ea3a6478e8f0 | train | class | class InvalidSources(MultipleSourcesField):
pass
| class InvalidSources(MultipleSourcesField):
| pass
| tranTarget(Target):
alias = "fortran"
core_fields = (FortranSources,)
class SmalltalkSources(MultipleSourcesField):
pass
class SmalltalkTarget(Target):
alias = "smalltalk"
core_fields = (SmalltalkSources,)
class InvalidSources(MultipleSourcesField):
| 63 | 64 | 11 | 8 | 55 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | InvalidSources | InvalidSources | 46 | 47 | 46 | 46 | 042e8c509768220557add242ad078afbc800c6f2 | bigcode/the-stack | train |
6633edc8d2a0fa21bcbb39d2 | train | function | def make_target(
address: Optional[Address] = None, *, target_cls: Type[Target] = FortranTarget
) -> Target:
return target_cls({}, address or Address("", target_name="tests"))
| def make_target(
address: Optional[Address] = None, *, target_cls: Type[Target] = FortranTarget
) -> Target:
| return target_cls({}, address or Address("", target_name="tests"))
| return rule_runner.make_snapshot(
{fc.path: fc.content.decode() for fc in (FORTRAN_FILE, SMALLTALK_FILE)}
).digest
def make_target(
address: Optional[Address] = None, *, target_cls: Type[Target] = FortranTarget
) -> Target:
| 64 | 64 | 45 | 31 | 32 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | make_target | make_target | 144 | 147 | 144 | 146 | dd8b5841d356933a669553d870012d4e8cefdb1a | bigcode/the-stack | train |
ce75e3e8a55126c6cb020e0d | train | function | def test_streaming_output_skip() -> None:
result = FmtResult.skip(formatter_name="formatter")
assert result.level() == LogLevel.DEBUG
assert result.message() == "formatter skipped."
| def test_streaming_output_skip() -> None:
| result = FmtResult.skip(formatter_name="formatter")
assert result.level() == LogLevel.DEBUG
assert result.message() == "formatter skipped."
| """\
+ FortranConditionallyDidChange made changes.
✓ SmalltalkDidNotChange made no changes.
- SmalltalkSkipped skipped.
"""
)
assert_expected(per_file_caching=False)
assert_expected(per_file_caching=True)
def test_streaming_output_skip() -> None:
| 64 | 64 | 43 | 10 | 54 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | test_streaming_output_skip | test_streaming_output_skip | 262 | 265 | 262 | 262 | 47d80bf442ff4d0ca9345aa6a1f9dfa1fe5803d7 | bigcode/the-stack | train |
b3e01a84169f4acb01e4fb24 | train | class | class SmalltalkTarget(Target):
alias = "smalltalk"
core_fields = (SmalltalkSources,)
| class SmalltalkTarget(Target):
| alias = "smalltalk"
core_fields = (SmalltalkSources,)
| _mocks
from pants.util.logging import LogLevel
class FortranSources(MultipleSourcesField):
pass
class FortranTarget(Target):
alias = "fortran"
core_fields = (FortranSources,)
class SmalltalkSources(MultipleSourcesField):
pass
class SmalltalkTarget(Target):
| 64 | 64 | 22 | 6 | 57 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | SmalltalkTarget | SmalltalkTarget | 41 | 43 | 41 | 41 | d0e62772443c147dda911c5419627cf4b396fe2f | bigcode/the-stack | train |
9a2f40a9d041a80f23b9c911 | train | class | class FortranSources(MultipleSourcesField):
pass
| class FortranSources(MultipleSourcesField):
| pass
| Target, Targets
from pants.engine.unions import UnionMembership
from pants.testutil.option_util import create_goal_subsystem
from pants.testutil.rule_runner import MockGet, RuleRunner, mock_console, run_rule_with_mocks
from pants.util.logging import LogLevel
class FortranSources(MultipleSourcesField):
| 64 | 64 | 12 | 9 | 54 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | FortranSources | FortranSources | 28 | 29 | 28 | 28 | b9f66ea78dab1767b6ff7b80bbc5cca54189748e | bigcode/the-stack | train |
318fab41ac006570937f6132 | train | function | def fortran_digest(rule_runner: RuleRunner) -> Digest:
return rule_runner.make_snapshot({FORTRAN_FILE.path: FORTRAN_FILE.content.decode()}).digest
| def fortran_digest(rule_runner: RuleRunner) -> Digest:
| return rule_runner.make_snapshot({FORTRAN_FILE.path: FORTRAN_FILE.content.decode()}).digest
| \n")
@pytest.fixture
def rule_runner() -> RuleRunner:
# While we use `run_rule_with_mocks`, rather than `RuleRunner.request()`, we still need an
# instance of a Scheduler.
return RuleRunner()
def fortran_digest(rule_runner: RuleRunner) -> Digest:
| 63 | 64 | 34 | 13 | 50 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | fortran_digest | fortran_digest | 134 | 135 | 134 | 134 | 5a1357cd2ab435981a1253612dfe8df4cb8f1f2a | bigcode/the-stack | train |
7a37f898bcac9cae82f96cf1 | train | function | @pytest.fixture
def rule_runner() -> RuleRunner:
# While we use `run_rule_with_mocks`, rather than `RuleRunner.request()`, we still need an
# instance of a Scheduler.
return RuleRunner()
| @pytest.fixture
def rule_runner() -> RuleRunner:
# While we use `run_rule_with_mocks`, rather than `RuleRunner.request()`, we still need an
# instance of a Scheduler.
| return RuleRunner()
| _FILE = FileContent("formatted.st", b"y := self size + super size.')\n")
@pytest.fixture
def rule_runner() -> RuleRunner:
# While we use `run_rule_with_mocks`, rather than `RuleRunner.request()`, we still need an
# instance of a Scheduler.
| 64 | 64 | 48 | 43 | 21 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | rule_runner | rule_runner | 127 | 131 | 127 | 130 | c725d0f9511bed387d4b5280aad716ad6a1e8e29 | bigcode/the-stack | train |
05bb177bed3803f860b54913 | train | class | class FortranTarget(Target):
alias = "fortran"
core_fields = (FortranSources,)
| class FortranTarget(Target):
| alias = "fortran"
core_fields = (FortranSources,)
| import UnionMembership
from pants.testutil.option_util import create_goal_subsystem
from pants.testutil.rule_runner import MockGet, RuleRunner, mock_console, run_rule_with_mocks
from pants.util.logging import LogLevel
class FortranSources(MultipleSourcesField):
pass
class FortranTarget(Target):
| 64 | 64 | 22 | 6 | 57 | yoav-orca/pants | src/python/pants/core/goals/fmt_test.py | Python | FortranTarget | FortranTarget | 32 | 34 | 32 | 32 | 2cc5702e9edb8c0f10b3dbecb782d56406566987 | bigcode/the-stack | train |
cac059ae06269a06ea9ae2ee | train | class | class FeatureExtractor:
@staticmethod
def get_melspectrogram(audio, sample_rate):
melspe = librosa.feature.melspectrogram(y=audio, sr=sample_rate)
melspe_db = librosa.power_to_db(melspe, ref=np.max)
# print(f'{melspe_db.shape} -> melspe_db')
return melspe_db
@staticmethod
... | class FeatureExtractor:
@staticmethod
| def get_melspectrogram(audio, sample_rate):
melspe = librosa.feature.melspectrogram(y=audio, sr=sample_rate)
melspe_db = librosa.power_to_db(melspe, ref=np.max)
# print(f'{melspe_db.shape} -> melspe_db')
return melspe_db
@staticmethod
def get_hpss(audio):
audio_harmo... | import librosa
import numpy as np
class FeatureExtractor:
@staticmethod
| 17 | 256 | 915 | 8 | 8 | tinydance/DanceRevolutioNN | extractor.py | Python | FeatureExtractor | FeatureExtractor | 5 | 88 | 5 | 6 | cc72531e1dbf828686f586f525480007a75dac6e | bigcode/the-stack | train |
f523e2dbfbeeec5c7e183e06 | train | function | def load_img(path_to_img):
# reference: tensorflow examples
max_dim = 512
img = tf.io.read_file(path_to_img)
img = tf.image.decode_image(img, channels=3)
img = tf.image.convert_image_dtype(img, tf.float32)
shape = tf.cast(tf.shape(img)[:-1], tf.float32)
long_dim = max(shape)
scale = max_dim ... | def load_img(path_to_img):
# reference: tensorflow examples
| max_dim = 512
img = tf.io.read_file(path_to_img)
img = tf.image.decode_image(img, channels=3)
img = tf.image.convert_image_dtype(img, tf.float32)
shape = tf.cast(tf.shape(img)[:-1], tf.float32)
long_dim = max(shape)
scale = max_dim / long_dim
new_shape = tf.cast(shape * scale, tf.int32)
... | ensor, dtype=np.uint8)
if np.ndim(tensor)>3:
assert tensor.shape[0] == 1
tensor = tensor[0]
return PIL.Image.fromarray(tensor)
#*****************************************************************************80
def load_img(path_to_img):
# reference: tensorflow examples
| 63 | 64 | 131 | 14 | 48 | ramanv1/Neural-Style-Transfer | src/utils.py | Python | load_img | load_img | 35 | 51 | 35 | 37 | e4e2ecb9e5bfef6c5f8fc53b8a404bc6ef99d4ba | bigcode/the-stack | train |
d9b9850ea5e9194a51a53f59 | train | function | def imshow(image, title=None):
if len(image.shape) > 3:
image = tf.squeeze(image, axis=0)
plt.imshow(image)
if title:
plt.title(title)
| def imshow(image, title=None):
| if len(image.shape) > 3:
image = tf.squeeze(image, axis=0)
plt.imshow(image)
if title:
plt.title(title)
| )
scale = max_dim / long_dim
new_shape = tf.cast(shape * scale, tf.int32)
img = tf.image.resize(img, new_shape)
img = img[tf.newaxis, :]
return img
#*****************************************************************************80
def imshow(image, title=None):
| 63 | 64 | 43 | 8 | 54 | ramanv1/Neural-Style-Transfer | src/utils.py | Python | imshow | imshow | 55 | 61 | 55 | 55 | d75a6fb477f7b5078f9af94f74bb2d0bc413d450 | bigcode/the-stack | train |
ba677379b3f56a4adb0653fd | train | function | def getModelIntermediateOutputs(model, layer_names):
model.trainable = False
outputs = [model.get_layer(name).output for name in layer_names]
model = tf.keras.Model([model.input], outputs)
return model
| def getModelIntermediateOutputs(model, layer_names):
| model.trainable = False
outputs = [model.get_layer(name).output for name in layer_names]
model = tf.keras.Model([model.input], outputs)
return model
| *****80
def imshow(image, title=None):
if len(image.shape) > 3:
image = tf.squeeze(image, axis=0)
plt.imshow(image)
if title:
plt.title(title)
#*****************************************************************************80
def getModelIntermediateOutputs(model, layer_names):
| 63 | 64 | 50 | 11 | 51 | ramanv1/Neural-Style-Transfer | src/utils.py | Python | getModelIntermediateOutputs | getModelIntermediateOutputs | 64 | 69 | 64 | 65 | ad5351cafafb5f054928ceea45a62d1baf31540c | bigcode/the-stack | train |
da637815d431e9676773567a | train | function | def tensor_to_image(tensor):
tensor = tensor*255
tensor = np.array(tensor, dtype=np.uint8)
if np.ndim(tensor)>3:
assert tensor.shape[0] == 1
tensor = tensor[0]
return PIL.Image.fromarray(tensor)
| def tensor_to_image(tensor):
| tensor = tensor*255
tensor = np.array(tensor, dtype=np.uint8)
if np.ndim(tensor)>3:
assert tensor.shape[0] == 1
tensor = tensor[0]
return PIL.Image.fromarray(tensor)
| matplotlib as mpl
mpl.rcParams['figure.figsize'] = (12,12)
mpl.rcParams['axes.grid'] = False
import numpy as np
import PIL.Image
import time
import functools
import tensorflow as tf
import time
#*****************************************************************************80
def tensor_to_image(tensor):
... | 63 | 64 | 64 | 7 | 55 | ramanv1/Neural-Style-Transfer | src/utils.py | Python | tensor_to_image | tensor_to_image | 25 | 31 | 25 | 25 | bb9db17d99b025ef5ea3929841acb5818fcfd10c | bigcode/the-stack | train |
765bd084e9d53b04dabd8ac0 | train | class | class ProfileUpdateForm(forms.ModelForm):
class Meta:
model = Profile
exclude = ['user','email'] | class ProfileUpdateForm(forms.ModelForm):
| class Meta:
model = Profile
exclude = ['user','email'] | email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
class NewProjectForm(forms.ModelForm):
class Meta:
model = Project
exclude = ['user']
class ProfileUpdateForm(forms.ModelForm):
| 64 | 64 | 25 | 8 | 56 | demarillacizere/demy-awards | awardsApp/forms.py | Python | ProfileUpdateForm | ProfileUpdateForm | 20 | 23 | 20 | 20 | 5fd2c6c927252c923aebe3db479a80964d6e3c00 | bigcode/the-stack | train |
ad3187f96627aa3bc7c977a9 | train | class | class RegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
| class RegisterForm(UserCreationForm):
| email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
|
from django import forms
from .models import Profile, Project
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class RegisterForm(UserCreationForm):
| 39 | 64 | 41 | 7 | 31 | demarillacizere/demy-awards | awardsApp/forms.py | Python | RegisterForm | RegisterForm | 8 | 13 | 8 | 8 | 7428ae17fac20d627201e36cb0c6752e77492558 | bigcode/the-stack | train |
9663f9379853fa1468831261 | train | class | class NewProjectForm(forms.ModelForm):
class Meta:
model = Project
exclude = ['user']
| class NewProjectForm(forms.ModelForm):
| class Meta:
model = Project
exclude = ['user']
| .auth.models import User
from django.contrib.auth.forms import UserCreationForm
class RegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
class NewProjectForm(forms.ModelForm):
| 64 | 64 | 23 | 8 | 56 | demarillacizere/demy-awards | awardsApp/forms.py | Python | NewProjectForm | NewProjectForm | 15 | 18 | 15 | 15 | 5c57a37cd0d0f48f494dbb045ee0653250c47e7d | bigcode/the-stack | train |
f52d7361f99f08d449280858 | train | class | class PostgreSQL():
def __init__(self, host, port, dbname, user, password, log):
self.host = host
self.port = port
self.dbname = dbname
self.user = user
self.password = password
self.log = log
self.conn = None
def connect(self):
try:
s... | class PostgreSQL():
| def __init__(self, host, port, dbname, user, password, log):
self.host = host
self.port = port
self.dbname = dbname
self.user = user
self.password = password
self.log = log
self.conn = None
def connect(self):
try:
self.conn = psycopg2.... | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import psycopg2
from psycopg2 import sql
from psycopg2 import extras
class PostgreSQL():
| 41 | 256 | 1,136 | 4 | 36 | yujungcheng/website-monitor | common/database.py | Python | PostgreSQL | PostgreSQL | 10 | 227 | 10 | 10 | f9e4eb37560032da98861c65451725d9dca8c74a | bigcode/the-stack | train |
7f2b0e05aa68ba78aa7916ad | train | class | class DescribeGtmAccessStrategyRequest(RpcRequest):
def __init__(self):
RpcRequest.__init__(self, 'Alidns', '2015-01-09', 'DescribeGtmAccessStrategy','alidns')
def get_UserClientIp(self):
return self.get_query_params().get('UserClientIp')
def set_UserClientIp(self,UserClientIp):
self.add_query_param('... | class DescribeGtmAccessStrategyRequest(RpcRequest):
| def __init__(self):
RpcRequest.__init__(self, 'Alidns', '2015-01-09', 'DescribeGtmAccessStrategy','alidns')
def get_UserClientIp(self):
return self.get_query_params().get('UserClientIp')
def set_UserClientIp(self,UserClientIp):
self.add_query_param('UserClientIp',UserClientIp)
def get_StrategyId(se... |
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
from aliyunsdkcore.request import RpcRequest
class DescribeGtmAccessStrategyRequest(RpcRequest):
| 64 | 64 | 170 | 11 | 52 | sdk-team/aliyun-openapi-python-sdk | aliyun-python-sdk-alidns/aliyunsdkalidns/request/v20150109/DescribeGtmAccessStrategyRequest.py | Python | DescribeGtmAccessStrategyRequest | DescribeGtmAccessStrategyRequest | 21 | 42 | 21 | 22 | 9fce375c6c7c2025cc5d42aeff9352afce0bda49 | bigcode/the-stack | train |
1827aaf0f16ccaac80137348 | train | class | class piped_callback(object):
def __init__(self, connection):
adopt_init_args(self, locals())
def __call__(self, message, data, accumulate=False, cached=True):
self.connection.send(
group_args(message=message,
data=data,
accumulate=accumulate,
cached... | class piped_callback(object):
| def __init__(self, connection):
adopt_init_args(self, locals())
def __call__(self, message, data, accumulate=False, cached=True):
self.connection.send(
group_args(message=message,
data=data,
accumulate=accumulate,
cached=cached))
| "WARNING: %s\n" % message
print("", file=log)
for line in str_utils.line_breaker(msg, 72):
print(" " + line, file=log)
#print >> log, str_utils.wordwrap(msg, 79)
class piped_callback(object):
| 64 | 64 | 67 | 6 | 58 | rimmartin/cctbx_project | libtbx/callbacks.py | Python | piped_callback | piped_callback | 117 | 126 | 117 | 117 | 4bce51172e1f256bdcd49382cdff42cddbb66715 | bigcode/the-stack | train |
13451020b34eea51cd5c8b57 | train | class | class manager(object):
def __init__(self):
self.handlers = []
self._pid = os.getpid()
self._log = None
def set_warning_log(self, log):
self._log = log
def add_piped_callback(self, connection):
cb = piped_callback(connection)
self.register_handler(cb)
def register_handler(self, handler... | class manager(object):
| def __init__(self):
self.handlers = []
self._pid = os.getpid()
self._log = None
def set_warning_log(self, log):
self._log = log
def add_piped_callback(self, connection):
cb = piped_callback(connection)
self.register_handler(cb)
def register_handler(self, handler):
assert hasattr(h... | while this is of course intended to be called from Python code,
it is possible to send callbacks from C++ code as well, and this is
implemented in the Phaser software.
"""
from __future__ import absolute_import, division, print_function
import six
from libtbx import str_utils
from libtbx import group_args, adopt_ini... | 92 | 92 | 308 | 4 | 87 | rimmartin/cctbx_project | libtbx/callbacks.py | Python | manager | manager | 73 | 114 | 73 | 73 | cc37b608d1eeabba8df25f7b9b21e676c243f30f | bigcode/the-stack | train |
bc7a5dbce1a2d641925b106b | train | class | class Migration(migrations.Migration):
dependencies = [
('audit', '0002_add_organization'),
]
operations = [
migrations.AlterModelOptions(
name='auditlog',
options={'ordering': ['-created']},
),
]
| class Migration(migrations.Migration):
| dependencies = [
('audit', '0002_add_organization'),
]
operations = [
migrations.AlterModelOptions(
name='auditlog',
options={'ordering': ['-created']},
),
]
| # Generated by Django 2.2.24 on 2021-09-13 22:06
from django.db import migrations
class Migration(migrations.Migration):
| 36 | 64 | 54 | 7 | 28 | yarons/readthedocs.org | readthedocs/audit/migrations/0003_update_ordering.py | Python | Migration | Migration | 6 | 17 | 6 | 7 | deee68a9a1ab4738c0dfea08a0a15776e0108c37 | bigcode/the-stack | train |
0ba547cab2e74bb80c5545b6 | train | class | class Component(tk.Frame, ABC):
_state: State
_component_childs: dict
_child_state: [dict]
_items: dict
__TYPE__: str
__ROOT__= None
def __init__(self, root, state : State =None) -> object:
super().__init__(root)
self.__TYPE__= 'Component'
Component.__ROOT__ = No... | class Component(tk.Frame, ABC):
| _state: State
_component_childs: dict
_child_state: [dict]
_items: dict
__TYPE__: str
__ROOT__= None
def __init__(self, root, state : State =None) -> object:
super().__init__(root)
self.__TYPE__= 'Component'
Component.__ROOT__ = None
if type(root) == tk.Tk... | from abc import abstractmethod, ABC
import tkinter as tk
from .state import State
class Component(tk.Frame, ABC):
| 27 | 135 | 450 | 8 | 18 | Salenia/Orca | core/component.py | Python | Component | Component | 7 | 80 | 7 | 8 | 2dd83227c8ccd3904457cd61d6d25df3246c3479 | bigcode/the-stack | train |
733e8ce52417fb25b1df228d | train | function | @pytest.mark.smokewifi
def test_smokewifi_info():
"""Test --info"""
return_value, out = subprocess.getstatusoutput('meshtastic --info --host meshtastic.local')
assert re.search(r'^Owner', out, re.MULTILINE)
assert re.search(r'^My info', out, re.MULTILINE)
assert re.search(r'^Nodes in mesh', out, re.... | @pytest.mark.smokewifi
def test_smokewifi_info():
| """Test --info"""
return_value, out = subprocess.getstatusoutput('meshtastic --info --host meshtastic.local')
assert re.search(r'^Owner', out, re.MULTILINE)
assert re.search(r'^My info', out, re.MULTILINE)
assert re.search(r'^Nodes in mesh', out, re.MULTILINE)
assert re.search(r'^Preferences', o... | a device setup with wifi.
Need to have run the following on an esp32 device:
meshtastic --set wifi_ssid 'foo' --set wifi_password 'sekret'
"""
import re
import subprocess
import pytest
@pytest.mark.smokewifi
def test_smokewifi_info():
| 64 | 64 | 163 | 15 | 48 | Hydra-Designs/Meshtastic-python | meshtastic/tests/test_smoke_wifi.py | Python | test_smokewifi_info | test_smokewifi_info | 12 | 23 | 12 | 13 | 55b260c40a51f9d30a38c7219e7f289892b63d02 | bigcode/the-stack | train |
b7f861fec40615c973c95eab | train | class | @xr.register_dataset_accessor("argo")
class ArgoAccessor:
"""
Class registered under scope ``argo`` to access a :class:`xarray.Dataset` object.
- Ensure all variables are of the Argo required dtype with:
>>> ds.argo.cast_types()
- Convert a collection of points into a collection o... | @xr.register_dataset_accessor("argo")
class ArgoAccessor:
| """
Class registered under scope ``argo`` to access a :class:`xarray.Dataset` object.
- Ensure all variables are of the Argo required dtype with:
>>> ds.argo.cast_types()
- Convert a collection of points into a collection of profiles:
>>> ds.argo.point2profile()
-... | import os
import sys
import warnings
import numpy as np
import pandas as pd
import xarray as xr
from sklearn import preprocessing
import logging
try:
import gsw
with_gsw = True
except ModuleNotFoundError:
with_gsw = False
from argopy.utilities import (
linear_interpolation_remap,
is_list_equal,
... | 137 | 256 | 18,119 | 13 | 124 | rabernat/argopy | argopy/xarray.py | Python | ArgoAccessor | ArgoAccessor | 31 | 1,922 | 31 | 32 | 95bfc5c4258c7f8e3b96a64ec207738bcf22a91d | bigcode/the-stack | train |
7022a14c3c4b5a31007de178 | train | function | @GameApi(url="by-summoner/{summoner_id}/recent")
def get_games(id):
""" Lookup information on a teams using summoner ids.
:param ids: Ids of summoners on teams to lookup.
:type ids: list or str
:return:
"""
resp = requests.get(get_url(api_url, summoner_id=id))
return resp.json()
| @GameApi(url="by-summoner/{summoner_id}/recent")
def get_games(id):
| """ Lookup information on a teams using summoner ids.
:param ids: Ids of summoners on teams to lookup.
:type ids: list or str
:return:
"""
resp = requests.get(get_url(api_url, summoner_id=id))
return resp.json()
| .decorators import LolApi
from league_py.api import get_url
class GameApi(LolApi):
""" Decorator for MatchListApi """
version = "1.3"
name = "game"
@GameApi(url="by-summoner/{summoner_id}/recent")
def get_games(id):
| 64 | 64 | 83 | 21 | 43 | cguethle/league_py | src/league_py/api/game.py | Python | get_games | get_games | 15 | 24 | 15 | 16 | d0985f3ec488b4ea63effd7c141aabab67f60533 | bigcode/the-stack | train |
f8e4d1ec38d6e401dbe431ae | train | class | class GameApi(LolApi):
""" Decorator for MatchListApi """
version = "1.3"
name = "game"
| class GameApi(LolApi):
| """ Decorator for MatchListApi """
version = "1.3"
name = "game"
| """ Methods and such for accessing the game api.
"""
import requests
from league_py.api.decorators import LolApi
from league_py.api import get_url
class GameApi(LolApi):
| 38 | 64 | 30 | 7 | 30 | cguethle/league_py | src/league_py/api/game.py | Python | GameApi | GameApi | 9 | 12 | 9 | 9 | 614cfcec32920ffeb26a298249a8f7a7353df821 | bigcode/the-stack | train |
c4705840c7bb1db7bc95e1f0 | train | class | class ShortInvestmentdecision(Investmentdecision):
"""
The class that decides to invest in some technologies according to last year simulation year results
Short term invest is done to PV or batteries that are very profitable in the last years.
"""
def __init__(self, reps: Repository):
supe... | class ShortInvestmentdecision(Investmentdecision):
| """
The class that decides to invest in some technologies according to last year simulation year results
Short term invest is done to PV or batteries that are very profitable in the last years.
"""
def __init__(self, reps: Repository):
super().__init__(reps)
self.quickInvestabletech... | from modules.Invest import Investmentdecision
import numpy_financial as npf
from util.repository import Repository
import logging
import pandas as pd
class ShortInvestmentdecision(Investmentdecision):
| 38 | 256 | 1,138 | 8 | 29 | TradeRES/toolbox-amiris-emlab | EMLABPY/modules/short_invest.py | Python | ShortInvestmentdecision | ShortInvestmentdecision | 8 | 109 | 8 | 8 | 2b383a32dadda5739258296ec425625657a275e9 | bigcode/the-stack | train |
4e2dad27bb465d8d638b2ad7 | train | function | def setup(bot):
bot.add_cog(StaffRoles(bot))
| def setup(bot):
| bot.add_cog(StaffRoles(bot))
| + ctx.thread.recipient.mention,
color=0xD0B8D6,
)
)
except KeyError:
await ctx.send(
embed=discord.Embed(description="helper role not found", color=0xD0B8D6)
)
def setup(bot):
| 64 | 64 | 14 | 4 | 60 | sourcery-ai-bot/pingpanapeng | staffrole/staffrole.py | Python | setup | setup | 156 | 157 | 156 | 156 | 012e67805df486c8bd3531076df407b7b8419cab | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.