_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
31
13.1k
language
stringclasses
1 value
meta_information
dict
q253800
SDecree.sys_receive
validation
def sys_receive(self, cpu, fd, buf, count, rx_bytes): """ Symbolic version of Decree.sys_receive """ if issymbolic(fd): logger.info("Ask to read from a symbolic file descriptor!!") cpu.PC = cpu.PC - cpu.instruction.size raise SymbolicSyscallArgument(cp...
python
{ "resource": "" }
q253801
SDecree.sys_transmit
validation
def sys_transmit(self, cpu, fd, buf, count, tx_bytes): """ Symbolic version of Decree.sys_transmit """ if issymbolic(fd): logger.info("Ask to write to a symbolic file descriptor!!") cpu.PC = cpu.PC - cpu.instruction.size raise SymbolicSyscallArgument(c...
python
{ "resource": "" }
q253802
sync
validation
def sync(f): """ Synchronization decorator. """ def new_function(self, *args, **kw): self._lock.acquire() try:
python
{ "resource": "" }
q253803
Store.save_value
validation
def save_value(self, key, value): """ Save an arbitrary, serializable `value` under `key`. :param str key: A string identifier under which to store the value. :param
python
{ "resource": "" }
q253804
Store.load_value
validation
def load_value(self, key, binary=False): """ Load an arbitrary value identified by `key`. :param str key: The key that identifies the value :return: The
python
{ "resource": "" }
q253805
Store.save_stream
validation
def save_stream(self, key, binary=False): """ Return a managed file-like object into which the calling code can write arbitrary data. :param key: :return: A managed stream-like object
python
{ "resource": "" }
q253806
Store.load_stream
validation
def load_stream(self, key, binary=False): """ Return a managed file-like object from which the calling code can read previously-serialized data. :param key: :return: A managed stream-like object """
python
{ "resource": "" }
q253807
Store.save_state
validation
def save_state(self, state, key): """ Save a state to storage. :param manticore.core.StateBase state: :param str key: :return: """
python
{ "resource": "" }
q253808
Store.load_state
validation
def load_state(self, key, delete=True): """ Load a state from storage. :param key: key that identifies state :rtype: manticore.core.StateBase """ with self.load_stream(key, binary=True) as f: state
python
{ "resource": "" }
q253809
FilesystemStore.save_stream
validation
def save_stream(self, key, binary=False): """ Yield a file object representing `key` :param str key: The file to save to :param bool binary: Whether we should treat it as binary :return:
python
{ "resource": "" }
q253810
FilesystemStore.rm
validation
def rm(self, key): """ Remove file identified by `key`. :param str key: The file to delete
python
{ "resource": "" }
q253811
FilesystemStore.ls
validation
def ls(self, glob_str): """ Return just the filenames that match `glob_str` inside the store directory. :param str glob_str: A glob string, i.e. 'state_*' :return: list of matched keys """
python
{ "resource": "" }
q253812
Workspace._get_id
validation
def _get_id(self): """ Get a unique state id. :rtype: int """
python
{ "resource": "" }
q253813
Workspace.load_state
validation
def load_state(self, state_id, delete=True): """ Load a state from storage identified by `state_id`. :param state_id: The state
python
{ "resource": "" }
q253814
Workspace.save_state
validation
def save_state(self, state, state_id=None): """ Save a state to storage, return identifier. :param state: The state to save :param int state_id: If not None force the state id potentially overwriting old states
python
{ "resource": "" }
q253815
ManticoreOutput._named_stream
validation
def _named_stream(self, name, binary=False): """ Create an indexed output stream i.e. 'test_00000001.name' :param name: Identifier for the stream :return: A context-managed stream-like object
python
{ "resource": "" }
q253816
cmp_regs
validation
def cmp_regs(cpu, should_print=False): """ Compare registers from a remote gdb session to current mcore. :param manticore.core.cpu Cpu: Current cpu :param bool should_print: Whether to print values to stdout :return: Whether or not any differences were detected :rtype: bool """ differin...
python
{ "resource": "" }
q253817
sync_svc
validation
def sync_svc(state): """ Mirror some service calls in manticore. Happens after qemu executed a SVC instruction, but before manticore did. """ syscall = state.cpu.R7 # Grab idx from manticore since qemu could have exited name = linux_syscalls.armv7[syscall] logger.debug(f"Syncing syscall: {n...
python
{ "resource": "" }
q253818
Visitor.visit
validation
def visit(self, node, use_fixed_point=False): """ The entry point of the visitor. The exploration algorithm is a DFS post-order traversal The implementation used two stacks instead of a recursion The final result is store in self.result :param node: Node to explore ...
python
{ "resource": "" }
q253819
PrettyPrinter._method
validation
def _method(self, expression, *args): """ Overload Visitor._method because we want to stop to iterate over the visit_ functions as soon as a valid visit_ function is found """ assert expression.__class__.__mro__[-1] is object for cls in expression.__class__.__mro__: ...
python
{ "resource": "" }
q253820
ArithmeticSimplifier.visit_BitVecAdd
validation
def visit_BitVecAdd(self, expression, *operands): """ a + 0 ==> a 0 + a ==> a """ left = expression.operands[0] right = expression.operands[1] if isinstance(right, BitVecConstant): if right.value == 0:
python
{ "resource": "" }
q253821
ArithmeticSimplifier.visit_BitVecOr
validation
def visit_BitVecOr(self, expression, *operands): """ a | 0 => a 0 | a => a 0xffffffff & a => 0xffffffff a & 0xffffffff => 0xffffffff """ left = expression.operands[0] right = expression.operands[1] if isinstance(right, BitVecConstant): ...
python
{ "resource": "" }
q253822
ABI._type_size
validation
def _type_size(ty): """ Calculate `static` type size """ if ty[0] in ('int', 'uint', 'bytesM', 'function'): return 32 elif ty[0] in ('tuple'): result = 0 for ty_i in ty[1]: result += ABI._type_size(ty_i) return result elif t...
python
{ "resource": "" }
q253823
ABI.function_call
validation
def function_call(type_spec, *args): """ Build transaction data from function signature and arguments """ m = re.match(r"(?P<name>[a-zA-Z_][a-zA-Z_0-9]*)(?P<type>\(.*\))", type_spec) if not m: raise EthereumError("Function signature expected")
python
{ "resource": "" }
q253824
ABI.function_selector
validation
def function_selector(method_name_and_signature): """ Makes a function hash id from a method signature """
python
{ "resource": "" }
q253825
ABI._serialize_uint
validation
def _serialize_uint(value, size=32, padding=0): """ Translates a python integral or a BitVec into a 32 byte string, MSB first """ if size <= 0 or size > 32: raise ValueError from .account import EVMAccount # because of circular import if not isinstance(value...
python
{ "resource": "" }
q253826
ABI._serialize_int
validation
def _serialize_int(value, size=32, padding=0): """ Translates a signed python integral or a BitVec into a 32 byte string, MSB first """ if size <= 0 or size > 32: raise ValueError if not isinstance(value, (int, BitVec)): raise ValueError if issymbo...
python
{ "resource": "" }
q253827
ABI._deserialize_uint
validation
def _deserialize_uint(data, nbytes=32, padding=0, offset=0): """ Read a `nbytes` bytes long big endian unsigned integer from `data` starting at `offset` :param data: sliceable buffer; symbolic buffer of Eth ABI encoded data :param nbytes: number of bytes to read starting from least sign...
python
{ "resource": "" }
q253828
ABI._deserialize_int
validation
def _deserialize_int(data, nbytes=32, padding=0): """ Read a `nbytes` bytes long big endian signed integer from `data` starting at `offset` :param data: sliceable buffer; symbolic buffer of Eth ABI encoded data :param nbytes: number of bytes to read starting from least significant byte ...
python
{ "resource": "" }
q253829
concretized_args
validation
def concretized_args(**policies): """ Make sure an EVM instruction has all of its arguments concretized according to provided policies. Example decoration: @concretized_args(size='ONE', address='') def LOG(self, address, size, *topics): ... The above will make sure tha...
python
{ "resource": "" }
q253830
EVM._get_memfee
validation
def _get_memfee(self, address, size=1): """ This calculates the amount of extra gas needed for accessing to previously unused memory. :param address: base memory offset :param size: size of the memory access """ if not issymbolic(size) and size == 0: ...
python
{ "resource": "" }
q253831
EVM.read_code
validation
def read_code(self, address, size=1): """ Read size byte from bytecode. If less than size bytes are available result will be pad with \x00 """ assert address < len(self.bytecode) value = self.bytecode[address:address + size]
python
{ "resource": "" }
q253832
EVM.instruction
validation
def instruction(self): """ Current instruction pointed by self.pc """ # FIXME check if pc points to invalid instruction # if self.pc >= len(self.bytecode): # return InvalidOpcode('Code out of range') # if self.pc in self.invalid: # raise InvalidOpcod...
python
{ "resource": "" }
q253833
EVM._push
validation
def _push(self, value): """ Push into the stack ITEM0 ITEM1 ITEM2 sp-> {empty} """ assert isinstance(value, int) or isinstance(value, BitVec) and value.size == 256 if len(self.stack) >= 1024: raise StackOverflow() ...
python
{ "resource": "" }
q253834
EVM._top
validation
def _top(self, n=0): """Read a value from the top of the stack without removing it""" if len(self.stack) - n < 0:
python
{ "resource": "" }
q253835
EVM._rollback
validation
def _rollback(self): """Revert the stack, gas, pc and memory allocation so it looks like before executing the instruction""" last_pc, last_gas, last_instruction, last_arguments, fee, allocated = self._checkpoint_data self._push_arguments(last_arguments)
python
{ "resource": "" }
q253836
EVM._store
validation
def _store(self, offset, value, size=1): """Stores value in memory as a big endian""" self.memory.write_BE(offset, value, size) for i in range(size):
python
{ "resource": "" }
q253837
EVM.DIV
validation
def DIV(self, a, b): """Integer division operation""" try: result = Operators.UDIV(a, b) except ZeroDivisionError:
python
{ "resource": "" }
q253838
EVM.MOD
validation
def MOD(self, a, b): """Modulo remainder operation""" try: result = Operators.ITEBV(256, b == 0, 0, a % b)
python
{ "resource": "" }
q253839
EVM.SMOD
validation
def SMOD(self, a, b): """Signed modulo remainder operation""" s0, s1 = to_signed(a), to_signed(b) sign = Operators.ITEBV(256, s0 < 0, -1, 1) try: result = (Operators.ABS(s0) % Operators.ABS(s1)) * sign
python
{ "resource": "" }
q253840
EVM.ADDMOD
validation
def ADDMOD(self, a, b, c): """Modulo addition operation""" try: result = Operators.ITEBV(256, c == 0, 0, (a + b) % c)
python
{ "resource": "" }
q253841
EVM.EXP_gas
validation
def EXP_gas(self, base, exponent): """Calculate extra gas fee""" EXP_SUPPLEMENTAL_GAS = 10 # cost of EXP exponent per byte def nbytes(e): result = 0 for i in range(32):
python
{ "resource": "" }
q253842
EVM.SIGNEXTEND
validation
def SIGNEXTEND(self, size, value): """Extend length of two's complement signed integer""" # FIXME maybe use Operators.SEXTEND testbit = Operators.ITEBV(256, size <= 31, size * 8 + 7, 257) result1 = (value | (TT256 - (1 << testbit))) result2 = (value
python
{ "resource": "" }
q253843
EVM.LT
validation
def LT(self, a, b): """Less-than comparison""" return
python
{ "resource": "" }
q253844
EVM.GT
validation
def GT(self, a, b): """Greater-than comparison""" return
python
{ "resource": "" }
q253845
EVM.SGT
validation
def SGT(self, a, b): """Signed greater-than comparison""" # http://gavwood.com/paper.pdf s0,
python
{ "resource": "" }
q253846
EVM.BYTE
validation
def BYTE(self, offset, value): """Retrieve single byte from word""" offset = Operators.ITEBV(256, offset < 32, (31 - offset) * 8, 256)
python
{ "resource": "" }
q253847
EVM.SHA3
validation
def SHA3(self, start, size): """Compute Keccak-256 hash""" # read memory from start to end # http://gavwood.com/paper.pdf data = self.try_simplify_to_constant(self.read_buffer(start, size)) if issymbolic(data): known_sha3 = {} # Broadcast the signal ...
python
{ "resource": "" }
q253848
EVM.CALLDATALOAD
validation
def CALLDATALOAD(self, offset): """Get input data of current environment""" if issymbolic(offset): if solver.can_be_true(self._constraints, offset == self._used_calldata_size): self.constraints.add(offset == self._used_calldata_size) raise ConcretizeArgument(1, p...
python
{ "resource": "" }
q253849
EVM.CALLDATACOPY
validation
def CALLDATACOPY(self, mem_offset, data_offset, size): """Copy input data in current environment to memory""" if issymbolic(size): if solver.can_be_true(self._constraints, size <= len(self.data) + 32): self.constraints.add(size <= len(self.data) + 32) raise Concr...
python
{ "resource": "" }
q253850
EVM.CODECOPY
validation
def CODECOPY(self, mem_offset, code_offset, size): """Copy code running in current environment to memory""" self._allocate(mem_offset, size) GCOPY = 3 # cost to copy one 32 byte word copyfee = self.safe_mul(GCOPY, Operators.UDIV(self.safe_add(size, 31), 32)) self._co...
python
{ "resource": "" }
q253851
EVM.EXTCODECOPY
validation
def EXTCODECOPY(self, account, address, offset, size): """Copy an account's code to memory""" extbytecode = self.world.get_code(account) self._allocate(address + size) for i in range(size): if offset + i < len(extbytecode):
python
{ "resource": "" }
q253852
EVM.MLOAD
validation
def MLOAD(self, address): """Load word from memory"""
python
{ "resource": "" }
q253853
EVM.MSTORE
validation
def MSTORE(self, address, value): """Save word to memory""" if istainted(self.pc): for taint in get_taints(self.pc):
python
{ "resource": "" }
q253854
EVM.MSTORE8
validation
def MSTORE8(self, address, value): """Save byte to memory""" if istainted(self.pc): for taint in get_taints(self.pc):
python
{ "resource": "" }
q253855
EVM.SLOAD
validation
def SLOAD(self, offset): """Load word from storage""" storage_address = self.address self._publish('will_evm_read_storage', storage_address, offset)
python
{ "resource": "" }
q253856
EVM.SSTORE
validation
def SSTORE(self, offset, value): """Save word to storage""" storage_address = self.address self._publish('will_evm_write_storage', storage_address, offset, value) #refund = Operators.ITEBV(256, # previous_value != 0, # Opera...
python
{ "resource": "" }
q253857
EVM.JUMPI
validation
def JUMPI(self, dest, cond): """Conditionally alter the program counter""" self.pc = Operators.ITEBV(256, cond != 0, dest, self.pc + self.instruction.size) #This set ups
python
{ "resource": "" }
q253858
EVM.SWAP
validation
def SWAP(self, *operands): """Exchange 1st and 2nd stack items""" a = operands[0]
python
{ "resource": "" }
q253859
EVM.CALLCODE
validation
def CALLCODE(self, gas, _ignored_, value, in_offset, in_size, out_offset, out_size): """Message-call into this account with alternative account's code""" self.world.start_transaction('CALLCODE', address=self.address,
python
{ "resource": "" }
q253860
EVM.RETURN
validation
def RETURN(self, offset, size): """Halt execution returning output data"""
python
{ "resource": "" }
q253861
EVM.SELFDESTRUCT
validation
def SELFDESTRUCT(self, recipient): """Halt execution and register account for later deletion""" #This may create a user account recipient = Operators.EXTRACT(recipient, 0, 160) address = self.address #FIXME for on the known addresses if issymbolic(recipient): ...
python
{ "resource": "" }
q253862
EVMWorld.human_transactions
validation
def human_transactions(self): """Completed human transaction""" txs = [] for tx in self.transactions:
python
{ "resource": "" }
q253863
EVMWorld.current_human_transaction
validation
def current_human_transaction(self): """Current ongoing human transaction""" try: tx, _, _, _, _ = self._callstack[0] if tx.result is not None: #That tx finished. No
python
{ "resource": "" }
q253864
EVMWorld.get_storage_data
validation
def get_storage_data(self, storage_address, offset): """ Read a value from a storage slot on the specified account :param storage_address: an account address :param offset: the storage slot to use. :type offset: int or BitVec
python
{ "resource": "" }
q253865
EVMWorld.set_storage_data
validation
def set_storage_data(self, storage_address, offset, value): """ Writes a value to a storage slot in specified account :param storage_address: an account address :param offset: the storage slot to use. :type offset: int or BitVec
python
{ "resource": "" }
q253866
EVMWorld.get_storage_items
validation
def get_storage_items(self, address): """ Gets all items in an account storage :param address: account address :return: all items in account storage. items are tuple of (index, value). value can be symbolic :rtype: list[(storage_index, storage_value)] """ storage...
python
{ "resource": "" }
q253867
EVMWorld.has_storage
validation
def has_storage(self, address): """ True if something has been written to the storage. Note that if a slot has been erased from the storage this function may lose any meaning. """ storage = self._world_state[address]['storage'] array = storage.array
python
{ "resource": "" }
q253868
EVMWorld.new_address
validation
def new_address(self, sender=None, nonce=None): """Create a fresh 160bit address""" if sender is not None and nonce is None: nonce = self.get_nonce(sender) new_address = self.calculate_new_address(sender, nonce)
python
{ "resource": "" }
q253869
EVMWorld.create_contract
validation
def create_contract(self, price=0, address=None, caller=None, balance=0, init=None, gas=None): """ Create a contract account. Sends a transaction to initialize the contract :param address: the address of the new account, if known. If omitted, a new address will be generated as closely to the Ye...
python
{ "resource": "" }
q253870
Armv7Cpu._swap_mode
validation
def _swap_mode(self): """Toggle between ARM and Thumb mode""" assert self.mode in (cs.CS_MODE_ARM, cs.CS_MODE_THUMB) if self.mode == cs.CS_MODE_ARM:
python
{ "resource": "" }
q253871
Armv7Cpu.MRC
validation
def MRC(cpu, coprocessor, opcode1, dest, coprocessor_reg_n, coprocessor_reg_m, opcode2): """ MRC moves to ARM register from coprocessor. :param Armv7Operand coprocessor: The name of the coprocessor; immediate :param Armv7Operand opcode1: coprocessor specific opcode; 3-bit immediate ...
python
{ "resource": "" }
q253872
Armv7Cpu.LDRD
validation
def LDRD(cpu, dest1, dest2, src, offset=None): """Loads double width data from memory.""" assert dest1.type == 'register' assert dest2.type == 'register' assert src.type == 'memory' mem1 = cpu.read_int(src.address(), 32) mem2 = cpu.read_int(src.address() + 4, 32)
python
{ "resource": "" }
q253873
Armv7Cpu.STRD
validation
def STRD(cpu, src1, src2, dest, offset=None): """Writes the contents of two registers to memory.""" assert src1.type == 'register' assert src2.type == 'register' assert dest.type == 'memory' val1 = src1.read() val2 = src2.read() writeback = cpu._compute_writeback(...
python
{ "resource": "" }
q253874
Armv7Cpu.ADR
validation
def ADR(cpu, dest, src): """ Address to Register adds an immediate value to the PC value, and writes the result to the destination register. :param ARMv7Operand dest: Specifies the destination register. :param ARMv7Operand src: Specifies the label of an instruction or litera...
python
{ "resource": "" }
q253875
Armv7Cpu.ADDW
validation
def ADDW(cpu, dest, src, add): """ This instruction adds an immediate value to a register value, and writes the result to the destination register. It doesn't update the condition flags. :param ARMv7Operand dest: Specifies the destination register. If omitted, this register is the same ...
python
{ "resource": "" }
q253876
Armv7Cpu.CBZ
validation
def CBZ(cpu, op, dest): """ Compare and Branch on Zero compares the value in a register with zero, and conditionally branches forward a constant value. It does not affect the condition flags. :param ARMv7Operand op: Specifies the register that contains the first operand. :param ...
python
{ "resource": "" }
q253877
Armv7Cpu.TBH
validation
def TBH(cpu, dest): """ Table Branch Halfword causes a PC-relative forward branch using a table of single halfword offsets. A base register provides a pointer to the table, and a second register supplies an index into the table. The branch length is twice the value of the halfword return...
python
{ "resource": "" }
q253878
_dict_diff
validation
def _dict_diff(d1, d2): """ Produce a dict that includes all the keys in d2 that represent different values in d1, as well as values that aren't in d1. :param dict d1: First dict :param dict d2: Dict to compare with :rtype: dict """ d = {} for
python
{ "resource": "" }
q253879
CapstoneDisasm.disassemble_instruction
validation
def disassemble_instruction(self, code, pc): """Get next instruction using the Capstone disassembler :param str code: binary blob to be disassembled
python
{ "resource": "" }
q253880
ConstraintSet.add
validation
def add(self, constraint, check=False): """ Add a constraint to the set :param constraint: The constraint to add to the set. :param check: Currently unused. :return: """ if isinstance(constraint, bool): constraint = BoolConstant(constraint) as...
python
{ "resource": "" }
q253881
ConstraintSet._declare
validation
def _declare(self, var): """ Declare the variable `var` """ if var.name in self._declarations:
python
{ "resource": "" }
q253882
ConstraintSet.declarations
validation
def declarations(self): """ Returns the variable expressions of this constraint set """ declarations = GetDeclarations() for a in self.constraints: try: declarations.visit(a) except RuntimeError: # TODO: (defunct) move recursion management ...
python
{ "resource": "" }
q253883
ConstraintSet.is_declared
validation
def is_declared(self, expression_var): """ True if expression_var is declared in this constraint set """ if not isinstance(expression_var, Variable): raise ValueError(f'Expression must be a
python
{ "resource": "" }
q253884
ConstraintSet.migrate
validation
def migrate(self, expression, name_migration_map=None): """ Migrate an expression created for a different constraint set to self. Returns an expression that can be used with this constraintSet All the foreign variables used in the expression are replaced by variables of this...
python
{ "resource": "" }
q253885
OrdinalEncoder.inverse_transform
validation
def inverse_transform(self, X_in): """ Perform the inverse transformation to encoded data. Will attempt best case reconstruction, which means it will return nan for handle_missing and handle_unknown settings that break the bijection. We issue warnings when some of those cases occur. ...
python
{ "resource": "" }
q253886
OrdinalEncoder.ordinal_encoding
validation
def ordinal_encoding(X_in, mapping=None, cols=None, handle_unknown='value', handle_missing='value'): """ Ordinal encoding uses a single column of integers to represent the classes. An optional mapping dict can be passed in, in this case we use the knowledge that there is some true order to the c...
python
{ "resource": "" }
q253887
OneHotEncoder.reverse_dummies
validation
def reverse_dummies(self, X, mapping): """ Convert dummy variable into numerical variables Parameters ---------- X : DataFrame mapping: list-like Contains mappings of column to be transformed to it's new columns and value represented Returns ...
python
{ "resource": "" }
q253888
get_cars_data
validation
def get_cars_data(): """ Load the cars dataset, split it into X and y, and then call the label encoder to get an integer y column. :return: """ df = pd.read_csv('source_data/cars/car.data.txt') X = df.reindex(columns=[x for x in df.columns.values if x != 'class']) y = df.reindex(columns=['...
python
{ "resource": "" }
q253889
get_splice_data
validation
def get_splice_data(): """ Load the mushroom dataset, split it into X and y, and then call the label encoder to get an integer y column. :return: """ df = pd.read_csv('source_data/splice/splice.csv') X = df.reindex(columns=[x for x in df.columns.values if x != 'class']) X['dna'] = X['dna']...
python
{ "resource": "" }
q253890
BaseNEncoder.basen_to_integer
validation
def basen_to_integer(self, X, cols, base): """ Convert basen code as integers. Parameters ---------- X : DataFrame encoded data cols : list-like Column names in the DataFrame that be encoded base : int The base of transform ...
python
{ "resource": "" }
q253891
BaseNEncoder.col_transform
validation
def col_transform(self, col, digits): """ The lambda body to transform the column values """ if col is None or float(col) < 0.0: return None else: col = self.number_to_base(int(col), self.base, digits)
python
{ "resource": "" }
q253892
get_obj_cols
validation
def get_obj_cols(df): """ Returns names of 'object' columns in the DataFrame. """ obj_cols = [] for idx, dt in enumerate(df.dtypes):
python
{ "resource": "" }
q253893
convert_input
validation
def convert_input(X): """ Unite data into a DataFrame. """ if not isinstance(X, pd.DataFrame): if isinstance(X, list): X = pd.DataFrame(X) elif isinstance(X, (np.generic, np.ndarray)): X = pd.DataFrame(X) elif isinstance(X, csr_matrix): X =
python
{ "resource": "" }
q253894
convert_input_vector
validation
def convert_input_vector(y, index): """ Unite target data type into a Series. If the target is a Series or a DataFrame, we preserve its index. But if the target does not contain index attribute, we use the index from the argument. """ if y is None: return None if isinstance(y, pd.Ser...
python
{ "resource": "" }
q253895
score_models
validation
def score_models(clf, X, y, encoder, runs=1): """ Takes in a classifier that supports multiclass classification, and X and a y, and returns a cross validation score. """ scores = [] X_test = None for _ in range(runs): X_test = encoder().fit_transform(X, y) # Some models, like...
python
{ "resource": "" }
q253896
main
validation
def main(loader, name): """ Here we iterate through the datasets and score them with a classifier using different encodings. """ scores = [] raw_scores_ds = {} # first get the dataset X, y, mapping = loader() clf = linear_model.LogisticRegression(solver='lbfgs', multi_class='auto', m...
python
{ "resource": "" }
q253897
secho
validation
def secho(message, **kwargs): """A wrapper around click.secho that disables any coloring being used if colors have been disabled. """ # If colors are disabled, remove any
python
{ "resource": "" }
q253898
Resource.associate_notification_template
validation
def associate_notification_template(self, job_template, notification_template, status): """Associate a notification template from this job template. =====API DOCS===== Associate a notification template from this job template. :param job_template:...
python
{ "resource": "" }
q253899
Resource.disassociate_notification_template
validation
def disassociate_notification_template(self, job_template, notification_template, status): """Disassociate a notification template from this job template. =====API DOCS===== Disassociate a notification template from this job template. :param j...
python
{ "resource": "" }