query
stringlengths
9
9.05k
document
stringlengths
10
222k
negatives
listlengths
19
20
metadata
dict
Perform a bitwise get int op with sign true.
def test_bit_get_int_signed(self): ops = [bitwise_operations.bit_get_int(self.five_255_bin, 0, 8, True)] _, _, result = self.as_connection.operate(self.test_key, ops) expected_result = -1 assert result["255"] == expected_result
[ "def get_bit(cls, int_val: int, idx: int) -> int:\n return (int_val >> idx) & 0x1", "def test_bit_get_int(self):\n ops = [bitwise_operations.bit_get_int(self.five_255_bin, 0, 8, False)]\n\n _, _, result = self.as_connection.operate(self.test_key, ops)\n\n expected_result = 255\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise insert op.
def test_bit_insert(self): value = bytearray([3]) ops = [bitwise_operations.bit_insert(self.test_bin_zeroes, 0, 1, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([3] * 1 + [0] * 5) ...
[ "def test_bit_insert_multiple_bytes_with_offset(self):\n value = bytearray([3] * 3)\n ops = [bitwise_operations.bit_insert(self.test_bin_zeroes, 2, 3, value, None)]\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n expected_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise insert op with multiple bytes and a non 0 offset.
def test_bit_insert_multiple_bytes_with_offset(self): value = bytearray([3] * 3) ops = [bitwise_operations.bit_insert(self.test_bin_zeroes, 2, 3, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = byt...
[ "def test_bit_insert(self):\n value = bytearray([3])\n ops = [bitwise_operations.bit_insert(self.test_bin_zeroes, 0, 1, value, None)]\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n expected_result = bytearray([3] * 1 + [0]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise insert op where byte_offset is out of range for the bitmap being modified. Places 0 untill proper offset is reached.
def test_bit_insert_offset_out_of_range(self): value = bytearray([3]) ops = [bitwise_operations.bit_insert(self.five_255_bin, 9, 1, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([255] ...
[ "def test_bit_insert_multiple_bytes_with_offset(self):\n value = bytearray([3] * 3)\n ops = [bitwise_operations.bit_insert(self.test_bin_zeroes, 2, 3, value, None)]\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n expected_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise insert op where value_byte_size is larger than the bitmap being modified.
def test_bit_insert_value_byte_size_too_large(self): value = bytearray([3] * 6) ops = [bitwise_operations.bit_insert(self.five_255_bin, 0, 6, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytear...
[ "def test_bit_insert_value_byte_size_smaller_than_value(self):\n value = bytearray([3] * 6)\n ops = [bitwise_operations.bit_insert(self.five_255_bin, 0, 2, value, None)]\n\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n exp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise insert op where value_byte_size is smaller than the bitmap being modified.
def test_bit_insert_value_byte_size_smaller_than_value(self): value = bytearray([3] * 6) ops = [bitwise_operations.bit_insert(self.five_255_bin, 0, 2, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result...
[ "def test_bit_insert_value_byte_size_too_large(self):\n value = bytearray([3] * 6)\n ops = [bitwise_operations.bit_insert(self.five_255_bin, 0, 6, value, None)]\n\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n expected_res...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise insert op with a non existent bin.
def test_bit_insert_nonexistent_bin_name(self): value = bytearray([3]) ops = [bitwise_operations.bit_insert("bad_name", 0, 1, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([3]) ...
[ "def test_bit_insert(self):\n value = bytearray([3])\n ops = [bitwise_operations.bit_insert(self.test_bin_zeroes, 0, 1, value, None)]\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n expected_result = bytearray([3] * 1 + [0]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise lscan op.
def test_bit_lscan(self): value = True ops = [bitwise_operations.bit_lscan(self.count_bin, 32, 8, value)] expected_value = 6 _, _, result = self.as_connection.operate(self.test_key, ops) assert result[self.count_bin] == expected_value
[ "def test_bit_lscan_across_bytes(self):\n value = False\n ops = [bitwise_operations.bit_lscan(self.test_bin_ones, 7, 8, value)]\n\n expected_value = 1\n _, _, result = self.as_connection.operate(self.test_key, ops)\n assert result[self.test_bin_ones] == expected_value", "def tes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise lscan op with an offset that causes the scan to search multiple bytes.
def test_bit_lscan_across_bytes(self): value = False ops = [bitwise_operations.bit_lscan(self.test_bin_ones, 7, 8, value)] expected_value = 1 _, _, result = self.as_connection.operate(self.test_key, ops) assert result[self.test_bin_ones] == expected_value
[ "def test_bit_lscan_offset_out_of_range(self):\n value = True\n ops = [bitwise_operations.bit_lscan(self.count_bin, 41, 8, value)]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "def test_bit_lscan(self):\n value = True\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise lscan op with bit_offset outside bitmap.S
def test_bit_lscan_offset_out_of_range(self): value = True ops = [bitwise_operations.bit_lscan(self.count_bin, 41, 8, value)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_lscan_across_bytes(self):\n value = False\n ops = [bitwise_operations.bit_lscan(self.test_bin_ones, 7, 8, value)]\n\n expected_value = 1\n _, _, result = self.as_connection.operate(self.test_key, ops)\n assert result[self.test_bin_ones] == expected_value", "def tes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise lscan op with bit_size larger than bitmap.S
def test_bit_lscan_bit_size_too_large(self): value = True ops = [bitwise_operations.bit_lscan(self.test_bin_ones, 0, 41, value)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_lscan_across_bytes(self):\n value = False\n ops = [bitwise_operations.bit_lscan(self.test_bin_ones, 7, 8, value)]\n\n expected_value = 1\n _, _, result = self.as_connection.operate(self.test_key, ops)\n assert result[self.test_bin_ones] == expected_value", "def tes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise lshift op with offset > bitmap.
def test_bit_lshift_offset_out_of_range(self): ops = [bitwise_operations.bit_lshift(self.test_bin_ones, 41, 8, 1, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_lshift(self, other: Any) -> ColumnOperators:\n\n return self.operate(bitwise_lshift_op, other)", "def lshift(self, value):\n return self.clone().lshift_(value)", "def lshift(b, n):\n return b[n:] + b[:n]", "def shift_left(self, size, a, b, flags = None):\n\t\treturn self.expr(cor...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise lshift op with bit_size > bitmap.
def test_bit_lshift_bit_size_too_large(self): ops = [bitwise_operations.bit_lshift(self.test_bin_ones, 0, 41, 1, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_lshift(self, other: Any) -> ColumnOperators:\n\n return self.operate(bitwise_lshift_op, other)", "def lshift(b, n):\n return b[n:] + b[:n]", "def shift_left(self, size, a, b, flags = None):\n\t\treturn self.expr(core.LLIL_LSL, a.index, b.index, size = size, flags = flags)", "def lshift(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise not op with a bit_size > bitmap.
def test_bit_not_bit_size_too_large(self): ops = [bitwise_operations.bit_not(self.five_255_bin, 0, 41, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_not(data):\n return _make.bitwise_not(data)", "def bitwise_not_(self):\n return math_funcs.bitwise_not(self, self)", "def bitwise_not(x, out=None, **kwargs):\n return _unary_func_helper(x, _npi.bitwise_not, _np.bitwise_not, out=out, **kwargs)", "def not_(bits: int) -> int:\n # The `& ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise or op on multiple bytes.
def test_bit_or_multiple_bytes(self): value = bytearray([8] * 5) ops = [bitwise_operations.bit_or(self.test_bin_ones, 0, 40, 5, value, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([9] * 5) ...
[ "def bitwise_or(x1, x2, out=None, **kwargs):\n return _ufunc_helper(x1, x2, _npi.bitwise_or, _np.bitwise_or, _npi.bitwise_or_scalar, None, out)", "def bit_op(op, a, b):\n initval = 0xFF if op == '&' else 0x00\n if len(b) > len(a):\n #a += bytearray(len(b) - len(a))\n a.extend([initval for i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise or op with bit_offset > bitmap.
def test_bit_or_bit_offset_out_of_range(self): value = bytearray() value.append(8) ops = [bitwise_operations.bit_or(self.test_bin_ones, 41, 8, 1, value, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_or(x1, x2, out=None, **kwargs):\n return _ufunc_helper(x1, x2, _npi.bitwise_or, _np.bitwise_or, _npi.bitwise_or_scalar, None, out)", "def __or__(self, other):\n return BitBoard(self.num | other.num)", "def convert_broadcast_logical_or(node, **kwargs):\n return create_basic_op_node('Or'...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise or op with bit_size > value.
def test_bit_or_bit_size_larger_than_value(self): value = bytearray() value.append(8) ops = [bitwise_operations.bit_or(self.test_bin_ones, 0, 9, 1, value, None)] with pytest.raises(e.InvalidRequest): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_or_bit_size_too_large(self):\n value = bytearray([8] * 6)\n ops = [bitwise_operations.bit_or(self.test_bin_ones, 0, 41, 6, value, None)]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "def or_expr(self, size, a, b, flags ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise or op with bit_size > bitmap.
def test_bit_or_bit_size_too_large(self): value = bytearray([8] * 6) ops = [bitwise_operations.bit_or(self.test_bin_ones, 0, 41, 6, value, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_or_bit_size_larger_than_value(self):\n value = bytearray()\n value.append(8)\n ops = [bitwise_operations.bit_or(self.test_bin_ones, 0, 9, 1, value, None)]\n\n with pytest.raises(e.InvalidRequest):\n self.as_connection.operate(self.test_key, ops)", "def or_expr(...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise or op with a non existent bin.
def test_bit_or_bad_bin_name(self): value = bytearray([8]) ops = [bitwise_operations.bit_or("bad_name", 0, 8, 1, value, None)] with pytest.raises(e.BinNotFound): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_or(x1, x2, out=None, **kwargs):\n return _ufunc_helper(x1, x2, _npi.bitwise_or, _np.bitwise_or, _npi.bitwise_or_scalar, None, out)", "def convert_broadcast_logical_or(node, **kwargs):\n return create_basic_op_node('Or', node, kwargs)", "def test_bit_or_bit_offset_out_of_range(self):\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise rscan op.
def test_bit_rscan(self): value = True ops = [bitwise_operations.bit_rscan(self.count_bin, 32, 8, value)] expected_value = 7 _, _, result = self.as_connection.operate(self.test_key, ops) assert result[self.count_bin] == expected_value
[ "def test_bit_rscan_across_bytes(self):\n value = False\n ops = [bitwise_operations.bit_rscan(self.count_bin, 4, 8, value)]\n\n expected_value = 6\n _, _, result = self.as_connection.operate(self.test_key, ops)\n assert result[self.count_bin] == expected_value", "def test_bit_rs...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise rscan op with an offset that causes the scan to search multiple bytes.
def test_bit_rscan_across_bytes(self): value = False ops = [bitwise_operations.bit_rscan(self.count_bin, 4, 8, value)] expected_value = 6 _, _, result = self.as_connection.operate(self.test_key, ops) assert result[self.count_bin] == expected_value
[ "def test_bit_rscan_offset_out_of_range(self):\n value = True\n ops = [bitwise_operations.bit_rscan(self.count_bin, 41, 8, value)]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "def test_bit_rscan(self):\n value = True\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise rscan op with bit_offset outside bitmap.
def test_bit_rscan_offset_out_of_range(self): value = True ops = [bitwise_operations.bit_rscan(self.count_bin, 41, 8, value)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_rscan_across_bytes(self):\n value = False\n ops = [bitwise_operations.bit_rscan(self.count_bin, 4, 8, value)]\n\n expected_value = 6\n _, _, result = self.as_connection.operate(self.test_key, ops)\n assert result[self.count_bin] == expected_value", "def test_bit_rs...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise rscan op with bit_size larger than bitmap.
def test_bit_rscan_bit_size_too_large(self): value = True ops = [bitwise_operations.bit_rscan(self.test_bin_ones, 0, 41, value)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_rscan_across_bytes(self):\n value = False\n ops = [bitwise_operations.bit_rscan(self.count_bin, 4, 8, value)]\n\n expected_value = 6\n _, _, result = self.as_connection.operate(self.test_key, ops)\n assert result[self.count_bin] == expected_value", "def test_bit_rs...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise rshift op with offset > bitmap.
def test_bit_rshift_offset_out_of_range(self): ops = [bitwise_operations.bit_rshift(self.test_bin_ones, 41, 8, 1, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_rshift(self, other: Any) -> ColumnOperators:\n\n return self.operate(bitwise_rshift_op, other)", "def __rshift__(self, other: Any) -> ColumnOperators:\n return self.operate(rshift, other)", "def rshift(self, value):\n return self.clone().rshift_(value)", "def shift_right(self...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise rshift op with bit_size > bitmap.
def test_bit_rshift_bit_size_too_large(self): ops = [bitwise_operations.bit_rshift(self.test_bin_ones, 0, 41, 1, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_rshift(self, other: Any) -> ColumnOperators:\n\n return self.operate(bitwise_rshift_op, other)", "def arith_shift_right(self, size, a, b, flags = None):\n\t\treturn self.expr(core.LLIL_ASR, a.index, b.index, size = size, flags = flags)", "def logical_shift_right(self, size, a, b, flags = Non...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op with an offset that lands inbetween bytes.
def test_bit_subtract_inbetween_bytes(self): ops = [bitwise_operations.bit_subtract(self.five_255_bin, 4, 8, 255, False, aerospike.BIT_OVERFLOW_FAIL, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([24...
[ "def test_bit_subtract_bit_offset_out_of_range(self):\n ops = [\n bitwise_operations.bit_subtract(self.test_bin_zeroes, 41, 1, 1, False, aerospike.BIT_OVERFLOW_FAIL, None)\n ]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op with multiple bytes.
def test_bit_subtract_multiple_bytes(self): ops = [ bitwise_operations.bit_subtract(self.test_bin_ones, 8, 16, 257, False, aerospike.BIT_OVERFLOW_FAIL, None) ] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected...
[ "def test_bit_subtract_inbetween_bytes(self):\n ops = [bitwise_operations.bit_subtract(self.five_255_bin, 4, 8, 255, False, aerospike.BIT_OVERFLOW_FAIL, None)]\n\n self.as_connection.operate(self.test_key, ops)\n\n _, _, bins = self.as_connection.get(self.test_key)\n expected_result = by...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op on a nonexistent bin.
def test_bit_subtract_bad_bin_name(self): ops = [bitwise_operations.bit_subtract("bad_name", 8, 16, 257, False, aerospike.BIT_OVERFLOW_FAIL, None)] with pytest.raises(e.BinNotFound): self.as_connection.operate(self.test_key, ops)
[ "def subtractbin(a, b): \n while b != 0:\n r = a ^ b # add without borrow\n c = ((~a) & b) << 1 # borrow\n a = int_overflow(r)\n b = int_overflow(c)\n return a", "def test_bit_subtract_overflow_fail(self):\n ops = [bitwise_operations.bit_subtra...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op with a bit_offset that is out of range for the bitmap being modified.
def test_bit_subtract_bit_offset_out_of_range(self): ops = [ bitwise_operations.bit_subtract(self.test_bin_zeroes, 41, 1, 1, False, aerospike.BIT_OVERFLOW_FAIL, None) ] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_remove_offset_out_of_range(self):\n ops = [bitwise_operations.bit_remove(self.test_bin_zeroes, 6, 1, None)]\n\n with pytest.raises(e.InvalidRequest):\n self.as_connection.operate(self.test_key, ops)", "def test_bit_subtract_inbetween_bytes(self):\n ops = [bitwise_oper...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op that overflows with the BIT_OVERFLOW_FAIL action.
def test_bit_subtract_overflow_fail(self): ops = [bitwise_operations.bit_subtract(self.test_bin_ones, 0, 8, 255, False, aerospike.BIT_OVERFLOW_FAIL, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_subtract_bit_offset_out_of_range(self):\n ops = [\n bitwise_operations.bit_subtract(self.test_bin_zeroes, 41, 1, 1, False, aerospike.BIT_OVERFLOW_FAIL, None)\n ]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op that overflows with the BIT_OVERFLOW_SATURATE action.
def test_bit_subtract_overflow_saturate(self): ops = [ bitwise_operations.bit_subtract(self.test_bin_ones, 0, 8, 255, False, aerospike.BIT_OVERFLOW_SATURATE, None) ] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) ex...
[ "def test_bit_subtract_overflow_fail(self):\n ops = [bitwise_operations.bit_subtract(self.test_bin_ones, 0, 8, 255, False, aerospike.BIT_OVERFLOW_FAIL, None)]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "def test_bit_subtract_bit_offset_ou...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise subtract op that overflows with the BIT_OVERFLOW_WRAP action.
def test_bit_subtract_overflow_wrap(self): ops = [bitwise_operations.bit_subtract(self.five_255_bin, 0, 8, 1, False, aerospike.BIT_OVERFLOW_WRAP, None)] self.as_connection.operate(self.test_key, ops) _, _, bins = self.as_connection.get(self.test_key) expected_result = bytearray([254] *...
[ "def test_bit_subtract_overflow_fail(self):\n ops = [bitwise_operations.bit_subtract(self.test_bin_ones, 0, 8, 255, False, aerospike.BIT_OVERFLOW_FAIL, None)]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "def test_bit_subtract_overflow_satu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise xor op with bit_offset > bitmap.
def test_bit_xor_bit_offset_out_of_range(self): value = bytearray() value.append(8) ops = [bitwise_operations.bit_xor(self.test_bin_ones, 41, 8, 1, value, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def bitwise_xor(self, other):\n return math_funcs.bitwise_xor(self, other)", "def test_bit_xor_with_policy(self):\n value = bytearray([0])\n bit_policy = {\n \"bit_write_flags\": aerospike.BIT_WRITE_UPDATE_ONLY,\n }\n ops = [bitwise_operations.bit_xor(self.test_bin_zeroe...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise xor op with bit_size > value.
def test_bit_xor_bit_size_larger_than_value(self): value = bytearray() value.append(8) ops = [bitwise_operations.bit_xor(self.test_bin_ones, 0, 9, 1, value, None)] with pytest.raises(e.InvalidRequest): self.as_connection.operate(self.test_key, ops)
[ "def test_bit_xor_bit_size_too_large(self):\n value = bytearray([8] * 6)\n ops = [bitwise_operations.bit_xor(self.test_bin_ones, 0, 41, 6, value, None)]\n\n with pytest.raises(e.OpNotApplicable):\n self.as_connection.operate(self.test_key, ops)", "def xor_expr(self, size, a, b, fla...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise xor op with bit_size > bitmap.
def test_bit_xor_bit_size_too_large(self): value = bytearray([8] * 6) ops = [bitwise_operations.bit_xor(self.test_bin_ones, 0, 41, 6, value, None)] with pytest.raises(e.OpNotApplicable): self.as_connection.operate(self.test_key, ops)
[ "def xor_expr(self, size, a, b, flags = None):\n\t\treturn self.expr(core.LLIL_XOR, a.index, b.index, size = size, flags = flags)", "def test_bit_xor_bit_size_larger_than_value(self):\n value = bytearray()\n value.append(8)\n ops = [bitwise_operations.bit_xor(self.test_bin_ones, 0, 9, 1, valu...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Perform a bitwise xor op with a policy.
def test_bit_xor_with_policy(self): value = bytearray([0]) bit_policy = { "bit_write_flags": aerospike.BIT_WRITE_UPDATE_ONLY, } ops = [bitwise_operations.bit_xor(self.test_bin_zeroes, 7, 8, 1, value, bit_policy)] self.as_connection.operate(self.test_key, ops) ...
[ "def xor(a, b):", "def bitwise_xor(self, other):\n return math_funcs.bitwise_xor(self, other)", "def __xor__(self, other):\n return _flagOp(xor, self, other)", "def special_xor(expr):\n \n if type(expr) == xor_t and expr.op1 == expr.op2:\n return value_t(0)\n \n return", "def lo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Attempts to find a candidate layer to use for CAM extraction
def locate_candidate_layer(mod: nn.Module, input_shape: Tuple[int, ...] = (3, 224, 224)) -> Optional[str]: # Set module in eval mode module_mode = mod.training mod.eval() output_shapes: List[Tuple[Optional[str], Tuple[int, ...]]] = [] def _record_output_shape(module: nn.Module, input: Tensor, outp...
[ "def find_layer(directory, tile, name):\n files = [f for f in os.listdir(directory) if _is_cglc(f)]\n for f in files:\n if f.startswith(tile) and f.split(\"_\")[6] == name:\n return os.path.join(directory, f)\n log.warning(f\"Layer {name} not found.\")\n return None", "def findLayerS...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the asset with the given id.
def get_asset(self, asset_id): text, code = ApiClient(self._config, 'assets/' + asset_id).get() return Asset.deserialize(text)
[ "def get_asset(self, asset_id):\n endpoint = '/assets/{}'.format(asset_id)\n return self._api_call('get', endpoint)", "def find_asset_by_id(self, asset_id):\n return super().request('GET', f'/api/network/assets/{asset_id}')", "def get_asset(self, asset_id, asset_type):\n return self.asset(as...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Obtains Marketplace object given its ID.
def get_marketplace(self, marketplace_id): return MarketplaceResource(self._config).get(marketplace_id)
[ "def get_object(self, id_):\n return self._objects.get(id_, None)", "def get_by_id(cls, id):\n e = api.get([key.Key(cls.__name__, id)])\n if e:\n return cls.from_entity(e[0])\n raise ObjectDoesNotExist", "def fetch_Place(self, id_value: str) -> Place:\n q = FetchByI...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
List the tier configs.
def list_tier_configs(self, filters=None): query = self._get_filters_query(filters, True) text, code = ApiClient(self._config, 'tier/configs' + query.compile()).get() return TierConfig.deserialize(text)
[ "async def getTiers(self, ctx):\n server_dict = self.get_server_dict(ctx)\n tierList = server_dict.setdefault(\"Tiers\", [])\n\n if(len(tierList) > 0):\n await self.bot.say(\"Tiers:\")\n for tier in tierList:\n await self.bot.say(tier)\n else:\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns the tier config with the given id.
def get_tier_config(self, tier_config_id): text, code = ApiClient(self._config, 'tier/configs/' + tier_config_id).get() return TierConfig.deserialize(text)
[ "def _get_tier(pkmn_id):\n if pkmn_id in tiers.TIERS[\"0\"]:\n return 0\n elif pkmn_id in tiers.TIERS[\"1\"]:\n return 1\n elif pkmn_id in tiers.TIERS[\"2\"]:\n return 2\n elif pkmn_id in tiers.TIERS[\"3\"]:\n return 3\n else:\n return 4", "def get_tenant_config(t...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Property for the event description based on the code
def event_desc(self) -> str: return _EVENT_DESC_MAPPINGS.get(self.transaction_event_code)
[ "def new_desc_event(self, event):\r\n pass", "def get_description(self, code):\n try:\n return self.message[str(code)]\n except KeyError:\n return \"Unknown (\" + str(code) + \")\"", "def getDescription(self):\n return self._eventType", "def event_for_event_descri...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Property for the enumeration of this transaction ()
def transaction_status_enum(self) -> TransactionStatus: return _TRANSACTION_STATUS_MAPPING.get(self.transaction_status)
[ "def transaction(self) -> str:\n return self.__transaction", "def attr(self):\n\n return EnumAttr(self)", "def transaction_type(self) -> str:\n return self.chunks[2].decode(\"ascii\")", "def __repr__(self):\n return u'<Transaction id={i}, amount={a}>'.format(\n i=self.id...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
通过 offset 构造 index_url
def construct_index_url(offset): request_para = { 'offset': offset, 'format': 'json', 'keyword': KEYWORD, 'autoload': 'true', 'count': 20, 'cur_tab': 3, 'from': 'gallery' } prefix_url = 'https://www.toutiao.com/search_content/?' return p...
[ "def index_url(self):", "def offset_index(self, offset):\n if self.has_index:\n self.index += offset", "def addIndex(indexDef):", "def url(index):\n return ALEXA_MAP[index]", "def get_index_page(self, spec_url: str) -> str:", "def build_index():\n pass", "def locationToRelion(ind...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Build the queryset's menu nodes
def queryset_nodes(queryset): for article in queryset: article_nodes.append(NavigationNode( article.title, aritcle.url, article.menu.menuid, article.menu.parent, ) ) return article_nodes
[ "def create_all_menus(self, ):\n m = self._model\n if not m:\n return\n indizes = self._flatten_hierarchy(m)\n for i in indizes:\n self.create_menu_for_index(i)", "def buildMenu(self):\n #-- Build Menu --#\n menuDict = self.menuActions()\n for...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the list of products that is visible to the given account
def get_visible_products(self): all_products = billing.loading.get_products(hidden=True) public_products = billing.loading.get_products() subscribed_product_types = ProductType.objects \ .filter(subscriptions__billing_account=self) \ .distinct() subscribed...
[ "def get_vendors_and_products_seen(cls, cb):\n url = \"/device_control/v3/orgs/{0}/products\".format(cb.credentials.org_key)\n resp = cb.get_object(url)\n return resp.get(\"results\", [])", "def show_available_products():\n return_fields = {'_id': False,\n 'product_id':...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns the subscriptions whose most recent status is one of those specified
def filter_by_current_statuses(self, statuses): annotated = self.annotate( newest=models.Max('approval_statuses__created')) newest_subs = annotated.filter( approval_statuses__created=models.F('newest'), approval_statuses__status__in=statuses ) ...
[ "def getSubscription(where):", "def get_docs_by_status(self):\n docs_by_status = self.get_documents().values_list(\n 'latest_revision__status', flat=True)\n by_status = Counter(docs_by_status)\n return self.build_list(by_status)", "def by_status(cls, status):\n return ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
If the billing account already has an IOU account, return the update form. If there isn't an account yet, then return the creation form
def get_billing_details_form(billing_account): try: iou_account = billing_account.simple_processor_iou_account return IOUAccountUpdateForm except IOUAccount.DoesNotExist: return IOUAccountCreationForm
[ "def manage():\n if current_user.is_agency:\n form = ManageAgencyUserAccountForm(user=current_user)\n else:\n form = ManageUserAccountForm(user=current_user)\n\n if request.method == \"POST\":\n if form.validate_on_submit():\n update_openrecords_user(form)\n redir...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`sender` is the subscription instance requiring approval
def do_subscription_approval(sender, **kwargs): req_payment = sender.get_product_class().get_requires_payment_details() if not req_payment or has_valid_billing_details(sender.billing_account): status = 'approved' else: status = 'declined' sender.set_current_approval_status(status) ...
[ "def save(self):\n owner = self.context[\"request\"].user\n recipient = self._recipient_email_inst.user\n\n logger.info(\n \"Transferring subscription %r from user %r to user %r\",\n owner.know_me_subscription,\n owner.pk,\n recipient.pk,\n )\n...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
returns a function to conditionally dispatch a view based on a user's current subscription status If the user is already subscribed to the plan, dispatch the current_subscription_view If the plan requires billing details, and the user doesn't have billing details on file (as reported by the processor), then dispatch th...
def subscription_view( current_subscription_view=CurrentSubscriptionView.as_view(), billing_details_view=SubscriptionBillingDetailsView.as_view(), confirmation_view=SubscriptionConfirmationView.as_view(), ): def dispatch(request, *args, **kwargs): cur_product_cls = request.user.billing_acc...
[ "def _view_subscription(request, subscription_holder):\n assert subscription_holder.has_active_subscription()\n return render(request, 'subscriptions/view_subscription.html', {\n 'active_tab': 'subscription',\n 'subscription': subscription_holder.active_stripe_subscription,\n 'subscriptio...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Takes a Nx9 prediction matrix, and a NxK prediction matrices of a subclassifier the subclassifier classifies only the classes in the subclasses list then, it combines the two predictions, and returns the new prediction matrix copyPred means that the prediction matrix will be copied, which costs more memory by default, ...
def combinePredictions(predictions, subpredictions, subclasses = [2,3], copyPred = False): assert len(subclasses) == np.shape(subpredictions)[1] assert np.shape(subpredictions)[1] < np.shape(predictions)[1] assert np.shape(subpredictions)[0] == np.shape(predictions)[0] if copyPred: predicti...
[ "def extract_rules_and_train_and_predict_multiclass(train_set, test_set, counts, min_max, class_col_name, k):\n minority_labels = train_set[class_col_name].unique()\n print(\"one-vs-all labels in the order they'll be processed\", minority_labels)\n rest_label = \"rest\"\n res = test_set.copy()\n # Ne...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets training data for classification, from only the given classes Either filter existing data, or load the default training data, and filter that. If either train_data or true_classes is None, the data will be loaded using get_training_data() from utils.loading
def getSubClassifierData(subclasses = [2,3], train_data = None, true_classes = None): if (train_data is None) or (true_classes is None): train_data, true_classes, _ = get_training_data() assert len(true_classes) == np.shape(train_data)[0] validsample = np.array([x in subclasses for x in true_c...
[ "def classes_train(self):\n return self._classes(train=True)", "def load_class(self, class_, only_modified=False):\n matches_class_train = self.y_train_cat == class_\n matches_class_test = self.y_test_cat == class_\n\n if only_modified:\n matches_class_train = matches_class_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Get an existing UserGpgKey resource's state with the given name, id, and optional extra properties used to qualify the lookup.
def get(resource_name: str, id: pulumi.Input[str], opts: Optional[pulumi.ResourceOptions] = None, created_at: Optional[pulumi.Input[str]] = None, key: Optional[pulumi.Input[str]] = None, key_id: Optional[pulumi.Input[int]] = None, user_id: Optional...
[ "def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None) -> 'Key':\n opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))\n\n __props__ = KeyArgs.__new__(KeyArgs)\n\n __props__.__dict__[\"disabled\"] = None\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
The ID of the GPG key.
def key_id(self) -> pulumi.Output[int]: return pulumi.get(self, "key_id")
[ "def identifier(self):\n listing = execute(' '.join([self.gpg_command, '--list-keys', '--with-colons']), capture=True)\n parsed_listing = [line.split(':') for line in listing.splitlines()]\n # Look for an 'fpr:*' line with a key fingerprint.\n for fields in parsed_listing:\n i...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Create python configuration file for the projection script
def createCfg_project(self, jobOptions): last_line = '%s %s %s %s' % (jobOptions['projection_module'], self.era, jobOptions['histName'], jobOptions['outputFile']) if self.projection_module != 'puHist': last_line += ' %.6e' % jobOptions['ref_genWeight'] lines = jobOptions['inputFiles'...
[ "def create_config_file():\n fn=\"scipaas/config.py\"\n if not os.path.exists(fn):\n with open(fn, \"w\") as f:\n f.write(\"# USER AUTHENTICATION\\n\")\n f.write(\"auth = False\\n\")\n f.write(\"\\n# DATABASE\\n\")\n f.write(\"db = 'scipaas.db'\\n\")\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Controller is allow user to change their password if they have valid username and password. It will generate the new password hash and write into the database. If username not exist, or wrong password, controller will not allow user change password.
def change_my_password(): form = ChangePassword() if request.method == 'GET': return render_template('changemypassword.html', form=form) if request.method == 'POST' and form.validate_on_submit(): username = form.username.data old_password = form.password.data new_password_has...
[ "def change_password(self,employee,new_password):\n pass", "def ChangePassword():\n print('\\n*****Note: Password should be at least 5 characters*****')\n password = getpass('\\nEnter new password: ')\n approved_password = validation.PasswordChecker(password) # Confirm validity of new password\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Controller that display the reset_password page. Only user_email is needed to be input. Controller will validate the email in database and generate a new password 10lenghtrandom string. Then it will try to send a email with new password to user's mailbox by gmail. Email template is email.txt
def reset_password(): form = ResetPassword() if form.validate_on_submit(): user_email = form.email.data mail_exist = db.check_email(user_email) if mail_exist is not None: new_password = generate_password() new_password_hash = generate_password_hash(new_password) ...
[ "def password_reset(request):\n\n\tcontext_dict = {}\n\tif request.method == 'POST':\n\t\temail = request.POST.get('email')\n\t\tif email:\n\t\t\tuser = models.Teacher.objects.get(\n\t\t\t\tsoft_delete=False, user__email=email\n\t\t\t)\n\t\t\tif not user:\n\t\t\t\tcontext_dict[\"message\"] = \"Email ID does'nt exis...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Background Cloud Function to be triggered by Cloud Storage. This generic function logs relevant data when a file is changed.
def hello_gcs_generic(data, context): print('Event ID: {}'.format(context.event_id)) print('Event type: {}'.format(context.event_type)) print('Bucket: {}'.format(data['bucket'])) print('File: {}'.format(data['name'])) print('Metageneration: {}'.format(data['metageneration'])) print('Created: {...
[ "def hello_gcs_generic(data, context):\n\n if context:\n print(\"Event ID: {}\".format(context.event_id))\n print(\"Event type: {}\".format(context.event_type))\n\n print(\"Bucket: {}\".format(data[\"bucket\"]))\n print(\"File: {}\".format(data[\"name\"]))\n print(\"Metageneration: {}\".fo...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test the get_factor_list function and factors generator on a few numbers.
def main(): print("-----------------\n|") print("| codedrome.com |") print("| Factorization |") print("-----------------\n") numbers_to_factorize = [15,19,25,50,77,99] print("factorization.get_factor_list\n-----------------------------") for n in numbers_to_factorize: factors = ...
[ "def test_factor(self):\n\n test_numbers = [1, 2, 8, 5, 21, 28]\n test_factorizations = [[1], [1, 2], [1, 2, 4, 8], [1, 5], [1, 3, 7, 21], [1, 2, 4, 7, 14, 28]]\n returned_factorizations = []\n\n for num in test_numbers:\n returned_factorizations.append(factor(num))\n\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test that we fallback to gecos if there is no displayname
def test_user_no_displayname(dummy_user_dict): del dummy_user_dict["displayname"] dummy_user_dict["gecos"] = ["GCOS"] user = User(dummy_user_dict) assert user.name == "GCOS"
[ "def test_us_standard_default_for_bogus():\r\n for bn in SUBDOMAIN_BOGUS:\r\n cinfo = calling_format.from_store_name(bn)\r\n assert cinfo.region == 'us-standard'", "def test_user_no_displayname_no_gcos(dummy_user_dict):\n del dummy_user_dict[\"displayname\"]\n del dummy_user_dict[\"gecos\"]...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test that we fallback to cn if there is no displayname nor gcos
def test_user_no_displayname_no_gcos(dummy_user_dict): del dummy_user_dict["displayname"] del dummy_user_dict["gecos"] dummy_user_dict["cn"] = ["CN"] user = User(dummy_user_dict) assert user.name == "CN"
[ "def test_user_no_displayname_no_gcos_no_cn(dummy_user_dict):\n del dummy_user_dict[\"displayname\"]\n del dummy_user_dict[\"gecos\"]\n del dummy_user_dict[\"cn\"]\n user = User(dummy_user_dict)\n assert user.name is None", "def exists_displayname(cursor, displayname):\n\t\n\tcursor.execute(\"selec...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test that we fallback to cn if there is no displayname nor gcos
def test_user_no_displayname_no_gcos_no_cn(dummy_user_dict): del dummy_user_dict["displayname"] del dummy_user_dict["gecos"] del dummy_user_dict["cn"] user = User(dummy_user_dict) assert user.name is None
[ "def test_user_no_displayname_no_gcos(dummy_user_dict):\n del dummy_user_dict[\"displayname\"]\n del dummy_user_dict[\"gecos\"]\n dummy_user_dict[\"cn\"] = [\"CN\"]\n user = User(dummy_user_dict)\n assert user.name == \"CN\"", "def exists_displayname(cursor, displayname):\n\t\n\tcursor.execute(\"se...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Gets the 95th percentile of bleakest_eval from bigtable
def get_95_percentile_bleak(n_back=500): end_game = int(bigtable_input._games_nr.latest_game_number()) start_game = end_game - n_back if end_game >= n_back else 0 moves = bigtable_input._games_nr.bleakest_moves(start_game, end_game) evals = np.array([m[2] for m in moves]) return np.percentile(evals,...
[ "def compute_95th_percentile(the_data):\n\n clut_series = pd.Series(the_data[~np.isnan(the_data)])\n to_return = clut_series.quantile(0.95)\n\n return to_return", "def _GetPercentile(sortedlist, percent):\n if not sortedlist:\n return None\n\n\n\n\n k = int(math.ceil(len(sortedlist) * percent)) - 1\...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Updates the flagfile at `flags_path`, changing the value for `resign_threshold` to `new_threshold`
def update_flagfile(flags_path, new_threshold): if abs(new_threshold) > 1: raise ValueError("Invalid new percentile for resign threshold") with tf.gfile.GFile(flags_path) as f: lines = f.read() if new_threshold > 0: new_threshold *= -1 if not RESIGN_FLAG_REGEX.search(lines): ...
[ "def chflags(path, flags):\n pass", "def update_threshold(self, threshold):\n self.mf.set_threshold(self.cm.estimate)", "def setflag(self, f, flags):\n if flags not in _manifestflags:\n raise TypeError(b\"Invalid manifest flag set.\")\n self._load()\n dir, subpath = _sp...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Authenticate with SoundCloud API. Cache access token in the secrets file.
def init_api(): global soundcloud import json SECRETS_VERSION = 1 # Load secrets file if os.path.exists(config.token_cache): with open(config.token_cache, 'r', encoding='utf-8') as f: secrets = json.load(f) else: secrets = {} # Try to reuse the ...
[ "def auth():\n creds = load_config(cred_fp)\n \n os.environ['consumer_key'] = creds['consumer_key']\n os.environ['consumer_secret'] = creds['consumer_secret']\n os.environ['access_token'] = creds['access_token']\n os.environ['access_token_secret'] = creds['access_token_secret']\n\n return", "...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Return true if the respost exists, according to soundcloud. Also update the database if a repost is already deleted on soundcloud, but is not marked as deleted in the db.
def check_repost_exists(type, id): try: soundcloud.get('/e1/me/{}_reposts/{}'.format(type, id)) return True except HTTPError as e: if e.response.status_code == 404: db.mark_as_deleted(type, id) return False else: raise
[ "def check_replied(comment):\n # change column replied to replied_id for naming comprehension\n comment_result = session.query(reddb.comment_id, reddb.replied).filter(\n reddb.comment_id == comment.id).first()\n if comment_result:\n comment.save(category='comment_r...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Repost a resource into the group and update the database.
def group_repost(user_id, resource_type, resource_id): logging.info('Reposting %s %d...', resource_type, resource_id) soundcloud.put('/e1/me/{}_reposts/{}'.format(resource_type, resource_id)) db.record_repost(user_id, resource_type, resource_id) db.commit()
[ "def commit_post(cls, post):\n post.put()", "def resubmit(self, resubmit):\n self._resubmit = resubmit", "def post_security_group_update(self, resource_id, resource_dict):\n pass", "def _resubmit(self, *args, **kwargs):\n self.retry()", "def post_database_node_update(self, resour...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Delete a resource from the group and update the database.
def group_delete(user_id, resource_type, resource_id): logging.info('Deleting %s %d...', resource_type, resource_id) soundcloud.delete('/e1/me/{}_reposts/{}'.format(resource_type, resource_id)) db.record_deletion(user_id, resource_type, resource_id) db.commit()
[ "def delete(self, resource_id=None):\n\n if resource_id:\n db.resources.delete_one({\"_id\":resource_id})\n else:\n db.resources.delete_many({})\n\n\treturn { \"success\": True }", "def destroy(self):\n self.client.resource_groups.delete(self.resource_group)", "def del...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Set a flag to update the description once all comments are processed.
def request_description_update(): global should_update_description should_update_description = True
[ "def updateDescription(self, descr):\n self.description = descr", "def _setDescription(self,newDescription):\n\t\tself._description = newDescription", "def set_description(desc):\n global last_description\n last_description = desc", "def set_description(self, description):\n self.descripti...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
`dict` group configurations keyed by name
def groups(self): group_config = {} # legacy way of threating any dict as a potential # group config (pre #44 implementation) # supported until vaping 2.0 for k,v in list(self.config.items()): if isinstance(v, collections.Mapping): group_config[k] =...
[ "def get_groups(self) -> dict[str, dict[str, Any]]:\n return {i.name: i.info() for i in self.groups}", "def _init_group_dicts(self):\n\n all_groups = set()\n\n for detection in config['detections'].values():\n if 'action' in detection and detection['action'] == 'buy':\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates and returns new message `dict`, setting `type`, `source`, `ts`, `data` `data` is initialized to an empty array Returns message (`dict`)
def new_message(self): msg = {} msg['data'] = [] msg['type'] = self.plugin_type msg['source'] = self.name msg['ts'] = (datetime.datetime.utcnow() - datetime.datetime(1970, 1, 1)).total_seconds() return msg
[ "def get_data(self):\n data = {}\n data['message_content'] = self.message_content\n data['time_stamp'] = self.get_time()\n data['source'] = self.source\n data['number'] = self.number\n data['message_id'] = self.message_id\n return data", "def createMessage(self, pa...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
creates a subprocess with passed args Returns Popen instance
def popen(self, args, **kwargs): self.log.debug("popen %s", ' '.join(args)) return vaping.io.subprocess.Popen(args, **kwargs)
[ "def popen_cmd(args, cwd=None, env=None, stdin='/dev/null',\n stdout=subprocess.PIPE, stderr=subprocess.PIPE):\n if isinstance(stdin, types.StringTypes):\n stdin = file(stdin, 'r')\n if isinstance(stdout, types.StringTypes):\n stdout = file(stdout, 'w')\n if isinstance(stderr, ty...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
logger instance for plugin type
def log(self): if not self._logger: self._logger = logging.getLogger('vaping.plugins.' + self.plugin_type) return self._logger
[ "def __init__(self):\n self.logger = logging.getLogger(FeatureEngineeringLogger.__name__)", "def log():\n return logging.getLogger(\"vodka\")", "def build_logger():\n return log", "def get_logger(plugin_name):\n return logging.getLogger('sopel.externals.%s' % plugin_name)", "def __init__(sel...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
queue an emission of a message for all output plugins Arguments
def queue_emission(self, msg): if not msg: return for _emitter in self._emit: if not hasattr(_emitter, 'emit'): continue def emit(emitter=_emitter): self.log.debug("emit to {}".format(emitter.name)) emitter.emit(msg) ...
[ "def emit(self,*args,**kwargs):\n self.emitted.append(args[0])", "def output_function(**kwargs):\n\n\t\toutput_queue = kwargs['q']\n\t\twhile True:\n\t\t\titem = output_queue.get()\n\t\t\t# expects to get a string or None\n\t\t\tif item is None:\n\t\t\t\tbreak\n\t\t\toutfile.write(item)\n\t\t\t# outfile.wr...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
emit and remove the first emission in the queue
def send_emission(self): if self._emit_queue.empty(): return emit = self._emit_queue.get() emit()
[ "def delete_first(self):\n self.deque.pop(0)", "def queue_emission(self, msg):\n if not msg:\n return\n for _emitter in self._emit:\n if not hasattr(_emitter, 'emit'):\n continue\n def emit(emitter=_emitter):\n self.log.debug(\"em...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
emit and remove all emissions in the queue
def emit_all(self): while not self._emit_queue.empty(): self.send_emission()
[ "def send_emission(self):\n if self._emit_queue.empty():\n return\n emit = self._emit_queue.get()\n emit()", "def queue_emission(self, msg):\n if not msg:\n return\n for _emitter in self._emit:\n if not hasattr(_emitter, 'emit'):\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Here we validate that our filehandler is pointing to an existing file. If it doesnt, because file has been deleted, we close the filehander and try to reopen
def validate_file_handler(self): if self.fh.closed: try: self.fh = open(self.path, "r") self.fh.seek(0, 2) except OSError as err: logging.error("Could not reopen file: {}".format(err)) return False open_stat = os.fs...
[ "def test_file_deleted(self):\n try:\n with get_temp_file() as (fd, name):\n os.unlink(name)\n except Exception as err:\n self.fail('Failed with exception \"{}\"'.format(err))", "def release_file_handle(self):\n pass", "def close(self) -> None:\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
accept message to emit
def emit(self, message):
[ "def receive(self, msg):", "def emit(self,*args,**kwargs):\n self.emitted.append(args[0])", "def transmit(self, message):\n pass", "def emit(self, signal, *args):\n self.__queue.put((signal, args))\n self.__w_socket.send(b'!')", "def msgHandler():", "def process_sink_msg(self):...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Returns a dict containing the various filename formatter values Values are gotten from the vaping data message as well as the currently processed row in the message Arguments
def filename_formatters(self, data, row): r = { "source" : data.get("source"), "field" : self.field, "type" : data.get("type") } r.update(**row) return r
[ "def filenames(self) -> dict[str, str]:\r\n ...", "def map_file_format_info(file_format_event, file_validation_event):\n event_info = {}\n if not file_format_event:\n return\n try:\n event_info.update(\n {\n \"dct:FileFormat\": file_format_event.event_outcom...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Label the provided ICA components with the ICLabel neural network. ICLabel is designed to classify ICs fitted with an extended infomax ICA decomposition algorithm on EEG datasets referenced to a common average and filtered between [1., 100.] Hz. It is possible to run ICLabel on datasets that do not meet those specifica...
def iclabel_label_components( inst: Union[BaseRaw, BaseEpochs], ica: ICA, inplace: bool = True, backend: Optional[str] = None, ): features = get_iclabel_features(inst, ica) labels_pred_proba = run_iclabel(*features, backend=backend) # type: ignore if inplace: from mne_icalabel.conf...
[ "def get_coco_label_names():\n coco_label_names = ('background', # class zero\n 'person', 'bicycle', 'car', 'motorcycle', 'airplane', 'bus', 'train', 'truck',\n 'boat', 'traffic light', 'fire hydrant', 'street sign', 'stop sign',\n 'parking me...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test if path is correctly recognized as not hidden.
def test_is_not_hidden(self) -> None: path = "home" result = is_hidden(path) self.assertFalse(result)
[ "def _isPathHidden(self, path: Path) -> bool:\n if os.name == 'nt': # on Windows, check Windows flags of the path\n try:\n fileAttrs = win32api.GetFileAttributes(str(path))\n return fileAttrs & (win32con.FILE_ATTRIBUTE_HIDDEN | win32con.FILE_ATTRIBUTE_SYSTEM)\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting dataset path.
def test_get_dataset_path(self) -> None: framework = "tensorflow" domain = "image_recognition" result = get_dataset_path(framework, domain) self.assertEqual(result, "examples/test/dataset/imagenet")
[ "def test_make_dataset_happy_path(self):\n # User story: user runs src.make_dataset() on the current directory\n # and gets a fully functional dataset\n pass", "def test_data_path(self):\n path = self._api.GetDatapath()\n self._api.End()\n self.assertRaises(\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting dataset path failure.
def test_get_dataset_path_unknown_domain(self) -> None: framework = "tensorflow" domain = "domain" with self.assertRaises(Exception): get_dataset_path(framework, domain)
[ "def _check_dataset_dir(self):\n # Check that dataset path is valid\n if not os.path.exists(self.dataset_dir):\n raise FileNotFoundError('Dataset path does not exist: {}'\n .format(self.dataset_dir))", "def test_data_path(self):\n path = self._api...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting framework name from path.
def test_get_onnx_framework_from_path(self) -> None: path = "/home/user/model.onnx" result = get_framework_from_path(path) self.assertEqual(result, "onnxrt")
[ "def test_get_unknown_framework_from_path(self) -> None:\n path = \"/home/user/model.some_extension\"\n result = get_framework_from_path(path)\n self.assertIsNone(result)", "def get_framework_name() -> str:\n return \"onnxrt\"", "def _framework_path(fw_uid):\n # type: (str) ->...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting framework name from path.
def test_get_unknown_framework_from_path(self) -> None: path = "/home/user/model.some_extension" result = get_framework_from_path(path) self.assertIsNone(result)
[ "def test_get_onnx_framework_from_path(self) -> None:\n path = \"/home/user/model.onnx\"\n result = get_framework_from_path(path)\n self.assertEqual(result, \"onnxrt\")", "def get_framework_name() -> str:\n return \"onnxrt\"", "def _framework_path(fw_uid):\n # type: (str) -> s...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting file extension from path.
def test_get_file_extension(self) -> None: path = "/home/user/file.ext" result = get_file_extension(path) self.assertEqual(result, "ext")
[ "def test_get_file_with_dots_extension(self) -> None:\n path = \"/home/user/file.name.ext2\"\n result = get_file_extension(path)\n self.assertEqual(result, \"ext2\")", "def get_ext(path):\n return os.path.splitext(path)[1]", "def get_file_extension(self) -> str:\n ...", "def tes...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting file extension from path.
def test_get_file_with_dots_extension(self) -> None: path = "/home/user/file.name.ext2" result = get_file_extension(path) self.assertEqual(result, "ext2")
[ "def test_get_file_extension(self) -> None:\n path = \"/home/user/file.ext\"\n result = get_file_extension(path)\n self.assertEqual(result, \"ext\")", "def get_ext(path):\n return os.path.splitext(path)[1]", "def get_file_extension(self) -> str:\n ...", "def test_get_filename_ex...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test if record is a valid dataset file.
def test_record_is_dataset_file(self) -> None: path = "/home/user/dataset.record" result = is_dataset_file(path) self.assertTrue(result)
[ "def _check_record(self):\n # we do not know filesize (structure_size) before reading first record,\n # so we try and pass\n try:\n if self.record_number >= self.structure_size / RECORD_BYTES:\n return False\n except AttributeError:\n pass\n ch...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for TF image recognition models.
def test_get_predefined_tf_image_recognition_config_path(self) -> None: self._assert_predefined_config_path( framework="tensorflow", domain="image_recognition", domain_flavour="", expected_filename="image_recognition.yaml", )
[ "def test_get_predefined_onnx_image_recognition_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"onnxrt\",\n domain=\"image_recognition\",\n domain_flavour=\"\",\n expected_filename=\"image_recognition.yaml\",\n )", "def test...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for TF object detection models.
def test_get_predefined_tf_object_detection_config_path(self) -> None: self._assert_predefined_config_path( framework="tensorflow", domain="object_detection", domain_flavour="", expected_filename="object_detection.yaml", )
[ "def test_get_predefined_tf_object_detection_unknown_flavour_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"tensorflow\",\n domain=\"object_detection\",\n domain_flavour=\"foo\",\n expected_filename=\"object_detection.yaml\",\n ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for TF object detection models.
def test_get_predefined_tf_object_detection_unknown_flavour_config_path(self) -> None: self._assert_predefined_config_path( framework="tensorflow", domain="object_detection", domain_flavour="foo", expected_filename="object_detection.yaml", )
[ "def test_get_predefined_tf_object_detection_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"tensorflow\",\n domain=\"object_detection\",\n domain_flavour=\"\",\n expected_filename=\"object_detection.yaml\",\n )", "def test_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for TF NLP models.
def test_get_predefined_tf_nlp_config_path(self) -> None: self._assert_predefined_config_path( framework="tensorflow", domain="nlp", domain_flavour="", expected_filename="nlp.yaml", )
[ "def test_get_predefined_onnx_nlp_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"onnxrt\",\n domain=\"nlp\",\n domain_flavour=\"\",\n expected_filename=\"nlp.yaml\",\n )", "def test_get_predefined_tf_recommendation_config_p...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for TF recommendation models.
def test_get_predefined_tf_recommendation_config_path(self) -> None: self._assert_predefined_config_path( framework="tensorflow", domain="recommendation", domain_flavour="", expected_filename="recommendation.yaml", )
[ "def test_get_predefined_tf_nlp_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"tensorflow\",\n domain=\"nlp\",\n domain_flavour=\"\",\n expected_filename=\"nlp.yaml\",\n )", "def test_get_predefined_tf_image_recognition_con...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for onnx image recognition models.
def test_get_predefined_onnx_image_recognition_config_path(self) -> None: self._assert_predefined_config_path( framework="onnxrt", domain="image_recognition", domain_flavour="", expected_filename="image_recognition.yaml", )
[ "def test_get_predefined_tf_image_recognition_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"tensorflow\",\n domain=\"image_recognition\",\n domain_flavour=\"\",\n expected_filename=\"image_recognition.yaml\",\n )", "def te...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting predefined config path for onnx NLP models.
def test_get_predefined_onnx_nlp_config_path(self) -> None: self._assert_predefined_config_path( framework="onnxrt", domain="nlp", domain_flavour="", expected_filename="nlp.yaml", )
[ "def test_get_predefined_tf_nlp_config_path(self) -> None:\n self._assert_predefined_config_path(\n framework=\"tensorflow\",\n domain=\"nlp\",\n domain_flavour=\"\",\n expected_filename=\"nlp.yaml\",\n )", "def test_get_predefined_onnx_image_recognition_c...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test checking existing module.
def test_check_module(self) -> None: check_module("os")
[ "def test_modules_install_nomodule(self):\n assert self.mods.install(\"foo\") is False", "def test_module_exists(self):\n project_path = os.getcwd()\n rango_app_path = os.path.join(project_path, 'rango')\n forms_module_path = os.path.join(rango_app_path, 'forms.py')\n\n self.ass...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test checking non existing module.
def test_check_non_existing_module(self) -> None: with self.assertRaises(ClientErrorException): check_module("non_existing_module")
[ "def test_notexist(self):\n root = os.path.dirname(os.path.dirname(twisted.__file__))\n for module in notPortedModules:\n segments = module.split(\".\")\n segments[-1] += \".py\"\n path = os.path.join(root, *segments)\n alternateSegments = module.split(\".\"...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting models config.
def test_load_model_config(self) -> None: result = load_model_config() self.assertIs(type(result), dict) self.assertIsNot(result, {})
[ "def test_modelconfigurations_get(self):\n pass", "def test_modelconfigurations_post(self):\n pass", "def test_coupledmodels_get(self):\n pass", "def test_no_models(self):\n app_config = apps.get_app_config('no_models')\n self.assertIsNone(app_config.models_module)", "def ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting dataloaders config.
def test_load_dataloader_config(self) -> None: result = load_dataloader_config() self.assertIs(type(result), list) self.assertIsNot(result, [])
[ "def test_dataloader(self):\n log.info(\"Test data loader called.\")\n return DataLoader(\n self.test_data,\n batch_size=self.hparams.batch_size,\n num_workers=0 if self.hparams.dry_run else 8,\n pin_memory=True if self.hparams.gpus else False,\n )", ...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
Test getting transforms config.
def test_load_transforms_config(self) -> None: result = load_transforms_config() self.assertIs(type(result), list) self.assertIsNot(result, [])
[ "def test_01_verify_transform_settings_func(self):\n self.fc.select_multiple_photos_to_preview(no_of_photos=1)\n self.fc.fd[\"preview\"].go_to_print_preview_pan_view(pan_view=False)\n preview_before_edit = self.fc.fd[\"preview\"].preview_img_screenshot()\n self.fc.fd[\"preview\"].select_...
{ "objective": { "paired": [], "self": [], "triplet": [ [ "query", "document", "negatives" ] ] } }