query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Scans the given hosts with nmap.
def nmap_scan(): # Create the search and config objects hs = HostSearch() config = Config() # Static options to be able to figure out what options to use depending on the input the user gives. nmap_types = ['top10', 'top100', 'custom', 'top1000', 'all'] options = {'top10':'--top-ports 10', 'top...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(args):\n if '-' in args['-p']:\n tmp = args['-p'].split('-')\n tgtPorts = [str(i) for i in xrange(int(tmp[0]), int(tmp[1])+1)]\n else:\n tgtPorts = [args['-p']]\n tgtHost = args['-H']\n for tgtPort in tgtPorts:\n nmapScan(tgtHost, tgtPort)", "def nmap_discover():\...
[ "0.7025049", "0.6521409", "0.6378542", "0.62963414", "0.6219195", "0.6097285", "0.60449445", "0.5851369", "0.5845113", "0.5843361", "0.5717884", "0.5716023", "0.5675595", "0.5556713", "0.5540878", "0.54813397", "0.5472343", "0.54518175", "0.54498523", "0.54407346", "0.5436073...
0.75665087
0
Scans available smb services in the database for smb signing and ms17010.
def nmap_smb_vulnscan(): service_search = ServiceSearch() services = service_search.get_services(ports=['445'], tags=['!smb_vulnscan'], up=True) services = [service for service in services] service_dict = {} for service in services: service.add_tag('smb_vulnscan') service_dict[str(se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_samba_clients(self):\n # TODO preferably use a library, don't assume localhost.\n logging.debug(\"inspecting samba...\")\n command = 'sudo smbstatus -p | sed -n 5p | tr -s \" \" | cut -d\" \" -f4'\n output = utils.run_os_command(command)\n return output.strip().split(\"\...
[ "0.62371737", "0.5669815", "0.53696716", "0.53552085", "0.53151625", "0.5273359", "0.5259361", "0.5240157", "0.51579183", "0.51324147", "0.5113975", "0.5078871", "0.5054602", "0.5043952", "0.5043248", "0.5041043", "0.503842", "0.5036707", "0.50204873", "0.5011913", "0.5010239...
0.6513238
0
Performs os (and domain) discovery of smb hosts.
def os_discovery(): hs = HostSearch() hosts = hs.get_hosts(ports=[445], tags=['!nmap_os']) # TODO fix filter for emtpy fields. hosts = [host for host in hosts if not host.os] host_dict = {} for host in hosts: host_dict[str(host.address)] = host arguments = "--script smb-os-discov...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nslookup(self):\n if len(self.hostnames) == 0:\n st, out = commands.getstatusoutput('get_instance_by_service %s' % self.bns)\n assert st == 0, \"Failure:'get_instance_by_service %s', errno=%d\" % (self.bns, st)\n self.hostnames = out.split('\\n')\n assert self.hos...
[ "0.57663345", "0.5488624", "0.53603756", "0.5260246", "0.52439183", "0.5241199", "0.52410096", "0.5170347", "0.51309216", "0.5104058", "0.50928646", "0.50926536", "0.5088061", "0.5071322", "0.50709414", "0.5067245", "0.5057643", "0.50443965", "0.50281113", "0.5010868", "0.500...
0.6300907
0
Get number of nodes in an evaluator tree
def nodeCount(eval): if not isEvaluator(eval): return 0 return eval.ReferencedNodes().Size()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self):\n return self.__tree.node_count", "def countNodes(epr):\n result = 1\n argLst = epr.args\n for arg in argLst:\n result += countNodes(arg)\n return result", "def uniqueNodeCount(eval):\n if not isEvaluator(eval):\n return 0\n return eva...
[ "0.75622797", "0.7529294", "0.7479575", "0.7247177", "0.72267604", "0.7162352", "0.7160398", "0.70068026", "0.69996077", "0.6992341", "0.6980684", "0.695798", "0.69542134", "0.69283307", "0.6926007", "0.6905633", "0.6887969", "0.68765336", "0.68759674", "0.68656826", "0.68631...
0.83393586
0
Get number of unique nodes in an evaluator tree
def uniqueNodeCount(eval): if not isEvaluator(eval): return 0 return eval.ReferencedUniqueNodes().Size()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodeCount(eval):\n if not isEvaluator(eval):\n return 0\n return eval.ReferencedNodes().Size()", "def countNodes(epr):\n result = 1\n argLst = epr.args\n for arg in argLst:\n result += countNodes(arg)\n return result", "def count_unique(self) -> int:\n ...
[ "0.7576809", "0.7254298", "0.71891284", "0.71155745", "0.70935607", "0.70214313", "0.6912688", "0.6897794", "0.6867565", "0.6790366", "0.67900467", "0.6774255", "0.6749377", "0.6732378", "0.672201", "0.67205966", "0.6686232", "0.66795933", "0.66662836", "0.66526145", "0.66101...
0.84147877
0
Get number of evaluators dependant of an evaluator, ie parents
def doDependentCount(eval, log): if not isEvaluator(eval): return 0 dependents = eval.Dependents() count = 0 if log: skippedMsgs = [] print ('***************************') print ('Input: ' + str(eval)) for dep in dependents: if hasattr(dep, "IsKindOf"...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodeCount(eval):\n if not isEvaluator(eval):\n return 0\n return eval.ReferencedNodes().Size()", "def get_number_of_evaluation(self):\n return self.n_eval", "def countNodes(epr):\n result = 1\n argLst = epr.args\n for arg in argLst:\n result += countNodes...
[ "0.6929427", "0.6591238", "0.6296858", "0.62552387", "0.60923344", "0.6016347", "0.59949905", "0.59949905", "0.59826666", "0.59242123", "0.58922696", "0.5888797", "0.58361304", "0.5833104", "0.58175397", "0.5810677", "0.57730937", "0.574246", "0.5709555", "0.5677782", "0.5672...
0.6347132
2
Get average profiling time for an evaluator
def avg(ev): profData = getProfilingData(ev) if profData is not None: return profData.Tavg() return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def avg_inference_time(self):\n return self._avg_inference_time", "def mean_run_time(self) -> float:\n return float(self.result_array.sum(axis=0).mean())", "def get_average_execution_time_value(execution_time):\n if all_results_are_merged:\n # There will be multiple branch cover...
[ "0.6653341", "0.6610705", "0.6419527", "0.63969165", "0.6383479", "0.63042825", "0.6289734", "0.62701607", "0.6252877", "0.6204559", "0.6181674", "0.6152221", "0.6139389", "0.6118519", "0.6111415", "0.6096281", "0.6076748", "0.6076074", "0.6073837", "0.6021519", "0.60152686",...
0.6432693
2
Get accumulated profiling time for an evaluator
def acc(ev): profData = getProfilingData(ev) if profData is not None: return profData.Tacc() return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_time(self):\n return self.compute_time_without_gc() + self.gc_time", "def timings(self):\r\n return self._timings", "def perf_timer():\n start_time = datetime.now()\n yield\n end_time = datetime.now()\n log.info(end_time - start_time)", "def GetCpuTimestamp(self):\n return {'...
[ "0.6357354", "0.6236055", "0.6222545", "0.61795944", "0.6170181", "0.607339", "0.6047909", "0.6019864", "0.59656215", "0.5904349", "0.58972514", "0.5896824", "0.5888479", "0.5883879", "0.5877799", "0.5868603", "0.58448243", "0.5841196", "0.583563", "0.58150375", "0.58019006",...
0.0
-1
Get max profiling time for an evaluator
def max(ev): profData = getProfilingData(ev) if profData is not None: return profData.Tmax() return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_time(self) -> float:\r\n if(len(self.operations_by_name) == 0):\r\n return -1\r\n return max(map(lambda x: x[\"time_step\"], self.operations_by_name.values()))", "def max(self):\n\n return time_stat(self, stat=\"max\")", "def getMaxSimTime(self):\n return self.max_sim...
[ "0.6709669", "0.62209153", "0.6059053", "0.6050143", "0.6025128", "0.60107434", "0.5955151", "0.5945843", "0.5939467", "0.59079236", "0.5812572", "0.5812572", "0.57888734", "0.57609487", "0.57224643", "0.57156175", "0.5695369", "0.56885415", "0.5660657", "0.56372124", "0.5609...
0.64209914
1
Get min profiling time for an evaluator
def min(ev): profData = getProfilingData(ev) if profData is not None: return profData.Tmin() return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_time(self):\n #{{{ function to return time of first sample\n\n return self.mintime", "def min(self):\n\n return time_stat(self, stat=\"min\")", "def get_min_tim(self):\n return self.get_shortest_mode().tim", "def min_time(self):\n return self._ll_tree_sequence.get_min_time(...
[ "0.65390086", "0.6491748", "0.6374993", "0.62546337", "0.62226903", "0.61515844", "0.5921736", "0.5845982", "0.5836962", "0.58335114", "0.5820608", "0.5797174", "0.57750994", "0.5770553", "0.57538813", "0.57335234", "0.57052904", "0.57025284", "0.56895", "0.5687751", "0.56761...
0.68451685
0
Get propagated cost profiling time for an evaluator
def cost(ev): profData = getProfilingData(ev) if profData is not None: return profData.PropagatedCost() return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_time(self):\n return self.compute_time_without_gc() + self.gc_time", "def computation_time(self) -> float:\r\n if self._computation_times is None:\r\n return None\r\n else:\r\n return self._computation_times[0]", "def perf_timer():\n start_time = datetime.n...
[ "0.6636906", "0.6144508", "0.61103594", "0.6105323", "0.6021323", "0.59983486", "0.5941204", "0.592668", "0.59159535", "0.59084445", "0.5887483", "0.5884865", "0.58274376", "0.5812681", "0.57631546", "0.5761986", "0.5759631", "0.57565475", "0.57422686", "0.57337075", "0.57311...
0.64273757
1
Get profiling call count for an evaluator
def count(ev): profData = getProfilingData(ev) if profData is not None: return profData.Count() return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def op_callcount(self):\r\n # timing is stored by node, we compute timing by Op on demand\r\n rval = {}\r\n for node, count in self.apply_callcount.items():\r\n rval.setdefault(node.op, 0)\r\n rval[node.op] += count\r\n return rval", "def class_callcount(self):\r...
[ "0.645071", "0.6406745", "0.63925785", "0.63677806", "0.63302857", "0.6281262", "0.6211619", "0.6148319", "0.6045033", "0.60330534", "0.6007769", "0.60064745", "0.5980804", "0.59685713", "0.5929456", "0.58637774", "0.5863227", "0.5843919", "0.58364314", "0.5831876", "0.582873...
0.6478726
0
Get profiling total call count for evaluator descendants
def dcount(ev): profData = getProfilingData(ev) if profData is not None: a = profData.Descendants().AsArray() if len(a) > 0: return profData.DescendantCount(a[0]) return ""
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def class_callcount(self):\r\n # timing is stored by node, we compute timing by class on demand\r\n rval = {}\r\n for node, count in self.apply_callcount.items():\r\n typ = type(node.op)\r\n rval.setdefault(typ, 0)\r\n rval[typ] += count\r\n return rval"...
[ "0.6942295", "0.6894825", "0.6448754", "0.6368588", "0.6336088", "0.6323855", "0.62947893", "0.62349457", "0.62281996", "0.6223465", "0.61490244", "0.6130873", "0.6120092", "0.61115897", "0.60901487", "0.604145", "0.60308754", "0.60130274", "0.5990126", "0.58869624", "0.58549...
0.60667473
15
a tuple containing the device and the autosave strings
def generate_device_specific( device, device_number: int, ip_asyn_port: str, sector ) -> typing.Tuple[str, str]: res = "" _as = "" prefix = device.prefix serial_address = device.serial_address channels = device.channels for i in range(4): if channels[i] is None: # @todo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getLatestAutosave():\n nukeAutoSavePath = nuke.toNode(\"preferences\").knob('AutoSaveName').evaluate()\n if os.path.exists(nukeAutoSavePath):\n latestAutosave = cmd.getstatusoutput('ls -1tr '+nukeAutoSavePath+' | tail -1')[1]\n latestAutosavePy = latestAutosave.split('.')[0]+'.nk'\n ...
[ "0.58341247", "0.57714856", "0.5669109", "0.5427801", "0.53116256", "0.5254177", "0.52220273", "0.52175", "0.5199559", "0.51973975", "0.5164707", "0.5159505", "0.51471555", "0.513835", "0.5134263", "0.5087733", "0.5082035", "0.50702757", "0.50481826", "0.5037174", "0.50205785...
0.0
-1
Van Der Pol oscilator rewritten as a system of two first order ODE's
def van_der_pol(pos): epsilon = 0.1 def x_dot(x, y): return (1 / epsilon) * (y - ((1/3)*(x**3) - x)) def y_dot(x, y): return -epsilon * x return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def van_der_pol_oscillator_deriv(x, t):\n \n x1 = x[1]\n y = -nu * (x[0] ** 2.0 - 1.0) * x[1] - x[0]\n result = np.array([x1, y])\n return result", "def ode(self, **kwargs):\n pass", "def get_ode(self, d):\n C1 = np.array([[-1./self.Q, -1.], [1., 0.]])\n C2 = np.array([[1.],...
[ "0.67783046", "0.6365935", "0.6167238", "0.6111346", "0.60931164", "0.6071298", "0.6022355", "0.5944856", "0.59336215", "0.5882533", "0.5867107", "0.58559364", "0.5838924", "0.58322763", "0.581218", "0.57877517", "0.5785348", "0.5784892", "0.57654876", "0.57618225", "0.575517...
0.0
-1
Model of a pendulum
def pendulum(pos): def x_dot(x, y): return y def y_dot(x, y): return -np.sin(x) return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulum\n self.dt = dt", "def damped_pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -0.1*y - np.sin(x)\n\n return np.array([x_dot(po...
[ "0.68147796", "0.6339868", "0.6296034", "0.60743606", "0.5980977", "0.5754878", "0.5716205", "0.56013805", "0.5563842", "0.54992867", "0.54514074", "0.5432418", "0.543091", "0.54245365", "0.54043674", "0.54034466", "0.5398115", "0.53881854", "0.5375106", "0.5373626", "0.53723...
0.6975272
0
Model of a damped pendulum
def damped_pendulum(pos): def x_dot(x, y): return y def y_dot(x, y): return -0.1*y - np.sin(x) return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulum\n self.dt = dt", "def _model(self, t, theta, period, tmpid):\n template = self.templates[tmpid]\n phase = (t / period - theta[2]) % 1\n return theta[0] + th...
[ "0.6389757", "0.62570584", "0.6251534", "0.6018877", "0.5953172", "0.58293605", "0.58160734", "0.5796524", "0.57523537", "0.56851745", "0.56645703", "0.5663768", "0.56319314", "0.562755", "0.55919474", "0.55872536", "0.5567067", "0.55479765", "0.5503377", "0.54973847", "0.549...
0.6742539
0
Model of a pendulum
def strange_attractor(pos): P = 10 R = 350 B = 8/3 #P = 10 #R = 35 #B = 5 def x_dot(x, y, z): return P * (y - x) def y_dot(x, y, z): return R*x - y - x*z def z_dot(x, y, z): return x*y - B*z return np.array([x_dot(pos[0], pos[1], pos[2]), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -np.sin(x)\n\n return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])", "def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulu...
[ "0.6975272", "0.68147796", "0.6339868", "0.6296034", "0.60743606", "0.5980977", "0.5754878", "0.5716205", "0.56013805", "0.5563842", "0.54992867", "0.54514074", "0.5432418", "0.543091", "0.54245365", "0.54043674", "0.54034466", "0.5398115", "0.53881854", "0.5375106", "0.53736...
0.0
-1
Model of a pendulum
def rossler_attractor(pos): A = 0.2 B = 0.2 C = 5.7 def x_dot(x, y, z): return -(y + z) def y_dot(x, y, z): return x + A*y def z_dot(x, y, z): return B + x*z - C*z return np.array([x_dot(pos[0], pos[1], pos[2]), y_dot(pos[0], pos[1], pos[2]),...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -np.sin(x)\n\n return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])", "def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulu...
[ "0.6975272", "0.68147796", "0.6339868", "0.6296034", "0.60743606", "0.5980977", "0.5754878", "0.5716205", "0.56013805", "0.5563842", "0.54992867", "0.54514074", "0.5432418", "0.543091", "0.54245365", "0.54043674", "0.54034466", "0.5398115", "0.53881854", "0.5375106", "0.53736...
0.0
-1
Hard sigmoid function For a given value u as input, it gives hard sigmoid of u as output.
def hard_sigmoid(u): if u > 1: ro = 1 elif u < 0: ro = 0 else: ro = u return ro
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hard_sigmoid_derivative(u):\r\n if u > 1:\r\n ro = 0\r\n elif u < 0:\r\n ro = 0\r\n else:\r\n ro = 1\r\n return ro", "def sigmoid(x):\n return 1 / (1 - (power(e,-x)))", "def sigmoid(z):\r\n \r\n return vSigmoid(z);", "def sigmoid(x):\n return 1 / (1 + exp(-x)...
[ "0.8340554", "0.7792559", "0.77599376", "0.7747133", "0.7747133", "0.76981646", "0.7667149", "0.7664956", "0.7651496", "0.76462394", "0.76462394", "0.76407063", "0.7631713", "0.76259273", "0.76033205", "0.76024806", "0.7595583", "0.7590885", "0.7590708", "0.7586715", "0.75819...
0.83319825
1
Hard sigmoid function for an array of values For a given array u as input, it gives hard sigmoid of u as output.
def hard_sigmoid_array(u): ro = np.zeros(len(u)) for i in np.arange(len(u)): ro[i] = hard_sigmoid(u[i]) return ro
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sigmoid(t):\n return np.exp(t)/(1+np.exp(t))", "def sigmoid(x: np.ndarray \n ) -> np.ndarray:\n return 1/(1+np.exp(-x))", "def sigmoid(values, gain, shift):\n import numpy as np\n\n tiny = 0.000000001\n\n # Make sure argument is a numpy array\n if type(values) != np.ndarr...
[ "0.7557232", "0.75521666", "0.7530991", "0.75062776", "0.74866426", "0.7473698", "0.74650526", "0.7455005", "0.7455005", "0.7455005", "0.7455005", "0.7455005", "0.7455005", "0.74319494", "0.7427566", "0.7409621", "0.74043214", "0.7399037", "0.7392596", "0.7390544", "0.7388159...
0.8358422
0
Derivative of hard sigmoid function For a given value u as input, it gives hard sigmoid derivative of u as output.
def hard_sigmoid_derivative(u): if u > 1: ro = 0 elif u < 0: ro = 0 else: ro = 1 return ro
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def derivative_sigmoid(x):\n return x * (1 - x)", "def derivative_sigmoid(x):\n return x * (1 - x)", "def sigmoid_derivative(x):\n return x * (1-x)", "def sigmoid_derivative(x):\n return x * (1.0 - x)", "def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))", "def sigmoid_der...
[ "0.7970959", "0.7970959", "0.79495186", "0.7897426", "0.7845998", "0.7710246", "0.7476678", "0.7226657", "0.7202913", "0.71984", "0.70288426", "0.69358486", "0.6927546", "0.69059795", "0.6862626", "0.6840817", "0.6803506", "0.6792324", "0.6756603", "0.67067933", "0.6668996", ...
0.8027031
0
Free phase function This function determines states dynamics and their final values, and the convergence time as output according to the free phase.
def free_phase(w, b, v, n_iter, eps, fan_in, fan_hidden, fan_out): start_time = time.time() s = np.asarray( np.random.RandomState().uniform(low=-np.sqrt(6. / (fan_in + fan_out)), high=np.sqrt(6. / (fan_in + fan_out)), size=(fan_hidden + fan_out,))) u = np...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __update_if_required(self, time, phase):\n if (not self.__force_update) and (time, phase) == self.__last_params:\n return\n self.__last_params = (time, phase)\n self.__sin = np.sin(self.__rabi_mod * 0.5 * time)\n self.__cos = np.cos(self.__rabi_mod * 0.5 * time)\n ...
[ "0.58598506", "0.57560414", "0.5753303", "0.5736742", "0.5542678", "0.5542645", "0.55395633", "0.553148", "0.5518612", "0.5518064", "0.54858553", "0.5479553", "0.5467217", "0.5458112", "0.5453849", "0.541411", "0.5410637", "0.54043305", "0.5385624", "0.5383069", "0.5352124", ...
0.5824797
1
Weakly clamped phase function This function determines states dynamics and their final values, and the convergence time as output according to the weakly clamped phase.
def weaklyClamped_phase(w, b, v, y_onehot, epoch, beta, n_iter, eps, fan_in, fan_hidden, fan_out): start_time = time.time() s = np.asarray( np.random.RandomState().uniform(low=-np.sqrt(6. / (fan_in + fan_out)), high=np.sqrt(6. / (fan_in + fan_out)), size=(fan_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phasefold(t, P, t0, starting_phase=-0.5):\n t = np.array(t)\n dt = t0shft( np.array(t), P, t0)\n tshift = t + dt\n t_phasefold = np.mod(tshift - starting_phase*P, P) + starting_phase * P\n phase = t_phasefold / P\n cycle = np.floor(tshift/P - starting_phase).astype(int)\n return t_phasefol...
[ "0.57427216", "0.5517094", "0.531438", "0.5293937", "0.52501124", "0.5207172", "0.5200721", "0.51790994", "0.5178072", "0.5168876", "0.5124565", "0.5105001", "0.50900114", "0.50700676", "0.50423545", "0.50392187", "0.5019811", "0.50197685", "0.5018847", "0.5014742", "0.500329...
0.59560907
0
Weight update function This function updates the weights.
def weight_update(u_ff, u_wc, alpha, beta, w, fan_all): mult_wc = np.matmul(np.reshape(hard_sigmoid_array(u_wc), (fan_all, 1)), np.reshape(hard_sigmoid_array(u_wc), (1, fan_all))) mult_ff = np.matmul(np.reshape(hard_sigmoid_array(u_ff), (fan_all, 1)), np.resha...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_weights(self):\n\t\tpass", "def update_weights(self):\n self._weights = self._weights + self.update_weights_value", "def update_weights(self):\n self._weights = self._weights + self.update_weights_value\n self.weights_clipping()", "def updateWeights(self,weightUpdate):\n\t\n\t...
[ "0.87812054", "0.86967194", "0.84079665", "0.823003", "0.7969475", "0.79565686", "0.79220754", "0.7916582", "0.7887394", "0.771643", "0.76431197", "0.7587686", "0.7503989", "0.74916613", "0.73891324", "0.7367587", "0.7352369", "0.7352369", "0.7352369", "0.7352369", "0.7291205...
0.73871416
15
This method is intended to create a new group element after the initial installation is complete. It will create a file containing the group and job selection/matchin criteria. This can then be manually merged into the existing frontend configuration file.
def get_new_config_group(self): filename = "%(config_dir)s/%(group)s.%(time)s" % \ { "config_dir": self.config_dir(), "group": self.group_name(), "time": common.time_suffix(),} common.write_file("w", 0o644, filename, self.get_match_criteria())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def createMainGroup(self):\n\t\tmc.group( n = self.grp.name, em = True )", "def createGroup(self, name):\n new_group = ET.SubElement(self._root,'group')\n group_name = ET.SubElement(new_group, 'name')\n group_name.text = name\n # update the document's groups\n self._groups = self._root.findall('gr...
[ "0.64204746", "0.6273165", "0.609973", "0.58930635", "0.58930635", "0.585004", "0.58285666", "0.5814239", "0.58060133", "0.57745683", "0.5757875", "0.575727", "0.5730281", "0.5723413", "0.5714178", "0.5712287", "0.56967247", "0.5644694", "0.56357884", "0.5604819", "0.5562929"...
0.67966115
0
This method attempts to clean up all directories so a fresh install can be accomplished successfully. It is consoldiated in a single check so as to only ask once and not for each directory.
def verify_directories_empty(self): if self.install_type == "rpm": return # For RPM install we don't want to clean anything instance_dir = "frontend_%(service)s-%(instance)s" % \ { "service": self.service_name(), "instance": self.glidein.instance_name(), } ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def try_clean(self):\n for f in self.FILES_TO_CLEAN:\n if not os.path.exists(f):\n continue\n\n if os.path.isdir(f):\n # don't care on error\n shutil.rmtree(f, onerror=lambda *x, **y: None)\n else:\n self.safe_delet...
[ "0.74447376", "0.73241925", "0.71441674", "0.7128869", "0.7061443", "0.7038404", "0.7005379", "0.69962335", "0.69664586", "0.6964546", "0.6936114", "0.69127035", "0.68968123", "0.6844384", "0.6836401", "0.6826492", "0.6820406", "0.6812501", "0.68029016", "0.6763443", "0.67616...
0.6714952
23
The VOFrontend service can share the same instance of Condor with the UserCollector and/or Schedd services. So we want to check and see if this is the case. We will skip the installation of Condor and just perform the configuration of the condor_config file.
def determine_colocated_services(self): if self.install_type() == "rpm": return # Not needed for RPM install services = "" # -- if not on same node, we don't have any co-located if self.hostname() == self.usercollector.hostname(): if self.condor_location() == self.usercollector.c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_config(self):", "def check_configs(self):\n\n pass", "def configure(self, conf):\n return False", "def handleCondorStatusService(self):\n procScript = \"cmssw_handle_condor_status_service.py\"\n cmd = \"%s --input_pkl %s --output_pkl %s --name %s\" % (\n proc...
[ "0.5896995", "0.5661055", "0.5633242", "0.5532198", "0.5482386", "0.5431263", "0.542196", "0.53726244", "0.5362765", "0.5343296", "0.5337556", "0.53289133", "0.53210413", "0.52994794", "0.529925", "0.52943397", "0.5285092", "0.528452", "0.5275828", "0.5275431", "0.5272948", ...
0.50878876
30
Determine the job constraints/matching criteria for submitting jobs.
def get_match_criteria(self): #-- factory attributes ---- print(""" What glidein/factory attributres are you using in the match expression? I have computed my best estimate for your match string, please verify and correct if needed. """) default_factory_attributes = string.join(self.extract_factory_attrs(), '...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def criteria(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Criterion]:", "def get_data_reqs(self):\n reqs = {\n \"requires_partial_lc\": True,\n \"metric\": self.metric,\n \"requires_hyperparameters\": False,\n \"hyperpara...
[ "0.57358813", "0.5659757", "0.5569344", "0.55406904", "0.55322236", "0.55069834", "0.54394615", "0.5389639", "0.5385479", "0.53590983", "0.5272351", "0.52676505", "0.5258483", "0.52503854", "0.5246914", "0.5218388", "0.5214789", "0.51990587", "0.5188233", "0.5180952", "0.5178...
0.4942156
71
Parses the file given to this object and stores the data obtained as the object's fields.
def parse(self): pass
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _parse(self, infile):\n raise NotImplementedError()", "def __init__(self, file):\n self.data = []\n parse_mode = 'unknown'\n for line in open(file, 'r'):\n # Figure out if we should change our parse mode\n if line == '':\n continue\n ...
[ "0.6832204", "0.68077624", "0.67919856", "0.67727983", "0.6633941", "0.65920854", "0.6585272", "0.6563904", "0.6557574", "0.65152675", "0.6491245", "0.6470125", "0.64425564", "0.64315665", "0.6416702", "0.6415605", "0.6415176", "0.6395", "0.63931954", "0.6372315", "0.636632",...
0.0
-1
calculate the attention scores of each word
def score(self, hidden, encoder_outputs): # after cat: [B, T, 2/3*H] # after attn: [B, T, H] # energy: [B, T, H] energy = F.relu(self.attn(torch.cat([hidden, encoder_outputs], dim=2))) # [B, T, H] energy = energy.transpose(1, 2) # [B, H, T] v = self.v.repeat(encod...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def analyze(self, text):\n\n score = 0.0;\n\n words = text.split(' ')\n # match each word in either the positives or negatives list adding or subtracting 1 from the score if present\n for word in words:\n for w in self.positives:\n if w == word.lower():\n ...
[ "0.69037485", "0.6777465", "0.669691", "0.66638595", "0.6655352", "0.6629472", "0.66284233", "0.6620621", "0.65981007", "0.6594562", "0.6559582", "0.6534421", "0.6527756", "0.6516296", "0.64836556", "0.6481548", "0.64703435", "0.64680326", "0.6458587", "0.64560616", "0.644371...
0.0
-1
Return the value for a given MC sample, energy or year, and information type If information is stored for both an energy and a year, the value for the given energy will be preferentially returned. If strict checking is turned on the function will raise an error if a given dictionary or piece of information isn't found....
def get_value(self, name, energy, year, key, strict=False): fields = [self.__key_field_map[key][0]+"_"+energy,self.__key_field_map[key][0]+"_"+year] if not name in self.__values_dict: raise KeyError("ERROR MCSampleValuesHelper::Unknown process \"" + str(name) + "\"") if not key in se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def value(self,pt,eta,mode):\n\n self._eta_range= get_eta_key(eta)+'_2012B'\n self._pt_range= get_pt_key(pt)\n\n if mode == '0' :\n return self._map['DoubleMu17Mu8_Mu8_Tight'][self._eta_range][self._pt_range]['data']['efficiency'] \n elif mode == '+1' :\n return self._map['DoubleMu1...
[ "0.54123473", "0.5368775", "0.5330085", "0.50552213", "0.50486755", "0.5037508", "0.49840373", "0.4980758", "0.4962545", "0.49597347", "0.4958092", "0.49424076", "0.49341348", "0.49290487", "0.49097136", "0.48970246", "0.48856208", "0.48642394", "0.4853736", "0.48443174", "0....
0.6362816
0
Execute some commands (python scripts) using a scheduler. If the script contains a '__hopla__' list of parameter names to keep trace on, all the specified parameters values are stored in the execution status.
def scheduler(commands, name="job", outputdir=None, cpus=1, use_subprocess=False, delay_upto=0, logfile=None, cluster=False, cluster_logdir=None, cluster_queue=None, cluster_memory=1, cluster_walltime=24, cluster_nb_threads=1, python_cmd="python", verbose=1): ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def call_script_on_staging(name, args=[]):\n def fn(): lib.call([os.path.join(env.staging_path, \"scripts\", name)] + args)\n time_duration(fn)", "def beginExecution(self):\n self.setup = self.am_getOption(\"Setup\", self.setup)\n self.enabled = self.am_getOption(\"EnableFlag\", self.enabled)\n self.r...
[ "0.5874737", "0.5848745", "0.58409274", "0.5711282", "0.5694308", "0.56838024", "0.56369233", "0.56181896", "0.56100684", "0.5592848", "0.55839664", "0.55704004", "0.55532855", "0.5543302", "0.5541781", "0.5539037", "0.5522676", "0.5521089", "0.5520722", "0.54800516", "0.5479...
0.56198955
7
Returns a random approximate maximum independent set.
def generate_mis(G, sample_size, nodes=None): # list of maximal independent sets max_ind_set_list=[] # iterates from 0 to the number of samples chosen for i in range(sample_size): # for each iteration generates a random maximal independent set that contains # UnitedHealth and Amazon ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_max_sampled_bandit(self)->Bandit:\n estimates = []\n for bandit in self.bandits:\n estimates.append(np.random.normal(loc =self.mu[bandit.id], scale = self.var[bandit.id]))\n return self.bandits[np.argmax(estimates)]", "def argmax(values):\n\tvalues = np.array(values)\n\tm...
[ "0.6385899", "0.6373035", "0.6325812", "0.6071461", "0.6059322", "0.60403305", "0.6027513", "0.5994413", "0.5994413", "0.5994413", "0.5994413", "0.5976374", "0.59618556", "0.59598696", "0.59598696", "0.59598696", "0.59382355", "0.5938174", "0.5854442", "0.5819924", "0.5764114...
0.6168583
3
Returns a dictionary of portfolio weights.
def centrality_to_portfolio_weights(weights): # iterates over the key, value pairs in the weights dict for key, value in weights.items(): # takes the inverse of the communicability betweeness centrality of each asset weights[key] = 1/value # normalization parameter for all weights to add ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_portfolio_weights(self) -> 'pd.Series[float]':\n position_values = pd.Series({\n asset: (\n position.last_sale_price *\n position.amount *\n asset.price_multiplier\n )\n for asset, position in self.position...
[ "0.7302032", "0.688067", "0.6818489", "0.67349046", "0.6629948", "0.65233266", "0.6515393", "0.6515393", "0.6515393", "0.6515393", "0.6513552", "0.6513552", "0.6500232", "0.6500232", "0.6455062", "0.6455062", "0.6455062", "0.6455062", "0.6455062", "0.64438415", "0.64048874", ...
0.698716
1
Returns the cumulative returns of a portfolio.
def cumulative_returns(shares_allocation, capital, test_data): # list of DataFrames of cumulative returns for each stock daily_returns = [] # iterates over every stock in the portfolio for stock in shares_allocation.index: # multiples shares by share prices in the validation dataset d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cumulative_returns(self):\n return (1 + self.pct_change).cumprod()", "def calculate_cumulative_returns_by_group(quantile_ret_ts: pd.DataFrame):\n # 1_period_return 5_period_return 10_period_return\n # factor_quantile Date\n # 1 2010-06-17 0....
[ "0.80346304", "0.7117688", "0.7020555", "0.68004584", "0.6599235", "0.65987766", "0.65317065", "0.6378568", "0.6267627", "0.61863387", "0.6161118", "0.61232454", "0.61232454", "0.6069886", "0.60389215", "0.6008858", "0.5964947", "0.5934377", "0.591715", "0.5849632", "0.582511...
0.76559335
1
Returns the daily return on investment.
def portfolio_daily_roi(shares_allocation, capital, test_data): # computes the cumulative returns cumulative_daily_returns = cumulative_returns( shares_allocation, capital, test_data ) # calculates daily return on investment daily_roi = cumulative_daily_returns.apply( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fetch_daily(self, dname, *args, **kwargs):\n if dname != 'returnsN':\n return super(QuoteFetcher, self).fetch_daily(dname, *args, **kwargs)\n\n N, date = args[:2]\n if 'offset' in kwargs:\n offset = kwargs.pop('offset')\n else:\n offset = args[-1] i...
[ "0.6251522", "0.62175494", "0.6184673", "0.6074017", "0.60315067", "0.5999271", "0.59204483", "0.58649945", "0.58231676", "0.5821116", "0.58064353", "0.57915264", "0.5759449", "0.5746898", "0.5705196", "0.5705196", "0.56715834", "0.5593716", "0.5593335", "0.55523324", "0.5540...
0.56852764
16
Returns the end of year returns of a portfolio.
def end_of_year_returns(model_roi, return_type, start, end): # converts index of datetimes to a list of strings dates = model_roi.index.astype('str').tolist() # list comprehension of a string of dates between the # start and end dates years = [str(x) for x in range(start, end + 1)] # generate...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def end_year(self) -> float:\n\n end_year = -np.inf\n for td_table in list(self.tdve.values()) + self.transfers + self.interpops:\n if len(td_table.tvec) and np.amax(td_table.tvec) > end_year:\n end_year = np.amax(td_table.tvec)\n return end_year", "def model_end_ye...
[ "0.66694117", "0.6252978", "0.5982185", "0.5906132", "0.59023", "0.5769457", "0.5755498", "0.5709566", "0.56960356", "0.56714946", "0.5662829", "0.563564", "0.55554664", "0.5549461", "0.5539725", "0.5533944", "0.54835814", "0.5468832", "0.5411401", "0.5375918", "0.536325", ...
0.6676339
0
Returns average annual returns.
def avg_annual_returns(end_of_year_returns, mstat): # imports mean stats from scipy.stats import mstats # converts returns dict to an array (in decimal fmt) returns_arr = np.array(list(end_of_year_returns.values()))/100 if mstat == 'geometric': # calculates the geometric mean gme...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def annual_return(returns, period=DAILY):\n\n if returns.size < 1:\n return np.nan\n\n try:\n ann_factor = ANNUALIZATION_FACTORS[period]\n except KeyError:\n raise ValueError(\n \"period cannot be '{}'. \"\n \"Must be '{}', '{}', or '{}'\".format(\n ...
[ "0.7513993", "0.7327938", "0.7215449", "0.6849367", "0.6817595", "0.68023896", "0.66719836", "0.66230255", "0.6608608", "0.6540497", "0.64067215", "0.6393488", "0.6343028", "0.6321957", "0.63070506", "0.62917763", "0.6256154", "0.6240215", "0.61818576", "0.60735667", "0.60480...
0.8158878
0
Returns annualized portfolio volatility.
def portfolio_std(weights, test_data): # computes daily change in returns from 2015-2017 daily_ret_delta = test_data.pct_change() # computes the covariance matrix of the above cov_matrix = daily_ret_delta.cov() # initializes weights weights_list = [] # iterates over weights dict and appe...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def annualized_volatility(self):\n return self.daily_std() * math.sqrt(252)", "def calc_volatility(self):\n volatility = std(self._returns)\n self._volatility = volatility\n return volatility", "def annual_volatility(returns, period=DAILY):\n\n if returns.size < 2:\n retur...
[ "0.8074476", "0.7391112", "0.7350425", "0.7104371", "0.6744522", "0.6657975", "0.66555136", "0.66555136", "0.6492553", "0.6439596", "0.6372493", "0.6310216", "0.61207324", "0.61000425", "0.60233104", "0.59982216", "0.5941567", "0.5931666", "0.59143764", "0.5911077", "0.588697...
0.564987
26
Returns annualized portfolio volatility.
def mis_portfolio_std(weights, test_data, maximum_independent_set): # computes daily change in returns from 2015-2017 daily_ret_delta = test_data[maximum_independent_set].pct_change() # computes the covariance matrix cov_matrix = daily_ret_delta.cov() # initializes weights list weights_list =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def annualized_volatility(self):\n return self.daily_std() * math.sqrt(252)", "def calc_volatility(self):\n volatility = std(self._returns)\n self._volatility = volatility\n return volatility", "def annual_volatility(returns, period=DAILY):\n\n if returns.size < 2:\n retur...
[ "0.8074476", "0.7391112", "0.7350425", "0.7104371", "0.6744522", "0.6657975", "0.66555136", "0.66555136", "0.6492553", "0.6439596", "0.6372493", "0.6310216", "0.61207324", "0.61000425", "0.60233104", "0.59982216", "0.5941567", "0.5931666", "0.59143764", "0.5911077", "0.588697...
0.0
-1
Returns the daily running 252day maximum.
def daily_rolling_max(cumulative_returns, window=252, min_periods=1): return cumulative_returns.rolling( window=window, min_periods=min_periods ).max()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def obtain_daily_maximum(data=pd.DataFrame()):\n return data.resample(\"D\").max()", "def _max_days(self):\n # type: (...) -> Union[int, Tuple[int]]\n\n return self.value.max_days", "def max_days(self):\n # This can be refined, as there are at max 2 consecutive months with 31\n #...
[ "0.73749036", "0.7217937", "0.70836467", "0.667602", "0.6598183", "0.6598183", "0.6532576", "0.64994997", "0.6396165", "0.6396148", "0.62458897", "0.6223828", "0.61432564", "0.6141461", "0.6097955", "0.60674804", "0.58854157", "0.58501315", "0.5818336", "0.5808526", "0.575486...
0.6340012
10
Returns the daily running 252day drawdown.
def daily_rolling_drawdown(cumulative_returns, rolling_max): return (cumulative_returns / rolling_max) - 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)", "def _get_daily_drawing_prompt(self) -> str:\n\n site = urllib.request.urlopen(\n urllib.request.Request(\"https://reddit.com/r/SketchDaily/new\", headers={'User-Agent': 'Mozilla/5.0'}))\n site_...
[ "0.6324104", "0.60545033", "0.6035098", "0.59931993", "0.5970094", "0.5958163", "0.59536815", "0.591748", "0.5884653", "0.5840686", "0.57922554", "0.56973386", "0.5680856", "0.5680856", "0.5662309", "0.56341743", "0.5618964", "0.5577764", "0.55763453", "0.55734617", "0.556395...
0.6346399
0
Returns the daily running 252day maximum daily drawdown.
def max_daily_rolling_drawdown(daily_drawdown, window=252, min_periods=1): return daily_drawdown.rolling( window=window, min_periods=min_periods ).min()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)", "def max_drawdown_date(self) -> dt.date:\n mdd_date = (self.tsdf / self.tsdf.expanding(min_periods=1).max()).idxmin().values[0].astype(dt.datetime)\n return dt.datetime.fromtimestamp(mdd_date / 1e9).date()...
[ "0.8053372", "0.7309904", "0.7136397", "0.6945596", "0.66620314", "0.65847397", "0.65381736", "0.6391821", "0.623571", "0.61597496", "0.59037566", "0.5875009", "0.5865871", "0.58287054", "0.5795373", "0.5767846", "0.57399833", "0.56995285", "0.5673958", "0.56637424", "0.56529...
0.7519542
1
Returns the lifetime maximum drawdown.
def lifetime_max_drawdown(daily_drawdown): return round(daily_drawdown.min()*100, 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def MaxLifetime(self):\r\n\t\treturn self._get_attribute('maxLifetime')", "def max_age(self):\n return 120 if self.realtime else 1800", "def max(self):\n\n return time_stat(self, stat=\"max\")", "def max_frame_age(self) -> float:\n return self._max_frame_age", "def max_time(self):\n ...
[ "0.70438933", "0.6749617", "0.6718662", "0.6696578", "0.6525013", "0.64177185", "0.6395959", "0.63215995", "0.6261537", "0.6258824", "0.6245386", "0.61703086", "0.6164336", "0.6164336", "0.6155133", "0.6142087", "0.6137692", "0.6115013", "0.60518104", "0.60164064", "0.5985856...
0.7830443
0
Returns the lifetime maximum drawdown.
def returns_over_max_drawdown(tot_returns_dict, year, lifetime_maximum_drawdown): return round(tot_returns_dict[year] / abs(lifetime_maximum_drawdown), 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)", "def MaxLifetime(self):\r\n\t\treturn self._get_attribute('maxLifetime')", "def max_age(self):\n return 120 if self.realtime else 1800", "def max(self):\n\n return time_stat(self, stat=\"max\")", "def ma...
[ "0.7830443", "0.70438933", "0.6749617", "0.6718662", "0.6696578", "0.6525013", "0.64177185", "0.6395959", "0.63215995", "0.6261537", "0.6258824", "0.6245386", "0.61703086", "0.6164336", "0.6164336", "0.6155133", "0.6142087", "0.6115013", "0.60518104", "0.60164064", "0.5985856...
0.6137692
17
Returns the growthrisk ratio.
def portfolio_growth_risk(avg_annual_returns, max_daily_rolling_drawdown): return round(avg_annual_returns / abs(max_daily_rolling_drawdown.mean()*100), 2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def golden_ratio():\n return 1.61803398875", "def bw_ratio(self):\r\n bw = self.bwstats.mean\r\n if bw == 0.0: return 0\r\n else: return self.bw/(1024.*bw)", "def adv_ratio(self): # XXX\r\n bw = StatsRouter.global_bw_mean\r\n if bw == 0.0: return 0\r\n else: return self.bw/bw", "def span...
[ "0.68468666", "0.6782805", "0.6716115", "0.67120725", "0.66483486", "0.663469", "0.6482645", "0.6453428", "0.6384429", "0.63716984", "0.6366324", "0.6349121", "0.6314736", "0.6272553", "0.62707216", "0.6267296", "0.6262057", "0.62570226", "0.6190915", "0.6126322", "0.60882515...
0.0
-1
Construct an ESL Receipt.
def __init__(self, db: DB, values: list, user_id: int) -> None: super(ESLReceipt, self).__init__() self.db = db self.transaction_number = values[0] self.date = format_date(values[1]) self.description = values[2] self.memo = values[3] self.amount_debit = values[4]...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def work_order_receipt_create(self, work_order_id, worker_id,\n worker_service_id,\n requester_id,\n receipt_create_status,\n work_order_request_hash,\n id=None):\n pass", "def _generate_cybersource_sa_payload(*, order, receipt_url, cancel_url, ip_address):\n # http:/...
[ "0.6053351", "0.60198313", "0.5788419", "0.57612604", "0.57396764", "0.56825536", "0.5476821", "0.54742515", "0.54360664", "0.5352504", "0.5342289", "0.53357846", "0.53357846", "0.53352183", "0.5319554", "0.5299511", "0.52830905", "0.52596617", "0.52482724", "0.52446", "0.519...
0.6187345
0
Create a list representation of this object.
def to_list(self) -> list: return [self.transaction_number, self.date, self.description, self.memo, self.amount_debit, self.amount_credit, self.balance, self.check_number, self.fees, self.card_type, self.is_payment, self.is_transaction, self.user_id]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_list(cls, *args):\n return _create_list(cls, *args)", "def create_list(cls, *args):\n return _create_list(cls, *args)", "def list(self):\r\n return List(self)", "def list(self):\r\n return List(self)", "def list(self):\r\n return List(self)", "def list(self) ...
[ "0.78831285", "0.78831285", "0.7854843", "0.7854843", "0.7854843", "0.7659452", "0.75172836", "0.71234053", "0.68021625", "0.67077607", "0.66552454", "0.6617766", "0.659643", "0.6589745", "0.6534543", "0.65066326", "0.6503789", "0.64903694", "0.6399522", "0.6393055", "0.63908...
0.617411
38
Create a tuple representation of this object.
def to_tuple(self) -> tuple: return (self.transaction_number, self.date, self.description, self.memo, self.amount_debit, self.amount_credit, self.balance, self.check_number, self.fees, self.card_type, self.is_payment, self.is_transaction, self.user_id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tuple(self) -> tuple:\n return tuple(self)", "def as_tuple(self):\n return (self.oid, self.type, self.value)", "def to_tuple(self):\n return tuple(self.to_list())", "def as_tuple(self):\n return self.value, self.name", "def to_tuple(self) -> Tuple[Any, Iterable[Tuple]]:\n ...
[ "0.8206062", "0.77906114", "0.77413464", "0.7683825", "0.7492797", "0.73772067", "0.73772067", "0.7250236", "0.7248604", "0.71830124", "0.71419895", "0.70949525", "0.70850444", "0.70850444", "0.7023691", "0.702011", "0.6996008", "0.6961932", "0.69082046", "0.6898514", "0.6879...
0.6833079
24
Create a dictionary representation of this object.
def to_dictionary(self) -> dict: return { 'transaction_number': self.transaction_number, 'date': self.date, 'description': self.description, 'memo': self.memo, 'amount_debit': self.amount_debit, 'amount_credit': self.amount_credit, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_obj(self):\n return dict()", "def to_dict(self):\n return dict(self)", "def asdict(self) -> dict:\n return self.__asdict(self)", "def as_dict(self):\n return dict(self.as_OD())", "def to_dict(self):\n return {}", "def to_dict(self):\n return to_dict(self._...
[ "0.81933457", "0.8123329", "0.80411434", "0.8013342", "0.7980575", "0.7973111", "0.7956117", "0.79091156", "0.7891545", "0.7891143", "0.7881474", "0.7878525", "0.7847243", "0.783445", "0.783445", "0.78194517", "0.7805945", "0.78007174", "0.77890986", "0.7784457", "0.7773048",...
0.0
-1
Remove a negative sign from the string.
def format_amount(self) -> str: if self.amount_debit != '': return self.amount_debit.replace('-', '') return self.amount_credit.replace('-', '')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_dash(string):\n\tif string[-1]=='-':\n\t\treturn string[:-1]\n\telse:\n\t\treturn string", "def remove_plus_minus(x):\n x = strip_stoich_wrapper(x)\n REPLACE_GROUP = r'([LSRD])[ -](\\([+-]\\))'\n # Adding in the r'\\1' ensures that we keep the L component, sub the rest\n ne...
[ "0.761538", "0.69173324", "0.67643726", "0.670503", "0.66739273", "0.655915", "0.64809096", "0.64616877", "0.6396145", "0.6362044", "0.62969035", "0.6272038", "0.6264692", "0.6227543", "0.62183565", "0.61224294", "0.61101955", "0.60865664", "0.6086379", "0.60761386", "0.60593...
0.0
-1
Insert this receipt into the database as well as inserting it into the transactions table, if a transaction.
def insert_to_db(self) -> None: query = '''INSERT INTO ESLReceipts(Transaction_Number, Date, Description, Memo, Amount_Debit, Amount_Credit, Balance, Check_Number, Fees, Card_Type, Is_Payment, Is_Transaction, User_id) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert(self):\n self.getDbRecord().insert()\n\n return", "def send_to_db(ck_transactions):\n db = DDDB()\n\n db.add_orders(ck_transactions)", "def insert(self, sql):\n try:\n # Execute the SQL command\n self.cursor.execute(sql)\n # Commit your cha...
[ "0.6211693", "0.6090155", "0.59534514", "0.5747204", "0.5717745", "0.57042015", "0.57042015", "0.57042015", "0.56759435", "0.5658691", "0.5618459", "0.56082004", "0.5607029", "0.56063724", "0.5585733", "0.5573718", "0.55546314", "0.5539944", "0.5531392", "0.5496173", "0.54764...
0.8284341
0
May not work with duplicate transactions on same dates, may want to figure out better query. Check to see if this object exists within the db.
def exists_in_db(self) -> bool: query = '''SELECT * FROM ESLReceipts WHERE Transaction_Number=? AND Date=? AND Description=? AND Memo=? AND Amount_Debit=? AND Amount_Credit=? AND...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _check_duplicate_trans(self):\n transactions_set = set(self._transactions)\n return len(transactions_set) == len(self._transactions)", "def alreadyStored(self, date_):\r\n for day in self._repo:\r\n if day.date == date_:\r\n return True\r\n return False",...
[ "0.63032657", "0.6060435", "0.59728163", "0.5909144", "0.5890913", "0.5875711", "0.5871815", "0.57318866", "0.5668111", "0.5658965", "0.56536156", "0.56436634", "0.5630893", "0.5628744", "0.5618186", "0.5599592", "0.5577646", "0.55707943", "0.55545235", "0.5551597", "0.551997...
0.597987
2
Retrieve the id of this object from the database.
def get_id(self) -> int: query = '''SELECT id FROM ESLReceipts WHERE Transaction_Number=? AND Date=? AND Description=? AND Memo=? AND Amount_Debit=? AND Amount_Credit=? AND Balan...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_id(self):\n return self.id", "def get_id(self):\n return self.id", "def get_id(self):\n return self.id", "def get_id(self):\n return self.id", "def get_id(self):\n return self.id", "def get_id(self):\n return self.id", "def get_id(self):\n return...
[ "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.8268289", "0.82324207", "0.82324207", "0.8194997", "0.81552595", ...
0.0
-1
Retrieve the string representation of this objects' type.
def get_type(self) -> str: return Tables.ESL.name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def type_as_string(self):\n return self.properties.get('TypeAsString', None)", "def type_name(self) -> str: # pragma: no cover\n return repr_type(self.type_obj)", "def getTypeString(self):\n return '_'.join(self.types)", "def type(self) -> str:\n return self._type", "def type(s...
[ "0.8733057", "0.8553197", "0.85377437", "0.8325933", "0.8325933", "0.8325933", "0.8290743", "0.8279878", "0.82764584", "0.82569075", "0.82285696", "0.82285696", "0.8195347", "0.81576073", "0.8149313", "0.8138784", "0.8124178", "0.81017655", "0.8085337", "0.8024441", "0.792285...
0.0
-1
Returns root endpoint HTML
def hello_world(): keyword_query = 'Gamestop' # Change it to something you're interested in! article_data = get_article_data(keyword_query) return render_template( "index.html", topic=keyword_query, headlines=article_data['headlines'], snippets=article_data['snippets'], ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_root():\r\n return render_template(\"index.html\"), 200", "def root(self):\n return self.app.get('/',headers=self.headers)", "def root():\n return render_template('index.html')", "def root():\n return render_template('index.html')", "def root():\n return render_template('index.ht...
[ "0.7781494", "0.7524314", "0.7460347", "0.7460347", "0.7460347", "0.73451215", "0.73225725", "0.7263215", "0.72324246", "0.7196254", "0.71309966", "0.7130514", "0.70534015", "0.6958472", "0.695357", "0.6901402", "0.6869037", "0.68371344", "0.68197304", "0.6809037", "0.6803652...
0.0
-1
Set a Source class from the input
def _set_source(source, context): if isinstance(source, (str, list, dict, Dataset)): return Source(source, context) elif isinstance(source, Source): return source else: raise ValueError('Wrong source')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, source):\n self._source = source", "def SphinxDummySourceClass(source: Any, *args: Any, **kwargs: Any) -> Any:\n return source", "def __init__(self, source):\r\n self.source = source", "def __init__(self, source):\n self.source = source", "def __init__(self, sourc...
[ "0.67583483", "0.67401874", "0.66732496", "0.6669555", "0.6669555", "0.65352905", "0.65030694", "0.63952017", "0.6294075", "0.6294075", "0.6294075", "0.6294075", "0.6294075", "0.6294075", "0.6294075", "0.62846047", "0.62708694", "0.6204473", "0.61683613", "0.61246663", "0.608...
0.72986305
0
Set a Style class from the input
def _set_style(style): if isinstance(style, (str, dict)): return Style(style) elif isinstance(style, Style): return style else: return Style()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_style(self):", "def set_style(self, style):\n if isinstance(style, string_types):\n style = get_style_by_name(style)\n self._style = style\n self._clear_caches()", "def style(self, style):\n\n self.container['style'] = style", "def update_css_class(kwargs, class...
[ "0.654943", "0.63310474", "0.6265196", "0.6194581", "0.61655325", "0.61655325", "0.61425185", "0.6124288", "0.6023133", "0.60221726", "0.6001759", "0.59781164", "0.59699464", "0.5902382", "0.58698934", "0.58513117", "0.5782348", "0.57525957", "0.57379335", "0.573579", "0.5732...
0.6732158
0
Set a Popup class from the input
def _set_popup(popup): if isinstance(popup, dict): return Popup(popup) elif isinstance(popup, Popup): return popup else: return Popup()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_popup(self):\n self.popup = Popup(Point(0, 2), self, \"\", \"\")\n self.popup.set_highlight_color(self.graphics.HIGHLIGHT)\n self.popup.set_secondary_color(self.graphics.DIM)\n title_color = self.graphics.BRIGHT | self.graphics.UNDERLINE\n self.popup.set_title_color(titl...
[ "0.63107663", "0.6060422", "0.5535878", "0.52886254", "0.52468014", "0.52125245", "0.51682144", "0.5146479", "0.5079666", "0.50717413", "0.50559866", "0.5050433", "0.49416202", "0.4940349", "0.48901185", "0.4874202", "0.48704216", "0.48458034", "0.4833469", "0.47811547", "0.4...
0.6512138
0
Set a Legend class from the input
def _set_legend(legend): if isinstance(legend, dict): return Legend(legend) elif isinstance(legend, Legend): return legend else: return Legend()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def legend(self, legend):\n\n self.container['legend'] = legend", "def legend(self, legend):\n\n self._legend = legend", "def legend (self, **kwargs):\n axes = self.twin_axes or self.axes\n self.mpl_legend = axes.legend (self.mpl_lines, self.labels, **kwargs)", "def finish (self, ...
[ "0.6538302", "0.64451087", "0.63078874", "0.60143113", "0.5830607", "0.5821305", "0.5782544", "0.5664723", "0.5637923", "0.55676806", "0.5538643", "0.55200446", "0.5487594", "0.54669875", "0.54185116", "0.54073274", "0.5400403", "0.53886503", "0.53818643", "0.53346527", "0.53...
0.67842346
0
generates a list of dice values into the class attribute dice. Increments throw number attribute.
def throw_dice(self): self.dice = [] for i in range (6): die = random.randint(1, 6) self.dice.append(die) self.num_throws += 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def roll_dice():\n rolled_number = []\n for number in range(0,4):\n rolled_number.append(random.randint(1, 6))\n \n rol\n \n \n class Dog():\n def __init__(self, name, age):\n self.name = name", "def rollDices():\n for i in range(5):\n dices[i] = randint(1,...
[ "0.7211979", "0.6997264", "0.6851038", "0.6751333", "0.6729713", "0.668519", "0.6677819", "0.66247433", "0.65643424", "0.6544101", "0.6543014", "0.6510373", "0.6505515", "0.6487591", "0.6461432", "0.6459857", "0.64389354", "0.6434398", "0.64102566", "0.6345126", "0.63131344",...
0.73881346
0
Calculates points from current dice roll.
def get_points(self): self.round_points = 0 for die in self.dice: if die == 1: self.round_points += 100 elif die == 5: self.round_points += 50 return self.round_points
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_points(self, dice):\n if not self.assigned:\n self._assigned = True\n self._points = self._calculate_points(dice)", "def calculate_points(self):\n points = 0\n for power in self.stats['powers']:\n points += self.stats['powers'][power]\n retu...
[ "0.66966766", "0.66681296", "0.6637562", "0.65762514", "0.6406548", "0.62852454", "0.6266145", "0.6250244", "0.62489074", "0.6243738", "0.615768", "0.6100919", "0.60981864", "0.60895824", "0.608306", "0.6028972", "0.59434074", "0.5937676", "0.5882016", "0.5868866", "0.5841612...
0.7415062
0
Determines if another throw is valid.
def can_throw(self): if self.round_points == 0: return False return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def WrapNonExceptionThrows(self) -> bool:", "def check_for_raise_condition(self, first_arg):\n for key, val in self.query_return_values.items():\n for sa_class, attr in [(DeclarativeMeta, '__table__'),\n (InstrumentedAttribute, 'property')]:\n if...
[ "0.5762478", "0.5735585", "0.5678639", "0.56598675", "0.56276846", "0.56141746", "0.55751085", "0.5548169", "0.55279744", "0.5496751", "0.54638016", "0.54616606", "0.54095435", "0.5398751", "0.539429", "0.5393722", "0.53783095", "0.53757596", "0.5365019", "0.5364991", "0.5339...
0.52178335
38
Show all data sets in one folder. Shortcut for 'demo.py show file1 e file2 ....'
def all(folder, mt=False): handles = [] experiments = get_experiment_series(folder, mT=mt) for ex in experiments: if mt: handles.append( plt.plot( ex.distance, ex.weight, label='{}mm {}mT'.format(ex.height, ex.ma...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def show_data_files(self):\n for idx in self.plot_data:\n self.plot_data[idx].show()", "def show ( self, **show_kw ):\n for package in self._subdirs.values():\n package.show ( **show_kw )", "def show_dataset(folder, n=10):\n volumes = volume_paths(folder)\n for i, v in enum...
[ "0.7206528", "0.6704359", "0.6531897", "0.62452567", "0.62223077", "0.6216129", "0.615565", "0.6036854", "0.5980537", "0.59479564", "0.59352255", "0.58796173", "0.58701545", "0.5865497", "0.586405", "0.58427453", "0.5840055", "0.5772605", "0.57498944", "0.57193184", "0.569840...
0.5747747
19
Render data in provided input file using row 2 and 3.
def show(infile, zero=False): assert len(infile) > 0, "At least one inputfile must be provided" experiments = [] for f in infile: experiments.append(Experiment(f)) plt.xlabel(r'Distance in $mm$') plt.ylabel(r'Weight in $g$') handles = [] for e in experiments: if zero: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def csvdata():\n return render_template(\"data.html\")", "def get_file_data(self):\n self.switch_row(self.PATTERN_INFO_ROW)\n\n # get background image file path\n if self.row[0] != 'No image':\n # set path to background image, and get/set screen size\n self.bg_img_pat...
[ "0.54804945", "0.5446267", "0.53765386", "0.53220177", "0.528258", "0.5273371", "0.5207391", "0.5203178", "0.5175294", "0.51712817", "0.5171099", "0.517103", "0.51068914", "0.510211", "0.5092412", "0.5082377", "0.5069564", "0.50449073", "0.50380313", "0.5024925", "0.5022232",...
0.0
-1
Find max value of every file in the provided folder.
def max(folder): experiments = get_experiment_series(folder) plt.plot([ex.height for ex in experiments], [ex.maxWeight() for ex in experiments]) plt.show()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_latest_file(folder):\n if not os.path.exists(folder):\n raise AppException(\"Folder does not exists!\")\n return max(glob.iglob(folder + \"/*\"), key=os.path.getctime)", "def get_latest(dir_list):\n int_list = []\n for directory in dir_list:\n try:\n int_l...
[ "0.70181876", "0.68163276", "0.65994817", "0.6551173", "0.6296109", "0.6280196", "0.6130655", "0.61263907", "0.60991913", "0.605896", "0.6038931", "0.6019283", "0.6011168", "0.5990008", "0.5971479", "0.5960095", "0.5925378", "0.5911864", "0.5896931", "0.5863172", "0.5847859",...
0.57354146
23
Find the breaking point of the provided graph
def find_breaks(infile, dx, minval, plot, fwmh): ex = Experiment(infile) ex.find_breaks(minval=minval, dx=dx, plot=plot)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_breaking_point(x, y):\n # select threshold where curve break\n slope = (y[-1] - y[0]) / len(y)\n y_grad = np.gradient(y)\n m = list(y_grad >= slope)\n j = m.index(False)\n m = m[j:]\n x = x[j:]\n y = y[j:]\n if True in m:\n i = m.index(True)\n else:\n i = -1\n ...
[ "0.69425875", "0.6751981", "0.62985086", "0.56206095", "0.56047994", "0.552724", "0.5449823", "0.53517556", "0.5321847", "0.5278051", "0.5276969", "0.5265826", "0.5265269", "0.52511835", "0.5230468", "0.5227905", "0.5221146", "0.52105725", "0.51963985", "0.51860183", "0.51475...
0.0
-1
kw ==>> function(file_path=file_path,save_path=save_path,kw) ex. conversion='s2t'
def CallF_DirFile_save(dir_path,function,file_head_name='new_',replace_old=False,file_filter_=None,regular=False,**kw): file_list = Get_dir_file_list(dir_path=dir_path,file_filter_=file_filter_,regular=regular,distinguish=True) file_list = file_list[0] for file_name in file_list: file_path = os.path...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def main(file):\n\n # Get the current working directory.\n here = os.getcwd()\n #Need the file_name to set globe, so that other functions can access to it.\n global file_name\n # Spite the Input into file_path and file_name.\n file_path = spilt_path(file)[0]\n file_name = spilt_path(file)[1]\n...
[ "0.5469621", "0.5448147", "0.5395161", "0.5394721", "0.52756107", "0.5140342", "0.509505", "0.50910085", "0.50839645", "0.50631875", "0.50515723", "0.50288105", "0.5018318", "0.5012531", "0.49956027", "0.49208355", "0.49167103", "0.48899543", "0.48839748", "0.48737064", "0.48...
0.0
-1
return list kw ==>> function(file_path=file_path,save_path=save_path,kw) ex. conversion='s2t'
def CallF_DirFile(dir_path,function,file_filter_=None,regular=False,**kw): file_list = Get_dir_file_list(dir_path=dir_path,file_filter_=file_filter_,regular=regular,distinguish=True) file_list = file_list[0] save_list = [] for file_name in file_list: file_path = os.path.join(dir_path,file_name) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convert(self, filepath):\n raise NotImplementedError()", "def convert_txt_to_data():\n pass", "def convert_01(filename,ext_out=\".json\"):\n summary=[]\n try:\n ext_in = os.path.splitext(filename)[1]\n if (ext_in == ext_out):\n print(\"\\tError input extention matc...
[ "0.56361085", "0.5504672", "0.54413015", "0.539796", "0.53592116", "0.53004533", "0.5227658", "0.52184165", "0.5096168", "0.502128", "0.49623695", "0.49120712", "0.48973635", "0.48932657", "0.48899108", "0.48844537", "0.48754358", "0.4872553", "0.4862515", "0.48617154", "0.48...
0.45459044
69
Filter out longer of line than max_word_num
def Filter_file_wlen(file_path,save_path,max_word_num,replace_old=False,encoding='utf-8', word_split=' ',row_split='\n',padding=None): with open(file_path,'r',encoding=encoding) as f: with open(save_path, 'w',encoding=encoding) as f_wrtie: if padding == None: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_long_words():\n f = open('session09/words.txt')\n \n for line in f:\n word = line.strip()\n if len(word) > 20:\n print(word, len(word))", "def remove_longer_words(text):\n return \" \".join([word for word in str(text).split() if len(word) <= 12])", "def filter_te...
[ "0.6970572", "0.6750624", "0.6748221", "0.6604386", "0.6440132", "0.63298947", "0.63013774", "0.6236585", "0.61541104", "0.6127007", "0.6068392", "0.5990749", "0.59631073", "0.5956658", "0.5945256", "0.59395516", "0.5923759", "0.5896358", "0.58945507", "0.58920485", "0.587292...
0.65711075
4
The number of words in the line does not exceed max_word_num, run padding.
def Padding_file_lword(file_path,save_path,max_word_num,replace_old=False,encoding='utf-8', padding='my_padding_str',word_split=' ',row_split='\n'): with open(file_path,'r',encoding=encoding) as f: with open(save_path, 'w',encoding=encoding) as f_wrtie: for line in f: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cut_in_words(self,linea):\n length = 0\n res = ''\n limit_screen = 30\n for word in linea.split(' '):\n if length + len(word) <= limit_screen:\n new_word = word + ' '\n length += len(new_word)\n else:\n new_word = '\...
[ "0.6321368", "0.62552446", "0.62552446", "0.62552446", "0.6224735", "0.62228525", "0.60601604", "0.60480917", "0.60226417", "0.59796304", "0.59780484", "0.5938737", "0.5922524", "0.59193945", "0.591625", "0.58862084", "0.58735347", "0.5864799", "0.58254963", "0.5813321", "0.5...
0.6182837
6
batch using dir_file_call_function() close log using "logging.disable(lvl)"
def Jieba_file_segmentation(file_path,save_path,replace_old=False,word_delimiter=' ', file_delimiter='\n',stopword_path=None,encoding='utf-8'): import jieba #設置log格式,以及print的log等級 logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) # ji...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setLogFileOff(self):\n self.edLogging.setLogFileOff()", "def clean_up_logging_decorator(func):\n filename = filename_regexp.match(inspect.getmodule(inspect.stack()[1][0]).__file__).group(1)\n\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n logger.info('{}: Start cleaning up'...
[ "0.62549573", "0.6227667", "0.62244844", "0.6010256", "0.58438027", "0.57851404", "0.57381016", "0.57026744", "0.5680886", "0.565489", "0.56436425", "0.5627239", "0.5612014", "0.5611865", "0.560305", "0.55806977", "0.55713636", "0.557088", "0.5515398", "0.55111116", "0.550829...
0.0
-1
batch using dir_file_call_function() close log using "logging.disable(lvl)"
def Opencc_file(file_path,save_path,replace_old=False,conversion='s2t',encoding='utf-8'): from opencc import OpenCC logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) cc = OpenCC(conversion) string = '' with open(file_path,'r',encoding=encoding) as read_f: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setLogFileOff(self):\n self.edLogging.setLogFileOff()", "def clean_up_logging_decorator(func):\n filename = filename_regexp.match(inspect.getmodule(inspect.stack()[1][0]).__file__).group(1)\n\n @functools.wraps(func)\n def wrapper(*args, **kwargs):\n logger.info('{}: Start cleaning up'...
[ "0.6256523", "0.62290466", "0.622886", "0.60116386", "0.5846248", "0.5788501", "0.57395935", "0.57019794", "0.5679706", "0.56533265", "0.5642139", "0.5629246", "0.56152624", "0.5612089", "0.56046575", "0.55847603", "0.55710196", "0.55698", "0.5516899", "0.5510668", "0.5508379...
0.0
-1
Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable here as well. By skipping the Engine creation we don't even need a DBAPI to be available. Calls to context.execute() here emit the given string to the script output.
def run_migrations_offline(): url = alembic_config.get_main_option("sqlalchemy.url") context.configure( url=url, target_metadata=target_metadata, literal_binds=True ) with context.begin_transaction(): context.run_migrations()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_migrations_offline():\n url = get_url()\n context.configure(\n url=url,\n target_metadata=target_metadata,\n literal_binds=True,\n compare_type=True,\n version_table_schema=POSTGRES_SCHEMA,\n )\n\n with context.begin_transaction():\n context.run_migrati...
[ "0.80311227", "0.8030696", "0.803014", "0.7821831", "0.7810445", "0.7810445", "0.7810445", "0.78074014", "0.78074014", "0.78003657", "0.7758784", "0.7664535", "0.75625294", "0.72418004", "0.683509", "0.6713637", "0.6491039", "0.64804435", "0.64549184", "0.6450837", "0.6417197...
0.77403295
11
Run migrations in 'online' mode. In this scenario we need to create an Engine and associate a connection with the context.
def run_migrations_online(): connectable = engine_from_config( alembic_config.get_section(alembic_config.config_ini_section), prefix='sqlalchemy.', poolclass=pool.NullPool) with connectable.connect() as connection: context.configure( connection=connection, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_migrations_online():\n # specify here how the engine is acquired\n engine = create_engine(db_url)\n if isinstance(engine, Engine):\n connection = engine.connect()\n else:\n raise Exception(\n 'Expected engine instance got %s instead' % type(engine)\n )\n # pyl...
[ "0.83303607", "0.80863214", "0.8021978", "0.7952788", "0.78426266", "0.78426266", "0.7835564", "0.7816424", "0.7793565", "0.77598333", "0.7744341", "0.7678985", "0.75311255", "0.74458575", "0.7393637", "0.72782445", "0.72048295", "0.72048295", "0.72048295", "0.7193927", "0.71...
0.77268213
11
A concordancer for Tregex queries over trees or regexes over plain text
def conc(corpus, query, n = 100, random = False, window = 40, trees = False, plaintext = 'guess'): import os import re import pandas as pd from pandas import DataFrame from time import localtime, strftime try: from IPython.display import d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def slow_tregex(sents, **dummy_args):\n speakr = dummy_args.get('speaker', '')\n import os\n from corpkit.process import tregex_engine\n # first, put the relevant trees into temp file\n to_open = '\\n'.join(sent.parse_string.strip() for sent in sents \\\n ...
[ "0.6346311", "0.63272005", "0.61945575", "0.5999631", "0.57411695", "0.57234347", "0.5704001", "0.5676995", "0.56152594", "0.5605837", "0.55126595", "0.5373799", "0.5355118", "0.53242844", "0.53140885", "0.5293481", "0.5287096", "0.52824426", "0.52277535", "0.5182872", "0.515...
0.0
-1
Generate Call number by Library of Congress Classification
def gen_call_number(self, serializer): data = serializer.validated_data original_data = self.request.data subject = data['subject'] author_id = original_data['authors'][0] publication_date = data['publication_date'].year code = Constant.BOOK_SUBJECT_CODE[subject] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_cnv(self):\r\n\r\n self.cnv = random.sample(range(1, 25), 4)\r\n self.c_array = random.sample(self.c_array, len(self.c_array))\r\n score = float(0)\r\n common = [i for i in self.cnv[1:] if i in self.c_array]\r\n if self.cnv[0] in self.c0_array:\r\n score += 0....
[ "0.54599875", "0.5346699", "0.5329161", "0.5242474", "0.52265507", "0.52088416", "0.5199471", "0.5125358", "0.51210237", "0.50600225", "0.50577676", "0.5043906", "0.5036982", "0.5026152", "0.5023245", "0.50229776", "0.5021118", "0.50144714", "0.5008166", "0.50016636", "0.4993...
0.52430516
3
Initialize your data structure here.
def __init__(self, values=1000000): self.size = int(sqrt(values)) self.buckets = [None] * self.size
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init_empty(self):\n self._data = []", "def __init__(self):\n self._data = []", "def __init__(self):\n self._data = []", "def __init__(self):\n self._data = []", "def __init__(self):\n self._data = []", "def __init__(self):\n self._data = []", "def __init__...
[ "0.7765608", "0.7645274", "0.7645274", "0.7645274", "0.7645274", "0.7645274", "0.7645274", "0.7595176", "0.75853467", "0.7558298", "0.7530608", "0.7530608", "0.7530608", "0.7530608", "0.7530608", "0.74971247", "0.74971247", "0.7478105", "0.7477832", "0.7477832", "0.7477832", ...
0.0
-1
Returns true if this set contains the specified element
def contains(self, key: int) -> bool: hash1, hash2 = self._hash(key) if not self.buckets[hash1]: return False return self.buckets[hash1][hash2]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _contains(self, element):\n if not isinstance(element, Tuple) or len(element) != 2:\n return S.false\n\n if not element[1].is_Integer:\n return S.false\n\n if element[1] >= len(self.sets) or element[1] < 0:\n return S.false\n\n return self.sets[eleme...
[ "0.8238365", "0.81394833", "0.8021257", "0.7981039", "0.76247203", "0.7380103", "0.7340669", "0.73250914", "0.73250914", "0.729173", "0.72639936", "0.7257722", "0.7257722", "0.72303694", "0.719921", "0.7197546", "0.7190269", "0.7190217", "0.7183452", "0.7173034", "0.7150846",...
0.0
-1
Check a translationonly field on one or more axes, different image orientations.
def test_itk_h5(tmp_path, testdata_path): os.chdir(str(tmp_path)) img_fname = testdata_path / "T1w_scanner.nii.gz" xfm_fname = ( testdata_path / "ds-005_sub-01_from-T1w_to-MNI152NLin2009cAsym_mode-image_xfm.h5" ) xfm = _load(xfm_fname) assert len(xfm) == 2 ref_fname = tmp_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_transformations(*args):\n assert args[0].shape == (21,21)\n assert args[0].dtype == np.float64\n if len(args) == 2:\n assert args[1].shape == (2,2)\n assert args[1].dtype == np.float64", "def checkField(fieldset, text=True):\n if text:\n print \"\\nFieldset contains the...
[ "0.58493704", "0.5795946", "0.55515265", "0.55038935", "0.5467156", "0.5446259", "0.5384152", "0.5367525", "0.5367525", "0.53530484", "0.53415245", "0.52947795", "0.52947795", "0.5200388", "0.5127027", "0.5111068", "0.5102852", "0.50853443", "0.50678736", "0.5057223", "0.5017...
0.0
-1
Check whether affines are correctly collapsed.
def test_collapse_affines(tmp_path, data_path, ext0, ext1, ext2): chain = TransformChain( [ Affine.from_filename( data_path / "regressions" / f"from-fsnative_to-scanner_mode-image.{ext0}", fmt=f"{FMT[ext0]}", ), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collapsed(blk):\n if blk is not None and blk.name in COLLAPSIBLE and\\\n len(blk.values) == 1 and blk.values[0] != 0:\n return True\n return False", "def collapsed(self) -> None:", "def check_done(grid):\r\n for row in grid:\r\n for el in row:\r\n if not el.collapsed...
[ "0.6648625", "0.64990586", "0.6319578", "0.6291907", "0.6267607", "0.6213155", "0.6111619", "0.5948826", "0.57925594", "0.5738614", "0.56732744", "0.53091776", "0.53027165", "0.52979547", "0.5263411", "0.52244925", "0.51575667", "0.51398015", "0.5111023", "0.5051264", "0.5032...
0.48665687
29
Calcualtes the name of the currency using the initials.
def currency_name(self, init): c2 = CurrencyCodes() c_name = c2.get_currency_name(init) return c_name
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def currency_word(self):\n result = \" \"\n for cr in self:\n if cr.currency_id.name == 'USD':\n result = \" Dollar\"\n elif cr.currency_id.name == 'EUR':\n result = \" Euro\"\n elif cr.currency_id.name == 'JPY':\n result =...
[ "0.6545595", "0.65187955", "0.6400594", "0.61858106", "0.6183995", "0.5940923", "0.5884641", "0.58576405", "0.57543", "0.5593448", "0.55822915", "0.5562207", "0.55397344", "0.5527879", "0.5522243", "0.55098426", "0.54883844", "0.54776466", "0.54487824", "0.54059935", "0.53924...
0.73644185
0
Calculates the latest rate for the currency at hand.
def currency_rate(self, init): curr = CurrencyRates() curr_rate = curr.get_rates(init) return curr_rate
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exchange_rate(self):\n res = r.get(self.url + self.current_rate)\n return self.execute(res)", "def get_current_rate(self):\n pass", "def update(self):\n self.rate = self.exchange.latest()", "def api_call(cls, currency):\n headers = {\"x-accept-version\": \"2.0.0\", \"Ac...
[ "0.7194681", "0.7087124", "0.7015733", "0.6857771", "0.6801177", "0.6785793", "0.66941553", "0.66645527", "0.66415185", "0.6638817", "0.6485171", "0.6424446", "0.6401379", "0.63694507", "0.63674176", "0.633374", "0.6300826", "0.628026", "0.62679833", "0.62639594", "0.62147737...
0.713497
1
Calculates the latest conversion rate for the currency at hand.
def conversion_rate(self, init, new_currency): curr = CurrencyRates() curr_conv_rate = curr.get_rate(init, new_currency) return curr_conv_rate
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def currency_rate(self, init):\r\n\r\n curr = CurrencyRates()\r\n curr_rate = curr.get_rates(init)\r\n return curr_rate", "def get_currency_exchange_rate(self, from_currency, to_currency):\n _FUNCTION_KEY = 'CURRENCY_EXCHANGE_RATE'\n return _FUNCTION_KEY, 'Realtime Currency Exc...
[ "0.6993551", "0.69812477", "0.6692026", "0.666445", "0.6645402", "0.6555873", "0.6546272", "0.6487058", "0.64221525", "0.6406838", "0.64052564", "0.6369392", "0.6346241", "0.63396156", "0.63319975", "0.6328635", "0.6302605", "0.6302515", "0.618671", "0.61817455", "0.60828835"...
0.74947244
0
Converts an amount from the currency at hand to a new currency.
def convert_amount(self, init, new_currency, amount): curr = CurrencyRates() curr_conversion = curr.convert(init, new_currency, amount) return curr_conversion
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convert(self, from_amount, to_currency, company, date, round=True):\n self, to_currency = self or to_currency, to_currency or self\n assert self, \"convert amount from unknown currency\"\n assert to_currency, \"convert amount to unknown currency\"\n assert company, \"convert amount...
[ "0.73006153", "0.72782034", "0.71290565", "0.70164573", "0.6842994", "0.6626046", "0.6571269", "0.65345883", "0.6460881", "0.64539254", "0.6389461", "0.6372568", "0.6338758", "0.6223571", "0.6182157", "0.6140729", "0.6137326", "0.6085868", "0.6061959", "0.6049651", "0.5981646...
0.77393734
0
Calculates the relative symbol for the currency at hand.
def currency_symbol(self, init): c2 = CurrencyCodes() c_symbol = c2.get_symbol(init) return c_symbol
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getCurrencySymbol():", "def monetary_base(self, symbol):\n pass", "def local_price(amount, currency):\n amt = convert(amount, currency)\n sym = symbol(currency)\n return f'{sym}{amt}'", "def getBaseCurrency():", "def getCurrencySymbol(id=None):", "def create_symbol(self, base_ccy, ass...
[ "0.7532425", "0.61583894", "0.6051573", "0.6010398", "0.6007663", "0.57941693", "0.5785363", "0.5702698", "0.568727", "0.5658896", "0.5622147", "0.5558757", "0.5514153", "0.5434841", "0.5427567", "0.54007", "0.53848547", "0.5369845", "0.53468686", "0.53214556", "0.5318823", ...
0.62263805
1
Checks whether or not an entered currency is valid.
def check_currency_validity(self, init): currencies = open("supported_curr.txt", "r") alert = "Not a valid currency. Please try again!" if init in currencies: return init else: return alert
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validateCurrency(self, currency_code):\n if currency_code in self.travel_db.currencies:\n return True\n else:\n return False", "def validate_currency(currency_code):\n try:\n rate = rates.get_rates(currency_code)\n return 0\n except:\n flash(f'Er...
[ "0.73480386", "0.7288969", "0.670163", "0.65683585", "0.6326081", "0.6306544", "0.6249831", "0.6232125", "0.6184508", "0.6178256", "0.6126641", "0.6100734", "0.60888636", "0.60436463", "0.60396165", "0.6022093", "0.60103476", "0.60070944", "0.5970834", "0.59520406", "0.595190...
0.68851346
2
Checks whether or not an entered amount is valid.
def check_amount_validity(self, amount): alert = "Not a valid amount. Please try again!" if type(amount) == int or type(amount) == float: return amount else: return alert
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_amount_valid(self):\n\t\tamount = self.entry_amount.get()\n\n\t\ttry:\n\t\t\tfloat(amount)\n\t\texcept ValueError:\n\t\t\tmessagebox.showerror(\"Invalid Amount\", \"Amount must be a positive number\")\n\t\t\treturn False\n\n\t\tif float(amount) < 0:\n\t\t\tmessagebox.showerror(\"Invalid Amount\", \"Amount ...
[ "0.82144606", "0.7673015", "0.75659555", "0.6944316", "0.6673183", "0.65760684", "0.6559131", "0.6552635", "0.6488286", "0.64840955", "0.6429893", "0.6422951", "0.6412067", "0.6382808", "0.63355726", "0.63257205", "0.6321893", "0.63069206", "0.626406", "0.62407017", "0.621087...
0.78239405
1
featuresn least square method impletement Use sum of square error function which aroses in the maximum likehood to get liner regression param set w for supervised learning. To control overfitting, use lmd for regularization.
def least_square(features, values, w, lmd=None, regularizer=2): if lmd == None: lmd = 0 size = len(values) R = lmd * eye(len(features[0, :])) # solve the equation features'*features*w=features'b w = linalg.solve(R+dot(features.T, features), dot(features.T, values)) return w
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def learn(self, Xtrain, ytrain):\n pass\n self.weights = np.zeros(Xtrain.shape[1],)\n\n ### YOUR CODE HERE\n \n lmbd = self.params['lamb']\n \n numsamples = Xtrain.shape[0]\n # Xless = Xtrain[:,self.params['features']]\n Xless = Xtrain\n self.we...
[ "0.59811664", "0.59792453", "0.5977199", "0.5910014", "0.57902515", "0.57429147", "0.5736021", "0.5726675", "0.5687944", "0.55737907", "0.55421764", "0.55418295", "0.5539954", "0.5535652", "0.5524679", "0.5473309", "0.5462243", "0.54486495", "0.5445677", "0.54421", "0.5438471...
0.63457775
0
linear Regression use bayesian approach
def bayesian(features, values, w, alpha=None, beta=None, steps=None): #alpha and beta can be init by user if alpha == None: alpha = .1 if beta == None: beta = 10 #iterate time control to fix alpha beta if steps == None: steps = 100 size = len(values) R = alpha * eye(l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nnRegression(data):", "def linear_model(inp, w1, b1):\n y = inp @ w1 + b1\n centered_y = y - y.mean()\n return centered_y.sum()", "def linear_regression(features, values):\n clf = SGDRegressor(n_iter=100)\n clf.fit(features,values)\n print(clf.score(features,values))\n intercept ...
[ "0.74872494", "0.673163", "0.66392136", "0.6557477", "0.65192616", "0.6501405", "0.63697916", "0.6348934", "0.6335981", "0.63249224", "0.63204587", "0.6319576", "0.6310046", "0.62668383", "0.62358856", "0.6211634", "0.6155481", "0.6148775", "0.6139724", "0.6126958", "0.607768...
0.0
-1
create_settings root_directory root directory of program"path/to/root" files files to be observed[files,...] variables variables to be observed[Variable,...] main_file main file of program"relative/path/from/root/to/main" output where to store PEL output "path/to/store/output"
def create_settings(root_directory, files, variables, main_file, output): files = [format_path(f) for f in files] variables = format_variables(variables) settings = { SETTINGS_ROOTDIR : root_directory if root_directory.endswith('/') else root_directory+'/', SETTINGS_FILES : files, SETTINGS_VARIABLES : variable...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setup_files(args):\n postfix = 'reinforce'\n has_value_model = False\n if args.baseline:\n postfix = \"reinforce-baseline\"\n has_value_model = True\n elif args.actor_critic:\n postfix = \"actor-critic\"\n has_value_model = True\n elif args.a2c:\n postfix = \"a...
[ "0.61745477", "0.61673695", "0.6149942", "0.6126735", "0.59460837", "0.59423786", "0.5937718", "0.5911535", "0.58622587", "0.5852425", "0.5816493", "0.5807516", "0.57808864", "0.5754789", "0.5721028", "0.5715072", "0.57069653", "0.5706456", "0.5699024", "0.56912315", "0.56876...
0.7556358
0
run settings takes a settings dictionary, can be correctly formatted by calling create_settings with valid parameters
def run(settings): print settings print "Loading operations.py..." ol = OperationsLoader(currrent_path+OPERATIONS_PATH) settings[SETTINGS_OPERATIONS] = ol.load(settings[SETTINGS_OUTPUT],settings[SETTINGS_VARIABLES]) print "Loading Transformers (parsers)..." settings[SETTINGS_TRANSFORMERS] = [PassTransformer(TRA...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_settings(self, settings_file):\n int_keys = [ 'first_base_to_keep', 'last_base_to_keep', 'max_reads_to_split', 'minimum_reads_for_inclusion',\n 'pool_5trim', 'pool_3trim', 'min_post_adaptor_length']\n #float_keys = []\n str_keys = ['adaptor_sequence', 'rrna_inde...
[ "0.7012952", "0.6709503", "0.6628244", "0.63827366", "0.6283154", "0.6199137", "0.6153022", "0.61143154", "0.61040217", "0.60619944", "0.60534656", "0.6021595", "0.5980613", "0.5956128", "0.590959", "0.58843094", "0.58827704", "0.5880984", "0.5863066", "0.58467436", "0.584559...
0.58851045
15
Method that converts data and labels to instances of class torch.utils.data.Dataset
def init_datasets(self, data_dict, label_dict, **kwargs): return { key: TensorDataset( torch.FloatTensor(data_dict[key]), torch.LongTensor(label_dict[key]) ) for key in data_dict.keys() }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_dataset(self, *data):\n # Make sure data is a tuple of dense tensors\n data = [self._to_torch(x, dtype=torch.FloatTensor) for x in data]\n return TensorDataset(*data)", "def labels_to_dataset(labels, label_mode, num_classes):\n label_ds = dataset_ops.Dataset.from_tensor_slices(l...
[ "0.7115415", "0.694991", "0.6914352", "0.6845197", "0.67110246", "0.66670096", "0.66645527", "0.66255164", "0.65189576", "0.6509893", "0.64952195", "0.64838934", "0.6474416", "0.64262444", "0.6405279", "0.6367776", "0.6365836", "0.63566065", "0.6337854", "0.6322987", "0.63042...
0.65559363
8
Method that converts data and labels to instances of class torch.utils.data.DataLoader
def init_loaders(self, *args, **kwargs): # Convert the data to Dataset dataset_dict = self.init_datasets(*args, **kwargs) # If the Dataset implements collate_fn, that is used. Otherwise, default_collate is used if hasattr(dataset_dict["train"], "collate_fn") and callable( g...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dataloaders():\n # train data path\n data_train = '../dataset/train/'\n # set transformations\n train_transforms = transforms.Compose([\n transforms.Resize((224, 224)),\n transforms.ToTensor(),\n transforms.Normalize([0.485, 0.456, 0.406],\n ...
[ "0.74957144", "0.74059236", "0.73900753", "0.73697627", "0.7280223", "0.7249118", "0.7240241", "0.71756315", "0.70918363", "0.7086592", "0.7085246", "0.7044244", "0.7007126", "0.6970048", "0.69508225", "0.6943519", "0.69286335", "0.6925529", "0.6924148", "0.6876771", "0.68674...
0.6935648
16
Creates data loaders from inputs for use at prediction time
def init_loaders_predict(self, data_dict, label_dict): return self.init_loaders(data_dict, label_dict)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_data_loaders(args, tokenizer):\n personachat = get_dataset(tokenizer, args.dataset_path, args.dataset_cache, args.train_lang)\n _ = personachat.pop(\"test\", None)\n logger.info(\"Build inputs and labels\")\n datasets = {\"train\": [], \"valid\": []}\n\n if args.train_lang in [\"En\", \"Fr\"...
[ "0.74005574", "0.7197881", "0.7158881", "0.6972034", "0.6917558", "0.68405676", "0.6837874", "0.678532", "0.6781111", "0.6738349", "0.67170435", "0.67128015", "0.66842", "0.6673706", "0.6673443", "0.6654735", "0.6637798", "0.659848", "0.65955985", "0.6593302", "0.6554777", ...
0.6874065
5
Initialize a dict of metrics
def init_metric_dict(self, metrics=[""], phases=["train", "val"]): metric_dict = {phase: {metric: [] for metric in metrics} for phase in phases} return metric_dict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_metrics():\n metrics = {\n 'cd_losses': [],\n 'cd_corrects': [],\n 'cd_precisions': [],\n 'cd_recalls': [],\n 'cd_f1scores': [],\n }\n\n return metrics", "def init_metrics():\n metrics = defaultdict(list)\n metrics['best_acc'] = 0.0\n metrics['b...
[ "0.8447349", "0.8055454", "0.7887387", "0.7674845", "0.7393849", "0.7364651", "0.7242206", "0.7189611", "0.7178743", "0.7161504", "0.71576923", "0.6911986", "0.68280876", "0.6823303", "0.6809899", "0.6747972", "0.67374635", "0.6736809", "0.67120516", "0.66915673", "0.6668668"...
0.78341216
3
Updates a metric dict with metrics from an epoch
def update_metric_dict(self, metric_dict, update_dict): for key in update_dict.keys(): metric_dict[key].append(update_dict[key]) return metric_dict
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_epoch_metrics(self, val_metrics=False):\n metric_names = self.tracked_metrics()\n\n for metric in metric_names:\n if val_metrics:\n mean_val = np.array(self.metrics_history[f\"val_{metric}\"][\"batch_vals\"]).mean()\n self.metrics_history[f\"val_...
[ "0.653285", "0.6474349", "0.64158195", "0.63220245", "0.6176943", "0.6079535", "0.6050288", "0.6017538", "0.5881254", "0.58689195", "0.5808414", "0.5795073", "0.5788146", "0.5759678", "0.5751611", "0.5738101", "0.573619", "0.57162505", "0.56976926", "0.5689485", "0.5674656", ...
0.5343309
64
Initialize the output dict
def init_output_dict(self): return { "outputs": torch.FloatTensor(), "pred_probs": torch.FloatTensor(), "labels": torch.LongTensor(), }
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _populate_output(self):\n pass", "def initialize_output_dict(self, label: Optional[str] = None):\n if label is not None or not self._does_output_dict_contain_info():\n for species in self.species_list:\n if label is None or species.label == label:\n ...
[ "0.7403707", "0.7319638", "0.719789", "0.718091", "0.6895616", "0.6818378", "0.6713962", "0.66572535", "0.6627214", "0.6627214", "0.6626906", "0.6612285", "0.6525927", "0.651021", "0.6355464", "0.6314832", "0.63007283", "0.6230506", "0.62086916", "0.61997986", "0.61873674", ...
0.7332433
1
Compute epoch statistics after an epoch of training using an output_dict.
def compute_epoch_statistics(self, output_dict): epoch_statistics = { "auc": roc_auc_score( output_dict["labels"].cpu().numpy(), output_dict["pred_probs"][:, 1].cpu().numpy(), ), "auprc": average_precision_score( output_dict["la...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def training_epoch_end(self, outputs: Any) -> None:\n self.log_dict(self.train_metrics.compute())\n self.train_metrics.reset()", "def validation_epoch_end(self, outputs):\n avg_loss = torch.stack([x['val_loss'] for x in outputs]).mean()\n val_acc = sum([x['n_correct_pred'] for x in ou...
[ "0.7093068", "0.6828395", "0.6732253", "0.669807", "0.669807", "0.6676033", "0.6524682", "0.64946216", "0.6488606", "0.6488606", "0.63934577", "0.6391537", "0.63756627", "0.6371239", "0.63657916", "0.63108504", "0.62925154", "0.6290336", "0.62839675", "0.6260386", "0.6257214"...
0.82542735
0