query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
calculate elbow score for a partition specified by labels | def elbow_score(X, labels, metric='euclidean', type=('inner', 'standard')):
if type == ('inner', 'standard'):
score = 0
for label in set(labels):
sub_samples = np.atleast_2d(X[labels == label])
dists = cdist(sub_samples, sub_samples, metric=metric)
tmp_score = np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def overlap_score(labels, labels_pred):\n raw_overlap = 1-fraction_mislabeled_nodes(labels, labels_pred)\n partition_true = np.array(labels).astype(int)\n partition_pred = np.array(labels_pred).astype(int)\n num_nodes = partition_pred.size\n num_groups = partition_true.max() + 1\n\n chance_level ... | [
"0.65524256",
"0.6286647",
"0.6196709",
"0.6085883",
"0.60324734",
"0.5888701",
"0.5882019",
"0.58427835",
"0.5783772",
"0.5759874",
"0.5710676",
"0.5702147",
"0.5696532",
"0.56714094",
"0.5647144",
"0.5626384",
"0.56258297",
"0.5609299",
"0.5585062",
"0.5583836",
"0.55611545... | 0.7236042 | 0 |
Ensure that a vertex will appear in at least one of the possible positions | def vertex_at_least_once(self,vertex):
clauses = []
for position in range(0,self.graph.num_vertices):
clauses.append(ClauseVariable(False,position,vertex))
return clauses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_vertex_values(self):\n for (line, row) in [(ln, rw) for ln in range(9) for rw in range(9)]:\n if self.grid[line][row] not in range(1, 10) and self.grid[line][row] is not None:\n raise VertexValueError()",
"def has_vertex(self, x, y):\n\n return min(x, y) > 0 and... | [
"0.72547096",
"0.65933186",
"0.65661526",
"0.64855134",
"0.6433209",
"0.6399874",
"0.6321705",
"0.62870926",
"0.626445",
"0.626445",
"0.623239",
"0.6083356",
"0.6008976",
"0.60075384",
"0.59953636",
"0.5975935",
"0.5967519",
"0.58793044",
"0.5859508",
"0.58269125",
"0.580967"... | 0.6731959 | 1 |
Ensure that a vertex will appear at most once at this is done by considering all combinations of vertices and ensuring that vertex can only ever appear at one position for each pair of positions. | def vertex_at_most_once(self,vertex):
clauses = []
for (p1,p2) in itertools.combinations(range(0,self.graph.num_vertices),2):
clause = [ ClauseVariable(True,vertex,p1),
ClauseVariable(True,vertex,p2)]
clauses.append(clause)
return clauses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertices_at_least_once(self):\n clauses = []\n for vertex in range(0,self.graph.num_vertices):\n clauses.append(self.vertex_at_least_once(vertex))\n return clauses",
"def vertex_at_least_once(self,vertex):\n clauses = []\n for position in range(0,self.graph.num_v... | [
"0.6299476",
"0.6132211",
"0.60620284",
"0.6046663",
"0.5724134",
"0.5719957",
"0.5699396",
"0.5691852",
"0.5682706",
"0.5675804",
"0.5652677",
"0.5579296",
"0.55651826",
"0.5511426",
"0.550808",
"0.55038774",
"0.5494495",
"0.54938024",
"0.5456598",
"0.543388",
"0.54337287",
... | 0.63261926 | 0 |
Decodes a minisat output instance back into a clause variable | def minisat_decode(clause_str):
factor = ClauseVariable.encoding_factor()
int_value = int(clause_str)
compliment = (int_value < 0)
int_value = abs(int_value)
position = (int_value % factor) -1
vertex = math.ceil(int_value/factor)-1
return ClauseVariable(complimen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode_result(found):\n ...",
"def decode_results(self, outputs):\n ...",
"def question_to_statement(self, question, answer):\n qid = question[1]\n pos_statement = self.statements[qid]\n if answer:\n return pos_statement\n else:\n utterance = pos_... | [
"0.5478467",
"0.5344261",
"0.52268684",
"0.5153329",
"0.5108831",
"0.5054543",
"0.50407106",
"0.5035657",
"0.4960097",
"0.49479723",
"0.48915848",
"0.48678803",
"0.48613107",
"0.48597178",
"0.485587",
"0.48152465",
"0.47930557",
"0.47837904",
"0.4771931",
"0.47243187",
"0.471... | 0.5379999 | 1 |
Write out minisait in format of minisat command runner | def write_minisat(self):
num_variables = len(self.label_encodings)
num_clauses = self.num_clauses
clauses = self.clauses
outfile = MinisatRunner.temp_in
out = open(outfile,"w")
try:
out.write("p cnf %3d %3d\n" % (num_variables,num_clauses))
for cla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_output(self):",
"def write_run(run):\n r=Run(run)\n r.write_all()",
"def _write_start():\n from ._common import header\n\n out = \"{:5}{}\\n\".format(\"----*\", header)\n return [out[:11] + \"MOP: 123456789*123456789*1234\" + out[40:]]",
"def makeCommands(f0,psi0,th,logFileName,mat,f... | [
"0.5751969",
"0.57239246",
"0.56050336",
"0.55627775",
"0.54654676",
"0.54399246",
"0.53894407",
"0.5349983",
"0.5335354",
"0.5317311",
"0.5316816",
"0.529644",
"0.52800936",
"0.52418727",
"0.5218804",
"0.517004",
"0.51613575",
"0.5155607",
"0.5141282",
"0.51330376",
"0.51251... | 0.61422515 | 0 |
choice the form of payment | def choice_payment(payment=None):
if payment is None:
return 3 # 支付宝
else:
return payment | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_payment(self, payment_type=None):\n self.payment_type = payment_type\n\n # choose a card AI \n self.choose_card_to_discard()\n #self.make_payment(card)",
"def test_individual_ACH(self):\n form_data = self.form_data()\n form_data['payment_type'] = 'Dire... | [
"0.66832644",
"0.635746",
"0.6349613",
"0.6226105",
"0.619822",
"0.6092286",
"0.60875404",
"0.60554206",
"0.6008281",
"0.5872958",
"0.58315575",
"0.5797233",
"0.57806766",
"0.5778123",
"0.5763689",
"0.5734996",
"0.56877613",
"0.5645532",
"0.5631109",
"0.5627127",
"0.5595929",... | 0.70399904 | 0 |
Returns lorentzian profile. 1/pi 0.5gamma / ((0.5gamma)2 + x2) | def lorentz(x, gamma):
return 1 / cs.pi * 0.5 * gamma / ((0.5 * gamma**2) + x**2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lorentz(x, x0, gamma): \n return (0.5/pi) * gamma / ((x-x0)**2 + 0.25 * gamma**2)",
"def profile_plaw(r_range, rho_x, r_x, gamma, **kwargs):\n profile = rho_x * (r_range / r_x)**(-gamma)\n profile[(r_range < r_x)] = 0.\n\n return profile",
"def s2profile(r,r0,A,B):\n x = r/r0\n res = A... | [
"0.67186457",
"0.61636627",
"0.6080515",
"0.6047759",
"0.5884529",
"0.58815324",
"0.58796155",
"0.58250004",
"0.577892",
"0.57624334",
"0.5681882",
"0.5681246",
"0.56588656",
"0.5637242",
"0.562519",
"0.56056446",
"0.5587748",
"0.55819565",
"0.5564628",
"0.5533224",
"0.552368... | 0.6791607 | 0 |
Returns gaussian profile. 1/sqrt(2pi) / gamma exp((x/gamma)2 / 2) | def gauss(x, gamma):
return 1 / np.sqrt(2*np.pi) / gamma * np.exp(-(x/gamma)**2 / 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gauss(x, x0, gamma):\n sigma = gamma / sqrt(2.0)\n \n A = 1/ (sigma * sqrt(2*pi))\n return (A * exp (-0.5 * (x-x0)**2/sigma**2))",
"def gaussian(x, mu, sigma):\n return (np.exp(-(x - mu)**2 / 2.0 / sigma**2) /\n np.sqrt(2.0 * np.pi) / sigma)",
"def gaussian(x, mean, sigma):\n r... | [
"0.75206435",
"0.71392494",
"0.6998809",
"0.6952576",
"0.69341147",
"0.68784",
"0.679881",
"0.67568934",
"0.6733555",
"0.6725777",
"0.6718593",
"0.6709496",
"0.6703196",
"0.6626777",
"0.6625177",
"0.6618803",
"0.6614837",
"0.65624034",
"0.6553338",
"0.6513534",
"0.65014327",
... | 0.7844662 | 0 |
callback for receiving TwistStamped message on /twist_cmd topic | def cb_twist_cmd(self,msg):
# log message
# rospy.logdebug('DBWNode::twist_cmd_cb %s',msg)
# store message
self.twist = msg.twist
self.velocity = msg.twist.linear.x
self.yaw = msg.twist.angular.z | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handler(event,context):\n tweet = setup_and_get_tweet()\n send_tweet(tweet)",
"def on_tweet(self, tweet):\n pass",
"def twistCallback(msg):\n global robot\n\n\n # extract message components and scale\n fwdRev = (msg.linear.x)/FWD_REV_SCALING\n spin = (msg.angular.z)/SPIN_SCALING\n\... | [
"0.63539106",
"0.6165861",
"0.5858024",
"0.5807404",
"0.57037586",
"0.5641173",
"0.5571492",
"0.55087745",
"0.55045485",
"0.5440439",
"0.5433192",
"0.54172784",
"0.5383471",
"0.5330142",
"0.53273475",
"0.5322685",
"0.53024226",
"0.528606",
"0.52760834",
"0.52526104",
"0.52349... | 0.70640725 | 0 |
callback for receiving TwistStamped message on /current_velocity topic | def cb_current_velocity(self,msg):
# log message
# rospy.logdebug('DBWNode::velocity_cb %s',msg)
# store message
self.current_twist = msg.twist
self.current_velocity = msg.twist.linear.x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rover_velocity_callback(self, msg):\n\t\t# print(\"Rover velocity callback message: {}\".format(msg))\n\t\tpass",
"def velocity_cmd_callback(self, data):\n with self.lock:\n self.twist = data",
"def cb_twist_cmd(self,msg):\n # log message\n # rospy.logdebug('DBWNode::twist_c... | [
"0.6958057",
"0.6950165",
"0.6463305",
"0.6463219",
"0.6407563",
"0.63438076",
"0.623812",
"0.62050366",
"0.6087701",
"0.5899115",
"0.58897585",
"0.5846776",
"0.5786905",
"0.57754254",
"0.5760638",
"0.575733",
"0.57383865",
"0.57151663",
"0.57124853",
"0.569276",
"0.5639724",... | 0.76706904 | 0 |
callback for receiving Bool message on /vehicle/dbw_enabled topic | def cb_vehicle_dbw_enabled(self,msg):
# log message
# rospy.logdebug('DBWNode::dbw_enabled_cb %s',msg)
# store message
self.dbw = bool(msg.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_enabled(self):",
"def Enabled(self) -> bool:",
"def isEnabled(self):",
"def isEnabled(self) -> bool:\n ...",
"def is_on(self) -> bool:\n return self.tuya_device.status.get(DPCODE_SWITCH, False)",
"def on_message(self, msg):\n self.enabled = (msg == \"ON\")\n self.log.in... | [
"0.6191051",
"0.604945",
"0.60477203",
"0.5949311",
"0.5756972",
"0.5711706",
"0.5695784",
"0.56757003",
"0.56757003",
"0.5673843",
"0.56621176",
"0.56335765",
"0.56089544",
"0.56003773",
"0.5595799",
"0.5588316",
"0.5575657",
"0.556023",
"0.55508816",
"0.55404013",
"0.553445... | 0.8801945 | 0 |
Plot a image grids of the dataset. If dataset is labeld it will generate one row of images per class and if it's unlabeled it will generate a bidimentional (almost square) grid of images sampled from dataset | def show_imagegrid_dataset(dataset,
num=10,
shuffle=True,
classes='auto',
figsize=None,
fontsize=20,
image_attr={'cmap': plt.cm.Greys_r}):
sample = datase... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_images(images, labels, nrows, ncols, cls_true=None, cls_pred=None, grey=False):\n fig, axes = plt.subplots(nrows, ncols, figsize=(16, 2*nrows))\n\n for i, ax in enumerate(axes.flat): \n if grey:\n ax.imshow(images[i,:,:,0], cmap='binary')\n else:\... | [
"0.7369182",
"0.7340669",
"0.73215216",
"0.722925",
"0.7174287",
"0.7159908",
"0.7060308",
"0.7036506",
"0.7008614",
"0.70057887",
"0.70050985",
"0.69809043",
"0.6962196",
"0.6962196",
"0.6871114",
"0.6860198",
"0.6790377",
"0.6773561",
"0.67644835",
"0.67433405",
"0.670146",... | 0.7943561 | 0 |
Setup follow through (jiggle planes) to each selected transform object. Jiggle deformers are returned to allow users to animate the deformer attributes before baking. | def setup_follow_through():
# -- Grab the selected transforms
node_list = pm.selected(type='transform')
# -- Validate node list
if not node_list:
pm.warning(
'Select at least 1 transform object!'
)
return None
# -- Grab the current start and end f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bake_follow_through():\r\n # -- Find all selected transforms that have a jiggle setup\r\n node_list = [\r\n node\r\n for node in pm.selected(type='transform')\r\n if any(pc.hasAttr('ld_jiggle_node')\r\n for pc in node.getChildren(type='parentConstraint'))\r\n ]\r\n ... | [
"0.7095333",
"0.56289697",
"0.55895954",
"0.54822636",
"0.5440794",
"0.5423058",
"0.540257",
"0.53933394",
"0.53719753",
"0.5346639",
"0.5332166",
"0.5310055",
"0.5305138",
"0.5296076",
"0.529135",
"0.52912456",
"0.52699417",
"0.5257043",
"0.5248384",
"0.5242137",
"0.5236481"... | 0.7946856 | 0 |
Bake and clean follow through (jiggle planes) on selected transform objects. | def bake_follow_through():
# -- Find all selected transforms that have a jiggle setup
node_list = [
node
for node in pm.selected(type='transform')
if any(pc.hasAttr('ld_jiggle_node')
for pc in node.getChildren(type='parentConstraint'))
]
# -- Validate... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_follow_through():\r\n # -- Grab the selected transforms\r\n node_list = pm.selected(type='transform')\r\n \r\n # -- Validate node list\r\n if not node_list:\r\n pm.warning(\r\n 'Select at least 1 transform object!'\r\n )\r\n return None\r\n\r\n # -- Grab ... | [
"0.65062296",
"0.61384195",
"0.61042535",
"0.6094468",
"0.58585864",
"0.5814782",
"0.5727799",
"0.572588",
"0.5693036",
"0.56779474",
"0.5572873",
"0.55572915",
"0.55426896",
"0.5536677",
"0.5533747",
"0.552068",
"0.55170244",
"0.54940814",
"0.5483527",
"0.54787827",
"0.54728... | 0.74857163 | 0 |
DSSAT model water uptake | def water_uptake_dssat(self, soil):
CONV1 = 1e-4 # convert m/m3 to cm/cm3
CONV2 = 100 # convert m to cm
CONV3 = 10 # convert cm to mm
daily_ref_evap_transp = soil.daily_ref_evap_transp
transp_pot = daily_ref_evap_transp * self.light_intercpt
root_dens = self.root_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def water_uptake_apsim(self, soil):\r\n soil_wat_avail = np.zeros(soil.total_layers)\r\n soil_wat_supply = np.zeros(soil.total_layers)\r\n daily_ref_evap_transp = soil.daily_ref_evap_transp\r\n transp_pot = daily_ref_evap_transp * self.light_intercpt\r\n # Water available in each... | [
"0.63875747",
"0.5779599",
"0.56435364",
"0.5643399",
"0.5585187",
"0.55371416",
"0.55039304",
"0.55021054",
"0.55002487",
"0.5457778",
"0.54443103",
"0.5432549",
"0.54273343",
"0.5426112",
"0.54110813",
"0.54018486",
"0.53810084",
"0.53796864",
"0.5377646",
"0.535681",
"0.53... | 0.69317263 | 0 |
APSIM model water uptake | def water_uptake_apsim(self, soil):
soil_wat_avail = np.zeros(soil.total_layers)
soil_wat_supply = np.zeros(soil.total_layers)
daily_ref_evap_transp = soil.daily_ref_evap_transp
transp_pot = daily_ref_evap_transp * self.light_intercpt
# Water available in each layer [mm]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n\n # path of model that should be pruned\n model_path = ('saved_models/PATH_TO_MODEL/model.h5')\n\n # weights below this threshold will be set to zero\n # thresholds can be defined per layer\n thresholds = [0.03, 0.01, 0.01]\n\n # specify training epochs for retraining\n epochs = ... | [
"0.5799173",
"0.56623626",
"0.5652759",
"0.5641658",
"0.5605927",
"0.5587602",
"0.55677724",
"0.5556802",
"0.55124027",
"0.55102175",
"0.5488853",
"0.5479511",
"0.5422332",
"0.5416626",
"0.54125524",
"0.5384084",
"0.53825665",
"0.53712916",
"0.5370684",
"0.5368271",
"0.536490... | 0.6915624 | 0 |
WOFOST model water uptake | def water_uptake_wofost(self, soil):
daily_ref_evap_transp = soil.daily_ref_evap_transp
transp_pot = daily_ref_evap_transp * self.light_intercpt
DROUGHT_CAT = 4
p_value = p_wofost(transp_pot, DROUGHT_CAT)
# WOFOST does not account for different layers
for lyr in soi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def water_uptake_apsim(self, soil):\r\n soil_wat_avail = np.zeros(soil.total_layers)\r\n soil_wat_supply = np.zeros(soil.total_layers)\r\n daily_ref_evap_transp = soil.daily_ref_evap_transp\r\n transp_pot = daily_ref_evap_transp * self.light_intercpt\r\n # Water available in each... | [
"0.6477119",
"0.59873176",
"0.5760386",
"0.5455309",
"0.5430531",
"0.5388874",
"0.53816193",
"0.53550756",
"0.5325988",
"0.5319237",
"0.53131473",
"0.52663887",
"0.5250491",
"0.5246521",
"0.51907617",
"0.518856",
"0.5131376",
"0.5131376",
"0.5131376",
"0.5131376",
"0.5131376"... | 0.6451454 | 1 |
CropSyst/Campbell model daily water uptake | def water_uptake_campbell(self, soil):
daily_ref_evap_transp = soil.daily_ref_evap_transp
root_hydr_cond = np.zeros(soil.total_layers)
shoot_hydr_cond = np.zeros(soil.total_layers)
plant_hydr_cond = np.zeros(soil.total_layers)
root_activity = np.zeros(soil.total_layers)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def water_uptake_dssat(self, soil):\r\n CONV1 = 1e-4 # convert m/m3 to cm/cm3\r\n CONV2 = 100 # convert m to cm\r\n CONV3 = 10 # convert cm to mm\r\n\r\n daily_ref_evap_transp = soil.daily_ref_evap_transp\r\n transp_pot = daily_ref_evap_transp * self.light_intercpt\r\n roo... | [
"0.63158184",
"0.6163963",
"0.60120946",
"0.594974",
"0.5815151",
"0.5648626",
"0.56108695",
"0.54560167",
"0.54519814",
"0.5440802",
"0.53856397",
"0.53609353",
"0.53162545",
"0.52887416",
"0.5240997",
"0.5221457",
"0.5217004",
"0.5190389",
"0.5163781",
"0.5143684",
"0.51383... | 0.6273377 | 1 |
Given a list of pysam.cbcf.VariantRecord split it into multiple lists, one for each chromosome copy | def split_copies(region, vl):
# Sniff out the ploidy
if len(vl) == 0:
logger.warning('Empty region ({}), assuming diploid'.format(region))
ploidy = 2
else:
ploidy = len(vl[0].samples[0]['GT'])
logger.debug('Region: {}, ploidy: {}'.format(region, ploidy))
# cpy_l = [
# (cpy, '|'.join(['0'] *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unsplit(self, variant_groups):\n for vargroup in variant_groups:\n self.variant_list.extend(vargroup.variant_list)\n self.pos = min([var.start for var in self.variant_list])\n self.end = max([var.end for var in self.variant_list])",
"def Chunks(l):\n return_list = [[]]\n ... | [
"0.5714213",
"0.5681728",
"0.5427925",
"0.5411116",
"0.538021",
"0.53091216",
"0.5299388",
"0.52366877",
"0.52330506",
"0.5231694",
"0.52247053",
"0.5207851",
"0.5207769",
"0.5184043",
"0.5158705",
"0.5153309",
"0.5130597",
"0.5109795",
"0.5106975",
"0.5104809",
"0.5101138",
... | 0.5779796 | 0 |
Take a pysam.cbcf.VariantRecord and convert it into a Variant object | def parse(v, cpy):
if v.samples[0]['GT'][cpy] == 0: # Not present in this copy
return None
alt = v.samples[0].alleles[cpy]
l_r, l_a = len(v.ref), len(alt)
if l_r == 1:
if l_a == 1:
op, op_len = 'X', 0
else:
op, op_len = 'I', l_a - l_r
elif l_a == 1:
op, op_len = 'D', l_r - l_a
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variant_from_example(example):\n features = example.features.feature\n var_string = features['variant/encoded'].bytes_list.value[0]\n return variants_pb2.Variant.FromString(var_string)",
"def variant_case(store, case_obj, variant_obj):\n case_obj['bam_files'] = []\n case_obj['mt_bams'] = []\n cas... | [
"0.5806947",
"0.5430533",
"0.54252964",
"0.5344559",
"0.53102547",
"0.52931106",
"0.5232737",
"0.52294105",
"0.517921",
"0.50639087",
"0.5034603",
"0.50143707",
"0.49965522",
"0.49807188",
"0.4961065",
"0.49577075",
"0.4936524",
"0.4915479",
"0.49094373",
"0.48896736",
"0.488... | 0.54504484 | 1 |
Prepare a variant file with only the given sample, complex variant calls filtered out, and restricted to the given bed file | def prepare_variant_file(fname_in, sample, bed_fname, fname_out, write_mode='w'):
def _complex_variant(_v):
var = _v.samples.values()[0]
for alt in var.alleles:
if _v.rlen > 1 and len(alt) > 1:
if _v.ref != alt:
logger.debug('Filtered out {}:{} {} -> {}'.format(_v.contig, _v.pos, _v.re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variant_case(store, case_obj, variant_obj):\n case_obj['bam_files'] = []\n case_obj['mt_bams'] = []\n case_obj['bai_files'] = []\n case_obj['mt_bais'] = []\n case_obj['sample_names'] = []\n for individual in case_obj['individuals']:\n bam_path = individual.get('bam_file')\n mt_b... | [
"0.5877613",
"0.58462787",
"0.5581498",
"0.5447532",
"0.54402614",
"0.53205305",
"0.5293866",
"0.52790785",
"0.5278006",
"0.5259671",
"0.52136654",
"0.5201567",
"0.51559687",
"0.51083004",
"0.50691414",
"0.50301903",
"0.50298095",
"0.5001772",
"0.49689683",
"0.49355268",
"0.4... | 0.73524356 | 0 |
Registers a file format from a recipe dictionary | def register_format(recipe):
afr = AFMFormatRecipe(recipe)
formats_available.append(afr)
# suffix
if afr.suffix not in formats_by_suffix:
formats_by_suffix[afr.suffix] = []
formats_by_suffix[afr.suffix].append(afr)
# mode
if afr.mode not in formats_by_mode:
formats_by_mode[af... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(file_format, extensions, reader, writer=None):\n register_format(\n fmt=file_format,\n ext_to_fmt=_extension_to_filetype,\n reader_map=_reader_map,\n writer_map=_writer_map,\n extensions=extensions,\n reader=reader,\n writer=writer,\n )",
"def r... | [
"0.68596166",
"0.68596166",
"0.64035183",
"0.6160948",
"0.57899994",
"0.5767842",
"0.5499242",
"0.5429027",
"0.52561927",
"0.5200761",
"0.51057297",
"0.5096522",
"0.50700337",
"0.5037854",
"0.50345564",
"0.50142324",
"0.5000288",
"0.49848488",
"0.4981142",
"0.49784878",
"0.49... | 0.730984 | 0 |
Shortcut method for getting random start and end points in a file | def get_random_start_and_end_points_in_file(self, file_data):
start_point = random.randint(2500, len(file_data))
end_point = start_point + random.randint(0, len(file_data) - start_point)
return start_point, end_point | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createRandomRange(self, start, end) :\n\t\ttime = random.randint(1, end-start)\n\t\treturn (start, start+time)",
"def random_line(filename):\n return random.choice(list(open(filename)))",
"def getRandomCoordinates( self, size ):\n if not self.mIsLoaded: self.__loadIndex()\n\n token = rand... | [
"0.62949705",
"0.6134966",
"0.60954434",
"0.5919487",
"0.59007275",
"0.5863535",
"0.585577",
"0.58109426",
"0.5758283",
"0.5748873",
"0.5682779",
"0.56414944",
"0.5631739",
"0.5604333",
"0.56005794",
"0.55697596",
"0.5545279",
"0.55299604",
"0.55119026",
"0.5484949",
"0.54259... | 0.79144514 | 0 |
Splice a chunk in a file. Picks out a random chunk of the file, duplicates it several times, and then inserts that chunk at some other random position in the file. | def splice_a_chunk_in_a_file(self, file_data, glitch_num):
start_point, end_point = self.get_random_start_and_end_points_in_file(file_data)
section = file_data[start_point:end_point]
repeated = ''
for i in range(1, glitch_num):
repeated += section
new_start_point, n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unshift(self, chunk):\n if chunk:\n self._pos -= len(chunk)\n self._unconsumed.append(chunk)",
"def truncate(data_path: str, n_chunks: int, idx=0):\n lines = open(data_path, 'r').readlines()\n n = len(lines)\n print('{} lines in original dataset'.format(n))\n chunk_si... | [
"0.5526482",
"0.53792644",
"0.5207515",
"0.5165682",
"0.5116689",
"0.50714445",
"0.50279456",
"0.501086",
"0.49219203",
"0.48947325",
"0.48261306",
"0.47752142",
"0.47166112",
"0.46978334",
"0.46897793",
"0.46859783",
"0.4681981",
"0.46798566",
"0.46583572",
"0.4646029",
"0.4... | 0.728253 | 0 |
Glitch! Opens the original image file, reads its contents and stores them as 'file_data' Calls 'splice_a_chunk_in_a_file()' method on the data a random number of times between 1 and 5 Writes the new glitched image out to a file | def glitch_an_image(self, local_image):
file_handler = open(local_image, 'r')
file_data = file_handler.read()
file_handler.close()
##YOUR NEW NUMBER##
search_num = tumblr.top_hit_num
# divide by 5,000,000 to normalize the range from [0,5000000] to [0,1]
# multiply... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def splice_a_chunk_in_a_file(self, file_data, glitch_num):\n start_point, end_point = self.get_random_start_and_end_points_in_file(file_data)\n section = file_data[start_point:end_point]\n repeated = ''\n\n for i in range(1, glitch_num):\n repeated += section\n\n new_s... | [
"0.73525065",
"0.5891271",
"0.5596695",
"0.55924076",
"0.5514683",
"0.5442865",
"0.535485",
"0.532658",
"0.52328813",
"0.5146267",
"0.5136913",
"0.5126074",
"0.50800765",
"0.50558335",
"0.5039814",
"0.50165755",
"0.5009086",
"0.49895605",
"0.49895605",
"0.49895605",
"0.498868... | 0.6877133 | 1 |
Returns the list of items generated by expanding nonterminal B, where B is the "next" terminal/nonterminal. Assumes the 'dot' is not at the end of the list of items, and therefore B exists, and B is a symbol. Cache the result, as it does not change over time. | def items_generated_by_next(self):
def lookup(rule):
return self.grammar.rules[rule.content] if rule.is_symbol_name() else rule
if self.the_items_generated_by_next is None:
self.the_items_generated_by_next = []
rhs = lookup(self.grammar.rules[self.the_next.content])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def go_to(self, state, symbol):\n C = []\n # in state search for LR(0) item that has dot in front of symbol\n for production in state:\n dot_index = production[1].index('.')\n alpha = production[1][:dot_index]\n xbeta = production[1][dot_index + 1:]\n ... | [
"0.60782635",
"0.5367849",
"0.52921903",
"0.5243204",
"0.5075236",
"0.50247693",
"0.49688762",
"0.49165177",
"0.4869679",
"0.48509085",
"0.48409092",
"0.48298466",
"0.48118484",
"0.48070458",
"0.47778127",
"0.4761203",
"0.4753579",
"0.47348222",
"0.47059587",
"0.46668696",
"0... | 0.5718888 | 1 |
Returns True when this item represents having accepted a valid sentence in the language | def is_accepting(self):
return (self.position == 1) and (self.lhs.content == LANGUAGE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid(self, sentence):\n return not self.rules.is_invalid(sentence)",
"def hasConstantForm(self, sentence):",
"def is_sentence_valid(w_input_sentence_warning, sentence):\n to_predict = True\n\n # show warning if the sentence shorter than 3 words\n if 0 < len(sentence.split()) <= 2:\n ... | [
"0.7314644",
"0.6832887",
"0.674819",
"0.673748",
"0.67186016",
"0.67153496",
"0.6683982",
"0.6666995",
"0.6652227",
"0.64221543",
"0.64155704",
"0.6394634",
"0.6362132",
"0.63527334",
"0.62846106",
"0.62810147",
"0.62630147",
"0.6105913",
"0.6096297",
"0.608771",
"0.606539",... | 0.6950517 | 1 |
Returns the set of names of symbols in the "externals" section of the Treesitter JSON grammar. Data looks like this, for section "externals". { | def json_externals(json):
return set([ x["name"] for x in json.get("externals",[]) ]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def external_terminologies(self):\n terms = set()\n for node_record in self.graph.run(\"MATCH (n) RETURN (n)\"):\n node = node_record[\"n\"]\n if \"links_to\" in node:\n terms.add(node[\"links_to\"])\n return terms",
"def get_external_host_tags(self):\n ... | [
"0.57053596",
"0.5550879",
"0.5326788",
"0.52498573",
"0.5130597",
"0.5110515",
"0.5100318",
"0.5075958",
"0.5071106",
"0.50482666",
"0.503921",
"0.50140154",
"0.4998172",
"0.4962017",
"0.49529403",
"0.49522096",
"0.49512246",
"0.49511516",
"0.49457997",
"0.49367157",
"0.4903... | 0.7155185 | 0 |
Translates a JSON dictionary into a corresponding grammar node, based on the 'type' entry. Returns 'dct' itself when 'dct' has no type entry or has an unrecognized type entry. We use Treesitter's conventions for representing a grammar in JSON form. | def json_hook(grammar,memo,tokens_only,dct):
def memoize(memo,name,node):
if name in memo:
return memo[name]
memo[name] = node
return node
result = dct
if "type" in dct:
type_entry = dct["type"]
if isinstance(type_entry,str):
if type_entry =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CustomTypeDecoder(dct):\n if len(dct) == 1:\n type_name, _ = dct.items()[0]\n type_name_stripped = type_name.strip('_')\n if type_name_stripped in TYPES:\n obj = TYPES[type_name_stripped]()\n obj.__dict__ = dct[type_name]\n return obj\n return dct",
... | [
"0.6035078",
"0.5538951",
"0.5173711",
"0.49358642",
"0.49114808",
"0.48749194",
"0.48417294",
"0.48001817",
"0.47498053",
"0.4648304",
"0.4629172",
"0.4613406",
"0.4605138",
"0.45951557",
"0.45777294",
"0.4507989",
"0.4484301",
"0.44649675",
"0.44622406",
"0.4459265",
"0.445... | 0.614961 | 0 |
Computes the Canonical Form of a GrammarDict | def canonicalize_grammar(grammar,empty):
rules = grammar.rules
# First ensure right-hand sides of containers are Choice nodes.
result = {}
for key, value in rules.items():
if isinstance(value,ContainerRule):
if isinstance(value,Choice):
# Choice nodes are unchanged
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def canonicalize(self):\n self.rules = canonicalize_grammar(self,self.empty)\n self.is_canonical = True",
"def getcontactcongressdict2(ccdump):\n d = {}\n for line in ccdump.strip().split('\\n'):\n if line.strip():\n (dist, email_form) = line.split()\n d[dist] = e... | [
"0.6435501",
"0.5088603",
"0.49550718",
"0.4946942",
"0.49384597",
"0.49277622",
"0.48983136",
"0.48827356",
"0.4867049",
"0.48520616",
"0.48256868",
"0.48221284",
"0.4769079",
"0.47471413",
"0.47440088",
"0.4743303",
"0.47369075",
"0.4717826",
"0.47074553",
"0.47037065",
"0.... | 0.57712275 | 1 |
Records a new rule with the given key and value. | def add_rule(key,*values):
rhs = grammar.MakeChoice(list(values))
result[key.content] = rhs
return key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setitem__(self, key, value):\n self.rules[key] = value",
"def addRule(self, ruleLine):\n cols = ruleLine.split(' ')\n positionNumber = int(cols[0])\n self._rules[positionNumber] = {}\n for i in range(1, len(cols)):\n self._rules[positionNumber][cols[i].upper()]... | [
"0.70236945",
"0.64182764",
"0.6383722",
"0.63762146",
"0.63658285",
"0.6229125",
"0.61702883",
"0.60239136",
"0.6008493",
"0.59731805",
"0.58936876",
"0.58755374",
"0.5871394",
"0.5816767",
"0.5798326",
"0.57449096",
"0.5696872",
"0.5616359",
"0.5581987",
"0.55750114",
"0.55... | 0.7085595 | 0 |
Computes the First set for each node in the grammar. Populates the `first` attribute of each node. | def compute_first_sets(grammar,rules):
grammar.reset_first_follow()
names_of_non_terminals = []
grammar.end_of_text.first_data = set({grammar.end_of_text})
grammar.empty.first_data = set({grammar.empty})
for key, rule in rules.items():
if rule.is_terminal() or rule.is_empty():
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_first(self):\n compute_first_sets(self, self.rules)",
"def get_first():\n for s in TERMINAL_SET:\n # For each terminal, initialize First with itself.\n sym = SYMBOL_DICT[s]\n sym.first_set = set([s])\n\n for s in NON_TERMINAL_SET:\n sym = SYMBOL_DICT[s]\n ... | [
"0.7219357",
"0.6483622",
"0.6467381",
"0.60188544",
"0.58658564",
"0.5787844",
"0.56534517",
"0.5636613",
"0.5614592",
"0.5549027",
"0.5497881",
"0.5446197",
"0.544467",
"0.54377466",
"0.53846097",
"0.5349789",
"0.5243688",
"0.5242174",
"0.52311367",
"0.5214554",
"0.5208327"... | 0.75325096 | 0 |
Returns a copy of list s without Empty | def list_without_empty(L):
return [i for i in L if not i.is_empty()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_blanks_list(src):\n return [el for el in src if el]",
"def compact_list(self):\n return [ele for ele in self if ele is not None]",
"def copy_list(self,list_):\r\n return list_[:]",
"def prune_empty(lst: List[T]) -> List[T]:\n return [elem for elem in lst if elem]",
"def copy(... | [
"0.6704229",
"0.6619279",
"0.652867",
"0.6456527",
"0.64414376",
"0.63256955",
"0.6119686",
"0.61053866",
"0.60512376",
"0.5973776",
"0.59730166",
"0.5944269",
"0.5879726",
"0.584061",
"0.58254147",
"0.57863045",
"0.57741314",
"0.5757702",
"0.57458293",
"0.5730203",
"0.572865... | 0.66275156 | 1 |
Computes the First set for a Phrase, in the given grammar | def first(grammar,phrase):
def lookup(rule):
return grammar.rules[rule.content] if isinstance(rule,SymbolName) else rule
# Map names of nonterminals to the nonterminals themselves
phrase = [lookup(i) for i in phrase]
result = set()
for item in phrase:
we = without_empty(item.first(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_first_sets(grammar,rules):\n grammar.reset_first_follow()\n\n names_of_non_terminals = []\n grammar.end_of_text.first_data = set({grammar.end_of_text})\n grammar.empty.first_data = set({grammar.empty})\n for key, rule in rules.items():\n if rule.is_terminal() or rule.is_empty():\n... | [
"0.7484193",
"0.59974676",
"0.5932933",
"0.5930215",
"0.5569531",
"0.54553574",
"0.5405768",
"0.5362232",
"0.5279543",
"0.52570534",
"0.5246636",
"0.5230497",
"0.52222943",
"0.52207184",
"0.521228",
"0.5203409",
"0.5192013",
"0.51704144",
"0.5169558",
"0.5164506",
"0.51628876... | 0.7570357 | 0 |
Computes the Follow set for each node in the grammar. Assumes First sets have been computed. Populates the `follow` attribute of each node. | def compute_follow_sets(grammar):
# 1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input
# right end marker.
grammar.rules[grammar.start_symbol].follow = set({grammar.end_of_text})
def lookup(rule):
return grammar.rules[rule.content] if isinstance(rule,SymbolName) else rule
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_follow(self):\n compute_follow_sets(self)",
"def followSet(self):\n FOLLOW = {}\n for A in self.N:\n FOLLOW[A] = set()\n FOLLOW[self.S] |= {'$$'}\n\n old = None\n while old != self._size_of_dict(FOLLOW):\n old = self._size_of_dict(FOLLOW... | [
"0.742819",
"0.7092153",
"0.6631537",
"0.63742447",
"0.62971425",
"0.57530606",
"0.5679638",
"0.56712836",
"0.5613986",
"0.55428976",
"0.5406604",
"0.53708106",
"0.5330948",
"0.5318362",
"0.5316769",
"0.53076124",
"0.530323",
"0.52977115",
"0.5269209",
"0.525497",
"0.51698226... | 0.7195605 | 1 |
Walk a JSON structure, yielding a new copy of the object. But for any dictionary 'd', first walk its contents, and then yield the result of calling dict_fn(d). | def walk(obj,dict_fn):
if isinstance(obj,dict):
result = dict()
for key, value in obj.items():
result[key] = walk(value, dict_fn)
return dict_fn(result)
if isinstance(obj,list):
return [walk(i,dict_fn) for i in obj]
return obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iterate(d, fun): # type: (Dict, Callable[[Any, Any], None]) -> None\n for key, value in d.items():\n if isinstance(value, dict):\n DictUtil.iterate(value, fun)\n else:\n fun(key, value)",
"def crawl_json(json):\n for key in json:\n if type... | [
"0.6695884",
"0.65684736",
"0.6518398",
"0.63584036",
"0.61934584",
"0.616072",
"0.60844105",
"0.5964013",
"0.59480333",
"0.5939359",
"0.59319097",
"0.58762056",
"0.5792758",
"0.57106143",
"0.5598589",
"0.5532778",
"0.5450643",
"0.5371491",
"0.5370872",
"0.53495574",
"0.52964... | 0.69596267 | 0 |
Recomputes self.str and self.hash | def rehash(self):
self.str = "{}{}{}".format(LBRACE, " ".join(sorted([str(i) for i in self])), RBRACE)
self.hash = self.str.__hash__()
self.has_end_of_text = any([isinstance(i,EndOfText) for i in self]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, str=None, hashfunc=None):\r\n self.str = str\r\n if hashfunc:\r\n self.hashfunc = hashfunc",
"def hash(self) -> str:\r\n ...",
"def __hash__(self):\n return hash(self.text)",
"def hash_me(cls, p_str, p_len=64):\n v_hash = str()\n v_len = ... | [
"0.68092525",
"0.675968",
"0.6637325",
"0.65762126",
"0.65433997",
"0.64874315",
"0.6398045",
"0.63752127",
"0.6372463",
"0.6358108",
"0.6358108",
"0.6358108",
"0.6358108",
"0.6302346",
"0.6302346",
"0.6302346",
"0.6286356",
"0.6232979",
"0.6173351",
"0.6162594",
"0.613785",
... | 0.7349005 | 0 |
Lazily creates an unclosed ItemSet out of the next_items tracked by this edge. If by_index_memo is not None, then find and return the previously saved ItemSet with the same core items, if one exists there. Returns a pair (bool,ItemSet) True if the ItemSet was newly created the destination ItemSet when following this ed... | def NextItemSet(self,grammar,by_index_memo=None):
changed = False
if self.next_item_set_cache is None:
# Create the item set from the "next" items and associated lookaheads.
d = dict()
for item_id, next_and_lookahead in self.next.items():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def LALR1(self, max_item_sets=None):\n\n # Part 1. Compute LALR(1) item sets\n\n # Mapping from a core index to an already-discovered item set.\n by_index = dict()\n\n root_item = self.MakeItem(LANGUAGE, self.rules[LANGUAGE][0],0)\n\n # An ItemSet can be found by any of the items... | [
"0.53293574",
"0.5068311",
"0.49573022",
"0.48379317",
"0.4810332",
"0.4803411",
"0.476375",
"0.4717968",
"0.4712506",
"0.46483055",
"0.46081868",
"0.45811048",
"0.45610908",
"0.45453298",
"0.45288816",
"0.45250455",
"0.4524672",
"0.45122492",
"0.45077547",
"0.4498581",
"0.44... | 0.6633974 | 0 |
Adds an itemtolookahead mapping. | def internal_add(self,item,lookahead):
assert isinstance(item, Item)
assert isinstance(lookahead, LookaheadSet)
index = item.reg_info.index
assert isinstance(index,int)
assert index not in self.id_to_item
self.id_to_item[index] = item
self.id_to_lookahead[index] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, item):\n self._dict[item] = item",
"def add_item(self, item: _T) -> None:\n if item not in self.item_to_index:\n self.item_to_index[item] = len(self.index_to_item)\n self.index_to_item.append(item)",
"def additemtoinventory(item):\n global ITEM_COUNT\n for i ... | [
"0.5171958",
"0.49563116",
"0.49124083",
"0.4861802",
"0.48607472",
"0.48448393",
"0.48432246",
"0.48409677",
"0.48383635",
"0.4831507",
"0.482311",
"0.4807569",
"0.48044515",
"0.48009375",
"0.47910455",
"0.47871062",
"0.47762462",
"0.47709268",
"0.4750976",
"0.47148854",
"0.... | 0.7629796 | 0 |
Returns a short string, based only on core_index. Assumes core_index has been computed. | def short_str(self):
return "#{}".format(self.core_index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index_as_string(self):\n return self.index().to_string() if self.index() else None",
"def core_name(self):\n buf_size = self.MAX_BUF_SIZE\n buf = (ctypes.c_char * buf_size)()\n self._dll.JLINKARM_Core2CoreName(self.core_cpu(), buf, buf_size)\n return ctypes.string_at(buf).d... | [
"0.5660094",
"0.562463",
"0.5596635",
"0.53800434",
"0.5312243",
"0.53054535",
"0.5275866",
"0.5229172",
"0.5226107",
"0.5148643",
"0.51462585",
"0.51282895",
"0.51020956",
"0.5039063",
"0.5014327",
"0.50048393",
"0.49870846",
"0.4973255",
"0.49626827",
"0.4954054",
"0.495224... | 0.77697337 | 0 |
Returns True if the parser action for this item set should be 'accept'. | def is_accepting(self):
for item_id, lookahead in self.id_to_lookahead.items():
if lookahead.includesEndOfText():
item = self.id_to_item[item_id]
if item.is_accepting():
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isAccepted(self, *__args): # real signature unknown; restored from __doc__ with multiple overloads\n return False",
"def is_accepting(self):\n return (self.position == 1) and (self.lhs.content == LANGUAGE)",
"def is_action(self) -> bool:\n return self.is_action_str(self.content)",
"d... | [
"0.6501114",
"0.63528556",
"0.6297905",
"0.6200649",
"0.6059053",
"0.5967852",
"0.5967003",
"0.5911329",
"0.5838699",
"0.58103883",
"0.58103883",
"0.5795249",
"0.57933563",
"0.57908297",
"0.5663897",
"0.56602097",
"0.5613129",
"0.55470943",
"0.5518393",
"0.5437106",
"0.540227... | 0.6434725 | 1 |
Loads a grammar from text. The text format is assumed to be JSON object representing a Treesitter grammar. | def Load(json_text, start_symbol, ignore='_reserved'):
g = Grammar(json_text, start_symbol, ignore=ignore)
g.canonicalize()
g.compute_first()
g.compute_follow()
return g | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_grammar(path):\n return SCFG(iterrules(smart_ropen(path)))",
"def _load_parser(self, grammar: str, protocol: Protocol) -> None:\n self.parser = parsley.makeGrammar(grammar, {\n 'punctuation': string.punctuation,\n 'ascii_uppercase': string.ascii_uppercase,\n 'a... | [
"0.6654417",
"0.60497326",
"0.59955835",
"0.5882323",
"0.58619785",
"0.5717015",
"0.55960184",
"0.559184",
"0.5571526",
"0.5547955",
"0.5544798",
"0.5487034",
"0.5477157",
"0.54342926",
"0.54124516",
"0.53949016",
"0.53861123",
"0.53754157",
"0.53649855",
"0.5353797",
"0.5333... | 0.748296 | 0 |
Finds a Rule by its Python string name. | def find(self, rule_name):
return self.rules[rule_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_name(self, name):\n if name not in self.rule_dict:\n raise PegvmException(\"Failed to find rule named '{}'\".format(name))\n return self.rule_dict[name]",
"def get_rule(self, name):\n if not self._rules:\n raise NoRulesException()\n if not name in self... | [
"0.72327983",
"0.68010986",
"0.65098494",
"0.65098494",
"0.65098494",
"0.64873236",
"0.6475164",
"0.6460521",
"0.6324386",
"0.6131065",
"0.6131065",
"0.6001113",
"0.59306926",
"0.58415884",
"0.5783659",
"0.57832754",
"0.5764284",
"0.57564",
"0.57564",
"0.5746668",
"0.5716955"... | 0.7614755 | 0 |
Finds a registered object by its index. Registered objects are either Item or Rule (including Token) | def findByIndex(self, obj_index):
return self.registry.findByIndex(obj_index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_index(self, obj):\n return self.model.indexlist[obj]",
"def getObject(name, index=-1):\n\n names = [x.name for x in bpy.data.objects if getNamePrefix(x.name) == name]\n names = sorted(names, key=getNameIndex)\n\n if len(names) == 0:\n print(\"Object '{}' not found!\".format(name))... | [
"0.6923253",
"0.6511828",
"0.6414528",
"0.63838357",
"0.62515825",
"0.61839396",
"0.60195625",
"0.60153675",
"0.5983119",
"0.5975968",
"0.59725803",
"0.59725803",
"0.59528816",
"0.5948798",
"0.5843048",
"0.57931817",
"0.5785484",
"0.57647073",
"0.57612133",
"0.57382756",
"0.5... | 0.7559963 | 0 |
Returns a new Fixed object, unique up to equivalence of its string text. | def MakeFixed(self,content):
return self.register(Fixed(content,reg=self)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fixed(self):\n return self.f_fixed().m_fixed()",
"def instance2fv(self, text):\n if isinstance(text, unicode):\n text = text.encode('utf8')\n\n arr = np.zeros((self.n_feats,), dtype='uint32')\n\n # Convert the text to a sequence of ascii values\n ords = map(ord, text)\n\n # Count t... | [
"0.50933117",
"0.4975673",
"0.49061912",
"0.48256734",
"0.476634",
"0.47550938",
"0.4729677",
"0.46913713",
"0.46866438",
"0.45747095",
"0.4565746",
"0.45626754",
"0.45316634",
"0.45182678",
"0.4494061",
"0.4493968",
"0.44902837",
"0.4489109",
"0.44701687",
"0.4465243",
"0.44... | 0.5763124 | 0 |
Returns a new Pattern object, unique up to equivalence of its pattern text. | def MakePattern(self,content):
return self.register(Pattern(content,reg=self)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relate_pattern(a, b, pattern, **kwargs):\n return lib.relate_pattern(a, b, pattern, **kwargs)",
"def get_pattern(self):\n if self.pattern is None:\n pattern_str = self.blueprint.pattern()\n pattern_file = self.remgr.lookup_pattern_file(self.blueprint, self.provider)\n ... | [
"0.5792537",
"0.5585",
"0.5559421",
"0.5530123",
"0.54837835",
"0.54252803",
"0.5418044",
"0.54112136",
"0.538951",
"0.5339793",
"0.5319212",
"0.531522",
"0.5246962",
"0.5242287",
"0.52363425",
"0.52203023",
"0.5204605",
"0.52017283",
"0.51949394",
"0.5193178",
"0.5146308",
... | 0.58428156 | 0 |
Returns a new Repeat1 object, unique up to equivalence of its member. | def MakeRepeat1(self,content):
return self.register(Repeat1(content,reg=self)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_repeat(self):\n if hasattr(self, '_m_to_repeat'):\n return self._m_to_repeat if hasattr(self, '_m_to_repeat') else None\n\n self._m_to_repeat = self.to_repeat_raw.value\n return self._m_to_repeat if hasattr(self, '_m_to_repeat')... | [
"0.62315536",
"0.5892301",
"0.57454616",
"0.5742474",
"0.5706816",
"0.5539956",
"0.55211467",
"0.5520314",
"0.55111814",
"0.54748863",
"0.54399043",
"0.5416626",
"0.5397096",
"0.52835655",
"0.5254687",
"0.52383393",
"0.5224376",
"0.52110064",
"0.51618063",
"0.5122607",
"0.510... | 0.62277514 | 1 |
Returns a new Item, unique up to equivalence of its lefthand side nonterminal, righthand side production rule, and its position within that righthand side. | def MakeItem(self,lhs,rule,position):
# Upconvert a lhs to a SymbolName if it's a Python string.
lhs = lhs if isinstance(lhs,SymbolName) else self.MakeSymbolName(lhs)
candidate = Item(lhs,rule,position,reg=self)
# Avoid double-registering.
result = self.register(candidate)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicate(self):\n\n return Note(self.nbr, self.length, self.vel)",
"def construct(self, rule):\n reads = set(self.reads) - set(rule.keys()) | set(rule.values())\n rhs = self.rhs.xreplace(rule)\n return Temporary(self.lhs, rhs, reads=reads, readby=self.readby)",
"def __getitem__... | [
"0.522883",
"0.5150924",
"0.505851",
"0.50136834",
"0.49676684",
"0.49488047",
"0.48961335",
"0.48812065",
"0.4836267",
"0.48335648",
"0.48042563",
"0.4794623",
"0.4794623",
"0.47915378",
"0.4764995",
"0.4737992",
"0.47363135",
"0.47355115",
"0.47323593",
"0.4722751",
"0.4721... | 0.5554848 | 0 |
Rewrites this Grammar's rules so they are in Canonical Form. | def canonicalize(self):
self.rules = canonicalize_grammar(self,self.empty)
self.is_canonical = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simplify_rules(self):\n for rule in self.grammar:\n if re.search(r'->', rule):\n temp = re.split(r'->', rule)\n if len(temp[1].strip()) == 0:\n print(\"Invalid rule. The rule does not have the RHS.\")\n return\n\n ... | [
"0.6701039",
"0.574",
"0.55820376",
"0.55024123",
"0.5463086",
"0.54190004",
"0.5369632",
"0.527828",
"0.52666974",
"0.5177244",
"0.51597923",
"0.51496726",
"0.5147174",
"0.51346004",
"0.5035184",
"0.50138915",
"0.50105506",
"0.5006201",
"0.4998683",
"0.49688843",
"0.49423853... | 0.81821036 | 0 |
Computes the First set for each rule, saving the result on each rule node. Also computes .derives_empty | def compute_first(self):
compute_first_sets(self, self.rules) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_first_sets(grammar,rules):\n grammar.reset_first_follow()\n\n names_of_non_terminals = []\n grammar.end_of_text.first_data = set({grammar.end_of_text})\n grammar.empty.first_data = set({grammar.empty})\n for key, rule in rules.items():\n if rule.is_terminal() or rule.is_empty():\n... | [
"0.70863134",
"0.6661198",
"0.5768406",
"0.5582631",
"0.53950924",
"0.53758353",
"0.52905947",
"0.5282538",
"0.5208242",
"0.515067",
"0.5143861",
"0.51085323",
"0.5101925",
"0.5083233",
"0.5082251",
"0.50380355",
"0.5036741",
"0.5025692",
"0.50147015",
"0.49965972",
"0.499153... | 0.7545464 | 0 |
Computes the Follow set for each rule, saving the result on each rule node. Assumes First sets have been computed. | def compute_follow(self):
compute_follow_sets(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_follow_sets(grammar):\n\n # 1. Place $ in FOLLOW(S), where S is the start symbol and $ is the input\n # right end marker.\n grammar.rules[grammar.start_symbol].follow = set({grammar.end_of_text})\n\n def lookup(rule):\n return grammar.rules[rule.content] if isinstance(rule,SymbolName... | [
"0.7028939",
"0.6961307",
"0.68911374",
"0.66436577",
"0.604697",
"0.5467792",
"0.546096",
"0.54508024",
"0.53658897",
"0.532478",
"0.5312309",
"0.52231175",
"0.51560307",
"0.51270264",
"0.51243985",
"0.50737786",
"0.5060376",
"0.50545925",
"0.50366515",
"0.5035921",
"0.49926... | 0.7579764 | 0 |
Emits the internal representation of the grammar to stdout | def dump(self):
dump_grammar(self.rules)
print(self.registry) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, grammar, trace=...):\n ...",
"def output_grammar():\r\n dummy = Word(alphas.lower(), exact=1)\r\n axis = Or([positive_integer('size'), dummy('identifier')])\r\n shape = squareBracketedExpr( ( delimitedList(axis) ) )('shape')\r\n default = Suppress(Literal('=')) + (number... | [
"0.6304773",
"0.6263026",
"0.6086649",
"0.59790736",
"0.5811984",
"0.5795127",
"0.57577735",
"0.57212657",
"0.5668163",
"0.5666324",
"0.56441975",
"0.5634003",
"0.5626058",
"0.5603363",
"0.5550799",
"0.5526594",
"0.55197406",
"0.55122966",
"0.55122966",
"0.5499346",
"0.549466... | 0.6871682 | 0 |
Registers an item set, and return an index such that any item set with the same core will map to the same index. Indices start at 0 and go up by 1. Returns its index. | def register_item_set(self,item_set):
assert isinstance(item_set,ItemSet)
core = item_set.kernel_item_ids
if core in self.item_set_core_index:
return self.item_set_core_index[core]
# Register it
result = len(self.item_set_core_index)
self.item_set_core_index[c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self, pset):\n self._sets.index(pset)",
"def set_indx(self, item):\n for i, s in enumerate(self._data):\n if item in s:\n return i\n return None",
"def register_index(self) -> int:\n return self._parent_node.register_index",
"def get_combo_idx(d... | [
"0.6214665",
"0.5874514",
"0.58666277",
"0.54375255",
"0.537685",
"0.5279745",
"0.5150319",
"0.51177126",
"0.51001793",
"0.5087408",
"0.5042109",
"0.5026496",
"0.5026496",
"0.49999517",
"0.4973817",
"0.49672085",
"0.49609482",
"0.49571735",
"0.4955578",
"0.49481794",
"0.49374... | 0.8432474 | 0 |
Returns the names of rules, in order, based on the preorder traversal starting from the LANGUAGE start node. Assumes the grammar is in canonical form | def preorder(self):
assert self.is_canonical
# Names of visited nodes
visited = set()
# Names of nodes to visit
worklist = [LANGUAGE]
result = []
while len(worklist) > 0:
successors = []
for rule_name in worklist:
if rule_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rule_names(self):\n return self.rules.keys()",
"def extract_rule_names(self):\n if self.scanner == YARA:\n return sorted({result['rule'] for result in self.results})\n if self.scanner == CUSTOMS and 'matchedRules' in self.results:\n return self.results['matchedR... | [
"0.60005575",
"0.58476996",
"0.55949664",
"0.55783236",
"0.5526621",
"0.5481297",
"0.5413346",
"0.5225151",
"0.5198539",
"0.5161763",
"0.5130225",
"0.51194996",
"0.5093414",
"0.5093071",
"0.5053559",
"0.5044478",
"0.5043568",
"0.5019573",
"0.5008506",
"0.5006204",
"0.49716237... | 0.7482429 | 0 |
Refactor the grammar, shifting uses of 'target_rule_name' in the first position out to the invoking context. That is, when 'target_rule_name' names nonterminal X, and 'A' is not in 'stop_at_set', | def left_refactor(self,target_rule_name,stop_at_set):
name_suffix = ".post.{}".format(target_rule_name)
# Map a rule name X to a set of rules Y where X appears
# as a first nonterminal in one of Y's options.
appears_first_in = defaultdict(set)
for name, rule in self.rules.items(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hoist_until(self,target_rule_name,stop_at_set):\n assert self.is_canonical\n\n\n def expand_first(grammar,rule):\n \"\"\"\n When rule is\n Seq(A rest)\n and A -> A1 | ... | An\n Return [ A1 rest | ... | An rest ]\n\n ... | [
"0.63939667",
"0.5259394",
"0.5166907",
"0.5160086",
"0.51084006",
"0.5063297",
"0.5055394",
"0.50120264",
"0.49730772",
"0.4949256",
"0.49390268",
"0.48663703",
"0.4849125",
"0.48239273",
"0.47951698",
"0.47782853",
"0.4711918",
"0.46807438",
"0.46658933",
"0.46512583",
"0.4... | 0.71751463 | 0 |
If two nonterminals have the same right hand side, combine them. Don't combine any rules named in inline_stop. | def dedup_rhs(self,inline_stop=set(),verbose=False):
# Map an object index to the nonterminal that first defines it.
index_to_name = dict()
# Map a rule name to the rule name it should be replaced by.
replacement = dict()
def process_replacement(grammar,name,replacement_dict):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cnf(self):\n nonterm = set(self.nonterminal)\n term = set(self.terminal)\n\n rules = list(self.rules)\n cnf = set()\n\n # STEP 1: eliminate nonsolitary terminals\n for i in range(len(rules)):\n rule = rules[i]\n lhs, rhs, log_prob = rule\n ... | [
"0.5043339",
"0.5019824",
"0.49600214",
"0.48698428",
"0.48641443",
"0.48044404",
"0.47883224",
"0.47840193",
"0.47740465",
"0.4722412",
"0.47152784",
"0.46691644",
"0.46416342",
"0.46308494",
"0.4580326",
"0.45753255",
"0.45638022",
"0.4558784",
"0.45551687",
"0.4530562",
"0... | 0.6068014 | 0 |
Inline a rule when it only has one option, and at least one of the symbols is a symbol name. Don't inline any symbol named by excepting_set. | def inline_single_choice_with_nonterminal(self,excepting_set=set()):
# Map a rule name to the phrase it should be replaced with.
replacement = dict()
# Needed for computing follow sets
excepting_set = set(excepting_set) | {self.start_symbol}
# Process descendants first
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _want_sym(sym):\n if sym is None or len(sym) < 2:\n return False\n if sym['name'] in extract_ignore_names:\n return False\n bad_types = ['t', 'b', 'r', 'd', 'w']\n return (sym['type'] not in bad_types\n and sym['name'] not in ['__bss_start', '_en... | [
"0.4967638",
"0.4935038",
"0.4867223",
"0.47817987",
"0.47697067",
"0.47697067",
"0.4762051",
"0.4745731",
"0.4715457",
"0.4708826",
"0.4695875",
"0.46882424",
"0.4686827",
"0.46597877",
"0.46322995",
"0.46064657",
"0.45897946",
"0.45387805",
"0.45264187",
"0.45204505",
"0.44... | 0.5666457 | 0 |
If there are rules X > ... X.post.POST Then set X > POST X.post.POST | def refactor_post(self,post_name):
for name in list(self.rules):
related_post = "{}.post.{}".format(name,post_name)
if related_post in self.rules:
parts = [self.MakeSymbolName(x) for x in [post_name, related_post]]
self.rules[name] = self.MakeChoice([self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def passivize(rule):\n rule[\"mother\"][\"subcat\"] = {\n \"obj\": None,\n \"preps\": {\n \"by\": [[\"*Subj\"]]}}\n\n rule[\"mother\"][\"hooks\"] = {\n \"head\": [\"*Obj\"]}\n\n rule[\"dtrs\"][0][\"subcat\"] = {\n \"obj\": [\"*Obj\"]}\n\n rule[\"dtrs\"][0][\"hooks... | [
"0.5904426",
"0.56316584",
"0.523491",
"0.5202099",
"0.51211447",
"0.51167923",
"0.50520116",
"0.5017483",
"0.5003283",
"0.49718618",
"0.49518344",
"0.49451202",
"0.4943816",
"0.49202237",
"0.49096993",
"0.4888172",
"0.4884482",
"0.48383063",
"0.4826782",
"0.48211488",
"0.482... | 0.64331836 | 0 |
Hoists the rules for a a nonterminal into its ancestors. When target_rule_name holds the name for nonterminal X, and | def hoist_until(self,target_rule_name,stop_at_set):
assert self.is_canonical
def expand_first(grammar,rule):
"""
When rule is
Seq(A rest)
and A -> A1 | ... | An
Return [ A1 rest | ... | An rest ]
If Ai is ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left_refactor(self,target_rule_name,stop_at_set):\n name_suffix = \".post.{}\".format(target_rule_name)\n\n # Map a rule name X to a set of rules Y where X appears\n # as a first nonterminal in one of Y's options.\n appears_first_in = defaultdict(set)\n for name, rule in self... | [
"0.53636134",
"0.48799896",
"0.4737397",
"0.47098532",
"0.46533763",
"0.46415",
"0.46326968",
"0.45365122",
"0.44336197",
"0.44258782",
"0.43993366",
"0.4395593",
"0.4362665",
"0.43400556",
"0.43341917",
"0.4332908",
"0.43276796",
"0.4327197",
"0.4322775",
"0.43044192",
"0.42... | 0.6397924 | 0 |
Constructs an LL(1) parser table and associated conflicts (if any). | def LL1(self):
conflicts = []
table = dict()
def add(lhs,terminal,action):
action_key = (lhs,terminal)
if action_key in table:
# Record the conflict, and only keep the original.
prev = table[action_key]
conflicts.append((lh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testLR0ParseTable(self):\r\n from pydsl.Parser.LR0 import _slr_build_parser_table, build_states_sets\r\n state_sets = build_states_sets(productionset0)\r\n self.assertEqual(len(state_sets), 5)\r\n #0 . EI: : . exp $ , \r\n # exp : .SR\r\n # transitions: S -> 2,... | [
"0.55573875",
"0.54191315",
"0.5143745",
"0.51170874",
"0.50475824",
"0.5011598",
"0.50006133",
"0.49978584",
"0.4950667",
"0.49418342",
"0.49181917",
"0.48893735",
"0.48863432",
"0.48850852",
"0.48627818",
"0.48621088",
"0.4854347",
"0.4852148",
"0.48512858",
"0.48301548",
"... | 0.63953745 | 0 |
Constructs the LR(1) sets of items. | def LR1_ItemSets(self):
# The root item is the one representing the entire language.
# Since the grammar is in canonical form, it's a Choice over a
# single sequence.
root_item = self.MakeItem(LANGUAGE, self.rules[LANGUAGE][0],0)
# An ItemSet can be found by any of the items in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct(self):\n\n newSet = {}\n current_index = 0\n\n for key_1, value_1 in self._sets[self._currentSet].items():\n current_index += 1\n for key_2,value_2 in list(self._sets[self._currentSet].items())[current_index:]:\n # join the 2 tuples\n ... | [
"0.61705273",
"0.5918468",
"0.5712086",
"0.5710754",
"0.56861305",
"0.5651593",
"0.56297493",
"0.56052625",
"0.55712545",
"0.55698526",
"0.55202484",
"0.54824775",
"0.54575783",
"0.545201",
"0.5429481",
"0.54270715",
"0.53982484",
"0.5382677",
"0.53647447",
"0.5356855",
"0.53... | 0.633001 | 0 |
Will compare running instances to purchased reservations across all EC2 regions for all of the accounts supplied. | def reserved_compare(options):
running_instances = defaultdict(dict)
reserved_purchases = defaultdict(dict)
regions = boto.ec2.regions()
good_regions = [r for r in regions if r.name not in ['us-gov-west-1',
'cn-north-1']]
for region in good_re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_reservations(config):\n reservations = []\n region_list = regions(aws_access_key_id=config.keys.api,\n aws_secret_access_key=config.keys.secret)\n for region in region_list:\n _logger.info(\"Searching %s\", region)\n cnx = region.connect(aws_access_key_id=config.keys.api,\... | [
"0.658702",
"0.6300251",
"0.6290711",
"0.6167918",
"0.61583686",
"0.6010611",
"0.6007168",
"0.6005972",
"0.5818605",
"0.5817194",
"0.5642353",
"0.5628755",
"0.5611951",
"0.5504251",
"0.5503392",
"0.5461961",
"0.54465055",
"0.54377943",
"0.5424516",
"0.54001635",
"0.5366801",
... | 0.79189426 | 0 |
Returns whether or not this MPCFramework supports the given game | def supports_game(cls, game: Game) -> bool:
return game in cls.SUPPORTED_GAMES | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_support(mode: int) -> bool:\n return mode in supported_modes\n pass",
"def isValid(self, game):\n return True",
"def is_supported():\n return not isinstance(_the_app, StubApp)",
"def platform_supported(self):\n return platform.system().lower() in self.platforms if self.platforms... | [
"0.65107864",
"0.62987363",
"0.6131972",
"0.61076665",
"0.6079678",
"0.60238105",
"0.5971767",
"0.5921434",
"0.58807635",
"0.57579356",
"0.574543",
"0.57257944",
"0.57189626",
"0.5686974",
"0.5674633",
"0.5671523",
"0.56437093",
"0.5639276",
"0.56391764",
"0.5628202",
"0.5610... | 0.86261773 | 0 |
Method that will be called to prepare input for an MPCFramework. This function takes `self.input_file` (given as a CSV) and converts it as necessary into a usable format for the framework. | async def prepare_input(self) -> Status:
with open(self.input_file) as fin:
reader = csv.DictReader(fin)
fieldnames = reader.fieldnames
if fieldnames is None:
raise ValueError("fieldnames is None from csv reader")
for col in self.game.input_column... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare_input(self):\n super().prepare_input()\n input_file = self._input_filepath.open(encoding='utf-8')\n input_formatted_file = Path(self.__input_formatted_filepath).open('w', encoding='utf8')\n for line in input_file.readlines():\n for token in line.split():\n ... | [
"0.6678045",
"0.63659924",
"0.61832535",
"0.6178484",
"0.60234016",
"0.59841347",
"0.59212697",
"0.5921055",
"0.58992505",
"0.5816316",
"0.5810478",
"0.5741596",
"0.5741494",
"0.5665782",
"0.5596558",
"0.5566605",
"0.5560635",
"0.55366546",
"0.55172884",
"0.55052334",
"0.5498... | 0.6668474 | 1 |
Abstract method that is called to actually run the MPC program and get its results. Results are returned as a map of metrics to their values. For example, if a framework writes output data to a CSV, this method | async def run_mpc(self) -> Dict[str, Dict[Metric, int]]:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_metrics(self, results: list) -> dict:",
"def compute_metrics(self, results: list) -> dict:\n dump(results, self.out_file_path)\n print_log(\n f'Results has been saved to {self.out_file_path}.',\n logger='current')\n return {}",
"def evaluate_data():\n ... | [
"0.67122155",
"0.6655885",
"0.6510935",
"0.6348492",
"0.63320374",
"0.61878014",
"0.6165703",
"0.61387163",
"0.612315",
"0.6116958",
"0.6081799",
"0.6070544",
"0.60652965",
"0.6057899",
"0.6014032",
"0.6010055",
"0.60026187",
"0.5997987",
"0.5995066",
"0.5994565",
"0.5993076"... | 0.72799563 | 0 |
Returns predefined, constant max rows per partition | def get_max_rows_per_partition() -> int:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def largest_part_size():\n return usb_part_size(largest_partition())",
"def max_partition(\n table, schema=\"default\", field=None, filter_map=None, metastore_conn_id=\"metastore_default\"\n):\n from airflow.providers.apache.hive.hooks.hive import HiveMetastoreHook\n\n if \".\" in table:\n sch... | [
"0.62912965",
"0.62024087",
"0.60331285",
"0.59018713",
"0.5811828",
"0.5743732",
"0.56790406",
"0.5608854",
"0.55901206",
"0.55634403",
"0.5531216",
"0.5530995",
"0.5518127",
"0.5492531",
"0.5490018",
"0.5482808",
"0.5481561",
"0.5477486",
"0.54766625",
"0.5462024",
"0.54412... | 0.8459171 | 0 |
A list to a single node linked list | def lstToLinkedList(lst):
if not lst: return
LinkedList = Node(lst[0])
LinkedList.next = lstToLinkedList(lst[1:])
return LinkedList | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_to_listnode(input_list):\n # initialize node, not to be included in the final result\n node = ListNode()\n # keep node at the beginning of the linked list\n temp = node\n\n if len(input_list) == 1:\n # if single node, return as it is\n node.next = ListNode(val=input_list[0], n... | [
"0.7689867",
"0.74998283",
"0.7171626",
"0.71129197",
"0.6927131",
"0.6882673",
"0.6817767",
"0.67541057",
"0.67541057",
"0.6740895",
"0.67166805",
"0.67076075",
"0.6686264",
"0.6672835",
"0.6657356",
"0.66057336",
"0.65983284",
"0.6571332",
"0.6513007",
"0.649571",
"0.648054... | 0.7675289 | 1 |
Save dicom images and images with masks on top of the corresponding images. All files will will be saved under main_dir by creating a new folder for contour type and then by creating a folder for each patient separately. | def save_images(all_patients, contour_type='i_contour',
main_dir='final_data/images/'):
# create folder for contour_type
dirname = main_dir + f'{contour_type}/'
os.makedirs(dirname, exist_ok=True)
for patient in all_patients:
# create patient folders for saving
dirname ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_patients(self):\n if not os.path.exists(self.out_dir):\n os.makedirs(self.out_dir)\n\n for patient in os.listdir(self.root_dir):\n if \".csv\" in patient or \".md\" in patient:\n continue\n patient_pth = os.path.join(self.root_dir, patient)\... | [
"0.62861353",
"0.616862",
"0.6056372",
"0.59437436",
"0.59157383",
"0.58623785",
"0.5839377",
"0.5777538",
"0.5696017",
"0.5684696",
"0.56278366",
"0.5573473",
"0.55719286",
"0.5565964",
"0.55530864",
"0.5543438",
"0.5541765",
"0.5523903",
"0.5523742",
"0.5514894",
"0.5509282... | 0.7806346 | 0 |
Creates a new JSON based on the return parameters specified by user. If no return parameters specified, still runs through to clean any URL values, converts URLs to their respective values with clean_value() function. | def clean_json(json, return_params):
cleaned_json = []
for element in json:
new_element = {}
for key in element:
if (return_params is None) or (key in return_params):
value = element[key]
new_element[key] = clean_value(value, key)
cleaned_json... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create() -> TJsonResponse:\n if request.headers['Content-Type'] == 'application/json':\n url = request.json.get('url')\n else:\n url = request.form.get('url')\n if not url:\n return jsonify(error='bad request'), 400\n result = scrape.scrape_meta_for_url(url)\n inserted_id, t... | [
"0.59374917",
"0.5405094",
"0.5354095",
"0.5266332",
"0.51881903",
"0.5186116",
"0.51577467",
"0.51448053",
"0.5123238",
"0.5116251",
"0.5111089",
"0.5100726",
"0.5025311",
"0.4997758",
"0.4993474",
"0.49896982",
"0.49742863",
"0.49505863",
"0.49287662",
"0.49123642",
"0.4908... | 0.6074537 | 0 |
Filters any elements out of JSON who's parameters are not within range specified. | def filter_json(json, param, param_range):
filtered_json = []
for element in json:
if element[param]:
try:
value = int(element[param])
if param_range[0] <= value <= param_range[1]:
filtered_json.append(element)
except:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self, data):\n l = len(data[\"start_times\"])\n for i in range(l):\n if data[\"start_times\"][i]>=data['end_times'][i]:\n raise serializers.ValidationError(\"Start times should come before end times\") \n return data",
"def test_filte... | [
"0.58409065",
"0.5508638",
"0.5436571",
"0.54290146",
"0.5371077",
"0.53509444",
"0.5345174",
"0.53403056",
"0.5330316",
"0.5301808",
"0.5300423",
"0.5294917",
"0.5251204",
"0.52305263",
"0.5230448",
"0.52102774",
"0.51994115",
"0.51790226",
"0.517034",
"0.5168191",
"0.516146... | 0.8165445 | 0 |
Precompute the polynomial hash values of all the substring starting from the first letter. | def _precompute_substrings(self, p: int) -> List[int]:
hash_vals: List[int] = [0]
for i in range(len(self._s)):
val = (hash_vals[i] * self.X + ord(self._s[i])) % p
hash_vals.append(val)
return hash_vals | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precompute_hashes(text, pattern_len, p, x):\n\n if len(text) < pattern_len or pattern_len == 0:\n return []\n\n hashes = [ 0 ] * (len(text) - pattern_len + 1)\n\n slice = text[len(text) - pattern_len:]\n hashes[len(text) - pattern_len] = SearchPattern.poly_hash(\n ... | [
"0.6839831",
"0.63260895",
"0.6266397",
"0.62024325",
"0.61921644",
"0.6178474",
"0.6141195",
"0.61348975",
"0.61310077",
"0.6084944",
"0.5924525",
"0.59095466",
"0.587965",
"0.58699226",
"0.5862857",
"0.57915723",
"0.57605505",
"0.57369167",
"0.57208353",
"0.57144654",
"0.57... | 0.7261117 | 0 |
Compute the value of Xl mod p for l = [0, len(s)] | def _precompute_xl(self, p: int) -> List[int]:
res = [1]
val = 1
for _ in range(len(self._s)):
val = (val * self.X) % p
res.append(val)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mod(p):\n return (p[0]**2 + p[1]**2 + p[2]**2)**0.5",
"def mod_inv(a,p):\r\n\r\n for i in range(1,p):\r\n if (i*a)%p==1: return i\r\n raise ValueError(str(a)+\" has no inverse mod \"+str(p))",
"def ModSqrt(a, p):\n a = a % p\n for x in range(p // 2 + 1):\n if x * x % p == a:\n ... | [
"0.7254188",
"0.6605625",
"0.6407147",
"0.6380116",
"0.63562644",
"0.60197103",
"0.59769803",
"0.59705365",
"0.59639233",
"0.59582186",
"0.59088165",
"0.5866518",
"0.5865667",
"0.585502",
"0.5849936",
"0.5811184",
"0.5805049",
"0.577011",
"0.5748945",
"0.57488036",
"0.5728245... | 0.7123825 | 1 |
N should be an int specifying what size window Ngram to use. Default is 2 (bigram). features should be an integer specifying how many features of the len(alph)^N features to use to build each profile. Default is 676 (26^2). extended_alphabet should be a boolean value specifying whether to build profiles using only alph... | def __init__(self, N=2, features=0, extended_alphabet=False):
self.alph += (string.punctuation + ' ') if extended_alphabet else ''
self.N = N
self.features = features if features != 0 else len(self.alph)**N | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _profile(self, text):\n prof = zeros(len(self.alph)**self.N)\n ngs = ngrams(text, self.N)\n for tup in ngs:\n loc = 0\n for i in range(len(tup)):\n loc += (len(self.alph)**i) * self.alph.index(tup[i])\n prof[loc] += 1\n return prof",
... | [
"0.5295727",
"0.51407915",
"0.5013194",
"0.5007742",
"0.50075006",
"0.49982417",
"0.49953595",
"0.49740466",
"0.49623084",
"0.49546182",
"0.49153745",
"0.49083975",
"0.49014306",
"0.48962018",
"0.4837598",
"0.48255348",
"0.48082608",
"0.47809005",
"0.47733",
"0.47624588",
"0.... | 0.7015037 | 0 |
Cleans the text into a form that works for processing by removing tabs and linefeeds, and punctuation is extended_alphabet = False, along with making the text uniformly lowercase and transforming it into asciicompatible characters. | def _clean(self, text):
if len(self.alph) == 26:
text = sub('[\n\t ' + string.punctuation + ']+?', '', text)
else:
text = sub('[\n\t]+?', '', text)
text = text.lower()
text = text.encode('ascii', 'ignore').decode()
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def text_cleaning(self, text):\n # remove string formatting '\\n' or '\\t'\n tmp_text = re.sub(r'\\n+', '. ', text)\n tmp_text = re.sub(r'\\t+', '. ', text)\n # remove words with non-ascii characters\n tmp_text = \" \".join([word for word in tmp_text.split() if self.is_ascii(word... | [
"0.7089762",
"0.7030888",
"0.7011495",
"0.6901245",
"0.68705463",
"0.68348545",
"0.68348545",
"0.68334574",
"0.67861676",
"0.67735624",
"0.6761075",
"0.673244",
"0.6727343",
"0.6723118",
"0.6716831",
"0.67066026",
"0.6696384",
"0.6644331",
"0.6644331",
"0.6644331",
"0.6644331... | 0.7909278 | 0 |
Reduces features to ones with largest variance. If "features" is not specified in instantiation, same as original profile. | def _reduceFeatures(self):
# Adds up all profiles corresponding to each author,
# then compiles into a matrix of these "group" profiles.
group_profiles = {auth : zeros(len(self.alph)**self.N) for auth in set(self.train_data[1])}
for i in range(len(self.train_data[1])):
group_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _scale_features(self, features):\n assert isinstance(features, np.ndarray), \"Input is not a numpy array!\"\n\n return self.scaler.transform(features.reshape(1, -1))",
"def test_reduce_features_size(self):\n # Get some data\n data = array([[0.564, 20.661, 1], [-18.512, 41.168, -1]... | [
"0.61816657",
"0.59276104",
"0.59100384",
"0.58602893",
"0.5847031",
"0.5812968",
"0.5746926",
"0.572695",
"0.572695",
"0.5707635",
"0.56395966",
"0.5633891",
"0.56001306",
"0.5564291",
"0.55267614",
"0.5483713",
"0.5483713",
"0.5483698",
"0.54620516",
"0.5434813",
"0.5427648... | 0.63739 | 0 |
Train the model based on the training_data. training_data should be a dictionary whose keys are strings corresponding to an author's name, and whose values are lists of texts written by that author. | def train(self, training_data, chunk_size=100):
# For some reason, for the SVM to work, the keys need to be in alphabetical order
training_data = {k : training_data[k] for k in sorted(training_data)}
# Compile all author texts into one large text to then be broken down
for auth in train... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self, training_data):\n pass",
"def train(self, training_data: TrainingData, config: RasaNLUModelConfig, **kwargs: Any) -> None:\n pass",
"def train(self, training_data, model_name):\n dataset = []\n for example in training_data:\n entity_offsets = self._convert... | [
"0.7491742",
"0.7081026",
"0.7024971",
"0.698054",
"0.6940347",
"0.6940347",
"0.6874835",
"0.68558615",
"0.67965704",
"0.67838323",
"0.67239964",
"0.6681644",
"0.66786915",
"0.664978",
"0.66082704",
"0.66024756",
"0.65962833",
"0.6578496",
"0.6560251",
"0.65377945",
"0.651779... | 0.76001686 | 0 |
Test the list devices endpoint WIFI3452 | def test_gwservice_listdevices(self, setup_controller):
resp = setup_controller.request("gw", "devices", "GET", None, None)
body = resp.url + "," + str(resp.status_code) + ',' + resp.text
allure.attach(name="gw list devices", body=body)
if resp.status_code != 200:
assert Fals... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_devices(self):\n pass",
"def test_get_devices(self):\n pass",
"def test_verify_list_of_devices_in_my_network():",
"def test_get_devices1(self):\n pass",
"def user_sends_get_call_to_the_devices():\n web_app.list_devices()",
"def list_devices():\n return _lib.SeaTeas... | [
"0.73646533",
"0.73646533",
"0.7279443",
"0.70936656",
"0.699219",
"0.6931419",
"0.6884572",
"0.68194383",
"0.67612463",
"0.67612463",
"0.66208494",
"0.65730584",
"0.6533507",
"0.6531842",
"0.64532113",
"0.6428311",
"0.64186794",
"0.6415154",
"0.6404095",
"0.6266183",
"0.6234... | 0.7410879 | 0 |
Removes detections with lower object confidence score than 'conf_thres' and performs NonMaximum Suppression to further filter detections. | def non_max_suppression(prediction, conf_thres=0.5, nms_thres=0.4):
# From (center x, center y, width, height) to (x1, y1, x2, y2)
prediction[..., :4] = change_box_order(prediction[..., :4], order="xywh2xyxy")
output = [None for _ in range(len(prediction))]
for image_i, image_pred in enumerate(predicti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_max_suppression(prediction, conf_thres=0.5, nms_thres=0.5):\n min_wh = 2 # (pixels) minimum box width and height\n\n output = [None] * len(prediction)\n for image_i, pred in enumerate(prediction):\n # Multiply conf by class conf to get combined confidence\n class_conf, class_pred = ... | [
"0.73838377",
"0.70225656",
"0.688687",
"0.67943317",
"0.67545784",
"0.67077035",
"0.6688915",
"0.6534796",
"0.62705123",
"0.6241854",
"0.6180899",
"0.6155851",
"0.5827579",
"0.57856023",
"0.5763159",
"0.55842763",
"0.555821",
"0.5550575",
"0.5529788",
"0.5489186",
"0.5482876... | 0.7614843 | 0 |
L{BaseLogFile.shouldRotate} is abstract and must be implemented by subclass. | def test_abstractShouldRotate(self):
log = logfile.BaseLogFile(self.name, self.dir)
self.addCleanup(log.close)
self.assertRaises(NotImplementedError, log.shouldRotate) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rotation(self):\n # this logfile should rotate every 10 bytes\n with contextlib.closing(\n logfile.LogFile(self.name, self.dir, rotateLength=10)\n ) as log:\n\n # test automatic rotation\n log.write(\"123\")\n log.write(\"4567890\")\n ... | [
"0.71487135",
"0.6492304",
"0.64736336",
"0.64527625",
"0.63196",
"0.6227223",
"0.6160279",
"0.6128817",
"0.60674125",
"0.60335624",
"0.6029823",
"0.58550125",
"0.57736146",
"0.5724196",
"0.56967515",
"0.5521593",
"0.5495449",
"0.54723734",
"0.54601",
"0.5436036",
"0.5279109"... | 0.8085365 | 0 |
Various tests for log readers. First of all, log readers can get logs by number and read what was written to those log files. Getting nonexistent log files raises C{ValueError}. Using anything other than an integer index raises C{TypeError}. As logs get older, their log numbers increase. | def test_logReader(self):
log = logfile.LogFile(self.name, self.dir)
self.addCleanup(log.close)
log.write("abc\n")
log.write("def\n")
log.rotate()
log.write("ghi\n")
log.flush()
# check reading logs
self.assertEqual(log.listLogs(), [1])
wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_read_logs(self):\n records = log_reader(self.input_data_path)\n\n results = list(records)\n\n self.assertEqual(4, len(results))\n\n self.assertEqual(\n deque([u'record 1\\n', u'\\tline 1\\n',\n u'\\tline 2\\n', u'\\tline 3\\n']),\n result... | [
"0.68103456",
"0.6534209",
"0.6531893",
"0.6460277",
"0.6354693",
"0.63483745",
"0.6344147",
"0.6059483",
"0.5766431",
"0.57321525",
"0.5725983",
"0.5687353",
"0.56618154",
"0.5638312",
"0.5596897",
"0.5578588",
"0.55629724",
"0.5526029",
"0.5516472",
"0.55151045",
"0.5510207... | 0.68883264 | 0 |
L{LogReader.readLines} supports reading no line. | def test_LogReaderReadsZeroLine(self):
# We don't need any content, just a file path that can be opened.
with open(self.path, "w"):
pass
reader = logfile.LogReader(self.path)
self.addCleanup(reader.close)
self.assertEqual([], reader.readLines(0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def myreadlines(self):\n lines = []\n while True:\n line = self.readline()\n if not line:\n return lines\n else:\n lines.append(line)",
"def _consume_blanklines(self):\n while True:\n line = self.reader.readline()\n if len(line) == 0:\... | [
"0.67332673",
"0.66607267",
"0.6356252",
"0.6341487",
"0.63176274",
"0.6276629",
"0.62745696",
"0.62190604",
"0.6175334",
"0.6134149",
"0.6123871",
"0.60674244",
"0.60674244",
"0.60674244",
"0.60674244",
"0.60674244",
"0.60674244",
"0.60674244",
"0.60674244",
"0.60674244",
"0... | 0.7608662 | 0 |
Test the fromFullPath method. | def test_fromFullPath(self):
log1 = logfile.LogFile(self.name, self.dir, 10, defaultMode=0o777)
self.addCleanup(log1.close)
log2 = logfile.LogFile.fromFullPath(self.path, 10, defaultMode=0o777)
self.addCleanup(log2.close)
self.assertEqual(log1.name, log2.name)
self.assert... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fromFullPath(self):\n log1 = logfile.LogFile(self.name, self.dir, 10, defaultMode=0777)\n log2 = logfile.LogFile.fromFullPath(self.path, 10, defaultMode=0777)\n self.assertEquals(log1.name, log2.name)\n self.assertEquals(os.path.abspath(log1.path), log2.path)\n self.asse... | [
"0.7311831",
"0.6667163",
"0.66629404",
"0.6523232",
"0.6366584",
"0.6325803",
"0.6300358",
"0.62475204",
"0.61943454",
"0.618361",
"0.6173475",
"0.6126438",
"0.6062561",
"0.6036115",
"0.6036055",
"0.60141873",
"0.6011796",
"0.60003114",
"0.599448",
"0.5986072",
"0.5981678",
... | 0.70760405 | 1 |
Test specifying the permissions used on the log file. | def test_specifiedPermissions(self):
log1 = logfile.LogFile(self.name, self.dir, defaultMode=0o066)
self.addCleanup(log1.close)
mode = stat.S_IMODE(os.stat(self.path)[stat.ST_MODE])
if runtime.platform.isWindows():
# The only thing we can get here is global read-only
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_specifiedPermissions(self):\n log1 = logfile.LogFile(self.name, self.dir, defaultMode=0066)\n mode = stat.S_IMODE(os.stat(self.path)[stat.ST_MODE])\n if runtime.platform.isWindows():\n # The only thing we can get here is global read-only\n self.assertEquals(mode,... | [
"0.8162897",
"0.72478354",
"0.66200453",
"0.66200453",
"0.6612495",
"0.6511051",
"0.641548",
"0.6336619",
"0.6332582",
"0.6299115",
"0.62703973",
"0.62536114",
"0.61752075",
"0.61353326",
"0.60526747",
"0.60353744",
"0.6025186",
"0.59882975",
"0.59793806",
"0.5972703",
"0.597... | 0.8171138 | 0 |
L{logfile.LogFile.reopen} allows to rename the currently used file and make L{logfile.LogFile} create a new file. | def test_reopen(self):
with contextlib.closing(logfile.LogFile(self.name, self.dir)) as log1:
log1.write("hello1")
savePath = os.path.join(self.dir, "save.log")
os.rename(self.path, savePath)
log1.reopen()
log1.write("hello2")
with open(self.p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reopen(self):\n log1 = logfile.LogFile(self.name, self.dir)\n log1.write(\"hello1\")\n savePath = os.path.join(self.dir, \"save.log\")\n os.rename(self.path, savePath)\n log1.reopen()\n log1.write(\"hello2\")\n log1.close()\n\n f = open(self.path, \"... | [
"0.7946377",
"0.64694947",
"0.63982296",
"0.59405273",
"0.5934263",
"0.5886852",
"0.5834705",
"0.57587516",
"0.57212925",
"0.5604787",
"0.5531132",
"0.5527666",
"0.55086905",
"0.5500291",
"0.54822856",
"0.547342",
"0.545335",
"0.53930455",
"0.5317504",
"0.52583057",
"0.525584... | 0.78429323 | 1 |
Specifying an invalid directory to L{LogFile} raises C{IOError}. | def test_nonExistentDir(self):
e = self.assertRaises(
IOError, logfile.LogFile, self.name, "this_dir_does_not_exist"
)
self.assertEqual(e.errno, errno.ENOENT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_slf_badfolder():\n oldlogfile = get_logfile()\n with pytest.warns(UserWarning, match=\"Cannot write to logfile\"):\n start_logfile(\"nonexistent-folder/log.txt\")\n set_logfile(oldlogfile)",
"def test_bad_log_dir():\n with pytest.warns(LoggerWarning):\n log_file = '/abc/log.log... | [
"0.68436676",
"0.67017156",
"0.6490114",
"0.63831156",
"0.63824093",
"0.6239327",
"0.6176036",
"0.6102296",
"0.60836774",
"0.5973037",
"0.59534276",
"0.59534276",
"0.5948382",
"0.5926003",
"0.5904776",
"0.58937776",
"0.589284",
"0.58544636",
"0.58523554",
"0.58483446",
"0.584... | 0.71894586 | 0 |
Opening a L{LogFile} which can be read and write but whose mode can't be changed doesn't trigger an error. | def test_cantChangeFileMode(self):
if runtime.platform.isWindows():
name, directory = "NUL", ""
expectedPath = "NUL"
else:
name, directory = "null", "/dev"
expectedPath = "/dev/null"
log = logfile.LogFile(name, directory, defaultMode=0o555)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_log(fn):\n\n global log_file\n if fn is not None:\n d = os.path.dirname(fn)\n if d != \"\":\n makedirs(d)\n log_file = open(fn, \"a+\")",
"def test_slf_readonly(read_only_file):\n oldlogfile = get_logfile()\n with pytest.warns(UserWarning, match=\"Cannot write... | [
"0.6616025",
"0.6545175",
"0.6315127",
"0.6270276",
"0.62506443",
"0.6169582",
"0.6090433",
"0.6053088",
"0.60519564",
"0.6036345",
"0.6032789",
"0.60268515",
"0.5983956",
"0.5974772",
"0.59665847",
"0.5963023",
"0.59392637",
"0.58879405",
"0.5856009",
"0.5837253",
"0.5785556... | 0.7473909 | 0 |
L{LogFile.listLogs} doesn't choke if it encounters a file with an unexpected name. | def test_listLogsWithBadlyNamedFiles(self):
log = logfile.LogFile(self.name, self.dir)
self.addCleanup(log.close)
with open("{}.1".format(log.path), "w") as fp:
fp.write("123")
with open("{}.bad-file".format(log.path), "w") as fp:
fp.write("123")
self.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_log_files():\n for filename in os.listdir(\"/home/malyhass/log-parser\"):\n if filename.startswith(\"access.log\"):\n yield filename",
"def test_listLogsIgnoresZeroSuffixedFiles(self):\n log = logfile.LogFile(self.name, self.dir)\n self.addCleanup(log.close)\n\n ... | [
"0.73426706",
"0.70452076",
"0.6829374",
"0.6824721",
"0.67591035",
"0.6753871",
"0.6636772",
"0.66222703",
"0.6560827",
"0.6523128",
"0.64634424",
"0.64634424",
"0.62073946",
"0.61896455",
"0.61524665",
"0.60308105",
"0.5954449",
"0.5924665",
"0.58753115",
"0.5863695",
"0.58... | 0.7593141 | 0 |
L{LogFile.listLogs} ignores log files which rotated suffix is 0. | def test_listLogsIgnoresZeroSuffixedFiles(self):
log = logfile.LogFile(self.name, self.dir)
self.addCleanup(log.close)
for i in range(0, 3):
with open("{}.{}".format(log.path, i), "w") as fp:
fp.write("123")
self.assertEqual([1, 2], log.listLogs()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_list_without_current_log():\n full_list = sorted(filter(os.path.isfile, os.listdir('.')), key=os.path.getmtime)\n full_list.remove(\"connect-log.log\")\n return full_list",
"def list_log_files():\n for filename in os.listdir(\"/home/malyhass/log-parser\"):\n if filename.startswith... | [
"0.687992",
"0.68560153",
"0.6781296",
"0.6669578",
"0.6669526",
"0.6665514",
"0.6498067",
"0.64108115",
"0.63948584",
"0.61453205",
"0.613642",
"0.60900474",
"0.60900474",
"0.6055192",
"0.6039035",
"0.60025483",
"0.5982148",
"0.59603906",
"0.5949518",
"0.5949518",
"0.5900916... | 0.75706 | 0 |
Daily log files rotate daily. | def test_rotation(self):
log = RiggedDailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
days = [(self.path + "." + log.suffix(day * 86400)) for day in range(3)]
# test automatic rotation
log._clock = 0.0 # 1970/01/01 00:00.00
log.write("123")
log._cloc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup_rotate_daily(self, backup_dir: str, rotate: int):\n if rotate < 1:\n raise Exception(\"Rotate should be more than 0\")\n backup_domain_dir = self.get_backup_domain_dir(backup_dir)\n # for every file in directory group backups\n for disk in self.get_disks():\n ... | [
"0.6491307",
"0.64848346",
"0.61145",
"0.60250175",
"0.595329",
"0.584923",
"0.5831635",
"0.57777596",
"0.5700385",
"0.5630765",
"0.5577364",
"0.5499653",
"0.54012597",
"0.52955353",
"0.52432585",
"0.52192646",
"0.52171814",
"0.51803863",
"0.5149426",
"0.5129501",
"0.5054763"... | 0.7184687 | 0 |
Test retrieving log files with L{DailyLogFile.getLog}. | def test_getLog(self):
data = ["1\n", "2\n", "3\n"]
log = RiggedDailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
for d in data:
log.write(d)
log.flush()
# This returns the current log file.
r = log.getLog(0.0)
self.addCleanup(r.clo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLogs():",
"def getLogs():",
"def test_02_log_something(self):\n logger = get_logger(self)\n logger.info('Info in test_02')\n logger.debug('Debug in test_02')\n logger.warn('Warn in test_02')\n logfiles = glob.glob(os.path.join(self.LOG_FOLDER,\n ... | [
"0.70789343",
"0.70789343",
"0.7076324",
"0.7074265",
"0.67947835",
"0.6757375",
"0.6727712",
"0.67131376",
"0.67010534",
"0.6648962",
"0.66467845",
"0.65692544",
"0.65282345",
"0.65043813",
"0.64974445",
"0.64873743",
"0.64582217",
"0.6442727",
"0.6421746",
"0.6409436",
"0.6... | 0.8062962 | 0 |
L{DailyLogFile.rotate} doesn't do anything if they new log file already exists on the disk. | def test_rotateAlreadyExists(self):
log = RiggedDailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
# Build a new file with the same name as the file which would be created
# if the log file is to be rotated.
newFilePath = "{}.{}".format(log.path, log.suffix(log.lastDat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rotation(self):\n log = RiggedDailyLogFile(self.name, self.dir)\n self.addCleanup(log.close)\n days = [(self.path + \".\" + log.suffix(day * 86400)) for day in range(3)]\n\n # test automatic rotation\n log._clock = 0.0 # 1970/01/01 00:00.00\n log.write(\"123\")\n... | [
"0.73030114",
"0.698689",
"0.6847525",
"0.6840788",
"0.6798561",
"0.6691533",
"0.6677794",
"0.6297389",
"0.6220103",
"0.59473693",
"0.5910658",
"0.5899709",
"0.58956224",
"0.58610725",
"0.5853624",
"0.57774526",
"0.5770104",
"0.5769655",
"0.5716921",
"0.5665606",
"0.5656464",... | 0.8134708 | 0 |
L{DailyLogFile.rotate} doesn't do anything if the directory containing the log files can't be written to. | def test_rotatePermissionDirectoryNotOk(self):
log = logfile.DailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
os.chmod(log.directory, 0o444)
# Restore permissions so tests can be cleaned up.
self.addCleanup(os.chmod, log.directory, 0o755)
previousFile = log._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rotation(self):\n log = RiggedDailyLogFile(self.name, self.dir)\n self.addCleanup(log.close)\n days = [(self.path + \".\" + log.suffix(day * 86400)) for day in range(3)]\n\n # test automatic rotation\n log._clock = 0.0 # 1970/01/01 00:00.00\n log.write(\"123\")\n... | [
"0.7095745",
"0.70506084",
"0.69622046",
"0.6680857",
"0.6465015",
"0.6385839",
"0.62457275",
"0.6217206",
"0.6153067",
"0.60400724",
"0.6036944",
"0.60092556",
"0.5932151",
"0.5929419",
"0.5753766",
"0.573158",
"0.57181424",
"0.5692316",
"0.5616413",
"0.555534",
"0.55492324"... | 0.7417176 | 0 |
L{DailyLogFile.rotate} doesn't do anything if the log file can't be written to. | def test_rotatePermissionFileNotOk(self):
log = logfile.DailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
os.chmod(log.path, 0o444)
previousFile = log._file
log.rotate()
self.assertEqual(previousFile, log._file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rotateAlreadyExists(self):\n log = RiggedDailyLogFile(self.name, self.dir)\n self.addCleanup(log.close)\n\n # Build a new file with the same name as the file which would be created\n # if the log file is to be rotated.\n newFilePath = \"{}.{}\".format(log.path, log.suffi... | [
"0.74119174",
"0.72119117",
"0.7091033",
"0.69300157",
"0.6746559",
"0.6664942",
"0.6637426",
"0.66031617",
"0.65224576",
"0.64638555",
"0.6437075",
"0.62858355",
"0.6198719",
"0.6155689",
"0.59311914",
"0.5851718",
"0.58270603",
"0.57980514",
"0.55997765",
"0.55813855",
"0.5... | 0.72692174 | 1 |
Test that L{DailyLogFile.toDate} converts its timestamp argument to a time tuple (year, month, day). | def test_toDate(self):
log = logfile.DailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
timestamp = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, 0))
self.assertEqual((2000, 1, 1), log.toDate(timestamp)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_toDateUsesArgumentsToMakeADate(self):\n log = logfile.DailyLogFile(self.name, self.dir)\n self.addCleanup(log.close)\n\n date = (2014, 10, 22)\n seconds = time.mktime(date + (0,) * 6)\n\n logDate = log.toDate(seconds)\n self.assertEqual(date, logDate)",
"def tes... | [
"0.73253757",
"0.6513783",
"0.6041685",
"0.5993253",
"0.59896183",
"0.58429",
"0.58173954",
"0.5814273",
"0.580627",
"0.57834035",
"0.5779967",
"0.5716261",
"0.56601375",
"0.5622248",
"0.56181383",
"0.5579738",
"0.5574767",
"0.5573614",
"0.55702555",
"0.55503386",
"0.55450135... | 0.7634906 | 0 |
Test that L{DailyLogFile.toDate} returns today's date by default. By mocking L{time.localtime}, we ensure that L{DailyLogFile.toDate} returns the first 3 values of L{time.localtime} which is the current date. Note that we don't compare the real result of L{DailyLogFile.toDate} to the real current date, as there's a sli... | def test_toDateDefaultToday(self):
def mock_localtime(*args):
self.assertEqual((), args)
return list(range(0, 9))
log = logfile.DailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
self.patch(time, "localtime", mock_localtime)
logDate = log.toDa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_toDate(self):\n log = logfile.DailyLogFile(self.name, self.dir)\n self.addCleanup(log.close)\n\n timestamp = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, 0))\n self.assertEqual((2000, 1, 1), log.toDate(timestamp))",
"def test_toDateUsesArgumentsToMakeADate(self):\n log = lo... | [
"0.724369",
"0.68642217",
"0.6288886",
"0.6186907",
"0.61391515",
"0.5835489",
"0.5828766",
"0.57547426",
"0.57421017",
"0.56687856",
"0.5586837",
"0.558184",
"0.5570703",
"0.55430096",
"0.5538359",
"0.5517559",
"0.54918987",
"0.54758483",
"0.54238665",
"0.5422457",
"0.540879... | 0.863226 | 0 |
Test that L{DailyLogFile.toDate} uses its arguments to create a new date. | def test_toDateUsesArgumentsToMakeADate(self):
log = logfile.DailyLogFile(self.name, self.dir)
self.addCleanup(log.close)
date = (2014, 10, 22)
seconds = time.mktime(date + (0,) * 6)
logDate = log.toDate(seconds)
self.assertEqual(date, logDate) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_toDate(self):\n log = logfile.DailyLogFile(self.name, self.dir)\n self.addCleanup(log.close)\n\n timestamp = time.mktime((2000, 1, 1, 0, 0, 0, 0, 0, 0))\n self.assertEqual((2000, 1, 1), log.toDate(timestamp))",
"def test_toDateDefaultToday(self):\n\n def mock_localtime... | [
"0.8066649",
"0.7104837",
"0.6503378",
"0.63718504",
"0.60607177",
"0.59687394",
"0.5933312",
"0.58151937",
"0.57977784",
"0.5757311",
"0.5743511",
"0.5741214",
"0.57226443",
"0.57186323",
"0.5686977",
"0.5681874",
"0.5680657",
"0.56493884",
"0.56150955",
"0.5610736",
"0.5587... | 0.88875306 | 0 |
Test extension_level parameter of Extended Isolation Forest. The extension_level=0 means Isolation Forest's behaviour. This test is testing the known Isolation Forest's behaviour of 'Ghost clusters' which Extended Isolation Forest mitigates. The overall variance in anomaly score of EIF should be lower than anomaly scor... | def extended_isolation_forest_extension_level_smoke():
seed = 0xBEEF
double_blob = make_blobs(centers=[[10, 0], [0, 10]], cluster_std=[1, 1], random_state=seed,
n_samples=500, n_features=2)[0]
train = h2o.H2OFrame(double_blob)
anomalies = h2o.H2OFrame([[0, 0], [10, 10]]) #... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_extended_isolation_forest_categorical():\n\n print(\"Extended Isolation Forest Categorical Test\")\n train = h2o.import_file(pyunit_utils.locate(\"smalldata/parser/hexdev_497/airlines_small_csv\"))\n train[\"Origin\"] = train[\"Origin\"].asfactor()\n train[\"Dest\"] = train[\"Dest\"].asfactor(... | [
"0.5861506",
"0.5104245",
"0.5055874",
"0.50445503",
"0.50417703",
"0.49671063",
"0.49630588",
"0.49009794",
"0.487647",
"0.48635438",
"0.48563376",
"0.4849839",
"0.48132083",
"0.47682765",
"0.47103968",
"0.46879795",
"0.46877152",
"0.46719715",
"0.46637863",
"0.46590954",
"0... | 0.7157335 | 0 |
Buy the required quantity Y of X | def Buy(self, X, Y):
if self.money - (int(Y) * self.price[X][0] * (1 + self.taxe)) < 0:
raise TradeError("Not Enough Money")
self.share[X] += int(Y)
self.money -= int(Y) * self.price[X][0] * (1 + self.taxe)
print(f"BUY:{str(int(Y))}:{str(X)}", flush = True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _buy(self, units=1):\n self.quantity -= units",
"async def buy(self, ctx, quantity: int, symbol: str):\r\n symbol = symbol.upper()\r\n author = ctx.author\r\n with DB() as db:\r\n company = await self.get_active_company(ctx, db, author)\r\n await self.market_... | [
"0.7238275",
"0.67132986",
"0.6397412",
"0.62846696",
"0.6236672",
"0.61686414",
"0.61398065",
"0.6100066",
"0.60873055",
"0.60862577",
"0.60640794",
"0.6057393",
"0.60468096",
"0.6044836",
"0.59907424",
"0.59554666",
"0.5952139",
"0.59387517",
"0.59303457",
"0.58676326",
"0.... | 0.719711 | 1 |
Get the value of all money and all share converted into money | def GetSpeculated(self):
return self.money + sum([self.share[i] * self.price[i][0] * (1 + self.taxe) for i in self.price]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCurrencies():",
"def getAmount2(*args):",
"def getAmount1(*args):",
"def get_money(self):\n return self.money",
"def getMoney(self):\n if 1 in self.money:\n return self.money[1]\n else:\n return 0",
"def get_cash(self):\r\n return self.cash",
"de... | [
"0.6711975",
"0.64237803",
"0.6346039",
"0.6321251",
"0.62965816",
"0.6288939",
"0.62287134",
"0.6211428",
"0.6123923",
"0.6059905",
"0.6005782",
"0.59984255",
"0.59953415",
"0.59829986",
"0.5922546",
"0.5908083",
"0.5864107",
"0.5860223",
"0.5854684",
"0.5848573",
"0.5820815... | 0.67540455 | 0 |
Draw Bollinger Bands for little value | def DrawBands(self, count):
value = self.little[0]
mobile_average = float(sum([float(self.little[i])
for i in range(len(self.little))])) / float(self.period)
standard_derivation = sqrt(sum([pow(self.little[i] - mobile_average, 2)
for i in range(len(self.little))]) / self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bollinger_bonds(rm, rstd):\r\n upper_band = rm + rstd * 2\r\n lower_band = rm - rstd * 2\r\n return upper_band, lower_band",
"def bblo(wave,bstar,airlimit,fig):\n import matplotlib.pyplot as plt\n import logging\n from scipy.interpolate import splrep,splev\n import tmath.wombat.womco... | [
"0.63031137",
"0.6106892",
"0.6081654",
"0.6056311",
"0.60343945",
"0.6010062",
"0.6008821",
"0.6005752",
"0.5995668",
"0.5961967",
"0.59498906",
"0.5860355",
"0.58507574",
"0.5788195",
"0.57752544",
"0.57669455",
"0.5724179",
"0.57093775",
"0.56955534",
"0.5668017",
"0.56461... | 0.70920604 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.