code stringlengths 1 1.49M | file_id stringlengths 42 46 | node_count int64 0 7.38k | total_lines int64 1 20.9k | vector_dim int64 15 15 | vector_labels stringclasses 1
value | nodes stringlengths 2 3.75M | connections stringlengths 2 964k |
|---|---|---|---|---|---|---|---|
#
# Stochastic Optimization PS#1 Problem 6a
# Nurse Staffing
#
# Reference Format: Vehicle Routing Problem
#
# Imports
#
from coopr.pyomo import *
#from coopr.opt.base import solver
#
# Model
#
model = AbstractModel()
#
# Parameters
#
# Define sets
model.I = Set() # units
model.J = Set() # days
# Data_determinis... | ajibawa-2023/Python-Code-Large/train/row_1656 | 34 | 88 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1656:ImportFrom_L11_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.125, 0.0114, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1656:FunctionDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1656:Return_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1656:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1656:Assign_L60_C4"}, {"f": "ajibawa-2023/Python-Code-L... |
#
# Stochastic Optimization PS#1 Problem 6a
# Nurse Staffing
#
# Reference Format: Vehicle Routing Problem
#
# Imports
#
from coopr.pyomo import *
#from coopr.opt.base import solver
#
# Model
#
model = AbstractModel()
#
# Parameters
#
# Define sets
model.I = Set() # units
model.J = Set() # days
# Data_determinis... | ajibawa-2023/Python-Code-Large/train/row_1657 | 25 | 74 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1657:ImportFrom_L11_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [11, 11], "level": 0, "parent": null, "vector": [1, 0, 0.1486, 0.0135, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1657:FunctionDef_L54_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1657:Return_L55_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1657:FunctionDef_L58_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1657:Return_L59_C4"}, {"f": "ajibawa-2023/Python-Code-L... |
import cplex
import random
import numpy as np
from pylab import *
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
NI = 20
NJ = 20
NW = 20
prob,demand = gen_stoch_trnsport(NI, NJ, NW)
prob.solve()
I = range(NI)
J = range(NJ)
O = range(NW)
bigm = 0.1
print prob.solution.get_objective_value(),
... | ajibawa-2023/Python-Code-Large/train/row_1658 | 39 | 48 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1658:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0208, 0.0208, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1658:For_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1658:For_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1658:For_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1658:For_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1658:Fo... |
import cplex
import random
import numpy as np
import time
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
import cplex.callbacks as CPX_CB
class MySolve(CPX_CB.SolveCallback):
def __call__(self):
self.times_called += 1
print "hello"
self.solve()
# print "Lowe... | ajibawa-2023/Python-Code-Large/train/row_1659 | 37 | 98 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1659:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0102, 0.0102, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1659:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1659:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1659:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1659:Expr_L12_C8"}, {"f": "ajibawa-2023/Python-Code-La... |
from coopr.pyomo import *
#
# Model
#
model = AbstractModel()
model.I = Set()
model.J = Set()
model.A = Param(model.J, model.I)
model.b = Param(model.J)
model.c = Param(model.I)
model.p = Param(model.J) #probability for scenarios
model.alpha = Param() #required chance
model.bigm = Param(model.J)
model.X = Var(... | ajibawa-2023/Python-Code-Large/train/row_1660 | 23 | 36 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1660:ImportFrom_L1_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0278, 0.0278, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1660:FunctionDef_L22_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1660:Return_L23_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1660:FunctionDef_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1660:Assign_L27_C4"}, {"f": "ajibawa-2023/Python-Code-L... |
import cplex
import random
import numpy as np
prob = cplex.Cplex()
prob.objective.set_sense(prob.objective.sense.minimize)
N = 5
M = 10
# Add continuous variables
bin_var_name = ["y" + str(i) for i in range(N)]
bin_var_type = ["B" for i in range(N)]
bin_var_obj = [random.randint(1,10) for i in range(N)]
con_var_nam... | ajibawa-2023/Python-Code-Large/train/row_1661 | 21 | 41 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1661:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0244, 0.0244, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1661:For_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1661:Assign_L32_C33"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1661:For_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1661:Assign_L33_C33"}] |
import cplex
import random
import numpy as np
import time
from pylab import *
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
import mpl_toolkits.mplot3d.axes3d as p3
NI = 50
NJ = 50
NW = 500
I = range(NI)
J = range(NJ)
O = range(NW)
prob,demand = gen_stoch_trnsport(NI, NJ, NW, eps=0.2)
#prob... | ajibawa-2023/Python-Code-Large/train/row_1662 | 49 | 91 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1662:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.011, 0.011, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_call_... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1662:For_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1662:Assign_L47_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1662:For_L45_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1662:Assign_L48_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
import random
fname = 'chance_mod.dat'
f = open(fname, 'w')
random.seed(1000)
f.write('\n')
#f.write('hello, world' + '\n')
#f.write('second line')
def write_set(name, data, file):
f = file
size = len(data)
f.write('set' + ' ' + name + ' ' + ':='+' ')
for i in range(size):
f.write(data[i] + ' '... | ajibawa-2023/Python-Code-Large/train/row_1663 | 68 | 90 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1663:Import_L1_C0", "label": "random import random", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0111, 0.0111, 0, 0.66, 0.0, 715, 0, 1, 0, 0, 715, 0, 0], "semantic": {"name": "random", "arg_names": [], "import_names": ["random"], "rhs... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1663:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1663:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1663:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1663:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Lar... |
import cplex
import random
import numpy as np
import time
from pylab import *
from stoch_trnsport_gen import *
from cplex.exceptions import CplexError
import mpl_toolkits.mplot3d.axes3d as p3
NI = 20
NJ = 20
NW = 20
I = range(NI)
J = range(NJ)
O = range(NW)
prob,demand = gen_stoch_trnsport(NI, NJ, NW, eps=0.5)
prob.s... | ajibawa-2023/Python-Code-Large/train/row_1664 | 70 | 98 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1664:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0102, 0.0102, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1664:For_L39_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1664:For_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1664:For_L40_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1664:For_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1664:Fo... |
"""
This script is used for benchmarking the time takes for different formulations
includes
IP, SIP, IP(M*)
"""
from time import time
from ccfs.fscplex import fscplex
f = open("../output/bench_formulations.txt", 'w')
header = "%4s %4s" % ('NI', 'NS')
header += "%10s %10s %10s" % ("IP_v", "SIP_v", "IP(M*)_v")
header +... | ajibawa-2023/Python-Code-Large/train/row_1665 | 50 | 79 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1665:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.038, 0.0633, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotatio... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1665:For_L26_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1665:For_L27_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1665:For_L27_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1665:Assign_L28_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1665... |
"""
This script is used for benchmarking the time takes for different formulations
includes
IP, SIP, IP(M*)
"""
from time import time
from ccfs.fscplex import fscplex
f = open("../output/bench_formulations.txt", 'w')
header = "%4s %4s" % ('NI', 'NS')
header += "%10s %10s %10s" % ("IP_v", "SIP_v", "IP(M*)_v")
header +... | ajibawa-2023/Python-Code-Large/train/row_1666 | 49 | 73 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1666:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 5], "level": 0, "parent": null, "vector": [8, 0, 0.0411, 0.0685, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotati... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1666:For_L25_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1666:For_L26_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1666:For_L26_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1666:Assign_L27_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1666... |
from ccfs.fscplex import fscplex
f = open("../output/bench_singlebigm.txt", 'w')
header = "%4s %4s" % ('NI', 'NS')
header += "%10s %10s %10s" % ("BigM", "Obj", "Nodes")
#header += "%10s %10s" % ('t_stre', 't_bigm')
header += "\n"
f.write(header)
NI = 20
NS = 20
fc = fscplex()
fc.generate_instance(NI, NS, eps=0.2)
f... | ajibawa-2023/Python-Code-Large/train/row_1667 | 19 | 31 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1667:ImportFrom_L1_C0", "label": "from ccfs.fscplex import fscplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0323, 0.0323, 0, 0.66, 0.0, 780, 0, 1, 0, 0, 780, 0, 0], "semantic": {"name": "ccfs.fscplex", "arg_names": [], "import_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1667:For_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1667:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1667:For_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1667:Expr_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_166... |
#################
# Created 5.5
# Used for benchmarking with range of two bigms
#################
from ccfs.fscplex import fscplex
fc = fscplex()
fc.generate_instance(NI = 2, NS=100, eps=0.2)
fc.parameters.read_file("../../param/stofac.prm")
fc.write("fc.lp")
for i in range(20):
val1 = i * 0.1
for j in range(... | ajibawa-2023/Python-Code-Large/train/row_1668 | 14 | 20 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1668:ImportFrom_L6_C0", "label": "from ccfs.fscplex import fscplex", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.3, 0.05, 0, 0.66, 0.0, 780, 0, 1, 0, 0, 780, 0, 0], "semantic": {"name": "ccfs.fscplex", "arg_names": [], "import_names":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1668:For_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1668:Assign_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1668:For_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1668:For_L14_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1668... |
import time
import cplex
import cplex.callbacks as CPX_CB
import random
import numpy as np
from ccfs.instances import genfs
from ccfs.callbacks import CheckBounds
def bench_checkresolve(NI = 40, NS=35):
step = 0.1
flag = [0] #mutable
I = range(NI)
S = range(NS)
x_name = ["x" + '_' + str(i) for i in... | ajibawa-2023/Python-Code-Large/train/row_1669 | 50 | 66 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1669:Import_L1_C0", "label": "time import time", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0152, 0.0152, 0, 0.66, 0.0, 654, 0, 1, 0, 0, 654, 0, 0], "semantic": {"name": "time", "arg_names": [], "import_names": ["time"], "rhs_call_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1669:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1669:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1669:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1669:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Lar... |
"""
This is the main benchmark script for the check and resolve procedure.
Created: May 7th
First version May 7th. Things begin to work as expected.
Todo:
Output result on instance from 10 to 100 with or without heuristics
Author: Derek Zhang
"""
import cplex
import random
import numpy as np
import sys
from time imp... | ajibawa-2023/Python-Code-Large/train/row_1670 | 59 | 124 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1670:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 10], "level": 0, "parent": null, "vector": [8, 0, 0.0444, 0.0806, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotat... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1670:For_L40_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1670:For_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1670:For_L41_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1670:Assign_L42_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1670... |
"""
This script contains all callback functions that might be called during the procedure
Created: May 1st?
Version 1.0: May 7th
Author: Derek Zhang
Todo:
- Optimality condition improvement
- Code optimization and organization
"""
import cplex.callbacks as CPX_CB
class MySolve(CPX_CB.SolveCallback):
def __call_... | ajibawa-2023/Python-Code-Large/train/row_1671 | 106 | 243 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1671:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 11], "level": 0, "parent": null, "vector": [8, 0, 0.0247, 0.0453, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotat... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1671:ClassDef_L15_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1671:FunctionDef_L16_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1671:FunctionDef_L16_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1671:If_L17_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
"""
The main script that contains subclass of cplex class.
All customized featured are to be added incrementally
Created: May 1st?
Version 1.0 May 7th
Author Derek Zhang
"""
import cplex
import random
from math import floor
from heapq import nlargest
class fscplex(cplex.Cplex):
def __init__(self):
cplex... | ajibawa-2023/Python-Code-Large/train/row_1672 | 218 | 316 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1672:Expr_L1_C0", "label": "expression", "type": "expression", "loc": [1, 10], "level": 0, "parent": null, "vector": [8, 0, 0.0174, 0.0316, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotat... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1672:ClassDef_L16_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1672:FunctionDef_L17_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1672:FunctionDef_L17_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1672:Expr_L18_C8"}, {"f": "ajibawa-2023/Python-Code-L... |
import cplex
from time import time
from fs import fs
from callback import check_bigm_at_incumbent
from callback import check_bigm_at_branch
SZ = 40
f = open("results.txt","w")
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = 2, NS = 50, RLB = 40, seed = 100)
c.solve()
f.write(str(c.solution.g... | ajibawa-2023/Python-Code-Large/train/row_1673 | 23 | 38 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1673:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0263, 0.0263, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1673:For_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1673:Expr_L33_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1673:For_L32_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1673:Expr_L34_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1673:... |
from pylab import *
from time import time
from fs import fs
import numpy as np
import mpl_toolkits.mplot3d.axes3d as p3
NI = 2
NS = 40
RLB = 20
SZ = 30
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = NI, NS = NS, RLB = RLB, seed = 100)
Z = np.zeros((SZ, SZ))
c.solve()
print c.solution.get_obj... | ajibawa-2023/Python-Code-Large/train/row_1674 | 37 | 42 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1674:ImportFrom_L1_C0", "label": "from pylab import *", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0238, 0.0238, 0, 0.66, 0.0, 735, 0, 1, 0, 0, 735, 0, 0], "semantic": {"name": "pylab", "arg_names": [], "import_names": ["*"], "rhs_ca... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1674:For_L21_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1674:For_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1674:For_L22_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1674:Expr_L23_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1674:F... |
from time import time
from fs import fs
org_times = []
str_times = []
org_vals = []
str_vals = []
org_nodes = []
str_nodes = []
for i in range(10):
c = fs()
c.parameters.read_file("../../param/stofac.prm")
c.gen_inst(NI = 5, NS = 5, seed = i*20)
c.init_lists()
t0 = time()
c.solve()
t1 = ti... | ajibawa-2023/Python-Code-Large/train/row_1675 | 29 | 37 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1675:ImportFrom_L1_C0", "label": "from time import time", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.027, 0.027, 0, 0.66, 0.0, 654, 0, 1, 0, 0, 654, 0, 0], "semantic": {"name": "time", "arg_names": [], "import_names": ["time"], "rhs_... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1675:For_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1675:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1675:For_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1675:Expr_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_167... |
import cplex
import random
class fs(cplex.Cplex):
def __init__(self):
cplex.Cplex.__init__(self) #has to be called to activa
self.NI = 1; self.NS = 1
self.I = range(self.NI); self.J = range(self.NS)
self.x_name = []; self.y_name = []; self.rhs = []
self.num_M = 0; self.M_row... | ajibawa-2023/Python-Code-Large/train/row_1676 | 79 | 107 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1676:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0093, 0.0093, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1676:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1676:FunctionDef_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1676:FunctionDef_L5_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1676:Expr_L6_C8"}, {"f": "ajibawa-2023/Python-Code-Large... |
import cplex.callbacks as CPX_CB
class check_bigm_at_incumbent(CPX_CB.IncumbentCallback):
def __call__(self):
print "\n"
if self.fc.flag == 1:
#self.times_called += 1
x_val = self.get_values(self.fc.x_name)
y_val = self.get_values(self.fc.y_name)
slac... | ajibawa-2023/Python-Code-Large/train/row_1677 | 39 | 63 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1677:Import_L1_C0", "label": "cplex.callbacks import CPX_CB", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0159, 0, 0.66, 0.0, 959, 0, 1, 0, 0, 959, 0, 0], "semantic": {"name": "cplex.callbacks", "arg_names": [], "import_names"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1677:ClassDef_L3_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1677:FunctionDef_L4_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1677:FunctionDef_L4_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1677:Expr_L5_C8"}, {"f": "ajibawa-2023/Python-Code-Large... |
import cplex
import random
import numpy as np
#from instances import fscplex
from ccfs.fscplex import fscplex
from ccfs.callbacks import CheckBigM
from ccfs.callbacks import Reject
# Generate instances and read in parameters
fc = fscplex()
fc.generate_instance(NI = 15, NS=15, eps=0.2, Ordered=False)
fc.parameters.read_... | ajibawa-2023/Python-Code-Large/train/row_1678 | 40 | 63 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1678:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0159, 0.0159, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1678:For_L23_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1678:For_L25_C8"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1678:For_L25_C8", "t": "ajibawa-2023/Python-Code-Large/train/row_1678:Assign_L26_C12"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_167... |
import cplex
import random
import sys
from time import time
f1 = sys.argv[1]
f2 = sys.argv[2]
c = cplex.Cplex()
c.parameters.read_file("../../param/stofac.prm")
c.read(f1)
t0 = time()
c.solve()
t1 = time()
print "time is ", t1 - t0
print "solution is", c.solution.get_objective_value()
print "nodes is ", c.solution... | ajibawa-2023/Python-Code-Large/train/row_1679 | 22 | 25 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1679:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.04, 0.04, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_call_na... | [] |
#This is a script that used on the command line to
# run .lp files
# The advantage is to be able to change the parameters
# directly from .lp file
import cplex
c=cplex.Cplex()
c.read("ccfs_new.lp")
c.parameters.read_file("../../param/stofac.prm")
c.solve()
print c.solution.get_objective_value()
print c.solution.get_... | ajibawa-2023/Python-Code-Large/train/row_1680 | 10 | 17 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1680:Import_L6_C0", "label": "cplex import cplex", "type": "import", "loc": [6, 6], "level": 0, "parent": null, "vector": [1, 0, 0.3529, 0.0588, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [] |
import cplex
import cplex.callbacks as CPX_CB
import random
import numpy as np
#from instances import fscplex
from fscplex import fscplex
from callbacks import CheckBounds
NI = 30
NS = 30
step = 0.1
# Generate instances and read in parameters
fc = fscplex()
fc.generate_instance(NI, NS)
fc.write("fc_org.lp")
fc.param... | ajibawa-2023/Python-Code-Large/train/row_1681 | 56 | 86 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1681:Import_L1_C0", "label": "cplex import cplex", "type": "import", "loc": [1, 1], "level": 0, "parent": null, "vector": [1, 0, 0.0116, 0.0116, 0, 0.66, 0.0, 287, 0, 1, 0, 0, 287, 0, 0], "semantic": {"name": "cplex", "arg_names": [], "import_names": ["cplex"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1681:While_L39_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1681:Expr_L40_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1681:While_L39_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1681:Expr_L41_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
# Farmer: rent out version has a singleton root node var
# note: this will minimize
#
# Imports
#
from coopr.pyomo import *
#
# Model
#
model = AbstractModel()
#
# Parameters
#
model.CROPS = Set()
model.TOTAL_ACREAGE = Param(within=PositiveReals)
model.PriceQuota = Param(model.CROPS, within=PositiveReals)
model... | ajibawa-2023/Python-Code-Large/train/row_1682 | 41 | 102 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1682:ImportFrom_L7_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [7, 7], "level": 0, "parent": null, "vector": [1, 0, 0.0686, 0.0098, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1682:FunctionDef_L27_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1682:Return_L28_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1682:FunctionDef_L58_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1682:Return_L59_C4"}, {"f": "ajibawa-2023/Python-Code-L... |
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
from ReferenceModel import model
import numpy
# Solve EV for given number of sample realizations with fixed X at X_EV
numSamples = 500
numX=5
optVal=numpy.array([0 for i in range(numSamples)])
# Choose the solver
opt = SolverFactory('gurobi')
# ... | ajibawa-2023/Python-Code-Large/train/row_1683 | 28 | 48 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1683:ImportFrom_L2_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0417, 0.0208, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1683:For_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1683:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1683:For_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1683:Assign_L21_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
from ReferenceModel import model
import numpy
# Solve WS for given number of sample realizations with fixed X at X_WS
numSamples = 500
numX = 5
optVal = numpy.array([0 for i in range(numSamples)])
# Choose the solver
opt = SolverFactory('gurobi')... | ajibawa-2023/Python-Code-Large/train/row_1684 | 28 | 46 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1684:ImportFrom_L2_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0435, 0.0217, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1684:For_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1684:Assign_L19_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1684:For_L18_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1684:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
#This file estimate EV
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
import numpy
from ReferenceModelBase import model
# Solve WS for given number of sample realizations
numSamples=1
numX = 5
optVal = numpy.array ([0 for i in range(numSamples)])
optSoln = numpy.array([[0 for... | ajibawa-2023/Python-Code-Large/train/row_1685 | 24 | 50 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1685:ImportFrom_L4_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.08, 0.02, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["*"],... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1685:For_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1685:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1685:For_L19_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1685:Assign_L22_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
#This file estimate EV
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
from ReferenceModel import model
import numpy
# Solve WS for given number of sample realizations
numSamples=20
numX = 5
optVal = numpy.array ([0 for i in range(numSamples)])
optSoln = numpy.array([[0 for i in range(numSam... | ajibawa-2023/Python-Code-Large/train/row_1686 | 30 | 49 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1686:ImportFrom_L3_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0612, 0.0204, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1686:For_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1686:Assign_L18_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1686:For_L17_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1686:Assign_L20_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
# Vehicle Routing Problem
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
# Model
model = AbstractModel()
# Sets
model.I = Set() #node
model.J = Set() #node
model.S = Set() #source node
model.D = Set() #demand node
# Data
model.Arc = Param(model.I, model.J) #arc available
m... | ajibawa-2023/Python-Code-Large/train/row_1687 | 51 | 91 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1687:ImportFrom_L4_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [4, 4], "level": 0, "parent": null, "vector": [1, 0, 0.044, 0.011, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["*"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1687:FunctionDef_L34_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1687:Return_L35_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1687:FunctionDef_L38_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1687:Return_L39_C4"}, {"f": "ajibawa-2023/Python-Code-L... |
# Imports
from coopr.pyomo import *
from coopr.opt import SolverFactory
import ReferenceModelBase
import numpy
"""
# Model
model = AbstractModel()
# Sets
model.I = Set() #node
model.J = Set() #node
model.S = Set() #source node
model.D = Set() #demand node
# Data
model.Arc = Param(model.I, model.J) ... | ajibawa-2023/Python-Code-Large/train/row_1688 | 25 | 112 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1688:ImportFrom_L2_C0", "label": "from coopr.pyomo import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0179, 0.0089, 0, 0.66, 0.0, 594, 0, 1, 0, 0, 594, 0, 0], "semantic": {"name": "coopr.pyomo", "arg_names": [], "import_names": ["... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1688:For_L84_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1688:Assign_L85_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1688:For_L84_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1688:Assign_L86_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1... |
#! /usr/bin/python
import glob
import shutil
import sys
import subprocess
import os
def cpfile(src, target):
sys.stdout.write("Copying %s to %s\n" % (src, target))
shutil.copy(src, target)
# We only copy the armeabi version of the binary
archs = ["armeabi"]
for arch in archs:
try:
os.makedirs(".... | ajibawa-2023/Python-Code-Large/train/row_1689 | 18 | 44 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1689:Import_L3_C0", "label": "glob import glob", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0682, 0.0227, 0, 0.66, 0.0, 958, 0, 1, 0, 0, 958, 0, 0], "semantic": {"name": "glob", "arg_names": [], "import_names": ["glob"], "rhs_call_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1689:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1689:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1689:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1689:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/t... |
#! /usr/bin/python
import glob
import shutil
import sys
import subprocess
import os
def cpfile(src, target):
sys.stdout.write("Copying %s to %s\n" % (src, target))
shutil.copy(src, target)
# We only copy the armeabi version of the binary
archs = ["armeabi"]
for arch in archs:
try:
os.makedirs(".... | ajibawa-2023/Python-Code-Large/train/row_1690 | 18 | 44 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1690:Import_L3_C0", "label": "glob import glob", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0682, 0.0227, 0, 0.66, 0.0, 958, 0, 1, 0, 0, 958, 0, 0], "semantic": {"name": "glob", "arg_names": [], "import_names": ["glob"], "rhs_call_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1690:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1690:Expr_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1690:FunctionDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1690:Expr_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/t... |
#! /usr/bin/python
import glob
import shutil
import sys
import subprocess
import os
if 'linux' in sys.platform:
platform = 'linux'
else:
platform = 'darwin'
toolchain = "%s/android-toolchain" % os.getenv("HOME")
openssl_version = "1.0.0k"
encfs_version = "1.7.4"
def cpfile(src, target):
sys.stdout.write... | ajibawa-2023/Python-Code-Large/train/row_1691 | 48 | 74 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1691:Import_L3_C0", "label": "glob import glob", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0405, 0.0135, 0, 0.66, 0.0, 958, 0, 1, 0, 0, 958, 0, 0], "semantic": {"name": "glob", "arg_names": [], "import_names": ["glob"], "rhs_call_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1691:If_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1691:Assign_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1691:If_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1691:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1691:... |
#!/usr/bin/env python
#
# Copyright 2006, 2007 Google Inc. All Rights Reserved.
# Author: danderson@google.com (David Anderson)
#
# Script for uploading files to a Google Code project.
#
# This is intended to be both a useful script for people who want to
# streamline project uploads and a reference implementation for
... | ajibawa-2023/Python-Code-Large/train/row_1692 | 90 | 248 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1692:Expr_L46_C0", "label": "expression", "type": "expression", "loc": [46, 47], "level": 0, "parent": null, "vector": [8, 0, 0.1875, 0.0081, 0, 0.66, 0.0, 0, 1, 0, 0, 0, 0, 0, 0], "semantic": {"name": "", "arg_names": [], "import_names": [], "rhs_call_name": "", "annot... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1692:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1692:Expr_L60_C2"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1692:FunctionDef_L59_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1692:If_L80_C2"}, {"f": "ajibawa-2023/Python-Code-Large/t... |
# -*- coding: utf-8 -*-
from ca import *
# Nombre: Claves Candidatas Creator/dor, aka clcncr)
# Funcion que toma un conjunto de cierres de atributos y es esquema universal
# y devuelve un NUEVO conjunto de claves candidatas.
# Requires:
# R = esquema universal (Set)
# LCA = List. de Cierre atributos (Set of tubples ... | ajibawa-2023/Python-Code-Large/train/row_1693 | 7 | 21 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1693:ImportFrom_L2_C0", "label": "from ca import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0952, 0.0476, 0, 0.66, 0.0, 749, 0, 1, 0, 0, 749, 0, 0], "semantic": {"name": "ca", "arg_names": [], "import_names": ["*"], "rhs_call_nam... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1693:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1693:Assign_L14_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1693:FunctionDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1693:For_L15_C1"}, {"f": "ajibawa-2023/Python-Code-Larg... |
# -*- coding: utf-8 -*-
from df import *
from ca import *
def cierreAtributos (f, eu):
"""Usando el conjunto de d.f. y el esquema universal construimos el
cierre de atributos de cada atributo. Lo representaremos con un TAD
que es un par ordenado, donde la primer componente ('a') es el
atributo considerad... | ajibawa-2023/Python-Code-Large/train/row_1694 | 69 | 104 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1694:ImportFrom_L3_C0", "label": "from df import *", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0288, 0.0096, 0, 0.66, 0.0, 411, 0, 1, 0, 0, 411, 0, 0], "semantic": {"name": "df", "arg_names": [], "import_names": ["*"], "rhs_call_nam... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1694:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1694:Expr_L7_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1694:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1694:Assign_L11_C1"}, {"f": "ajibawa-2023/Python-Code-Large/... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# df.py
#
# Copyright 2009 Drasky Vanderhoff <drasky@drasky-laptop>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Softw... | ajibawa-2023/Python-Code-Large/train/row_1695 | 28 | 65 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1695:ImportFrom_L22_C0", "label": "from sys import *", "type": "import", "loc": [22, 22], "level": 0, "parent": null, "vector": [1, 0, 0.3385, 0.0154, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["*"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1695:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1695:Assign_L25_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1695:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1695:Assign_L26_C1"}, {"f": "ajibawa-2023/Python-Code-Large/t... |
# -*- coding: utf-8 -*-
#
# FC.py
#
# Copyright 2009 Drasky Vanderhoff <drasky.vanderhoff@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation;... | ajibawa-2023/Python-Code-Large/train/row_1696 | 65 | 138 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1696:Import_L26_C0", "label": "copy import copy", "type": "import", "loc": [26, 26], "level": 0, "parent": null, "vector": [1, 0, 0.1884, 0.0072, 0, 0.66, 0.0, 739, 0, 1, 0, 0, 739, 0, 0], "semantic": {"name": "copy", "arg_names": [], "import_names": ["copy"], "rhs_call... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1696:FunctionDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1696:Expr_L33_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1696:FunctionDef_L31_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1696:Assign_L36_C1"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
from attrs import *
from df import *
from clcncr import getCCC
from fprima import *
from c3fn import calculate3FN
from FNBC import calcular_FNBC, chequear_FNBC , chequear_FNBC_df
from FC import *
def mainProg():
# Para saber si ya se ha calculado la descomposición en FNBC
calcFNBC = False
... | ajibawa-2023/Python-Code-Large/train/row_1697 | 90 | 116 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1697:ImportFrom_L2_C0", "label": "from attrs import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0172, 0.0086, 0, 0.66, 0.0, 251, 0, 1, 0, 0, 251, 0, 0], "semantic": {"name": "attrs", "arg_names": [], "import_names": ["*"], "rhs_ca... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1697:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1697:Assign_L14_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1697:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1697:Expr_L15_C1"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
from df import *
import copy
#Vamos a hacer la parte primero del foreach
#Esta funcion va a chequear si algun Ri contiene a la dep. func. a->b
#LRi = Conjuntos de Ri (sets of sets)
#dep = Dependencia funcional a->b (es un tubple (a,b))
# Returns:
# True si encontramos
# False caso contrario
d... | ajibawa-2023/Python-Code-Large/train/row_1698 | 23 | 81 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1698:ImportFrom_L2_C0", "label": "from df import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0247, 0.0123, 0, 0.66, 0.0, 411, 0, 1, 0, 0, 411, 0, 0], "semantic": {"name": "df", "arg_names": [], "import_names": ["*"], "rhs_call_nam... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1698:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1698:Assign_L13_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1698:FunctionDef_L12_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1698:For_L15_C1"}, {"f": "ajibawa-2023/Python-Code-Larg... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# df.py
#
# Copyright 2009 Drasky Vanderhoff <drasky@drasky-laptop>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Softw... | ajibawa-2023/Python-Code-Large/train/row_1699 | 28 | 65 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1699:ImportFrom_L22_C0", "label": "from sys import *", "type": "import", "loc": [22, 22], "level": 0, "parent": null, "vector": [1, 0, 0.3385, 0.0154, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["*"], "rhs_cal... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1699:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1699:Assign_L25_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1699:ClassDef_L24_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1699:Assign_L26_C1"}, {"f": "ajibawa-2023/Python-Code-Large/t... |
# -*- coding: utf-8 -*-
from sys import *
class ca:
a = set()
am = set()
def __hash__(self):
return 0
def __repr__(self):
rep = "(ATRIBUTO/S: "
for elem in self.a:
rep += elem+' '
rep += ", CIERRE:"
for elem in self.am:
rep += ' '+elem
rep += ')'
return rep
def __str__(self):
rep = "(ATRIB... | ajibawa-2023/Python-Code-Large/train/row_1700 | 21 | 37 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1700:ImportFrom_L3_C0", "label": "from sys import *", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0811, 0.027, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["*"], "rhs_call_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1700:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1700:Assign_L6_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1700:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1700:Assign_L7_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train... |
# -*- coding: utf-8 -*-
from df import *
# Aca vamos a definir todos los atributos, y una funcion nos va a devolver un
# set, que vendria a ser el Esquema universal
# TODO
def getEsquemaUniversal():
return set(['Planilla.Numero', 'Planilla.Fecha', 'Encuestado.Edad', \
'Encuestado.Sexo', 'Encuestado.Ingreso_mensua... | ajibawa-2023/Python-Code-Large/train/row_1701 | 6 | 141 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1701:ImportFrom_L3_C0", "label": "from df import *", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0213, 0.0071, 0, 0.66, 0.0, 411, 0, 1, 0, 0, 411, 0, 0], "semantic": {"name": "df", "arg_names": [], "import_names": ["*"], "rhs_call_nam... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1701:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1701:Return_L11_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1701:FunctionDef_L67_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1701:Assign_L68_C1"}, {"f": "ajibawa-2023/Python-Code-L... |
# -*- coding: utf-8 -*-
from fprima import cierreAtributosAlfa
import copy
def calcular_FNBC (conjRi, Fpri, cierreAtr):
"""Descomposición en la forma normal de Boyce-Codd de un
conjunto de esquemas relacionales, para un F+ dado.
1º parámetro => conjunto de esquemas relacionales
2º parámetro => cierre de... | ajibawa-2023/Python-Code-Large/train/row_1702 | 72 | 127 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1702:ImportFrom_L3_C0", "label": "from fprima import cierreAtributosAlfa", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0236, 0.0079, 0, 0.66, 0.0, 540, 0, 1, 0, 0, 540, 0, 0], "semantic": {"name": "fprima", "arg_names": [], "import_na... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1702:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1702:Expr_L8_C1"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1702:FunctionDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1702:If_L14_C1"}, {"f": "ajibawa-2023/Python-Code-Large/trai... |
# -*- coding: utf-8 *-*
import sys
import unittest
from tests.dijkstra import *
from tests.prim import *
from tests.kruskal import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1703 | 7 | 10 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1703:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.2, 0.1, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name": "", "... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1703:If_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1703:Expr_L10_C4"}] |
# -*- coding: utf-8 *-*
import unittest
from tests_algorithms import *
from tests_graphs import *
from tests_structures import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1704 | 6 | 9 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1704:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.2222, 0.1111, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1704:If_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1704:Expr_L9_C4"}] |
# -*- coding: utf-8 -*-
from graphs.listgraph import *
from graphs.matrixgraph import *
from graphs.generator import *
from timeit import Timer
class Main():
def __init__(self):
self.repeat = 5
def log(self, message):
print message
def measure(self):
start = 500
delta = ... | ajibawa-2023/Python-Code-Large/train/row_1705 | 97 | 174 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1705:ImportFrom_L2_C0", "label": "from graphs.listgraph import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0115, 0.0057, 0, 0.66, 0.0, 217, 0, 1, 0, 0, 217, 0, 0], "semantic": {"name": "graphs.listgraph", "arg_names": [], "import_... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1705:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1705:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1705:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1705:Assign_L11_C8"}, {"f": "ajibawa-2023/Python-Code-... |
# -*- coding: utf-8 -*-
import unittest
from structures.unionfind import UnionFind
class UnionFindTest(unittest.TestCase):
def test_create_unionfind(self):
unionfind = UnionFind(['V1', 'V2'])
self.assertEqual(2, unionfind.count())
def test_create_unionfind_union_check_count(self):
u... | ajibawa-2023/Python-Code-Large/train/row_1706 | 25 | 41 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1706:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0488, 0.0244, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1706:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1706:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1706:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1706:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from graphs.matrixgraph import MatrixGraph
class MatrixGraphTest(unittest.TestCase):
def setUp(self):
self.graph = MatrixGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(... | ajibawa-2023/Python-Code-Large/train/row_1707 | 35 | 53 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1707:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0377, 0.0189, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1707:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1707:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1707:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1707:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from structures.hashtable import HashTable
class HashTableTest(unittest.TestCase):
def test_add_and_retrieve_item(self):
hash = HashTable()
key = "one"
hash.set(key, 1)
self.assertEqual(1, hash.get(key))
def test_add_and_retrieve_two_i... | ajibawa-2023/Python-Code-Large/train/row_1708 | 64 | 90 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1708:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0222, 0.0111, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1708:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1708:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1708:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1708:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from structures.list import List
class ListTest(unittest.TestCase):
def test_create_list_check_empty(self):
list = List()
self.assertTrue(list.empty())
def test_create_list_add_element_check_emtpy(self):
list = List()
list.add(1)
... | ajibawa-2023/Python-Code-Large/train/row_1709 | 36 | 59 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1709:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0339, 0.0169, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1709:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1709:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1709:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1709:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from graphs.listgraph import ListGraph
class ListGraphTest(unittest.TestCase):
def setUp(self):
self.graph = ListGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(2, self.... | ajibawa-2023/Python-Code-Large/train/row_1710 | 36 | 54 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1710:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.037, 0.0185, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"],... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1710:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1710:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1710:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1710:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class DijkstraTest(unittest.TestCase):
def test_dijkstra_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
d... | ajibawa-2023/Python-Code-Large/train/row_1711 | 35 | 49 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1711:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0408, 0.0204, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1711:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1711:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1711:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1711:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Larg... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class KruskalTest(unittest.TestCase):
def test_kruskal_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
def... | ajibawa-2023/Python-Code-Large/train/row_1712 | 48 | 70 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1712:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0286, 0.0143, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1712:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1712:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1712:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1712:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Larg... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class PrimTest(unittest.TestCase):
def test_prim_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
def test_... | ajibawa-2023/Python-Code-Large/train/row_1713 | 48 | 70 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1713:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0286, 0.0143, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1713:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1713:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1713:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1713:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Larg... |
# -*- coding: utf-8 -*-
import unittest
from structures.heap import Heap
class HeapTest(unittest.TestCase):
def test_add_n_elements_verify_order(self):
heap = Heap()
n = 65
#Insert elements in reverse order
for i in range(n):
heap.insert(n - i, n - i)
#Then ve... | ajibawa-2023/Python-Code-Large/train/row_1714 | 27 | 39 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1714:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0513, 0.0256, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1714:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1714:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1714:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1714:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class MatrixGraph(Graph):
def __init__(self):
self.__adjacency = []
self.__vertices = HashTabl... | ajibawa-2023/Python-Code-Large/train/row_1715 | 163 | 238 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1715:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0084, 0.0042, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1715:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1715:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1715:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1715:Assign_L12_C8"}, {"f": "ajibawa-2023/Python-Code-... |
# -*- coding: utf-8 -*-
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class ListGraph(Graph):
def __init__(self, size=None):
self.__vertices = HashTable(size)
def add_vertex(self, name):
self.__vertices... | ajibawa-2023/Python-Code-Large/train/row_1716 | 153 | 228 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1716:ImportFrom_L2_C0", "label": "from structures.list import List", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0088, 0.0044, 0, 0.66, 0.0, 593, 0, 1, 0, 0, 593, 0, 0], "semantic": {"name": "structures.list", "arg_names": [], "import... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1716:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1716:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1716:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1716:Assign_L11_C8"}, {"f": "ajibawa-2023/Python-Code-... |
# -*- coding: utf-8 -*-
from graphs.matrixgraph import MatrixGraph
import random
import math
class Generator():
def __init__(self):
pass
def generate(self, vcount, factor, filename):
if factor > 1:
raise Exception('Invalid density factor.')
maxedges = (vcount - 1) * vcou... | ajibawa-2023/Python-Code-Large/train/row_1717 | 49 | 75 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1717:ImportFrom_L2_C0", "label": "from graphs.matrixgraph import MatrixGraph", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0267, 0.0133, 0, 0.66, 0.0, 941, 0, 1, 0, 0, 941, 0, 0], "semantic": {"name": "graphs.matrixgraph", "arg_names"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1717:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1717:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1717:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1717:FunctionDef_L12_C4"}, {"f": "ajibawa-2023/Python-Code-... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class Graph():
NAME_SEPARATOR = '->'
ADJ_LIST_SEPARATOR = '||'
WEIGHT_SEPARATOR = ';'
def __init__(self):
pass
def load(self, filename):
pass
def save(self, filename):
raise Exception('save() not imp... | ajibawa-2023/Python-Code-Large/train/row_1718 | 17 | 42 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1718:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0238, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1718:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1718:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1718:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1718:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train... |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.matrixgraph import *
from tests.listgraph import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1719 | 6 | 9 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1719:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.2222, 0.1111, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1719:If_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1719:Expr_L9_C4"}] |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.hashtable import *
from tests.heap import *
from tests.unionfind import *
from tests.list import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1720 | 8 | 11 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1720:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1818, 0.0909, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1720:If_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1720:Expr_L11_C4"}] |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class UnionFind():
def __init__(self, items):
self.sets = HashTable()
for item in items:
node = [item, None, 1]
self.sets[item] = node
self.__count = len(items)
def find(self, item):
no... | ajibawa-2023/Python-Code-Large/train/row_1721 | 22 | 42 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1721:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0238, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1721:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1721:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1721:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1721:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
class HashTable():
__initial_size = 10000
def __init__(self, size=None):
self.__size = size
if size is None:
self.__size = HashTable.__initial_size
self.items = [None] * self.__size
self.__keys = []
def count(self):
return len... | ajibawa-2023/Python-Code-Large/train/row_1722 | 86 | 134 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1722:ClassDef_L4_C0", "label": "HashTable", "type": "class", "loc": [4, 134], "level": 0, "parent": null, "vector": [3, 0, 0.5149, 0.9776, 0, 0.66, 0.0, 631, 0, 16, 0, 0, 0, 0, 25], "semantic": {"name": "HashTable", "arg_names": [], "import_names": [], "rhs_call_name": ... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1722:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1722:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1722:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1722:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/... |
# -*- coding: utf-8 -*-
class List():
def __init__(self):
self.__begin = None
self.__end = None
self.__current = None
self.__size = 0
def empty(self):
return self.__size == 0
def pop(self):
return self.pop_last()
def pop_last(self):
item = No... | ajibawa-2023/Python-Code-Large/train/row_1723 | 93 | 140 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1723:ClassDef_L4_C0", "label": "List", "type": "class", "loc": [4, 110], "level": 0, "parent": null, "vector": [3, 0, 0.4071, 0.7643, 0, 0.66, 0.0, 24, 0, 17, 0, 0, 0, 0, 4], "semantic": {"name": "List", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotat... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1723:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1723:FunctionDef_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1723:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1723:Assign_L7_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
class Heap():
__maxSize = 100
def __init__(self):
self.items = []
def insert(self, key, data):
item = [key, data]
self.items.append(item)
index = len(self.items) - 1
self.__heapify_up(index)
def change_key(self, index, key):
se... | ajibawa-2023/Python-Code-Large/train/row_1724 | 91 | 129 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1724:ClassDef_L4_C0", "label": "Heap", "type": "class", "loc": [4, 129], "level": 0, "parent": null, "vector": [3, 0, 0.5155, 0.9767, 0, 0.66, 0.0, 538, 0, 18, 0, 0, 0, 0, 37], "semantic": {"name": "Heap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annot... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1724:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1724:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1724:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1724:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/... |
# -*- coding: utf-8 *-*
class DBActors():
def __init__(self, filename):
self.filename = filename
self.file = None
self.currentline = None
def open(self):
if self.file is None:
self.file = open(self.filename)
# Read file until the start of actor/actres... | ajibawa-2023/Python-Code-Large/train/row_1725 | 51 | 79 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1725:ClassDef_L4_C0", "label": "DBActors", "type": "class", "loc": [4, 79], "level": 0, "parent": null, "vector": [3, 0, 0.5253, 0.962, 0, 0.66, 0.0, 402, 0, 11, 0, 0, 0, 0, 21], "semantic": {"name": "DBActors", "arg_names": [], "import_names": [], "rhs_call_name": "", ... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1725:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1725:FunctionDef_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1725:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1725:Assign_L7_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 *-*
from structures.hashtable import HashTable
class Actor():
def __init__(self, name):
self.name = name
self.__titlesHash = HashTable()
self.titles = []
def add_title(self, title):
if self.__titlesHash[title] is None:
self.__titlesHash[title] ... | ajibawa-2023/Python-Code-Large/train/row_1726 | 14 | 22 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1726:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0909, 0.0455, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1726:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1726:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1726:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1726:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 *-*
from structures.hashtable import HashTable
class Movie():
def __init__(self, title):
self.title = title
self.actors = HashTable()
def add_actor(self, actor):
if self.actors[actor] is None:
self.actors[actor] = True
| ajibawa-2023/Python-Code-Large/train/row_1727 | 8 | 13 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1727:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1538, 0.0769, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1727:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1727:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1727:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1727:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 *-*
from graphs.listgraph import *
def add_edge(g, src, dest):
g.add_edge(src, dest, 1)
g.add_edge(dest, src, 1)
def generate_test1():
graph = ListGraph()
graph.add_vertex('A')
graph.add_vertex('B')
graph.add_vertex('C')
graph.add_vertex('D')
graph.add_vertex('E... | ajibawa-2023/Python-Code-Large/train/row_1728 | 57 | 82 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1728:ImportFrom_L2_C0", "label": "from graphs.listgraph import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0244, 0.0122, 0, 0.66, 0.0, 217, 0, 1, 0, 0, 217, 0, 0], "semantic": {"name": "graphs.listgraph", "arg_names": [], "import_... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1728:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1728:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1728:FunctionDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1728:Expr_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/tra... |
# -*- coding: utf-8 *-*
import sys
import unittest
from tests.dijkstra import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1729 | 5 | 8 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1729:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.25, 0.125, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name": ""... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1729:If_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1729:Expr_L8_C4"}] |
# -*- coding: utf-8 *-*
import unittest
from tests_algorithms import *
from tests_graphs import *
from tests_structures import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1730 | 6 | 9 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1730:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.2222, 0.1111, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1730:If_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1730:Expr_L9_C4"}] |
# -*- coding: utf-8 *-*
from graphs.matrixgraph import *
from graphs.listgraph import *
from structures.hashtable import HashTable
from imdb.dbactors import DBActors
# Total
# Around 1450000 actors
# Around 819000 actresses
# RAM: 524.8 MB
class Main():
def __init__(self):
pass
def main(self):
... | ajibawa-2023/Python-Code-Large/train/row_1731 | 85 | 133 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1731:ImportFrom_L2_C0", "label": "from graphs.matrixgraph import *", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.015, 0.0075, 0, 0.66, 0.0, 941, 0, 1, 0, 0, 941, 0, 0], "semantic": {"name": "graphs.matrixgraph", "arg_names": [], "impo... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1731:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1731:FunctionDef_L15_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1731:ClassDef_L13_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1731:FunctionDef_L18_C4"}, {"f": "ajibawa-2023/Python-Co... |
# -*- coding: utf-8 -*-
import unittest
from structures.unionfind import UnionFind
class UnionFindTest(unittest.TestCase):
def test_create_unionfind(self):
unionfind = UnionFind(['V1', 'V2'])
self.assertEqual(2, unionfind.count())
def test_create_unionfind_union_check_count(self):
u... | ajibawa-2023/Python-Code-Large/train/row_1732 | 25 | 41 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1732:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0488, 0.0244, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1732:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1732:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1732:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1732:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from graphs.matrixgraph import MatrixGraph
class MatrixGraphTest(unittest.TestCase):
def setUp(self):
self.graph = MatrixGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(... | ajibawa-2023/Python-Code-Large/train/row_1733 | 35 | 54 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1733:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.037, 0.0185, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"],... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1733:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1733:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1733:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1733:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from structures.hashtable import HashTable
class HashTableTest(unittest.TestCase):
def test_add_and_retrieve_item(self):
hash = HashTable()
key = "one"
hash.set(key, 1)
self.assertEqual(1, hash.get(key))
def test_add_and_retrieve_two_i... | ajibawa-2023/Python-Code-Large/train/row_1734 | 64 | 90 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1734:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0222, 0.0111, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1734:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1734:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1734:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1734:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from structures.list import List
class ListTest(unittest.TestCase):
def test_create_list_check_empty(self):
list = List()
self.assertTrue(list.empty())
def test_create_list_add_element_check_emtpy(self):
list = List()
list.add(1)
... | ajibawa-2023/Python-Code-Large/train/row_1735 | 36 | 59 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1735:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0339, 0.0169, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1735:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1735:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1735:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1735:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
import unittest
from graphs.listgraph import ListGraph
class ListGraphTest(unittest.TestCase):
def setUp(self):
self.graph = ListGraph()
def test_add_two_vertices(self):
self.graph.add_vertex('V1')
self.graph.add_vertex('V2')
self.assertEqual(2, self.... | ajibawa-2023/Python-Code-Large/train/row_1736 | 36 | 55 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1736:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0364, 0.0182, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1736:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1736:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1736:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1736:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 *-*
import unittest
from graphs.listgraph import ListGraph
from graphs.matrixgraph import MatrixGraph
class DijkstraTest(unittest.TestCase):
def test_dijkstra_matrix(self):
self.run_test1(MatrixGraph())
self.run_test2(MatrixGraph())
self.run_test3(MatrixGraph())
... | ajibawa-2023/Python-Code-Large/train/row_1737 | 42 | 61 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1737:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0328, 0.0164, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1737:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1737:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1737:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1737:Expr_L10_C8"}, {"f": "ajibawa-2023/Python-Code-Larg... |
# -*- coding: utf-8 -*-
import unittest
from structures.heap import Heap
class HeapTest(unittest.TestCase):
def test_add_n_elements_verify_order(self):
heap = Heap()
n = 65
#Insert elements in reverse order
for i in range(n):
heap.insert(n - i, n - i)
#Then ve... | ajibawa-2023/Python-Code-Large/train/row_1738 | 27 | 39 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1738:Import_L2_C0", "label": "unittest import unittest", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0513, 0.0256, 0, 0.66, 0.0, 88, 0, 1, 0, 0, 88, 0, 0], "semantic": {"name": "unittest", "arg_names": [], "import_names": ["unittest"]... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1738:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1738:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1738:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1738:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class MatrixGraph(Graph):
def __init__(self):
self.__adjacency = []
self.__vertices = HashTabl... | ajibawa-2023/Python-Code-Large/train/row_1739 | 98 | 146 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1739:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0137, 0.0068, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1739:ClassDef_L9_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1739:FunctionDef_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1739:FunctionDef_L11_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1739:Assign_L12_C8"}, {"f": "ajibawa-2023/Python-Code-... |
# -*- coding: utf-8 -*-
from structures.list import List
from structures.heap import Heap
from structures.unionfind import UnionFind
from graphs.graph import *
class ListGraph(Graph):
def __init__(self, size=None):
self.__vertices = HashTable(size)
def add_vertex(self, name):
self.__vertices... | ajibawa-2023/Python-Code-Large/train/row_1740 | 102 | 153 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1740:ImportFrom_L2_C0", "label": "from structures.list import List", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0131, 0.0065, 0, 0.66, 0.0, 593, 0, 1, 0, 0, 593, 0, 0], "semantic": {"name": "structures.list", "arg_names": [], "import... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1740:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1740:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1740:FunctionDef_L10_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1740:Assign_L11_C8"}, {"f": "ajibawa-2023/Python-Code-... |
# -*- coding: utf-8 -*-
from graphs.matrixgraph import MatrixGraph
from graphs.graph import Edge
import random
import math
class Generator():
def __init__(self):
pass
def generate(self, vcount, factor, filename):
if factor > 1:
raise Exception('Invalid density factor.')
... | ajibawa-2023/Python-Code-Large/train/row_1741 | 48 | 74 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1741:ImportFrom_L2_C0", "label": "from graphs.matrixgraph import MatrixGraph", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.027, 0.0135, 0, 0.66, 0.0, 941, 0, 1, 0, 0, 941, 0, 0], "semantic": {"name": "graphs.matrixgraph", "arg_names":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1741:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1741:FunctionDef_L10_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1741:ClassDef_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1741:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code... |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class Graph():
NAME_SEPARATOR = '->'
ADJ_LIST_SEPARATOR = '||'
WEIGHT_SEPARATOR = ';'
def __init__(self):
pass
def load(self, filename):
pass
def save(self, filename):
raise Exception('save() not imp... | ajibawa-2023/Python-Code-Large/train/row_1742 | 17 | 42 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1742:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0238, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1742:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1742:Assign_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1742:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1742:Assign_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train... |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.matrixgraph import *
from tests.listgraph import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1743 | 6 | 9 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1743:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.2222, 0.1111, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1743:If_L8_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1743:Expr_L9_C4"}] |
# -*- coding: utf-8 -*-
import sys
import unittest
from tests.hashtable import *
from tests.heap import *
from tests.unionfind import *
from tests.list import *
if __name__ == '__main__':
unittest.main()
| ajibawa-2023/Python-Code-Large/train/row_1744 | 8 | 11 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1744:Import_L2_C0", "label": "sys import sys", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.1818, 0.0909, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1744:If_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1744:Expr_L11_C4"}] |
# -*- coding: utf-8 -*-
from structures.hashtable import HashTable
class UnionFind():
def __init__(self, items):
self.sets = HashTable()
for item in items:
node = UnionFindNode(item)
self.sets.set(item, node)
self.__count = len(items)
def find(self, item):
... | ajibawa-2023/Python-Code-Large/train/row_1745 | 27 | 42 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1745:ImportFrom_L2_C0", "label": "from structures.hashtable import HashTable", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0476, 0.0238, 0, 0.66, 0.0, 112, 0, 1, 0, 0, 112, 0, 0], "semantic": {"name": "structures.hashtable", "arg_name... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1745:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1745:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1745:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1745:Assign_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
class HashTable():
__initial_size = 32
def __init__(self, size=None):
self.__size = size
if size is None:
self.__size = HashTable.__initial_size
self.items = [None] * self.__size
self.__keys = []
def count(self):
return len(se... | ajibawa-2023/Python-Code-Large/train/row_1746 | 86 | 134 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1746:ClassDef_L4_C0", "label": "HashTable", "type": "class", "loc": [4, 134], "level": 0, "parent": null, "vector": [3, 0, 0.5149, 0.9776, 0, 0.66, 0.0, 631, 0, 16, 0, 0, 0, 0, 25], "semantic": {"name": "HashTable", "arg_names": [], "import_names": [], "rhs_call_name": ... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1746:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1746:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1746:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1746:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/... |
# -*- coding: utf-8 -*-
class List():
def __init__(self):
self.__begin = None
self.__end = None
self.__current = None
self.__size = 0
def empty(self):
return self.__size == 0
def pop(self):
return self.pop_last()
def pop_last(self):
item = No... | ajibawa-2023/Python-Code-Large/train/row_1747 | 93 | 140 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1747:ClassDef_L4_C0", "label": "List", "type": "class", "loc": [4, 110], "level": 0, "parent": null, "vector": [3, 0, 0.4071, 0.7643, 0, 0.66, 0.0, 24, 0, 17, 0, 0, 0, 0, 4], "semantic": {"name": "List", "arg_names": [], "import_names": [], "rhs_call_name": "", "annotat... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1747:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1747:FunctionDef_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1747:FunctionDef_L6_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1747:Assign_L7_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
class Heap():
__maxSize = 100
def __init__(self):
self.items = []
def insert(self, key, data):
item = HeapItem(key, data)
self.items.append(item)
index = len(self.items) - 1
self.__heapify_up(index)
def change_key(self, index, key):
... | ajibawa-2023/Python-Code-Large/train/row_1748 | 95 | 136 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1748:ClassDef_L4_C0", "label": "Heap", "type": "class", "loc": [4, 129], "level": 0, "parent": null, "vector": [3, 0, 0.489, 0.9265, 0, 0.66, 0.0, 538, 0, 18, 0, 0, 0, 0, 38], "semantic": {"name": "Heap", "arg_names": [], "import_names": [], "rhs_call_name": "", "annota... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1748:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1748:Assign_L5_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1748:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1748:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/... |
# -*- coding: utf-8 -*-
###############################################################################
# Import Modules
###############################################################################
import sys
import unittest
from backtracking import backtracking
from galeshapley import galeshapley
class TdaTP1(uni... | ajibawa-2023/Python-Code-Large/train/row_1749 | 42 | 59 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1749:Import_L5_C0", "label": "sys import sys", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0847, 0.0169, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1749:ClassDef_L11_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1749:FunctionDef_L13_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1749:FunctionDef_L13_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1749:Assign_L14_C8"}, {"f": "ajibawa-2023/Python-Code... |
# -*- coding: utf-8 -*-
###############################################################################
# Import Modules
###############################################################################
import sys
from backtracking import backtracking
from galeshapley import galeshapley
def compareResult(filename, resu... | ajibawa-2023/Python-Code-Large/train/row_1750 | 39 | 57 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1750:Import_L5_C0", "label": "sys import sys", "type": "import", "loc": [5, 5], "level": 0, "parent": null, "vector": [1, 0, 0.0877, 0.0175, 0, 0.66, 0.0, 509, 0, 1, 0, 0, 509, 0, 0], "semantic": {"name": "sys", "arg_names": [], "import_names": ["sys"], "rhs_call_name":... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1750:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1750:Assign_L11_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1750:FunctionDef_L10_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1750:Assign_L12_C4"}, {"f": "ajibawa-2023/Python-Code-L... |
# -*- coding: utf-8 -*-
from collections import deque
from model.person import Person
from model.solution import Solution
class Backtracking:
def __init__(self, filename):
self.men = deque()
self.women = []
self.solution = None
self.__temp = Solution()
self.load_data(filen... | ajibawa-2023/Python-Code-Large/train/row_1751 | 41 | 59 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1751:ImportFrom_L2_C0", "label": "from collections import deque", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0339, 0.0169, 0, 0.66, 0.0, 193, 0, 1, 0, 0, 193, 0, 0], "semantic": {"name": "collections", "arg_names": [], "import_names"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1751:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1751:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1751:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1751:Assign_L10_C8"}, {"f": "ajibawa-2023/Python-Code-La... |
# -*- coding: utf-8 -*-
from collections import deque
from model.person import Person
from model.solution import Solution
class GaleShapley:
def __init__(self, filename):
self.singles = deque()
self.men = []
self.women = dict()
self.load_data(filename)
def load_data(self, fi... | ajibawa-2023/Python-Code-Large/train/row_1752 | 42 | 63 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1752:ImportFrom_L2_C0", "label": "from collections import deque", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0317, 0.0159, 0, 0.66, 0.0, 193, 0, 1, 0, 0, 193, 0, 0], "semantic": {"name": "collections", "arg_names": [], "import_names"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1752:ClassDef_L7_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1752:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1752:FunctionDef_L9_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1752:Assign_L10_C8"}, {"f": "ajibawa-2023/Python-Code-La... |
# -*- coding: utf-8 -*-
from collections import deque
class Solution:
def __init__(self):
self.__pairs = deque()
def is_stable(self, pair):
for p in self.__pairs:
m1 = p[0]
w1 = p[1]
m2 = pair[0]
w2 = pair[1]
if ((m1.prefers(w2) an... | ajibawa-2023/Python-Code-Large/train/row_1753 | 24 | 36 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1753:ImportFrom_L3_C0", "label": "from collections import deque", "type": "import", "loc": [3, 3], "level": 0, "parent": null, "vector": [1, 0, 0.0833, 0.0278, 0, 0.66, 0.0, 193, 0, 1, 0, 0, 193, 0, 0], "semantic": {"name": "collections", "arg_names": [], "import_names"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1753:ClassDef_L6_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1753:FunctionDef_L8_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1753:FunctionDef_L8_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1753:Assign_L9_C8"}, {"f": "ajibawa-2023/Python-Code-Lar... |
# -*- coding: utf-8 -*-
from collections import deque
class Person:
def __init__(self, name, preferences=[]):
"""Initializes the preferences hashtable.
O(n)"""
self.prefnames = deque()
self.name = name
self.fiancee = None
self.prefs = dict()
i = 0
f... | ajibawa-2023/Python-Code-Large/train/row_1754 | 31 | 43 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1754:ImportFrom_L2_C0", "label": "from collections import deque", "type": "import", "loc": [2, 2], "level": 0, "parent": null, "vector": [1, 0, 0.0465, 0.0233, 0, 0.66, 0.0, 193, 0, 1, 0, 0, 193, 0, 0], "semantic": {"name": "collections", "arg_names": [], "import_names"... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1754:ClassDef_L5_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1754:FunctionDef_L7_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1754:FunctionDef_L7_C4", "t": "ajibawa-2023/Python-Code-Large/train/row_1754:Expr_L8_C8"}, {"f": "ajibawa-2023/Python-Code-Large... |
__author__="Sergey Karakovskiy, sergey at idsia fullstop ch"
__date__ ="$Feb 18, 2009 1:01:12 AM$"
class SimplePyAgent:
# class MarioAgent(Agent):
""" example of usage of AmiCo
"""
def getAction(self, obs):
ret = (0, 1, 0, 0, 0)
return ret
def giveReward(self, reward):
pass... | ajibawa-2023/Python-Code-Large/train/row_1755 | 21 | 35 | 15 | ["cat_id", "level", "center", "span", "parent_depth", "parent_weight", "sibling_index", "name_hash", "rhs_type", "arg_count", "return_type", "is_async", "module_hash", "value_type", "calls_count"] | [{"id": "ajibawa-2023/Python-Code-Large/train/row_1755:Assign_L1_C0", "label": "__author__ =", "type": "assigned_variable", "loc": [1, 1], "level": 0, "parent": null, "vector": [14, 0, 0.0286, 0.0286, 0, 0.66, 0.0, 777, 1, 0, 0, 0, 0, 3, 0], "semantic": {"name": "__author__", "arg_names": [], "import_names": [], "rhs_c... | [{"f": "ajibawa-2023/Python-Code-Large/train/row_1755:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1755:Expr_L6_C4"}, {"f": "ajibawa-2023/Python-Code-Large/train/row_1755:ClassDef_L4_C0", "t": "ajibawa-2023/Python-Code-Large/train/row_1755:FunctionDef_L9_C4"}, {"f": "ajibawa-2023/Python-Code-Large/tr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.