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 |
|---|---|---|---|---|---|---|
Given a list of parsed scene_items (a plain list of dicts) Provide methods for redering that data timesigniture is only used for debug printing | def __init__(self, scene_items, timesigniture=DEFAULT_TIMESIGNITURE_):
self.scene_items = scene_items
self.total_beats = sum(scene_item['duration'] for scene_item in self.scene_items)
self.timesigniture = timesigniture | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_items_function(self):\n ars = self.ar[2009][11]['general']\n self.assertEqual(list(ars.items()), [('LastLine', ['20091202000343', '1011585', '206082338', '54716901457']), ('FirstTime', ['20091101000237']), ('LastTime', ['20091130234113']), ('LastUpdate', ['20091201094510', '1011585', '0', '8... | [
"0.5740542",
"0.56621575",
"0.5524638",
"0.5478715",
"0.54087716",
"0.53677016",
"0.53536004",
"0.52064437",
"0.51765895",
"0.5169679",
"0.51359755",
"0.51294976",
"0.5126739",
"0.5117502",
"0.51156247",
"0.511032",
"0.49845767",
"0.49424937",
"0.49424642",
"0.49300858",
"0.4... | 0.64365894 | 0 |
Return a list of all live Python objects, not including the list itself. | def get_all_objects():
gc.collect()
gcl = gc.get_objects()
olist = []
seen = {}
# Just in case:
seen[id(gcl)] = None
seen[id(olist)] = None
seen[id(seen)] = None
# _getr does the real work.
_getr(gcl, olist, seen)
return olist | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_objects():\n gcl = gc.get_objects()\n olist = []\n seen = {}\n # Just in case:\n seen[id(gcl)] = None\n seen[id(olist)] = None\n seen[id(seen)] = None\n # _getr does the real work.\n _getr(gcl, olist, seen)\n return olist",
"def get_all_objects():\n gcl = gc.get_o... | [
"0.736436",
"0.729643",
"0.6785282",
"0.6629329",
"0.65524584",
"0.6406",
"0.6404724",
"0.63662046",
"0.6298751",
"0.62828684",
"0.62828684",
"0.62828684",
"0.62828684",
"0.62828684",
"0.62828684",
"0.626183",
"0.6255329",
"0.6242195",
"0.61547345",
"0.6152571",
"0.6122982",
... | 0.7565201 | 0 |
Method that returns the rest energy of the particle. | def RestEnergy(self):
return (self.restMass * const.speed_of_light * const.speed_of_light) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy(self):\n energy = -0.5*np.sum(self.phi)+0.5*np.sum(self.mass*np.sqrt(self.particles.momentum[:,0]**2+self.particles.momentum[:,1]**2)**2)\n return energy",
"def TotalEnergy(self):\n return (math.sqrt((Particle.RestEnergy(self) ** 2)\n + (np.linalg.norm(Particle.Momentum(sel... | [
"0.7668576",
"0.7595888",
"0.7482029",
"0.7454896",
"0.74329084",
"0.74117565",
"0.7405934",
"0.7287761",
"0.7283499",
"0.70380706",
"0.70380706",
"0.6973054",
"0.69607884",
"0.6895652",
"0.67723006",
"0.6750274",
"0.67392176",
"0.67377317",
"0.6689237",
"0.6675212",
"0.66727... | 0.7802598 | 0 |
Method that returns Beta (velocity/speed of light) as a float | def BetaVelocity(self):
return np.linalg.norm(self.velocity) / const.speed_of_light | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def betaT(self):\n if self.maTail > 1:\n return 0\n else:\n return sqrt(1 - self.maTail**2)",
"def getBeta(self, alpha):\n return 2.0*(2.0-alpha) + -4.0*np.sqrt(1.0-alpha)",
"def beta(self):\n eTheta = self.eTheta()\n cosOmg = np.cos(self.omega())\n ... | [
"0.7552084",
"0.754992",
"0.7535426",
"0.7439897",
"0.74009764",
"0.7362183",
"0.7362183",
"0.71039945",
"0.707216",
"0.707216",
"0.707216",
"0.7020982",
"0.69366413",
"0.6877576",
"0.6866696",
"0.67877996",
"0.6773138",
"0.6760468",
"0.6758375",
"0.67385536",
"0.670362",
"... | 0.8313839 | 0 |
Method that returns the Lorentz Factor of the particle. | def LorentzFactor(self):
# Use of abs() and x ** 0.5 provides a more stable calculation of lorentz
# factor than math.sqrt() at high velocities.
return 1 / abs( 1 - Particle.BetaVelocity(self) * Particle.BetaVelocity(self))**0.5 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def L(self) -> float:\n return self._L",
"def Lorentz(x, x0, A, B, d):\n return B + A / (((x - x0) / d) ** 2 + 1)",
"def lorentz(x, gamma):\n return 1 / cs.pi * 0.5 * gamma / ((0.5 * gamma**2) + x**2)",
"def relu(z: float) -> float:\n return z if z > 0 else 0.01 * z",
"def lorentz(x, x0... | [
"0.65476906",
"0.65036815",
"0.6469627",
"0.638012",
"0.6348522",
"0.6347106",
"0.6341828",
"0.6334289",
"0.6333599",
"0.63280964",
"0.62715966",
"0.62416214",
"0.6189796",
"0.61773413",
"0.61520237",
"0.6139124",
"0.6098995",
"0.60558134",
"0.60534275",
"0.5988797",
"0.59480... | 0.8493009 | 0 |
Method that returns the relativistic momentum of the particle | def Momentum(self):
return (np.multiply(Particle.LorentzFactor(self)
, np.array(self.velocity,dtype=float))* self.restMass) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMomentum(self):\n return self.p",
"def calcMomentumFromVelocity(self):\n if self.mass is None:\n raise CoordinateVector(\"The particle mass needs to be specified to calculate the particle momentum from velocity.\")\n values = {}\n for direction in self.v.order:\n gamma = self.calcLor... | [
"0.74322164",
"0.73959345",
"0.73226726",
"0.72440016",
"0.69533795",
"0.69061005",
"0.6754555",
"0.665831",
"0.6585926",
"0.6467245",
"0.6458798",
"0.64507335",
"0.6449878",
"0.64052224",
"0.63391316",
"0.63144106",
"0.6260632",
"0.61805636",
"0.61436313",
"0.6129185",
"0.61... | 0.75053847 | 0 |
Method that returns the electric field from the particle that affects another particle. | def GenerateElectricField(self, affectedParticle):
return self.electricField.GenerateField(affectedParticle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def electric_field(self, xyz):\n dxyz = self.vector_distance(xyz)\n r = spatial.repeat_scalar(self.distance(xyz))\n kr = self.wavenumber*r\n ikr = 1j * kr\n\n front_term = (\n (1j * self.omega * self.mu * self.moment) / (4. * np.pi * r**2) *\n (ikr + 1) * np... | [
"0.6565109",
"0.6523056",
"0.6255628",
"0.62081003",
"0.61325175",
"0.6086595",
"0.5954075",
"0.5868522",
"0.58501065",
"0.5768421",
"0.5700194",
"0.5639009",
"0.5562006",
"0.55513227",
"0.55293006",
"0.54763085",
"0.5419618",
"0.53979456",
"0.53979456",
"0.53847796",
"0.5378... | 0.72869897 | 0 |
Method that returns the magnetic field from the particle that affects another particle. | def GenerateMagneticField(self, affectedParticle):
return self.magneticField.GenerateField(affectedParticle) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnetic_field(self, xyz):\n dxyz = self.vector_distance(xyz)\n r = spatial.repeat_scalar(self.distance(xyz))\n kr = self.wavenumber * r\n ikr = 1j*kr\n\n front_term = (\n self.current * self.length / (4 * np.pi * r**2) * (ikr + 1) *\n np.exp(-ikr)\n ... | [
"0.67325306",
"0.65006876",
"0.64733946",
"0.64133286",
"0.61525905",
"0.6089795",
"0.594535",
"0.5899009",
"0.58383423",
"0.5798657",
"0.5736236",
"0.57189417",
"0.5650898",
"0.5645273",
"0.5644613",
"0.55965346",
"0.5590425",
"0.5575774",
"0.5534189",
"0.5524397",
"0.551204... | 0.6843076 | 0 |
Returns the initialized component manager. This is used as FastAPI dependency and called for every request. | def get_component_manager(
token: str = Depends(get_api_token),
) -> ComponentOperations:
session = BaseUrlSession(base_url=CONTAXY_API_ENDPOINT)
session.headers = {"Authorization": f"Bearer {token}"}
return ComponentClient(session) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_manager():\n\n return multiprocessing.Manager()",
"def GetManager(self):\r\n\r\n return self.manager",
"def get_manager():\n return __manager__",
"def getManager(self):\n return self._manager",
"def core(self):\n return CoreManager(self)",
"def manager(self):\n ... | [
"0.68361783",
"0.6697513",
"0.66576326",
"0.660257",
"0.6231092",
"0.61051804",
"0.61051804",
"0.6104129",
"0.5990772",
"0.5973677",
"0.5936767",
"0.5933692",
"0.588824",
"0.5797466",
"0.57823783",
"0.5773982",
"0.5772796",
"0.57626957",
"0.5757743",
"0.57147866",
"0.5693136"... | 0.69490683 | 0 |
Get a string for the status overview of the pool and nodes. | def get_pool_overview_string(self, mission):
# get statuses
pool_status, allocation_status, node_status = self.get_pool_status(mission)
s = "Pool status: {}\n".format(pool_status)
s += "Allocation status: {}".format(allocation_status)
if pool_status != "N/A":
othe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status_str(self, spaced=False):\n if self.args.vverbose:\n ## Print profile of all nodes\n status = self.pool.status(string=True)\n\n elif self.args.verbose:\n ## Print profile of usable nodes\n status = self.pool.status(min_state=PLNodeState.usable, string=True)\n\n ... | [
"0.78566015",
"0.72541404",
"0.690066",
"0.68025947",
"0.67186147",
"0.6582966",
"0.65206933",
"0.65195024",
"0.65195024",
"0.6434992",
"0.64222366",
"0.6364477",
"0.6364477",
"0.6364477",
"0.6364477",
"0.6364477",
"0.6364477",
"0.6364477",
"0.6364477",
"0.6364477",
"0.636447... | 0.7833251 | 1 |
Get a string for the status overview of the job and tasks. | def get_job_overview_string(self, mission):
# get statuses
job_status, task_status = self.get_job_status(mission)
s = "Job status: {}".format(job_status)
if job_status != "N/A":
s += "\n"
s += "Tasks status: "
s += "{} active; ".format(task_status["... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_job_status(self):\n total_hits = session.query(BoxHit).filter_by(training_job_id=self.id).count()\n num_hits_left = session.query(BoxHit).filter_by(training_job_id=self.id, outstanding=True).count()\n total_urls = self.num_urls\n num_urls_left = session.query(VideoTrainingURL).... | [
"0.74661416",
"0.7176071",
"0.7176071",
"0.71116614",
"0.7109996",
"0.7087766",
"0.7026905",
"0.69023955",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
"0.6890844",
... | 0.7895506 | 0 |
Get the status of a mission's storage container. | def get_storage_container_status(self, mission):
if self.storage_client.exists(container_name=mission.container_name):
return "available"
# TODO: calculate space used in the container
return "N/A" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_storage_container_overview_string(self, mission):\n\n status = self.get_storage_container_status(mission)\n s = \"Storage container status: {}\".format(status)\n return s",
"def container_status(self) -> str:\n return pulumi.get(self, \"container_status\")",
"def container_s... | [
"0.7662295",
"0.68757343",
"0.65628034",
"0.61149687",
"0.61096156",
"0.60097855",
"0.59428936",
"0.5903649",
"0.58938575",
"0.5616815",
"0.560521",
"0.5599396",
"0.55950266",
"0.5577565",
"0.55629945",
"0.556032",
"0.5544695",
"0.5521543",
"0.5521207",
"0.551155",
"0.5508292... | 0.85038316 | 0 |
Get a string for the status of the storage container. | def get_storage_container_overview_string(self, mission):
status = self.get_storage_container_status(mission)
s = "Storage container status: {}".format(status)
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def container_status(self) -> str:\n return pulumi.get(self, \"container_status\")",
"def storage_bytes_status(self) -> str:\n return pulumi.get(self, \"storage_bytes_status\")",
"def status(self) -> str:\n return pulumi.get(self, \"status\")",
"def status(self) -> str:\n return p... | [
"0.8081375",
"0.7568696",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
"0.72568953",
... | 0.7668451 | 1 |
Shows a simple scatterplot of X, colored by the classes in y. Technically, this shows the 1st three principal components of X if X has more than 3 dimensions. If X only has 2 dimensions, then just a 2dimensional scatterplot is returned. This will not produce a plot for 1 dimensional data. | def plot_data(X, y):
x_dim = X.shape[1]
# Ignore 1 dimensional data
if x_dim == 1:
print("plot_data not gonna bother with 1 dimensional data")
return
# For 2 dimensional data, just plot it
if x_dim == 2:
plt.scatter(X[:,0], X[:,1], c=y)
plt.show()
return
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scatter_plot(self):\n\n X = self.reduce_dimension(n_components=2)\n\n plt.figure()\n plt.scatter(X[:,0], X[:,1])\n\n return plt",
"def plot_dataset(X, classes):\n data = pd.DataFrame(X, columns=['x', 'y'])\n data['dataset'] = classes\n sns.lmplot('x', 'y', data=data, hue=... | [
"0.68430007",
"0.66364133",
"0.6596344",
"0.6580677",
"0.65084815",
"0.645392",
"0.6410972",
"0.6298724",
"0.6219223",
"0.621192",
"0.61827666",
"0.61542743",
"0.6125981",
"0.60232717",
"0.59843695",
"0.590425",
"0.59014237",
"0.5894517",
"0.58731264",
"0.58717024",
"0.586803... | 0.7091436 | 0 |
Log and assert based on condition. If condition True, log message as PASS to testcase log file. If condition False, Assert and Print message with status FAIL. | def logfile_assert_message(s, condition, message):
if not condition:
s.log_to_file += now_short() + message + ": FAIL\r\n"
assert 0, message + ": FAIL\r\n"
else:
log_message(s, message + ": PASS") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test(self):\n self.info(\"LOGGING: Testing log messages\")\n self.debug(\"This is a debugging message\")\n self.info(\"This is an informational message\")\n self.warning(\"This is a warning message\")\n self.error(\"This is an error message\")\n self.critical(\"This is... | [
"0.6288022",
"0.61218476",
"0.6107574",
"0.60947496",
"0.5991102",
"0.5953129",
"0.5885416",
"0.587344",
"0.5861646",
"0.58180374",
"0.5753832",
"0.5752025",
"0.5750852",
"0.5717795",
"0.57175326",
"0.570502",
"0.5684395",
"0.5653539",
"0.5651103",
"0.5643155",
"0.5638683",
... | 0.78782284 | 1 |
Write detailed log file for given test. | def write_test_log(t, output_dir):
if t.log_to_file is not None and hasattr(t, "stop_time"):
filename = type(t).__name__ + "-" + time.strftime("%Y%m%d-%H%M%S") + ".txt"
testtime = t.stop_time - t.start_time
with open(os.path.join(output_dir, filename), "w") as log:
log.write("\t=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_test_log(t, output_dir):\n if t.log_to_file is not None and hasattr(t, \"stop_time\"):\n filename = type(t).__name__ + \"-\" + time.strftime(\"%Y%m%d-%H%M%S\") + \".txt\"\n testtime = t.stop_time - t.start_time\n with open(os.path.join(output_dir, filename), \"w\") as log:\n ... | [
"0.77759415",
"0.6469761",
"0.6405734",
"0.63734347",
"0.6358866",
"0.6292069",
"0.627844",
"0.6241813",
"0.62395686",
"0.6190359",
"0.618326",
"0.6178866",
"0.6163366",
"0.61453724",
"0.61151177",
"0.6075739",
"0.6044056",
"0.6033274",
"0.5966068",
"0.59578186",
"0.5957704",... | 0.7797923 | 0 |
Add process time with the log messages. | def extra_log(self, string):
if hasattr(self.parent, "log"):
self.parent.log += f"\r\n[{time.process_time()}] "
self.parent.log += string + "\r\n" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_line_in_log():\n logging.info(' ' + '-' * 60 + '\\n')",
"def add_log(self, log):\n log = str(datetime.datetime.now()) + \": \"+log+\"\\n\"\n print(log)\n self.logs.append(log)\n if len(self.logs) > 10:\n self.append_to_logfile()",
"def extra_log(self, string):\... | [
"0.67774904",
"0.6688818",
"0.6468294",
"0.64525807",
"0.6431555",
"0.6324461",
"0.6312171",
"0.6251729",
"0.6245165",
"0.62316775",
"0.6187182",
"0.61647475",
"0.6160086",
"0.61188847",
"0.6091051",
"0.60706383",
"0.6057694",
"0.60288566",
"0.60258675",
"0.60083884",
"0.6007... | 0.66905326 | 1 |
Factory for subfield items. | def subfieldFactory(name):
from pythia.pyre.inventory import facility
return facility(name, family="subfield", factory=Subfield) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subfield():\n return Subfield()",
"def __init__(self, *args, **kwargs):\n super(ListFieldType, self).__init__(*args, **kwargs)\n\n self.item_info = self.field_info.get('items')",
"def create_subspecialty(sub_data):\n return get_or_create_object(sub_data, Subspecialty)",
"def test_cust... | [
"0.7079664",
"0.60948706",
"0.57870966",
"0.5703622",
"0.5617625",
"0.56146836",
"0.56075746",
"0.5595222",
"0.554094",
"0.546303",
"0.54049605",
"0.53629017",
"0.53175354",
"0.5301199",
"0.5221799",
"0.5221799",
"0.51944876",
"0.51886076",
"0.5142889",
"0.5127228",
"0.512640... | 0.7673134 | 0 |
Factory associated with Subfield. | def subfield():
return Subfield() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subfieldFactory(name):\n from pythia.pyre.inventory import facility\n return facility(name, family=\"subfield\", factory=Subfield)",
"def add_sub_factories(self) -> None:\n for field in get_model_fields(self.model, base=False, foreign=True, m2m=False):\n if not hasattr(self.factory, f... | [
"0.8500797",
"0.66517395",
"0.6441253",
"0.6377734",
"0.59815156",
"0.58264554",
"0.5662838",
"0.5660655",
"0.56087625",
"0.5576944",
"0.5576053",
"0.5484294",
"0.54726523",
"0.5440579",
"0.5439738",
"0.5400487",
"0.528335",
"0.52721506",
"0.52566725",
"0.52566725",
"0.519902... | 0.77598864 | 1 |
Gets the short path name of a given long path. | def get_short_path_name(long_name: str):
output_buf_size = _GetShortPathNameW(long_name, None, 0)
if output_buf_size <= 0:
return None
output_buf = ctypes.create_unicode_buffer(output_buf_size)
needed = _GetShortPathNameW(long_name, output_buf, output_buf_size)
assert 0 < needed < output_buf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_short_path_name(long_name):\n output_buf_size = 0\n while True:\n output_buf = ctypes.create_unicode_buffer(output_buf_size)\n needed = _GetShortPathNameW(long_name, output_buf, output_buf_size)\n if output_buf_size >= needed:\n return output_buf.value\n else:\n... | [
"0.8374927",
"0.692538",
"0.6779394",
"0.6752157",
"0.6703952",
"0.65418506",
"0.6538999",
"0.6492663",
"0.64758646",
"0.6439164",
"0.63933027",
"0.6386224",
"0.636427",
"0.6346333",
"0.6328241",
"0.63225263",
"0.6192011",
"0.61536336",
"0.6148895",
"0.6138921",
"0.61234444",... | 0.8415998 | 0 |
open jpg file or merge several jpg file then open it | def execute_file(self, event=None):
file_list = self.get_path_list()
print(file_list)
if not file_list:
return
# merge image
# 修复内存泄露的bug,由于没有清除之前打开的图片,第二次打开的图片仍然为之前的图片
try:
self.photos.destroy()
except:
pass
self.photos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_frame(path,number):\n num=str(number).zfill(3) #Zero filling\n name = glob.glob(path+\"/*\"+num+\"*\")\n if len(name)==0:\n name = glob.glob(path+\"/\"+str(number)+\".png\")\n if len(name)>1:\n print \"too many matches \",len(name),\" found\"\n name = name[0]\n img = Imag... | [
"0.58855605",
"0.5591409",
"0.55525833",
"0.5439224",
"0.5414354",
"0.5400621",
"0.5384213",
"0.53814346",
"0.5351015",
"0.5304343",
"0.52945495",
"0.5280849",
"0.52760863",
"0.52742296",
"0.527252",
"0.5259538",
"0.5245993",
"0.52299297",
"0.5225909",
"0.52070266",
"0.519107... | 0.60279435 | 0 |
Scroll canvas horizontally and redraw the image | def __scroll_x(self, *args, **kwargs):
self.canvas_image.xview(*args) # scroll horizontally
self.__show_image() # redraw the image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __scroll_x(self, *args, **kwargs):\n self.canvas.xview(*args) # scroll horizontally\n self.__show_image() # redraw the image",
"def continuous_scroll(self, context):\n\n self.drawing.redraw_canvas(self.dy)\n \n return True",
"def refresh(self):\n\n # Delete old i... | [
"0.7781856",
"0.6695677",
"0.6625122",
"0.66034824",
"0.64015204",
"0.6336621",
"0.62105596",
"0.6134658",
"0.6117314",
"0.6087952",
"0.60482293",
"0.5974955",
"0.59536266",
"0.59532565",
"0.5856979",
"0.58364534",
"0.58310264",
"0.58037436",
"0.5784162",
"0.5746283",
"0.5735... | 0.78580177 | 0 |
Scroll canvas vertically and redraw the image | def __scroll_y(self, *args, **kwargs):
self.canvas_image.yview(*args) # scroll vertically
self.__show_image() # redraw the image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __scroll_y(self, *args, **kwargs):\n self.canvas.yview(*args) # scroll vertically\n self.__show_image() # redraw the image",
"def refresh(self):\n\n # Delete old image (if needed) \n if self.canvas_image_id:\n self.canvas.delete(self.canvas_image_id)\n if debug... | [
"0.78763294",
"0.7029265",
"0.6990234",
"0.6822299",
"0.67670774",
"0.6654772",
"0.6486098",
"0.63472086",
"0.6317045",
"0.6261508",
"0.62313896",
"0.61648124",
"0.6163939",
"0.613647",
"0.61271584",
"0.61243415",
"0.61053514",
"0.6080344",
"0.60629725",
"0.606112",
"0.605199... | 0.79207057 | 0 |
Checks if the point (x,y) is outside the image area | def outside(self, x, y):
bbox = self.canvas_image.coords(self.container) # get image area
if bbox[0] < x < bbox[2] and bbox[1] < y < bbox[3]:
return False # point (x,y) is inside the image area
else:
return True # point (x,y) is outside the image area | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outside(self, x, y):\n bbox = self.canvas.coords(self.container) # get image area\n if bbox[0] < x < bbox[2] and bbox[1] < y < bbox[3]:\n return False # point (x,y) is inside the image area\n else:\n return True # point (x,y) is outside the image area",
"def poin... | [
"0.87402356",
"0.7378075",
"0.7371467",
"0.7322463",
"0.7271476",
"0.71669763",
"0.7123005",
"0.70656526",
"0.7022389",
"0.7014238",
"0.696292",
"0.6954585",
"0.69515514",
"0.69209486",
"0.6896473",
"0.68796045",
"0.6856969",
"0.68375915",
"0.67989755",
"0.6798606",
"0.678162... | 0.8744287 | 0 |
Dummy function to redraw figures in the children classes | def redraw_figures(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redraw(event):\n if np.size(plt.get_figlabels()):\n #Need to check if figure is closed or not and only then do the following\n #operations. Else, the following operations will create a new figure\n ax.clear()\n drawRectangle(ax)\n fig.canvas.draw()\n else:\n pas... | [
"0.69585615",
"0.68990314",
"0.6801519",
"0.67597973",
"0.6633574",
"0.64148325",
"0.6317707",
"0.6250047",
"0.6198424",
"0.61798114",
"0.61377364",
"0.6077331",
"0.60669315",
"0.60655534",
"0.60549927",
"0.6053331",
"0.60529304",
"0.6050833",
"0.604263",
"0.6037915",
"0.6037... | 0.78338176 | 1 |
Repeat the retrieval of the metrics of a metrics context until at least one of the specified metric group names has data. Returns the MetricGroupValues object for the metric group that has data. | def wait_for_metrics(metric_context, metric_groups):
retries = 0
got_data = False
while not got_data:
mr_str = metric_context.get_metrics()
mr = zhmcclient.MetricsResponse(metric_context, mr_str)
for mg_values in mr.metric_group_values:
if mg_values.name in metric_groups:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result_group(group_id, failures=False, wait=0, count=None, cached=Conf.CACHED):\n if cached:\n return result_group_cached(group_id, failures, wait, count)\n start = time.time()\n if count:\n while 1:\n if count_group(group_id) == count or wait and (time.time() - start) * 1000 ... | [
"0.55873525",
"0.55362415",
"0.54371434",
"0.51211834",
"0.50748",
"0.50633067",
"0.50494426",
"0.50236344",
"0.5014017",
"0.49106795",
"0.4888227",
"0.48790106",
"0.48743725",
"0.4858078",
"0.48575234",
"0.48438308",
"0.48435786",
"0.4804029",
"0.47981688",
"0.47835502",
"0.... | 0.72703934 | 0 |
Retrieve and print metric groups. | def print_metric_groups(cmd_ctx, client, metric_groups, resource_filter):
if not isinstance(metric_groups, (list, tuple)):
metric_groups = [metric_groups]
properties = {
'anticipated-frequency-seconds': MIN_ANTICIPATED_FREQUENCY,
'metric-groups': metric_groups,
}
mc = client.me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_groups(self):\n\n for counter, label in enumerate(self.exp_labels_list):\n print('Key {}: {} \\n'.format(str(counter), label))",
"def metrics_group():",
"def groups(self):\n #return self.get('{}/groups'.format(ApiVersion.A1.value))\n return self.get('{}/groups'.format(ApiVersio... | [
"0.72279793",
"0.70860595",
"0.674111",
"0.66355723",
"0.64703333",
"0.6281449",
"0.62582123",
"0.62421024",
"0.62346387",
"0.6213498",
"0.61584836",
"0.61584836",
"0.6125847",
"0.6110818",
"0.61033535",
"0.60848945",
"0.6041761",
"0.6026084",
"0.599124",
"0.5982218",
"0.5980... | 0.73456234 | 0 |
Report usage overview metrics for CPCs. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_cpc(cmd_ctx, cpc, **options):
cmd_ctx.execute_cmd(lambda: cmd_metrics_cpc(cmd_ctx, cpc, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_channel(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options))",
"def do_hostinfo(self, args):\n host = opts = None\n if args:\n args = args.split()\n host = args.pop()\n\n if not host:\n print('Usag... | [
"0.6095599",
"0.59995025",
"0.5967684",
"0.58918285",
"0.5879187",
"0.58760214",
"0.58532023",
"0.58369166",
"0.58359265",
"0.5832341",
"0.58278644",
"0.58267254",
"0.582368",
"0.57165456",
"0.5707957",
"0.56925315",
"0.5681756",
"0.5681756",
"0.5672487",
"0.5671114",
"0.5671... | 0.60818744 | 1 |
Report usage metrics for active adapters of CPCs in DPM mode. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_adapter(cmd_ctx, cpc, adapter, **options):
cmd_ctx.execute_cmd(
lambda: cmd_metrics_adapter(cmd_ctx, cpc, adapter, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_channel(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options))",
"def metrics_proc(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_proc(cmd_ctx, cpc, options))",
"def metrics_networkport(cmd_ctx, cpc, adapter, **options):\n c... | [
"0.6317614",
"0.59251046",
"0.58999896",
"0.58430314",
"0.57148993",
"0.56526655",
"0.547031",
"0.53368515",
"0.5278745",
"0.52745694",
"0.52628577",
"0.51370335",
"0.5132186",
"0.51290196",
"0.512005",
"0.5110605",
"0.51074606",
"0.5080317",
"0.5074927",
"0.50636065",
"0.504... | 0.643978 | 0 |
Report usage metrics for all channels of CPCs in classic mode. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_channel(cmd_ctx, cpc, **options):
cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stats(caesar, input):\n commands = {}\n users = {}\n channels = {}\n\n ignore = set(['f_note', 'startup', 'message', 'noteuri'])\n for (name, user), count in caesar.stats.items(): \n if name in ignore: continue\n if not user: continue\n\n if not user.startswith('#'): \n try: us... | [
"0.59195566",
"0.5586245",
"0.5444794",
"0.54191935",
"0.53922415",
"0.5380868",
"0.53543603",
"0.52876854",
"0.52462244",
"0.51891714",
"0.5112807",
"0.51073605",
"0.50244516",
"0.49929634",
"0.49870348",
"0.4977524",
"0.49535966",
"0.4952735",
"0.4930333",
"0.4928074",
"0.4... | 0.6753259 | 0 |
Report environmental and power consumption metrics for CPCs. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_env(cmd_ctx, cpc, **options):
cmd_ctx.execute_cmd(lambda: cmd_metrics_env(cmd_ctx, cpc, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_cpc(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_cpc(cmd_ctx, cpc, options))",
"def metrics_channel(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options))",
"def metrics_proc(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd... | [
"0.629929",
"0.6273303",
"0.60736",
"0.5926187",
"0.5641638",
"0.55025315",
"0.5396064",
"0.53120846",
"0.52493966",
"0.5243705",
"0.523837",
"0.5222159",
"0.51953936",
"0.519269",
"0.5182496",
"0.5178438",
"0.51700777",
"0.5129585",
"0.51175195",
"0.51148605",
"0.51081395",
... | 0.649805 | 0 |
Report processor usage metrics for CPCs. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_proc(cmd_ctx, cpc, **options):
cmd_ctx.execute_cmd(lambda: cmd_metrics_proc(cmd_ctx, cpc, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_cpc(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_cpc(cmd_ctx, cpc, options))",
"def metrics_channel(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options))",
"def metrics_crypto(cmd_ctx, cpc, **options):\n cmd_ctx.execute_c... | [
"0.65378803",
"0.627548",
"0.6020114",
"0.5702169",
"0.56018233",
"0.55116755",
"0.55000883",
"0.5320139",
"0.5315897",
"0.5299815",
"0.52958316",
"0.5274619",
"0.52392995",
"0.52203125",
"0.52038133",
"0.5199431",
"0.5187151",
"0.5178949",
"0.5170392",
"0.5164013",
"0.510556... | 0.66221523 | 0 |
Report usage metrics for all active Crypto Express adapters of CPCs. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_crypto(cmd_ctx, cpc, **options):
cmd_ctx.execute_cmd(lambda: cmd_metrics_crypto(cmd_ctx, cpc, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_channel(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options))",
"def metrics_adapter(cmd_ctx, cpc, adapter, **options):\n cmd_ctx.execute_cmd(\n lambda: cmd_metrics_adapter(cmd_ctx, cpc, adapter, options))",
"def do_hostinfo(self, args):\n ... | [
"0.61710244",
"0.5943986",
"0.5742064",
"0.5595102",
"0.55200773",
"0.54445076",
"0.5411969",
"0.53798133",
"0.5354008",
"0.535235",
"0.5349474",
"0.5332392",
"0.53124905",
"0.5226011",
"0.51669437",
"0.51390135",
"0.5104674",
"0.5103828",
"0.50836706",
"0.5078611",
"0.507831... | 0.6303562 | 0 |
Report usage metrics for the ports of network adapters of CPCs in DPM mode. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_networkport(cmd_ctx, cpc, adapter, **options):
cmd_ctx.execute_cmd(
lambda: cmd_metrics_networkport(cmd_ctx, cpc, adapter, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_channel(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_channel(cmd_ctx, cpc, options))",
"def metrics_adapter(cmd_ctx, cpc, adapter, **options):\n cmd_ctx.execute_cmd(\n lambda: cmd_metrics_adapter(cmd_ctx, cpc, adapter, options))",
"def do_hostinfo(self, args):\n ... | [
"0.6124976",
"0.59950477",
"0.5756093",
"0.5687688",
"0.55233353",
"0.5309227",
"0.52750784",
"0.5252932",
"0.5208929",
"0.5170246",
"0.5106128",
"0.50764817",
"0.50519806",
"0.50233275",
"0.5003854",
"0.4984393",
"0.4930946",
"0.49051604",
"0.49042228",
"0.49029616",
"0.4877... | 0.70290184 | 0 |
Report usage metrics for the NICs of partitions of CPCs in DPM mode. In addition to the commandspecific options shown in this help text, the general options (see 'zhmc help') can also be specified right after the 'zhmc' command name. | def metrics_nic(cmd_ctx, cpc, partition, nic, **options):
cmd_ctx.execute_cmd(
lambda: cmd_metrics_nic(cmd_ctx, cpc, partition, nic, options)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metrics_cpc(cmd_ctx, cpc, **options):\n cmd_ctx.execute_cmd(lambda: cmd_metrics_cpc(cmd_ctx, cpc, options))",
"def metrics_networkport(cmd_ctx, cpc, adapter, **options):\n cmd_ctx.execute_cmd(\n lambda: cmd_metrics_networkport(cmd_ctx, cpc, adapter, options))",
"def metrics_channel(cmd_ctx, cp... | [
"0.6029862",
"0.59694433",
"0.593867",
"0.5872437",
"0.57943094",
"0.56738853",
"0.5640134",
"0.5486397",
"0.5422634",
"0.53095937",
"0.5250618",
"0.5230403",
"0.510633",
"0.5087089",
"0.50808835",
"0.5045866",
"0.49836123",
"0.4982057",
"0.49766484",
"0.4954867",
"0.49396986... | 0.6058172 | 0 |
Computes the Modulation SpectrumBased ECG Quality Index (MSQI) for one or many ECG signals defined in x, sampled with a sampling frequency fs | def msqi_ama(x, fs):
# test ecg shape
try:
x.shape[1]
except IndexError:
x = x[:, np.newaxis]
# Empirical values for the STFFT transformation
win_size_sec = 0.125 #seconds
win_over_sec = 0.09375 #seconds
nfft_factor_1 = 16
nfft_factor_2 = 4
win_size_smp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_optimal_Q(x, y, data, min_Q, max_Q, fs=1., added_kernel = None, plot_BIC=True):\n Qs= np.arange(min_Q, max_Q)\n BIC = np.zeros((Qs.shape[0]))\n \n for i, q in enumerate(Qs):\n sm = SpectralMixture(q, x=x.flatten(),y=y.flatten(),fs=fs)\n for k in sm.kernels:\n ... | [
"0.5476735",
"0.5465266",
"0.5431895",
"0.5348803",
"0.5319814",
"0.5249597",
"0.5233212",
"0.52282983",
"0.51446587",
"0.51347893",
"0.51147515",
"0.5109146",
"0.50809836",
"0.50781864",
"0.5074541",
"0.50507593",
"0.5049618",
"0.5042971",
"0.50428605",
"0.5027192",
"0.50248... | 0.64019674 | 0 |
Load the image on initial load of the application | def OnInit(self):
self.imageID = self.loadImage() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnInit( self ):\n self.imageID = self.loadImage ()",
"def load_image(self, **kwargs):\n ...",
"def load_image(self):\n # Minimal progress display while image is loaded.\n group = displayio.Group()\n group.append(centered_label('LOADING...', 40, 3))\n #self.rect = R... | [
"0.7676823",
"0.72862685",
"0.6990877",
"0.69560045",
"0.69560045",
"0.69560045",
"0.6736933",
"0.66402304",
"0.6628148",
"0.65887284",
"0.65709776",
"0.6562708",
"0.6558569",
"0.6513278",
"0.64529467",
"0.6451759",
"0.6443347",
"0.64257944",
"0.64138216",
"0.6399771",
"0.637... | 0.77568126 | 0 |
Draw a cube with texture coordinates | def drawCube(self):
glBegin(GL_QUADS);
glTexCoord2f(0.0, 0.0);
glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 0.0);
glVertex3f(1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0);
glVertex3f(1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0);
glVertex3f(-1.0, 1.0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def drawCube( self ):\n glBegin(GL_QUADS);\n glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);\n glTexCoord2f(1.0, 0.0); glVertex3f( 1.0, -1.0, 1.0);\n glTexCoord2f(1.0, 1.0); glVertex3f( 1.0, 1.0, 1.0);\n glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);\n glTe... | [
"0.8082414",
"0.790963",
"0.73804325",
"0.7115595",
"0.7054056",
"0.70481575",
"0.6607423",
"0.6532412",
"0.64749116",
"0.6449474",
"0.6229988",
"0.6222093",
"0.6187685",
"0.61688286",
"0.6162942",
"0.6152132",
"0.6028768",
"0.59879607",
"0.5984257",
"0.59456533",
"0.5933637"... | 0.80746436 | 1 |
Adds a message to the chat and scrolls down. | def add_message_to_chat(self, message: str):
scroll_length = (len(message) // Client.TEXTBOX_CHARACTER_LENGTH) + 1
self.chat_text.config(state=NORMAL)
self.chat_text.insert(END, message + '\n')
self.chat_text.yview_scroll(scroll_length, "units")
self.chat_text.config(state=DISAB... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_add_chat_message(self, chat_message):\n self.chat_messages.append(chat_message)\n\n #logging.info(\"adding message: %s\" % chat_message.message)\n\n if len(self.chat_messages) > ENVIRONMENT['BUFFER_SIZE']:\n self.chat_messages.pop(0)\n\n # alert our polling clients\n... | [
"0.6858262",
"0.68089944",
"0.6778456",
"0.67170316",
"0.66270477",
"0.65076065",
"0.6480786",
"0.6332747",
"0.6320004",
"0.6282979",
"0.6253987",
"0.6231954",
"0.6195",
"0.6192585",
"0.61682373",
"0.61682373",
"0.6153406",
"0.61134017",
"0.6108938",
"0.60916406",
"0.60653615... | 0.799143 | 0 |
Creates a data folder containing a 100class subset of ImageNet, then creates a zipped copy of it | def zip_imagenet100c():
#First make sure the directory we are given is correct!
if not os.path.isdir(DATA_SRC_ROOT):
raise Exception("Bad filepath given")
#create the destiantion directories if they don't exist
if not os.path.isdir(IMAGENET100_DIR):
os.mkdir(IMAGENET100_DIR)
#grab ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(data_folder: str, dataset_file: str, targets_file: str = os.path.join('data', 'targets.pkl')):\n files = sorted(glob.glob(os.path.join(data_folder, '**/*.jpg'), recursive=True))\n images = []\n crop_sizes = []\n crop_centers = []\n targets = []\n for image in tqdm(files, desc='... | [
"0.6529704",
"0.6481513",
"0.6435279",
"0.6418067",
"0.63397163",
"0.6227401",
"0.62035155",
"0.61983734",
"0.6165103",
"0.61225355",
"0.612228",
"0.60964",
"0.60848254",
"0.6073827",
"0.60563177",
"0.6047265",
"0.60234",
"0.6019958",
"0.60174394",
"0.6004536",
"0.5983722",
... | 0.7347322 | 0 |
Show the popup and return True if accepted, False if canceled. | def popup(self):
return self.exec_() == QDialog.Accepted | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_popup(self, type):",
"def _show_popup(self) -> None:\n\n top = tk.Toplevel()\n email_list_len = len(self.get_recipients())\n msg = tk.messagebox.askquestion('Confirm send emails', 'Are you sure you want to email {} client{}?'\n .format(email_... | [
"0.6642623",
"0.6464855",
"0.63802284",
"0.62683916",
"0.6240332",
"0.6218975",
"0.6172441",
"0.61592615",
"0.6059267",
"0.5996099",
"0.5937343",
"0.5933337",
"0.5915153",
"0.5883959",
"0.5883959",
"0.5883959",
"0.58716357",
"0.58673215",
"0.5851311",
"0.5851311",
"0.5847941"... | 0.79470927 | 0 |
Fill the heavy metal unit labels with the selected unit. | def set_hm_unit_display(self):
units = str(self.entries['units'].combobox.currentText())
self.ui.is_unitL1.setText(units)
self.ui.is_unitL2.setText(units)
self.ui.is_unitL3.setText(units)
self.ui.is_unitL4.setText(units) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_label(self, unit_label):\n\n self._unit_label = unit_label",
"def unit_label(self, unit_label):\n\n self._unit_label = unit_label",
"def unit_label(self, unit_label):\n\n self._unit_label = unit_label",
"def update_units(self):\n unit_var_value = self.view.vars['unit'].ge... | [
"0.65493584",
"0.65493584",
"0.65493584",
"0.61209",
"0.5876205",
"0.5848301",
"0.5719211",
"0.56192005",
"0.56159955",
"0.5609573",
"0.55953413",
"0.55090725",
"0.5500092",
"0.54777503",
"0.54361576",
"0.5392763",
"0.5386514",
"0.53529835",
"0.5319486",
"0.53029513",
"0.5297... | 0.6863121 | 0 |
Check if a task exists on the server | def exists(self, server):
try:
server.get(
'task',
replacements={
'slug': self.__challenge__.slug,
'identifier': self.identifier})
except Exception:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __check_if_task_exists(self, server_id):\n if server_id in self.__migrating_tasks.keys():\n return True\n return False",
"def exists_task(self, task):\n assert task, \"Must input a valid task name.\"\n return any(self.get_by_task(task))",
"def isTasksExists(request):... | [
"0.77683973",
"0.7662436",
"0.74845606",
"0.73977894",
"0.7334475",
"0.68549156",
"0.68336856",
"0.6772",
"0.67269367",
"0.6711562",
"0.67005736",
"0.6666161",
"0.6534565",
"0.64875007",
"0.6391127",
"0.6377171",
"0.6374866",
"0.63482434",
"0.63294256",
"0.6309257",
"0.629597... | 0.8097337 | 0 |
Find the pooled sample variance for two samples. | def pooled_sample_variance(sample1, sample2):
deg_freedom = len(sample1) + len(sample2) - 2
mean1 = statistics.mean(sample1)
squares1 = ((x - mean1) ** 2 for x in sample1)
mean2 = statistics.mean(sample2)
squares2 = ((x - mean2) ** 2 for x in sample2)
return (math.fsum(squares1) + math.fsum(squ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variance(self):\r\n\t\t_mean = sum(self.sample)/len(self.sample)\r\n\t\treturn sum(map(lambda x: (x - _mean)**2, self.sample))/(len(self.sample) - 1)",
"def variance( values, sample=False ):\n mean_val = mean_value( values )\n n_val = len( values ) -1 if sample else len( values )\n return sum( [ j**... | [
"0.69535667",
"0.68496686",
"0.67732096",
"0.6738547",
"0.67180645",
"0.65582496",
"0.6516183",
"0.64949",
"0.6486372",
"0.6415831",
"0.6393349",
"0.639173",
"0.63470465",
"0.63140863",
"0.6311792",
"0.6310086",
"0.6282926",
"0.62156796",
"0.62076354",
"0.61959153",
"0.604445... | 0.80888563 | 0 |
Calculate a ttest score for the difference between two samples. | def tscore(sample1, sample2):
if len(sample1) != len(sample2):
raise ValueError("different number of values")
error = pooled_sample_variance(sample1, sample2) / len(sample1)
diff = statistics.mean(sample1) - statistics.mean(sample2)
return diff / math.sqrt(error * 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ttest(array1, array2):\n diff = np.mean(array1) - np.mean(array2)\n if diff < c.cart_p60:\n return c.low_score\n if array1.size <= 1 or array2.size <= 1:\n return min(diff, c.single_item_cart_max)\n return 1 - ttest_ind(array1, array2, equal_var=False).pvalue\n # return diff",
"d... | [
"0.75622785",
"0.6732271",
"0.67147094",
"0.67101526",
"0.66661763",
"0.64419353",
"0.6416758",
"0.64082766",
"0.63968855",
"0.6324951",
"0.6282402",
"0.6253952",
"0.6186208",
"0.61227715",
"0.6105249",
"0.60951906",
"0.5997991",
"0.59836954",
"0.59664416",
"0.5946647",
"0.59... | 0.7724763 | 0 |
return autsizeable field names in idfobject | def autosize_fieldname(idfobject):
# undocumented stuff in this code
return [
fname
for (fname, dct) in zip(idfobject.objls, idfobject["objidd"])
if "autosizable" in dct
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field_names(self):\n ...",
"def objectFields(self):\n raise NotImplementedError",
"def fields(self):",
"def _fields_names(cls) -> List:\n return list(field.name for field in dataclasses.fields(cls))",
"def fields(self):\n ...",
"def get_field_names(self):\n return {rv[0... | [
"0.7096624",
"0.7052038",
"0.68935066",
"0.66643006",
"0.6553258",
"0.6494789",
"0.6485936",
"0.6427995",
"0.64223516",
"0.63584894",
"0.6328418",
"0.63140696",
"0.62944096",
"0.62799215",
"0.6263371",
"0.62606794",
"0.6165774",
"0.6162808",
"0.61518234",
"0.611477",
"0.61031... | 0.765945 | 0 |
Checks whether the given ISBN10 code is valid. >>> isISBN10('9971502100') True >>> isISBN10('9971502108') False | def isISBN10(code):
# helper function for computing ISBN-10 check digit
def check_digit(code):
# compute check digit
check = sum((i + 1) * int(code[i]) for i in range(9)) % 11
# convert check digit into its string representation
return 'X' if check == 10 else str(check)
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isISBN(code):\n if not (\n isinstance(code, str) and # code must be a string\n len(code) == 10 and # code must contain 10 characters\n code[:9].isdigit() # first nine characters must be digits\n ):\n return False\n\n # check the check digit\n return check... | [
"0.82796675",
"0.8265154",
"0.7875872",
"0.76414096",
"0.7556362",
"0.734542",
"0.73319346",
"0.72045577",
"0.7138764",
"0.7138109",
"0.704493",
"0.64504737",
"0.6407236",
"0.6328351",
"0.63012135",
"0.6227752",
"0.6151876",
"0.60880727",
"0.60821617",
"0.60790056",
"0.601290... | 0.8820598 | 0 |
Checks whether the given ISBN13 code is valid. >>> isISBN13('9789743159664') True >>> isISBN13('9787954527409') False >>> isISBN13('8799743159665') False | def isISBN13(code):
# helper function for computing ISBN-10 check digit
def check_digit(code):
# compute check digit
check = sum((3 if i % 2 else 1) * int(code[i]) for i in range(12))
# convert check digit into a single digit
return str((10 - check) % 10)
# check whether ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_isbn_13(isbn13):\r\n isbn13 = re.sub(r'[^0-9X]', '', isbn13.replace('x', 'X'))\r\n if len(isbn13) != 13: return False\r\n if isbn13[0:3] not in ('978', '979'): return False\r\n return False if isbn_13_check_digit(isbn13[:-1]) != isbn13[-1] else True",
"def isISBN(code, isbn13=True):\n\n ret... | [
"0.8294502",
"0.8156061",
"0.7813687",
"0.7593365",
"0.7539352",
"0.7096975",
"0.70109516",
"0.6998053",
"0.6760535",
"0.6702344",
"0.6442007",
"0.64231825",
"0.6403078",
"0.6313602",
"0.6305555",
"0.6260889",
"0.6107894",
"0.5969835",
"0.5896946",
"0.57390374",
"0.56742215",... | 0.86895674 | 0 |
>>> codes = ['0012345678', '0012345679', '9971502100', '080442957X', 5, True, 'The Practice of Computing Using Python', '9789027439642', '5486948320146'] >>> areISBN(codes) [False, True, True, True, False, False, False, True, False] >>> areISBN(codes, True) [False, False, False, False, False, False, False, True, False]... | def areISBN(codes, isbn13=None):
# initialize list of checks
checks = []
# construct list of checks
for code in codes:
if isinstance(code, str):
if isbn13 is None:
checks.append(isISBN(code, len(code) == 13))
else:
checks.append(isISBN(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_isbn(val):\n if is_isbn10(val) or is_isbn13(val):\n if val[0:3] in [\"978\", \"979\"] or not is_ean13(val):\n return True\n return False",
"def isISBN(code, isbn13=True):\n\n return isISBN13(code) if isbn13 else isISBN10(code)",
"def isISBN(code):\n if not (\n isinst... | [
"0.74519074",
"0.72815156",
"0.7090671",
"0.65742284",
"0.65578085",
"0.6463269",
"0.63166803",
"0.6275632",
"0.6265059",
"0.62025166",
"0.6028817",
"0.59755796",
"0.58285195",
"0.5798127",
"0.5781443",
"0.5775947",
"0.570381",
"0.563113",
"0.5504642",
"0.54982454",
"0.548243... | 0.8204821 | 0 |
Calculates a two's complement integer from the given input value's bits | def twos_complement(input_value, num_bits=16):
mask = 2 ** (num_bits - 1)
return -(input_value & mask) + (input_value & ~mask) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def twos_complement(n, bits):\n if n < 0 or n >= 2**bits:\n raise ValueError\n\n return 2**bits - n",
"def twos_complement(val, bits):\n if (val & (1 << (bits - 1))) != 0: # if sign bit is set e.g., 8bit: 128-255\n val = val - (1 << bits) # compute negative value\n return val ... | [
"0.773702",
"0.7683835",
"0.76752746",
"0.7462103",
"0.74167454",
"0.7336416",
"0.70802414",
"0.70657045",
"0.70034766",
"0.6954941",
"0.69006544",
"0.68687546",
"0.676691",
"0.67314565",
"0.67230797",
"0.67230797",
"0.67230797",
"0.6720881",
"0.6720881",
"0.6685405",
"0.6657... | 0.79249084 | 0 |
Transfer models to target port | def transfer(self, target_port: Port, evaluator: Evaluator, config_uids: List[int] = None) -> None:
if target_port.name not in self.transfer_defs:
print(f"No transfer definition found for target port '{target_port.name}'")
return
# transfer definitions for specified target port
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deploy_to_device(self):\n if self.device_ids is not None and len(self.device_ids) > 1:\n if not isinstance(self.model, torch.nn.DataParallel):\n self.model = torch.nn.DataParallel(self.model, self.device_ids)\n\n self.model = self.model.to(self.device)\n self.crit... | [
"0.60630095",
"0.60588175",
"0.57406735",
"0.56002295",
"0.551898",
"0.55181533",
"0.5453672",
"0.5411719",
"0.5400127",
"0.53960764",
"0.538731",
"0.53615785",
"0.53615785",
"0.5356729",
"0.53435755",
"0.5335418",
"0.5325586",
"0.5305902",
"0.52706647",
"0.52651966",
"0.5254... | 0.6467971 | 0 |
Generate TransferDefinitions based on transferconfig.json, containing those ports that have a base training for transferring to another port | def _generate_transfers(self) -> Dict[str, List[TransferDefinition]]:
config = read_json(self.config_path)
transfer_defs = {}
ports = list(config["ports"])
permutations = list(itertools.permutations(ports, r=2))
# for pair in _permute(config["ports"]):
for pair in permut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transfer(self, target_port: Port, evaluator: Evaluator, config_uids: List[int] = None) -> None:\n if target_port.name not in self.transfer_defs:\n print(f\"No transfer definition found for target port '{target_port.name}'\")\n return\n # transfer definitions for specified ta... | [
"0.6021851",
"0.5251869",
"0.51448715",
"0.5136205",
"0.5126871",
"0.5095791",
"0.50636524",
"0.49946162",
"0.49695787",
"0.49350056",
"0.49320048",
"0.49314785",
"0.4922587",
"0.48967493",
"0.48889312",
"0.4869051",
"0.48633268",
"0.4862456",
"0.4857697",
"0.484664",
"0.4846... | 0.8338399 | 0 |
Compares each curve with the next to verify continuity. Note that this function treats curves as directed, thus two curves that start at the same point will return `False` when compared. | def assert_continuous(*curves: CubicBezierCurve) -> bool:
if not curves:
raise ValueError("CurveChecker.assert_continuous() cannot be called on an empty list")
previous_curve = curves[0]
for curve in curves[1:]:
if previous_curve.p1 != curve.p0:
return False
previous_cur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_differentiable(*curves: CubicBezierCurve) -> bool:\n if not curves:\n raise ValueError(\"CurveChecker.assert_differentiable() cannot be called on an empty list\")\n\n if not assert_continuous(*curves):\n return False\n\n for curve0, curve1 in zip(curves, curves[1:]):\n if n... | [
"0.6867624",
"0.65761954",
"0.60859615",
"0.60859615",
"0.6069512",
"0.5920149",
"0.5899444",
"0.58113146",
"0.5743151",
"0.5739253",
"0.5737969",
"0.57277334",
"0.5719145",
"0.570918",
"0.5702754",
"0.5661689",
"0.5660275",
"0.5631335",
"0.5627203",
"0.5584733",
"0.55798703"... | 0.67138547 | 1 |
Verifies that the adjacent slopes between points are within specified tolerance of one another. Note that assert_collinear assumes ordered points; three actually collinear points passed with the middle point as the first or last argument will return `False` | def assert_collinear(*points: Point, tolerance: float = 1e-2) -> bool:
if len(points) < 3:
raise ValueError("CurveChecker.assert_collinear() must be called with at least three points")
thetas = [np.arctan2(p0[1] - p1[1], p0[0] - p1[0]) for p0, p1 in zip(points, points[1:])]
for t0, t1 in zip(thetas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isCollinear(a,b,c):\r\n #return slope(a, b) == slope(b, c) == slope(c, a) #DOES NOT WORK\r\n #return (b[0] - a[0]) * (c[1] - a[1]) == (c[0] - a[0]) * (b[1] - a[1]) \r\n #return distance(a,b) + distance(b,c) == distance(a,c)\r\n x1 = a[0]\r\n y1 = a[1]\r\n x2 = b[0]\r\n y2 = b[1]\r\n x3 ... | [
"0.70717025",
"0.6318565",
"0.6101531",
"0.60696363",
"0.605181",
"0.59607244",
"0.5879398",
"0.5877427",
"0.5806856",
"0.57670236",
"0.5622218",
"0.5608094",
"0.5563991",
"0.55154955",
"0.5489862",
"0.54876494",
"0.54695606",
"0.5420858",
"0.5409832",
"0.5381098",
"0.5375114... | 0.80137265 | 0 |
Verifies differentiability of curves by checking collinearity of adjacent curves' control points | def assert_differentiable(*curves: CubicBezierCurve) -> bool:
if not curves:
raise ValueError("CurveChecker.assert_differentiable() cannot be called on an empty list")
if not assert_continuous(*curves):
return False
for curve0, curve1 in zip(curves, curves[1:]):
if not assert_colli... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isCollinear(a,b,c):\r\n #return slope(a, b) == slope(b, c) == slope(c, a) #DOES NOT WORK\r\n #return (b[0] - a[0]) * (c[1] - a[1]) == (c[0] - a[0]) * (b[1] - a[1]) \r\n #return distance(a,b) + distance(b,c) == distance(a,c)\r\n x1 = a[0]\r\n y1 = a[1]\r\n x2 = b[0]\r\n y2 = b[1]\r\n x3 ... | [
"0.6670978",
"0.6513759",
"0.6198429",
"0.6138979",
"0.61240935",
"0.61158717",
"0.60906714",
"0.6050059",
"0.6006302",
"0.59238374",
"0.5918185",
"0.59094197",
"0.58958864",
"0.5882234",
"0.5876733",
"0.5855049",
"0.579847",
"0.579847",
"0.577797",
"0.57669806",
"0.5764593",... | 0.68860763 | 0 |
Converts a path to a string representation for inclusion in an SVG file as | def path_to_string(path: Path) -> str:
assert_continuous(path)
pieces = ["M {} {}".format(path[0].p0[0], path[0].p0[1])]
for curve in iter(path): # iter cast not strictly necessary
piece = "C {} {} {} {} {} {}".format(
int(round(curve.c0[0])), int(round(curve.c0[1])),
int(r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_string(path: pathlib.Path) -> str:\n return path.as_posix()",
"def path_to_str(path):\n if hasattr(path, '__fspath__'):\n path = as_str_any(path.__fspath__())\n return path",
"def save_svg(string, file_name):\n file_handle = file(file_name, \"w\")\n file_handle.write(string)\n ... | [
"0.664361",
"0.6505727",
"0.6453225",
"0.6349524",
"0.631118",
"0.62037516",
"0.6048819",
"0.6006023",
"0.5888196",
"0.5883319",
"0.5875403",
"0.5838811",
"0.578169",
"0.57720757",
"0.57636064",
"0.5753614",
"0.5715025",
"0.57089794",
"0.569792",
"0.5695481",
"0.56592214",
... | 0.6743669 | 0 |
Tests the TurbiniaSetup method. | def testTurbiniaSetup(self, _mock_read_config):
_mock_read_config.return_value = {"OUTPUT_DIR": "/tmp"}
self.turbinia_processor.TurbiniaSetUp(
project="turbinia-project",
turbinia_auth=False,
turbinia_recipe=None,
turbinia_zone="us-central1f",
turbinia_api="http://localho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup():\n pass",
"def TurbiniaSetUp(\n self, project: str, turbinia_auth: bool,\n turbinia_recipe: Union[str, None], turbinia_zone: str, turbinia_api: str,\n incident_id: str, sketch_id: int) -> None:\n self.project = project\n self.turbinia_auth = turbinia_auth\n self.turbinia_ap... | [
"0.6720269",
"0.65703833",
"0.6467602",
"0.6449046",
"0.6447386",
"0.64372605",
"0.64077723",
"0.6403362",
"0.63865745",
"0.635866",
"0.6345223",
"0.63323843",
"0.63103575",
"0.6282889",
"0.6277148",
"0.62679124",
"0.62679124",
"0.62679124",
"0.62679124",
"0.62679124",
"0.626... | 0.77893466 | 0 |
Tests the _isInterestingPath method. | def testIsInterestingPath(self):
# pylint: disable=protected-access
self.assertTrue(self.turbinia_processor._isInterestingPath(TEST_TASK_PATH)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _isInterestingPath(self, path: str) -> bool:\n for suffix in self.extensions:\n if path.endswith(suffix):\n return True\n return False",
"def test_find_path_bi():\n assert True",
"def is_path(self, s):\n return True",
"def _is_interesting_op(self, op):\n return op_priority(... | [
"0.72631514",
"0.58760685",
"0.58147526",
"0.56765735",
"0.55693245",
"0.55457276",
"0.54889286",
"0.5446209",
"0.53737456",
"0.53603786",
"0.53477657",
"0.5298553",
"0.5297065",
"0.5293575",
"0.5228027",
"0.5226015",
"0.519997",
"0.51928556",
"0.5165649",
"0.51393193",
"0.51... | 0.81139785 | 0 |
Tests the RefreshClientCredentials method. | def testRefreshClientCredentials(self,
mock_get_credentials, mock_initialize_client):
# Set an expired token.
self.turbinia_processor.credentials = mock.MagicMock(
expiry = FAKE_CREDENTIALS['expiry'], expired = True)
self.turbinia_processor.RefreshClientCredentials... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RefreshClientCredentials(self) -> bool:\n refresh = False\n if self.credentials and self.credentials.expired:\n self.credentials = self.GetCredentials(\n self.credentials_path, self.client_secrets_path)\n self.client = self.InitializeTurbiniaApiClient(self.credentials)\n refresh =... | [
"0.7480343",
"0.6987335",
"0.6519567",
"0.647827",
"0.64674634",
"0.6362675",
"0.6351274",
"0.6320688",
"0.6314245",
"0.6286668",
"0.6279366",
"0.6243212",
"0.6241278",
"0.6184748",
"0.6173102",
"0.61290675",
"0.6063998",
"0.6048179",
"0.60427195",
"0.6041711",
"0.6039306",
... | 0.791131 | 0 |
Tests the InitializeTurbiniaApiClient method. | def testInitializeTurbiniaApiClientNoCreds(self, mock_get_credentials):
self.turbinia_processor.turbinia_api = 'http://127.0.0.1:8000'
self.turbinia_processor.turbinia_auth = True
mock_credentials = mock.MagicMock(spec=Credentials, id_token = FAKE_CREDENTIALS['token'])
mock_credentials.id_token = mock.M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testInitializeTurbiniaApiClient(self, mock_get_credentials):\n self.turbinia_processor.turbinia_api = 'http://127.0.0.1:8000'\n self.turbinia_processor.turbinia_auth = True\n mock_credentials = mock.MagicMock(spec=Credentials, id_token = FAKE_CREDENTIALS['token'])\n mock_credentials.id_token = mock... | [
"0.763972",
"0.71817064",
"0.69348216",
"0.6902786",
"0.6898086",
"0.68290806",
"0.68290806",
"0.6813784",
"0.6806354",
"0.67816716",
"0.6775598",
"0.6775598",
"0.6775598",
"0.6712668",
"0.6631375",
"0.65852684",
"0.65815634",
"0.6529811",
"0.6472687",
"0.6472687",
"0.6472687... | 0.73480415 | 1 |
Tests the InitializeTurbiniaApiClient method. | def testInitializeTurbiniaApiClient(self, mock_get_credentials):
self.turbinia_processor.turbinia_api = 'http://127.0.0.1:8000'
self.turbinia_processor.turbinia_auth = True
mock_credentials = mock.MagicMock(spec=Credentials, id_token = FAKE_CREDENTIALS['token'])
mock_credentials.id_token = mock.MagicMoc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testInitializeTurbiniaApiClientNoCreds(self, mock_get_credentials):\n self.turbinia_processor.turbinia_api = 'http://127.0.0.1:8000'\n self.turbinia_processor.turbinia_auth = True\n mock_credentials = mock.MagicMock(spec=Credentials, id_token = FAKE_CREDENTIALS['token'])\n mock_credentials.id_token... | [
"0.73480415",
"0.71817064",
"0.69348216",
"0.6902786",
"0.6898086",
"0.68290806",
"0.68290806",
"0.6813784",
"0.6806354",
"0.67816716",
"0.6775598",
"0.6775598",
"0.6775598",
"0.6712668",
"0.6631375",
"0.65852684",
"0.65815634",
"0.6529811",
"0.6472687",
"0.6472687",
"0.64726... | 0.763972 | 0 |
Parse OpenSSLstyle foo.0, foo.1, ... subscripted options. Returns a list of values matching the specified option name. | def multiget(self, option, section = None):
matches = []
if section is None:
section = self.default_section
if self.cfg.has_option(section, option):
matches.append((-1, self.get(option, section = section)))
for key, value in self.cfg.items(section):
s = key.rsplit(".", 1)
if len... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_option(self, name):\r\n if not isinstance(name, str):\r\n name = \" \".join(name)\r\n lines = self.sendAndRecv(\"GETCONF %s\\r\\n\" % name)\r\n\r\n r = []\r\n for _,line,_ in lines:\r\n try:\r\n key, val = line.split(\"=\", 1)\r\n r.append((key,val))\r\n except Valu... | [
"0.5681802",
"0.5620391",
"0.5565046",
"0.541359",
"0.53751975",
"0.5340231",
"0.5283279",
"0.5276728",
"0.52554685",
"0.5251639",
"0.51984483",
"0.5196909",
"0.519201",
"0.5174309",
"0.5122386",
"0.51024044",
"0.51020473",
"0.5095427",
"0.5034037",
"0.5030856",
"0.50224656",... | 0.5834238 | 0 |
Get an integer option, perhaps with a default value. | def getint(self, option, default = None, section = None):
return int(self.get(option, default, section)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getint(self, option, default=None):\n\t\treturn self._get_raw(option, 'int', default)",
"def getint(self, option):\n return getint(self.name, option)",
"def getint(self, section, option, default=None):\r\n return self.get(section, option, type=int, default=default)",
"def getint(self, option, a... | [
"0.84793097",
"0.81527907",
"0.79768705",
"0.7929183",
"0.7760084",
"0.7490237",
"0.73363376",
"0.71646047",
"0.7082002",
"0.7010749",
"0.6840518",
"0.66669184",
"0.65775895",
"0.6542784",
"0.65416443",
"0.652801",
"0.63949615",
"0.6394363",
"0.63876903",
"0.633896",
"0.63153... | 0.8415297 | 1 |
Get a long integer option, perhaps with a default value. | def getlong(self, option, default = None, section = None):
return long(self.get(option, default, section)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getint(self, option, default = None, section = None):\n return int(self.get(option, default, section))",
"def getLong(self, int: int, int2: int) -> int:\n ...",
"def getLong(t, swipl):\n i = c_long()\n if swipl.PL_get_long(t, byref(i)):\n return i.value\n else:\n raise Inva... | [
"0.70192164",
"0.68363434",
"0.6702272",
"0.66861874",
"0.6630546",
"0.66111416",
"0.6431476",
"0.6385897",
"0.6310543",
"0.628531",
"0.6267423",
"0.62353796",
"0.6210837",
"0.61966425",
"0.6178884",
"0.6079542",
"0.60778195",
"0.60364276",
"0.59944767",
"0.59922874",
"0.5992... | 0.8568428 | 0 |
Consolidated control for all the little global control flags scattered through the libraries. This isn't a particularly good place for this function to live, but it has to live somewhere and making it a method of the config parser from which it gets all of its data is less silly than the available alternatives. | def set_global_flags(self):
import rpki.http, rpki.x509, rpki.sql, rpki.async, rpki.log
try:
rpki.http.debug_http = self.getboolean("debug_http")
except ConfigParser.NoOptionError:
pass
try:
rpki.http.want_persistent_client = self.getboolean("want_persistent_client")
except Conf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _GclStyleSettings(self):\n settings = {\n 'port': self.GetCodeReviewSetting('TRYSERVER_HTTP_PORT'),\n 'host': self.GetCodeReviewSetting('TRYSERVER_HTTP_HOST'),\n 'svn_repo': self.GetCodeReviewSetting('TRYSERVER_SVN_URL'),\n 'gerrit_url': self.GetCodeReviewSetting('TRYSERVER_GERRIT_URL'),... | [
"0.5948904",
"0.55440557",
"0.55275595",
"0.5320084",
"0.5296819",
"0.5249181",
"0.5204246",
"0.520022",
"0.51432735",
"0.5137308",
"0.5134827",
"0.5134588",
"0.5134572",
"0.5123408",
"0.50960565",
"0.5094958",
"0.50912803",
"0.50796866",
"0.50630355",
"0.50593835",
"0.505469... | 0.66763616 | 0 |
Checks for vertices' degrees >>> vertices_degree([[1, 0], [1, 1]], [[0, 1], [1, 0]]) (False, []) >>> vertices_degree([[1, 1], [0, 1]], [[1, 0], [1, 1]]) (True, [2, 1], [1, 2]) | def vertices_degree(graph1: list, graph2: list):
check1 = []
check2 = []
for row, _ in enumerate(graph1):
degree1 = 0
degree2 = 0
for column, _ in enumerate(graph1[row]):
if graph1[row][column] == 1:
degree1 += 1
if graph2[row][column] == 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _has_degree(\n self,\n degree: int,\n vertex: Vertex,\n ) -> bool:\n\n return vertex.get_id() in self._vertices_of_degree[degree]",
"def vertice_degree(self):\r\n if(self.is_empty()):\r\n raise ValueError(\"Graph is empty.\")\r\n else:\r\n if... | [
"0.70981395",
"0.6648923",
"0.66187066",
"0.6453982",
"0.6208992",
"0.6075277",
"0.6049173",
"0.6037286",
"0.59577584",
"0.5948439",
"0.59199977",
"0.5896408",
"0.58028036",
"0.580261",
"0.57468504",
"0.57298976",
"0.5702665",
"0.5702665",
"0.56859505",
"0.56500363",
"0.56339... | 0.6969743 | 1 |
r""" Wait for the user to type a character (and hit Enter). If the user enters one of the characters in letters, return that character. If the user hits Enter without entering a character, and default is specified, returns `default`, Otherwise, asks the user to enter a character again. | def _prompt(letters='yn', default=None):
import sys
while True:
try:
inputstr = sys.stdin.readline().strip()
except KeyboardInterrupt:
sys.exit(0)
if inputstr and inputstr in letters:
return inputstr
if default is not None and inputstr == '':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prompt(letters='yn', default=None):\n while True:\n try:\n input_text = sys.stdin.readline().strip()\n except KeyboardInterrupt:\n sys.exit(0)\n if input_text and input_text in letters:\n return input_text\n if default is not None and input_text ... | [
"0.7521456",
"0.7162696",
"0.7019684",
"0.6967578",
"0.6841188",
"0.67817444",
"0.6743779",
"0.66840625",
"0.66546315",
"0.65572464",
"0.6538709",
"0.64224786",
"0.636659",
"0.63616836",
"0.63427144",
"0.63147855",
"0.6242766",
"0.61260843",
"0.60846496",
"0.6079177",
"0.6052... | 0.750709 | 1 |
Function to remove test results and confirmations older than 10 blocks | async def cleanTestResults(CURRENT_HEIGHT):
LAST_GOOD_HEIGHT = int(CURRENT_HEIGHT) - 10
for testId in list(testResults):
if int(testId) <= LAST_GOOD_HEIGHT:
del testResults[testId]
for testId in list(testConfirmations):
if int(testId) <= LAST_GOOD_HEIGHT:
del te... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remaining_batch_tests(loaded_batch_tests):\n remaining_tests = batch_test_set - set(loaded_batch_tests)\n with open('remaining_tests.txt', mode='w') as outfile:\n for batch_test in remaining_tests:\n outfile.write(\"%s\\n\" % batch_test)",
"def clean_leftovers(tests):\n for test in... | [
"0.6036735",
"0.58126444",
"0.5707902",
"0.5680992",
"0.5655867",
"0.56548756",
"0.5543772",
"0.5505886",
"0.5502805",
"0.5481863",
"0.54809284",
"0.5464488",
"0.5420158",
"0.5416538",
"0.5402889",
"0.5371889",
"0.5359482",
"0.5342731",
"0.53407174",
"0.5334368",
"0.5320321",... | 0.73820996 | 0 |
Instance data use_wsdl if True try to construct XML Instance from information in WSDL. | def __init__(self, wsdl, service=None, port=None, tracefile=None,
typesmodule=None, nsdict=None, soapAction=None, ns=None, op_ns=None, use_wsdl=False):
if not hasattr(wsdl, 'targetNamespace'):
wsdl = wstools.WSDLTools.WSDLReader().loadFromURL(wsdl)
# for item in wsdl.ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_wsdl_objects(self):\r\n # This holds some optional options for the request..\r\n self.AddressValidationOptions = self.client.factory.create('AddressValidationOptions')\r\n \r\n # This is good to review if you'd like to see what the data structure\r\n ... | [
"0.5577236",
"0.5367035",
"0.5321477",
"0.5150564",
"0.50830454",
"0.5067312",
"0.4986971",
"0.49749762",
"0.4935389",
"0.48817945",
"0.4843432",
"0.48354465",
"0.48144224",
"0.47744632",
"0.47571477",
"0.47335753",
"0.47333562",
"0.47290888",
"0.47188824",
"0.46990353",
"0.4... | 0.54205626 | 1 |
Returns typecodes representing input and output messages, if request and/or response fails to be generated return None for either or both. callinfo WSDLTools.SOAPCallInfo instance describing an operation. | def _getTypeCodes(self, callinfo):
prefix = None
self._resetPrefixDict()
if callinfo.use == 'encoded':
prefix = self._getPrefix(callinfo.namespace)
try:
requestTC = self._getTypeCode(parameters=callinfo.getInParameters(), literal=(callinfo.use=='literal'))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetModelOutputInfo(self, request, context):\n context.set_code(grpc.StatusCode.UNIMPLEMENTED)\n context.set_details('Method not implemented!')\n raise NotImplementedError('Method not implemented!')",
"def verify_call(obj):\n\tassert obj.tag == 'OMOBJ'\n\tattr = obj[0]\n\t\n\tassert attr.tag == 'OMAT... | [
"0.5174658",
"0.5018817",
"0.4834404",
"0.47635424",
"0.4631196",
"0.46073565",
"0.45646647",
"0.45536888",
"0.4535534",
"0.45211482",
"0.44949257",
"0.4465704",
"0.44512537",
"0.4426451",
"0.44040138",
"0.44033703",
"0.43914264",
"0.43877032",
"0.4385859",
"0.43828747",
"0.4... | 0.73895764 | 0 |
namespaces typecodes representing global elements with literal encoding. typeCode typecode representing an element. namespaceURI namespace literal True/False | def _globalElement(self, typeCode, namespaceURI, literal):
if literal:
typeCode.oname = '%(prefix)s:%(name)s xmlns:%(prefix)s="%(namespaceURI)s"' \
%{'prefix':self._getPrefix(namespaceURI), 'name':typeCode.oname, 'namespaceURI':namespaceURI} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def XmlTypeNamespace(self) -> str:",
"def is_namespace_type(self):\n raise exceptions.NotImplementedError()",
"def GetNamespaces(self):\n return list(self.type_namespaces_map.values())",
"def element_type(self) -> global___Type:",
"def patch_well_known_namespaces(etree_module):\n etree_module.... | [
"0.66442066",
"0.5593534",
"0.5443724",
"0.5412149",
"0.5365882",
"0.5329653",
"0.5311929",
"0.5237586",
"0.5178215",
"0.5165827",
"0.5055696",
"0.5044016",
"0.5007665",
"0.4926739",
"0.48959085",
"0.48641986",
"0.48631665",
"0.4855509",
"0.48434836",
"0.48183277",
"0.4792356... | 0.6797826 | 0 |
Retrieves a prefix/namespace mapping. namespaceURI namespace | def _getPrefix(self, namespaceURI):
prefixDict = self._getPrefixDict()
if prefixDict.has_key(namespaceURI):
prefix = prefixDict[namespaceURI]
else:
prefix = 'ns1'
while prefix in prefixDict.values():
prefix = 'ns%d' %int(prefix[-1]) + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefix_to_ns(self, prefix):\n defin = self.module.i_ctx.get_module(\n self.module.i_prefixes[prefix][0])\n return defin.search_one(\"namespace\").arg",
"def get_namespace(self, prefix):\n try:\n return self.parser.namespaces[prefix]\n except KeyError as err:\... | [
"0.74894905",
"0.723001",
"0.7178781",
"0.7092518",
"0.7036941",
"0.6799343",
"0.67157125",
"0.67054284",
"0.66477394",
"0.6579663",
"0.64730036",
"0.646861",
"0.6420464",
"0.64164484",
"0.64045894",
"0.63432497",
"0.63370234",
"0.63120365",
"0.63070714",
"0.62537974",
"0.623... | 0.78372264 | 0 |
Clears the prefix dictionary, this needs to be done before creating a new typecode for a message (ie. before, and after creating a new message typecode) | def _resetPrefixDict(self):
self._getPrefixDict().clear() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.footnotes = OrderedDict()\n self.unique_prefix += 1",
"def remove_prefix(self, state_dict, prefix):\n print('remove prefix \\'{}\\''.format(prefix))\n f = lambda x: x.split(prefix, 1)[-1] if x.startswith(prefix) else x # 去除带有prefix的名字\n return {f(key): ... | [
"0.661214",
"0.6500577",
"0.6333235",
"0.60439557",
"0.6028406",
"0.60041296",
"0.5998321",
"0.59930265",
"0.59643847",
"0.59600914",
"0.59294903",
"0.5922057",
"0.5883665",
"0.5853302",
"0.58453923",
"0.5836675",
"0.5826535",
"0.5804847",
"0.5762894",
"0.5750483",
"0.5747566... | 0.8281239 | 0 |
Returns a typecode instance representing the passed in element. element XMLSchema.ElementDeclaration instance literal literal encoding? local is locally defined? namespaceURI namespace | def _getElement(self, element, literal=False, local=False, namespaceURI=None):
if not element.isElement():
raise TypeError, 'Expecting an ElementDeclaration'
tc = None
elementName = element.getAttribute('name')
tp = element.getTypeDefinition('type')
typeObj ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_type(self) -> global___Type:",
"def create_class_instance(element, element_id, doc_id):\n xsi_type = get_xsi_type(element)\n element_class = XSI_TYPE_CLASSES[xsi_type]\n return element_class.from_etree(element)",
"def element_type(self):\r\n result = conf.lib.clang_getElementType(se... | [
"0.6112495",
"0.5760717",
"0.54377365",
"0.5435102",
"0.54039854",
"0.5333338",
"0.5304633",
"0.5193657",
"0.51740164",
"0.51256275",
"0.51102036",
"0.50124407",
"0.5008194",
"0.4974934",
"0.49698183",
"0.49652553",
"0.49299234",
"0.4924845",
"0.49117178",
"0.48976466",
"0.48... | 0.6733242 | 0 |
Returns a typecode class representing the type we are looking for. localName name of the type we are looking for. namespaceURI defining XMLSchema targetNamespace. | def _getTypeClass(self, namespaceURI, localName):
bti = BaseTypeInterpreter()
simpleTypeClass = bti.get_typeclass(localName, namespaceURI)
return simpleTypeClass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_class(self, class_name: str) -> Type:\n return self.class_resolver.find_class(class_name)",
"def find_class(self, class_name: str) -> Type:\n pass",
"def get_class(self, class_name, output_type=\"PythonClass\"):\n uris = self.cls_converter.get_uri(class_name)\n if type(uri... | [
"0.6334454",
"0.63214386",
"0.621163",
"0.60691124",
"0.5908769",
"0.58564675",
"0.5796145",
"0.5774467",
"0.5729281",
"0.5662747",
"0.5652824",
"0.55890405",
"0.5530385",
"0.5529409",
"0.5522239",
"0.5496328",
"0.54915804",
"0.54823256",
"0.54342365",
"0.5419367",
"0.5410473... | 0.7862565 | 0 |
extracts the features used to calculate neural style cost gram_style_features a list of gram matrices calculated from the style layer outputs of the style image content_feature the content layer output of the content image | def generate_features(self):
content_input = self.content_image * 255
style_input = self.style_image * 255
preprocessed_content = tf.keras.applications.vgg19.preprocess_input(
content_input)
preprocessed_style = tf.keras.applications.vgg19.preprocess_input(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_style_image_features(image):\n ### START CODE HERE ###\n # preprocess the image using the given preprocessing function\n preprocessed_style_image = preprocess_image(image)\n\n # get the outputs from the inception model that you created using inception_model()\n outputs = inception(preprocessed_style_i... | [
"0.78582704",
"0.7087954",
"0.6903325",
"0.6433953",
"0.64332956",
"0.64121157",
"0.6316672",
"0.62753826",
"0.61490476",
"0.6146242",
"0.61101943",
"0.60842645",
"0.6055493",
"0.60267216",
"0.60207623",
"0.6020109",
"0.6018783",
"0.6010386",
"0.5994345",
"0.5985522",
"0.5985... | 0.78912055 | 0 |
Downsamples spike data to include only the top 1% of frames | def downsample_spikes(S, thres=150, verbose=1):
sum_S = np.sum(S, axis=0)
if verbose > 0:
print(
'Downsampling spike data to {} frames using threshold {}'
.format(np.sum(np.greater(sum_S, thres)), thres))
return S[:, np.greater(sum_S, thres)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _down_sample(self):\n self._subsamples = self._raw_data.samples[::self._down_sample_factor]\n # Neglects the redundant subsamples in the tails.\n if len(self._subsamples) >= self._number_of_subsamples:\n self._subsamples = self._subsamples[:self._number_of_subsamples]\n if not len(self._subsam... | [
"0.6455042",
"0.61035407",
"0.59346664",
"0.58270806",
"0.58128667",
"0.57843024",
"0.5715292",
"0.57149154",
"0.57001853",
"0.5676207",
"0.5668947",
"0.559317",
"0.5588073",
"0.5547957",
"0.5523909",
"0.5510277",
"0.5501954",
"0.54938704",
"0.54915655",
"0.5463476",
"0.54344... | 0.66121924 | 0 |
Downsamples fluorescence data to include approximately the top 1% of frames based on total increase in activity. Currently the threshold is set for 1000 neurons. Original code from | def downsample_fluorescence(F, thres=20, verbose=1):
diff_F = np.diff(F, axis=1)
sum_F = np.sum(diff_F, axis=0)
F = F[:,:-1]
if verbose > 0:
print(
'Downsampling fluorescence data to {} frames using threshold {}'
.format(np.sum(np.greater(sum_F, thres))))
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_overfitting(self):\n\n # Instance with minimun length should be the maximum length\n train_len = []\n [train_len.append(st['Nevents']) for st in self.stats]\n train_len = np.array(train_len)\n max_len = train_len[train_len != 0].min()\n\n # CROPS FEATURE SAMPLES\n ... | [
"0.61294377",
"0.58991325",
"0.5723101",
"0.56286037",
"0.557679",
"0.5432801",
"0.5261728",
"0.52388954",
"0.5201363",
"0.5196606",
"0.51883674",
"0.5182593",
"0.51802176",
"0.51758677",
"0.5150192",
"0.5148113",
"0.5143918",
"0.51152796",
"0.51152796",
"0.51152796",
"0.5087... | 0.66418946 | 0 |
Generates a balanced set of training examples from one or more datasets. | def generate_dataset(
datasets, networks, parents, mode='train', mean=None,
verbose=1, **params):
# Parameters
classes = params.setdefault('classes', [-1,0,1])
data_type = params.setdefault('data_type', 'spikes')
thres = params.setdefault('thres', 150.0)
target = params.setdefault('target',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_datasets(self):\n\n degrade_test = False\n if self._opts['degrade_step'] == 'test':\n degrade_test = True\n\n use_trainset_for_tests = UseTrainForTest.IDENTICAL # can be different in few shot workflow\n\n train_dataset, test_dataset = self._gen_datasets_with_options(self._opts['tr... | [
"0.6996355",
"0.66383696",
"0.6572915",
"0.6517153",
"0.64793134",
"0.64199245",
"0.64149666",
"0.63592505",
"0.63368434",
"0.63012886",
"0.6289509",
"0.62852",
"0.6267794",
"0.62432927",
"0.622932",
"0.62188154",
"0.62153995",
"0.62117213",
"0.6202799",
"0.6186463",
"0.61816... | 0.68757796 | 1 |
Submit a metric as a rate, additional tags provided will be added to the ones from the label provided via the metrics object. | def _submit_rate(self, metric_name, val, metric, custom_tags=None, hostname=None):
_tags = self._metric_tags(metric_name, val, metric, custom_tags, hostname)
self.check.rate('{}.{}'.format(self.NAMESPACE, metric_name), val, _tags, hostname=hostname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def submit_metric(self, metric_suffix, metric, scraper_config, gauge=True, monotonic_count=True):\n metric_name = scraper_config['namespace'] + metric_suffix\n for sample in metric.samples:\n # Explicit shallow copy of the instance tags\n _tags = list(scraper_config['custom_tags... | [
"0.65285105",
"0.58314323",
"0.57720864",
"0.55562365",
"0.5346391",
"0.5288677",
"0.5270663",
"0.5265564",
"0.51896477",
"0.51511014",
"0.5126361",
"0.51259017",
"0.51075906",
"0.5091107",
"0.5091107",
"0.5021949",
"0.5016198",
"0.4961651",
"0.49544987",
"0.49520537",
"0.494... | 0.7829274 | 0 |
Submit a metric as a gauge, additional tags provided will be added to the ones from the label provided via the metrics object. | def _submit_gauge(self, metric_name, val, metric, custom_tags=None, hostname=None):
_tags = self._metric_tags(metric_name, val, metric, custom_tags, hostname)
self.check.gauge('{}.{}'.format(self.NAMESPACE, metric_name), val, _tags, hostname=hostname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gauge(self, gauge, value):\n try:\n self._thread_pool_executor.submit(self._delegate.gauge, gauge, value)\n except:\n self._logger.exception('Exception caught submitting gauge metric')",
"def add_gauge(self, data, metric_id=None):\n self._post_data(prefix_id='gauges... | [
"0.7285011",
"0.6867734",
"0.68111044",
"0.6699969",
"0.6642851",
"0.6484831",
"0.64751744",
"0.6383549",
"0.6362057",
"0.6242089",
"0.61857253",
"0.60445803",
"0.5981221",
"0.5947248",
"0.58967316",
"0.5812371",
"0.57682973",
"0.5750602",
"0.5690605",
"0.5674989",
"0.5456014... | 0.7893012 | 0 |
Submit a metric as a monotonic count, additional tags provided will be added to the ones from the label provided via the metrics object. | def _submit_monotonic_count(self, metric_name, val, metric, custom_tags=None, hostname=None):
_tags = self._metric_tags(metric_name, val, metric, custom_tags, hostname)
self.check.monotonic_count('{}.{}'.format(self.NAMESPACE, metric_name), val, _tags, hostname=hostname) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inc_count(self, metric, value, tags):\n self.increment(metric, value, tags=tags)\n self.increment('%s.count' % metric, tags=tags)",
"def post_save_metrics(sender, **kwargs):\r\n action = 'created' if kwargs.pop('created', False) else 'updated'\r\n\r\n tags = _database_tags(action, sender, kwargs)... | [
"0.7103015",
"0.62737775",
"0.60384905",
"0.60204303",
"0.59881437",
"0.58371973",
"0.5602605",
"0.55809146",
"0.5569244",
"0.5481773",
"0.5438321",
"0.5368393",
"0.53387356",
"0.53331786",
"0.5259395",
"0.5257974",
"0.52503383",
"0.52373564",
"0.52249354",
"0.5209548",
"0.52... | 0.75249547 | 0 |
Visit assignment node whose targets are all simple. | def visit_simple_assign(self, node):
temp = gensym()
temp_target = to_name(temp, ast.Store())
stmts = [ ast.Assign([temp_target], node.value) ]
stmts += [ ast.Assign([target], to_name(temp))
for target in node.targets ]
return stmts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_Assign(self, node):\n self.generic_visit(node)\n is_multiple = len(node.targets) > 1\n is_compound = any(map(is_sequence_node, node.targets))\n is_simple = not is_compound\n if is_simple and is_multiple:\n return self.visit_simple_assign(node)\n elif i... | [
"0.69212425",
"0.64886594",
"0.6375846",
"0.6128011",
"0.5978111",
"0.5925981",
"0.59075874",
"0.58308166",
"0.57873815",
"0.572006",
"0.5688921",
"0.5654621",
"0.5651131",
"0.5596672",
"0.5524254",
"0.5473678",
"0.5473099",
"0.53852975",
"0.53435594",
"0.529892",
"0.52969265... | 0.70178634 | 0 |
Visit assignment node with at least one compound target. | def visit_compound_assign(self, node):
# Determine number of values (arity) of compound assignment.
nvalues = { len(target.elts) for target in node.targets
if is_sequence_node(target) }
if len(nvalues) > 1:
# A multiple, compound assignment with different arities... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visit_Assign(self, node):\n self.generic_visit(node)\n is_multiple = len(node.targets) > 1\n is_compound = any(map(is_sequence_node, node.targets))\n is_simple = not is_compound\n if is_simple and is_multiple:\n return self.visit_simple_assign(node)\n elif i... | [
"0.7261902",
"0.6757224",
"0.64843816",
"0.63659924",
"0.624103",
"0.62127984",
"0.6177989",
"0.61282015",
"0.60786444",
"0.604624",
"0.60448",
"0.5942896",
"0.59183824",
"0.5750465",
"0.57303625",
"0.5648947",
"0.55960566",
"0.5571266",
"0.5543112",
"0.5511169",
"0.5493238",... | 0.7176904 | 1 |
Convert assignment to attributes to `setattr` call. | def visit_Assign(self, node):
self.generic_visit(node)
target = get_single_target(node)
if isinstance(target, ast.Attribute):
args = [ target.value, ast.Str(target.attr), node.value ]
return ast.Expr(to_call(to_name('setattr'), args))
return node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",
"def __setattr__(*args):",... | [
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.65005827",
"0.64025",
... | 0.708953 | 0 |
Convert index (slice) to functional expression. | def index_to_expr(self, index):
if isinstance(index, ast.Index):
return index.value
elif isinstance(index, ast.Slice):
if index.lower is None and index.step is None:
args = [ index.upper ]
elif index.step is None:
args = [ index.lower, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getitem__(self, index: Any) -> ColumnOperators:\n return self.operate(getitem, index)",
"def special_slice(self, form):\n obj = self.reallyCompile(form[1])\n rest = form[2:]\n if len(rest) == 1:\n return ast.Subscript(obj, 'OP_APPLY', [self.reallyCompile(rest[0])])\n ... | [
"0.6217184",
"0.5981041",
"0.5913932",
"0.5875691",
"0.57255584",
"0.56947947",
"0.55419147",
"0.5474115",
"0.5463078",
"0.5445567",
"0.5418668",
"0.53971356",
"0.5378227",
"0.53756636",
"0.5320697",
"0.53108877",
"0.5268785",
"0.52610666",
"0.52600414",
"0.5241331",
"0.52413... | 0.7314768 | 0 |
Convert indexed `del` operation to `delitem` call. | def visit_Delete(self, node):
self.generic_visit(node)
target = get_single_target(node)
if isinstance(target, ast.Subscript):
fun = to_attribute(self.operator, 'delitem')
args = [ target.value, self.index_to_expr(target.slice) ]
return ast.Expr(to_call(fun, ar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __delitem__(self, key):\n if self.__pepth__ != 0:\n return plist.__getattr__(self, '__delitem__')(key)\n try:\n if (isinstance(key, list)\n and plist(key).all(isinstance, int)):\n for k in sorted(key, reverse=True):\n operator.__delitem__(self, k)\n else:\n ... | [
"0.66921794",
"0.6634915",
"0.6633796",
"0.6570889",
"0.6552683",
"0.65220124",
"0.6386673",
"0.637424",
"0.633695",
"0.6330479",
"0.63189936",
"0.629664",
"0.62494636",
"0.6222551",
"0.6222551",
"0.6154767",
"0.6154767",
"0.6136742",
"0.6106075",
"0.6077464",
"0.60384274",
... | 0.67726755 | 0 |
Whether the AST node can be safely evaluated twice. | def can_reevaluate(self, node):
return isinstance(node, (ast.Name, ast.Num, ast.Str)) or \
(six.PY3 and isinstance(node, ast.Bytes)) or \
(ast_has_name_constant and isinstance(node, ast.NameConstant)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evil_hack(self, other):\n if isinstance(other, FExpr):\n return other == self\n return isinstance(other, self.__class__) and self.id == other.id",
"def can_rewrite(self, lhs):\n return len(self[lhs]) > 0",
"def is_used_as_expression(item):\n # note: this is not accurate because of th... | [
"0.5983335",
"0.5781899",
"0.5668821",
"0.5606019",
"0.5595086",
"0.556334",
"0.5537646",
"0.55246955",
"0.542583",
"0.5423907",
"0.5420764",
"0.54188806",
"0.5378163",
"0.5366631",
"0.53475344",
"0.53304714",
"0.5311328",
"0.5301695",
"0.5297375",
"0.52919585",
"0.5287243",
... | 0.6013396 | 0 |
Convert AST operator to function in operator module. | def op_to_function(self, op):
name = op.__class__.__name__.lower()
return to_attribute(self.operator, inplace_operator_table[name]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def op_to_function(self, op):\n name = op.__class__.__name__.lower()\n name = operator_table.get(name, name)\n return to_attribute(self.operator, name)",
"def _convert_operator(\n self, op_name, node_name, inputs, attrs, identity_list=None, convert_map=None\n ):\n identity_l... | [
"0.7403406",
"0.68868965",
"0.670449",
"0.6681713",
"0.65929717",
"0.65538996",
"0.6334976",
"0.6330674",
"0.63050497",
"0.62751913",
"0.59945136",
"0.59220994",
"0.58847594",
"0.582918",
"0.58211267",
"0.5793635",
"0.579274",
"0.57560617",
"0.56892043",
"0.5672466",
"0.56405... | 0.7269648 | 1 |
Convert augmented assignment to assignment plus function call. | def visit_AugAssign(self, node):
# FIXME: Gensym the LHS to avoid two evaluations.
self.generic_visit(node)
rhs = to_call(self.op_to_function(node.op),
[set_ctx(node.target), node.value])
return ast.Assign([node.target], rhs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _AugAssign(self, t):\n if not isinstance(t.target, ast.Name):\n self.RaiseError(t, \"Augmented assignment to complex expressions not supported\")\n # check if target exists in locals\n if t.target.id not in self._locals :\n self.RaiseError(t, \"Augmented assignment no... | [
"0.6730379",
"0.60008764",
"0.59139097",
"0.5711847",
"0.56486744",
"0.56235904",
"0.558098",
"0.5525872",
"0.5452114",
"0.5416577",
"0.5416467",
"0.53805333",
"0.53741395",
"0.53737843",
"0.53596747",
"0.5325352",
"0.5319974",
"0.5307721",
"0.52776676",
"0.5269577",
"0.52540... | 0.61607265 | 1 |
Convert AST operator to function in operator module. | def op_to_function(self, op):
name = op.__class__.__name__.lower()
name = operator_table.get(name, name)
return to_attribute(self.operator, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def op_to_function(self, op):\n name = op.__class__.__name__.lower()\n return to_attribute(self.operator, inplace_operator_table[name])",
"def _convert_operator(\n self, op_name, node_name, inputs, attrs, identity_list=None, convert_map=None\n ):\n identity_list = identity_list if ... | [
"0.7269387",
"0.68856734",
"0.67033535",
"0.6680751",
"0.6593878",
"0.65538615",
"0.6333541",
"0.6330422",
"0.63046694",
"0.6274489",
"0.5995828",
"0.5922164",
"0.5883966",
"0.5829021",
"0.5820589",
"0.5794242",
"0.5792682",
"0.57558066",
"0.5689504",
"0.5672094",
"0.56409925... | 0.740287 | 0 |
Convert list literal to function call. | def visit_List(self, node):
self.generic_visit(node)
if isinstance(node.ctx, ast.Load):
return to_call(to_attribute(self.operator, '__list__'), node.elts)
return node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _maplist_vm(vm, f, xs):\n def f_(*args):\n return vm.call(f, args)\n return list(map(f_, xs))",
"def listify(arg):\n if isinstance(arg, list):\n return arg\n else:\n return [arg]",
"def eval_f(f, xs):\n l = []\n for x in xs:\n l.append(f(x))\n return l",
"... | [
"0.6245148",
"0.61611956",
"0.60648584",
"0.6038298",
"0.59792304",
"0.59553707",
"0.59013915",
"0.5873387",
"0.5854381",
"0.5801732",
"0.57718545",
"0.5754236",
"0.5722947",
"0.5686056",
"0.5682627",
"0.56783223",
"0.5655683",
"0.5624097",
"0.5621373",
"0.5564674",
"0.555357... | 0.6453626 | 0 |
Convert tuple literal to function call. | def visit_Tuple(self, node):
self.generic_visit(node)
if isinstance(node.ctx, ast.Load):
return to_call(to_attribute(self.operator, '__tuple__'), node.elts)
return node | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eval_func_tuple(f_args):\n return f_args[0](*f_args[1:])",
"def tuple(x):\n pass",
"def parse_tuple(value):\n match = re.match(r'(\\w+)=(\\w+)\\((.*?)\\)', value)\n assert match, \"could not parse '%s'\" % value\n return match.group(1), eval(match.group(2))(match.group(3))",
"def func_call(s... | [
"0.7458055",
"0.63818896",
"0.6287098",
"0.62121403",
"0.6174",
"0.61714363",
"0.61672425",
"0.61028904",
"0.6084416",
"0.606182",
"0.6054684",
"0.6038045",
"0.5894287",
"0.58655924",
"0.5855375",
"0.5848195",
"0.58276147",
"0.58071357",
"0.57829064",
"0.57389504",
"0.5675090... | 0.65799105 | 1 |
Convert set literal to function call. | def visit_Set(self, node):
self.generic_visit(node)
return to_call(to_attribute(self.operator, '__set__'), node.elts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set(self, arg: SeField[Any]) -> str:\n if is_bare_set(arg.type):\n return f\"list({arg.varname}) if convert_sets else {arg.varname}\"\n else:\n earg = arg[0]\n earg.name = \"v\"\n return (\n f\"[{self.render(earg)} for v in {arg.varname}]... | [
"0.6105887",
"0.60869235",
"0.6042422",
"0.594492",
"0.58734345",
"0.5806317",
"0.5636314",
"0.5612864",
"0.5483707",
"0.546873",
"0.54369307",
"0.5421345",
"0.5389135",
"0.5195353",
"0.5110589",
"0.5105132",
"0.5087218",
"0.5083517",
"0.5051965",
"0.50517464",
"0.5040997",
... | 0.6132109 | 0 |
This takes a string as an input parameter and treats it as a zip code, looks up the weather for that zipcode, and returns the current temperature at that zipcode in Fahrenheit. | def weather(zipcode):
URL = 'http://api.openweathermap.org/data/2.5/weather?zip=' + zipcode + ',us&appid=' + '7d7a3cf9902ef14f54f49f160fc8a550' + '&units=imperial'
webpage = urllib.request.urlopen(URL)
contents = webpage.read()
contents = contents.decode('ascii')
weather = eval(contents) #this ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, zipcode):\n response = hereService.getWeatherByZipcode(zipcode)\n return response",
"def get_current_temperature(zipcode, country):\n owm = pyowm.OWM(os.environ.get('OWM_KEY'))\n observation = owm.weather_at_zip_code(zipcode, country)\n weather = observation.get_weather()\n ... | [
"0.6631745",
"0.6549503",
"0.6489142",
"0.6372373",
"0.63502383",
"0.62462974",
"0.6226757",
"0.6073102",
"0.6010607",
"0.5896707",
"0.58758765",
"0.58282274",
"0.57842165",
"0.57408905",
"0.57213604",
"0.57094175",
"0.56968915",
"0.56946063",
"0.5681781",
"0.5656904",
"0.561... | 0.787071 | 0 |
Finds the token where the value is stored. | def _value_token_index(self):
# TODO: memoize this value
for i, token in enumerate(self.tokens):
if not token.type.is_metadata:
return i
raise RuntimeError('could not find a value token') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_value(self, token_type, token_value):\n if isinstance(self.cursor(), token_type) and self.cursor().token == token_value:\n token = self.cursor()\n self.pos += 1\n else:\n raise ParseError(\"Expected {!s}.\".format(token_value))\n return token",
"def... | [
"0.6786406",
"0.6442385",
"0.631681",
"0.61292017",
"0.60891455",
"0.60803986",
"0.5987252",
"0.5974573",
"0.5974573",
"0.59730595",
"0.5952903",
"0.5946502",
"0.59407806",
"0.5928285",
"0.5908328",
"0.5895346",
"0.5840744",
"0.5825658",
"0.58217704",
"0.58217704",
"0.5821770... | 0.6961675 | 0 |
>>> import shutil >>> import os.path >>> import core.docprocessor >>> basepath = 'core/test_output' >>> f = open('core/test/cv_1.doc', 'r') >>> cv1 = core.docprocessor.Processor(f, 'cv_1.doc', basepath) >>> cv1.result True >>> os.path.isfile(os.path.join(cv1.markdown_path, ... cv1.name.md)) True >>> cv1.deleteconvert()... | def deleteconvert(self):
filename = os.path.join(self.docx_path, self.name.docx)
if os.path.isfile(filename):
os.remove(filename)
filename = os.path.join(self.html_path, self.name.html)
if os.path.isfile(filename):
os.remove(filename)
filename = os.path.jo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanup(asciitest_out_dir, doc_file):\n # path join uses backslash win32 which is not cmake compatible\n filename = os.path.join(asciitest_out_dir, save_cmake_filename(doc_file)).replace(\"\\\\\",\"/\")\n \n #print(\"cleanup %s %s\" % (doc_file, filename))\n try:\n os.remove(filename)\n ... | [
"0.65258646",
"0.63766783",
"0.62430525",
"0.6167361",
"0.5848033",
"0.57737476",
"0.5623585",
"0.5583894",
"0.5582149",
"0.5558321",
"0.5547012",
"0.55358094",
"0.553127",
"0.5530632",
"0.5524219",
"0.5511022",
"0.54836005",
"0.5472407",
"0.5460167",
"0.53966826",
"0.5396682... | 0.73595536 | 0 |
Read ascii file to get weather info | def read_weather(self):
print "Reading weather data from file",self.datafile
tab = ascii.read(self.datafile)
# Fix 'T' values in precipitation column, which represent tiny
# amounts of rain (not measurable)
TINY_VALUE = '.005' # 0.005 is half the smallest measurable va... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_raw_temperature():\n with open(device_file, 'r') as f:\n content = f.readlines()\n return content",
"def read_ascii(file):\n wvlen, band, mag, emag, fmag, unit, beam, odate, ref = [],[],[],[],[],[],[],[],[]\n with open(file, 'r') as f_in:\n for line in f_in:\n try:\... | [
"0.6585251",
"0.65576595",
"0.6403347",
"0.60498667",
"0.59925395",
"0.59534574",
"0.59316444",
"0.58384484",
"0.5829025",
"0.5764885",
"0.57411146",
"0.571867",
"0.57075197",
"0.56858313",
"0.5685079",
"0.56707263",
"0.56707263",
"0.56704044",
"0.5669247",
"0.5663918",
"0.56... | 0.67925274 | 0 |
Get features (for regression) based on this bikedata's weather data | def get_weather_features(self):
if self.weather_features is None:
raise Exception("Weather features not made yet.")
### self.make_weather_features()
else:
return self.weather_features | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def feature_extraction(self) -> None:\n # Add the hour, minute, and x column to the data\n self.df_poly[\"hour\"] = self.df_poly[\"time\"].apply(lambda y: y.hour)\n self.df_poly[\"minute\"] = self.df_poly[\"time\"].apply(lambda y: y.minute)\n self.df_poly[\"x\"] = self.df_poly[\"hour\"]... | [
"0.65693516",
"0.6504419",
"0.63095343",
"0.6184907",
"0.6181109",
"0.61156017",
"0.6097132",
"0.60952747",
"0.60912675",
"0.6084227",
"0.6035357",
"0.59760165",
"0.5962229",
"0.5936362",
"0.5921777",
"0.59124935",
"0.59112424",
"0.58922076",
"0.58688956",
"0.58619624",
"0.58... | 0.7378489 | 0 |
Publish response to kafka topic | def publish_response(class_label):
client = KProducer(config=publisher_config)
client.produce(class_label, PUBLISHER_TOPIC) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def publish(self, node, topic, data={}, on_publish=None, on_response=None):\n pass",
"def produce(self, response, regex, ts):\n self.logger.info(\"Producing message...\")\n\n payload = {\n \"url\": response.url,\n \"latency\": response.elapsed,\n \"status\": ... | [
"0.6920841",
"0.6638568",
"0.6578799",
"0.6561684",
"0.6525909",
"0.65240884",
"0.6514028",
"0.641655",
"0.62882924",
"0.627717",
"0.62517506",
"0.61733186",
"0.61410475",
"0.6117747",
"0.61167103",
"0.61138386",
"0.61064917",
"0.608827",
"0.6083523",
"0.6068794",
"0.60644025... | 0.7494711 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.