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 |
|---|---|---|---|---|---|---|
Questions Card Update Form | def admin_card_update(card_id):
mongo_collection = mongo_database["questions"]
card = mongo_collection.find_one({"id": card_id})
return render_template(
"admin_card_update.html",
card=card,
datetime=date_today.strftime("%x"),
admin_logged=session.get('logged_in'),
adm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _edit_question(request, question):\n latest_revision = question.get_latest_revision()\n preview = None\n revision_form = None\n if request.method == 'POST':\n if 'select_revision' in request.POST:\n # The user submitted to change the revision to start editing from\n rev... | [
"0.6444939",
"0.6333186",
"0.6309494",
"0.61862105",
"0.6130509",
"0.611069",
"0.60459816",
"0.601469",
"0.5895587",
"0.5894713",
"0.58369786",
"0.5770874",
"0.5741646",
"0.56520283",
"0.5640494",
"0.5598499",
"0.5576267",
"0.55752164",
"0.5573383",
"0.55517626",
"0.55438817"... | 0.68466634 | 0 |
Generate the closest possible SEO friendly path for this campaign. Note that these paths are only generated for campaigns which are already published. | def generate_seo_friendly_path(self, base_pathname_string='', campaignx_we_vote_id='', campaignx_title=None):
from politician.controllers_generate_seo_friendly_path import generate_seo_friendly_path_generic
return generate_seo_friendly_path_generic(
base_pathname_string=base_pathname_string,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_url(self):\n u = urlparse.urljoin(settings.SITE_URL, '/#/')\n\n m = self.object.__class__.__name__\n\n if m == 'Workspace':\n return urlparse.urljoin(\n u, 'workspaces/w/{}'.format(self.object.slug)\n )\n elif m == 'Vault':\n re... | [
"0.64412355",
"0.6416239",
"0.622437",
"0.5910468",
"0.589471",
"0.58929414",
"0.58899176",
"0.58650005",
"0.5810434",
"0.578214",
"0.57725555",
"0.5756489",
"0.5720189",
"0.5715019",
"0.5710717",
"0.57071894",
"0.56893915",
"0.5652677",
"0.5633637",
"0.56251574",
"0.56203246... | 0.67637473 | 0 |
This function calculates the information gain, where ig(f1, f2) = H(f1) H(f1\f2) | def information_gain(f1, f2):
ig = ee.entropyd(f1) - conditional_entropy(f1, f2)
return ig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def su_calculation(f1, f2):\n # calculate information gain of f1 and f2, t1 = ig(f1, f2)\n t1 = information_gain(f1, f2)\n # calculate entropy of f1\n t2 = ee.entropyd(f1)\n # calculate entropy of f2\n t3 = ee.entropyd(f2)\n\n su = 2.0 * t1 / (t2 + t3)\n\n return su",
"def info_gain(left,... | [
"0.6145874",
"0.6053615",
"0.58665586",
"0.58400637",
"0.5828656",
"0.5826964",
"0.58186895",
"0.5816665",
"0.579917",
"0.5762117",
"0.5662728",
"0.5646631",
"0.563621",
"0.55903405",
"0.55712414",
"0.5564625",
"0.5501128",
"0.5493852",
"0.547589",
"0.54473156",
"0.54442096",... | 0.7910877 | 0 |
This function calculates the conditional entropy, where ce = H(f1) I(f1;f2) | def conditional_entropy(f1, f2):
ce = ee.entropyd(f1) - ee.midd(f1, f2)
return ce | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conditional_entropy_hyper(self) -> float:\n pass",
"def conditional_entropy(self) -> float:\n pass",
"def information_gain(f1, f2):\n\n ig = ee.entropyd(f1) - conditional_entropy(f1, f2)\n return ig",
"def _conditional_entropy_compute(confmat: Tensor) ->Tensor:\n confmat = _drop_em... | [
"0.75129586",
"0.74474317",
"0.7124733",
"0.70022875",
"0.6818115",
"0.6687272",
"0.66868997",
"0.6578242",
"0.6539494",
"0.6472258",
"0.6470226",
"0.64497244",
"0.63971204",
"0.63714343",
"0.6354874",
"0.63437366",
"0.6324555",
"0.6300499",
"0.62546587",
"0.6242879",
"0.6210... | 0.85797334 | 0 |
This function calculates the symmetrical uncertainty, where su(f1,f2) = 2IG(f1,f2)/(H(f1)+H(f2)) | def su_calculation(f1, f2):
# calculate information gain of f1 and f2, t1 = ig(f1, f2)
t1 = information_gain(f1, f2)
# calculate entropy of f1
t2 = ee.entropyd(f1)
# calculate entropy of f2
t3 = ee.entropyd(f2)
su = 2.0 * t1 / (t2 + t3)
return su | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uncertainty_mm(self,m1,m2):\n # ID and isolation uncertainty (TO BE FIXED)\n unc = (self._muIDISOWeight.value(m1.pt(),m1.eta(),'+1')/self._muIDISOWeight.value(m1.pt(),m1.eta(),'+1')+ \\\n self._muIDISOWeight.value(m2.pt(),m2.eta(),'+1')/self._muIDISOWeight.value(m2.pt(),m2.eta(),'+1'))**2... | [
"0.60060245",
"0.58210576",
"0.5776708",
"0.5709511",
"0.56543845",
"0.5593671",
"0.55274516",
"0.5487926",
"0.54671097",
"0.54472774",
"0.54185194",
"0.53845024",
"0.53705823",
"0.5368508",
"0.53540176",
"0.533016",
"0.5324873",
"0.5292968",
"0.52852327",
"0.52852046",
"0.52... | 0.69187057 | 0 |
Chooses the appropriate rpc class based on the address format. Does not work for EtherscanRPC because there is no good way to check if an api_key is valid. If you know you have an apikey for Etherscan, instantiate the EtherscanRPC client directly. | def rpc_factory(address, verbose):
if not isinstance(address, str):
raise RPCError('The address must be a string: {!r}'.format(address))
if _os.path.exists(address) and _stat.S_ISSOCK(_os.stat(address).st_mode):
return IPCRPC(address, verbose)
elif _HTTP.match(address):
return HTTPR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_str(cls, address: str) -> Optional[Address]:\n if len(address) < 26 or len(address) > 35:\n return None\n # decode\n data = base58_decode(address)\n if data is None or len(data) != 25:\n return None\n # check code\n prefix = data[:21]\n ... | [
"0.571346",
"0.5449916",
"0.52416897",
"0.5139773",
"0.5136199",
"0.5135899",
"0.51007897",
"0.5040956",
"0.49199766",
"0.47267127",
"0.4723684",
"0.46901482",
"0.46455255",
"0.4626003",
"0.4620554",
"0.46186823",
"0.45921576",
"0.45775348",
"0.4561937",
"0.45299584",
"0.4527... | 0.6459828 | 0 |
Locates the specified datafiles and returns the matches in a data_files compatible format. source is the root of the source data tree. Use '' or '.' for current directory. target is the root of the target data tree. Use '' or '.' for the distribution directory. patterns is a sequence of globpatterns for the files you w... | def find_data_files(source, target, patterns):
if glob.has_magic(source) or glob.has_magic(target):
raise ValueError("Magic not allowed in src, target")
ret = {}
for pattern in patterns:
pattern = os.path.join(source, pattern)
for filename in glob.glob(pattern):
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _DataSourceFromFilePattern(self,\n file_pattern,\n input_source_weights=None,\n **extra_input_kwargs):\n del input_source_weights # Unused.\n return py_utils.NestedMap(data=tf.constant(file_pattern))",
"def... | [
"0.61576617",
"0.6129363",
"0.5919765",
"0.5905183",
"0.58921427",
"0.5833857",
"0.58126956",
"0.5732098",
"0.5684496",
"0.5594679",
"0.558987",
"0.5580824",
"0.5559924",
"0.55368453",
"0.5534052",
"0.5506687",
"0.53464913",
"0.52918094",
"0.5241423",
"0.52367634",
"0.5205368... | 0.7973076 | 0 |
Matches template image in a target grayscaled image | def match_template(img, template, threshold=0.9):
#print(img)
#print(template)
res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED)
matches = np.where(res >= threshold)
return matches | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def matchTemplate(image, template):\n match_hmap = cvCreateImage(\n cvSize(image.width-template.width+1, image.height-template.height+1),\n IPL_DEPTH_32F,\n 1\n )\n cvMatchTemplate(image, template, match_hmap, CV_TM_SQDIFF_NORMED)\n return match_hmap",
"def templateMatchSingle(im... | [
"0.7127601",
"0.7048085",
"0.70070684",
"0.6867089",
"0.67477554",
"0.6726216",
"0.66068804",
"0.6604652",
"0.6569852",
"0.6569769",
"0.654987",
"0.64846456",
"0.6334263",
"0.6333618",
"0.6229734",
"0.6184669",
"0.6158788",
"0.60949856",
"0.60808086",
"0.59501326",
"0.5947968... | 0.741164 | 0 |
Try to load the part this method is called by the connect method of this object and by cltremote.RemoteBase RemoteBase | def load_part(self, partname, remoteclassname):
success = False
logger.info(u"{} Loading of part: {}".format(self.uid, partname))
try:
module = importlib.import_module("parts.{p}.{p}Remote".format(
p=partname))
logger.info(
le2mtrans(u"{j}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load(self, pkgpart, part_dict):\n # call parent to do generic aspects of load\n super(SlideMaster, self)._load(pkgpart, part_dict)\n\n # selectively unmarshal relationships for now\n for rel in self._relationships:\n # log.debug(\"SlideMaster Relationship %s\", rel._relt... | [
"0.59609467",
"0.5939916",
"0.58889776",
"0.581184",
"0.57881945",
"0.5732381",
"0.5723686",
"0.5715784",
"0.567733",
"0.5595642",
"0.55748475",
"0.555035",
"0.5547567",
"0.5536446",
"0.5526269",
"0.5427431",
"0.54074895",
"0.54074895",
"0.54074895",
"0.54074895",
"0.539921",... | 0.7296799 | 0 |
Load the rlhuboplus model and a scene into openhubo. Returns a servocontroller and a reference robot to show desired movements vs. actual pose. The returned tuple contains the robots, controller, and a nametojointindex converter. | def load_rlhuboplus(env,scenename=None,stop=False):
return _oh.load_scene(env,'rlhuboplus.robot.xml',scenename,stop) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\r\n\t\t# Publishers\r\n\t\tself._pub_rate = rospy.Publisher('robot/joint_state_publish_rate', UInt16, queue_size=10)\r\n\t\tself.image_pub = rospy.Publisher(\"baxter_view\",Image,queue_size=4)\r\n\t\tself._obj_state = rospy.ServiceProxy(\"/gazebo/set_model_state\",SetModelState)\r\n\t\t\r\n\t\t... | [
"0.53342927",
"0.5223863",
"0.51131403",
"0.50385404",
"0.5028461",
"0.495816",
"0.49522844",
"0.4951688",
"0.48854965",
"0.48458624",
"0.4845302",
"0.4821964",
"0.47963774",
"0.47869748",
"0.47868013",
"0.47747764",
"0.4767754",
"0.4742408",
"0.473562",
"0.47332805",
"0.4684... | 0.62102795 | 0 |
A closure to easily convert from a string joint name to the robot's actual DOF index. | def makeNameToIndexConverter(robot,autotranslate=True):
return _oh.make_name_to_index_converter(robot,autotranslate) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_index(identify):\n\n pedaco = identify.replace('/', '')\n return int(pedaco)",
"def index2word(index_word, index_dict):\n if index_word == -1 or index_word not in index_dict.keys():\n return '_eps_'\n else:\n return index_dict[index_word]",
"def make_dof_value_map(robot):\n ... | [
"0.5482621",
"0.5456526",
"0.5411834",
"0.5256262",
"0.52252036",
"0.5196534",
"0.51575613",
"0.5150166",
"0.5116707",
"0.50905156",
"0.5075703",
"0.50337106",
"0.4960798",
"0.49572524",
"0.4953177",
"0.4950627",
"0.49415132",
"0.4921745",
"0.49088845",
"0.49038202",
"0.49000... | 0.55940926 | 0 |
Load up and configure the simpleFloor environment for hacking with physics. Sets some useful defaults. | def load_simplefloor(env):
return _oh.load_scene(env,None,'simpleFloor.env.xml',True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def InitEnvironment(self):\r\n\t\t\r\n\t\t# Turn antialiasing on\r\n\t\trender.setAntialias(AntialiasAttrib.MMultisample,1)\r\n\t\t\r\n\t\t# load the falcon model\r\n\t\tfalcon = loader.loadModel(\"Content/falcon/falcon.bam\")\r\n\t\tfalcon.setScale(30)\r\n\t\tfalcon.setPos(0, 0, 28.5)\r\n\t\tfalcon.reparentTo(ren... | [
"0.6248853",
"0.60405487",
"0.57158166",
"0.56440204",
"0.558289",
"0.55495113",
"0.55436087",
"0.5526429",
"0.55164933",
"0.5507159",
"0.54870534",
"0.5484633",
"0.5480351",
"0.5469515",
"0.5452306",
"0.5410114",
"0.5379484",
"0.53766954",
"0.5355727",
"0.5351993",
"0.534364... | 0.6798784 | 0 |
Set tweaked finger torque for grasping experiment. Deprecated due to new torquebased servo control. | def set_finger_torque(robot,maxT,fingers):
#Super kludgy...
for f in fingers:
if robot.GetJoint(f):
robot.GetJoint(f).SetTorqueLimits([maxT])
robot.GetJoint(f).SetVelocityLimits([3])
robot.GetJoint(f).SetAccelerationLimits([30]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setMotorTorque(self, torque):\r\n if torque < 0.0:\r\n torque = 0.0\r\n elif torque > 1.0:\r\n torque = 1.0\r\n torque *= self.maxTorque\r\n if self.reverse:\r\n torque *= -1\r\n dTorque = 2\r\n if self.torque < torque:\r\n s... | [
"0.630241",
"0.5443808",
"0.54325783",
"0.5350345",
"0.5200339",
"0.5137968",
"0.5102211",
"0.5079462",
"0.50652754",
"0.50623274",
"0.5060927",
"0.5049635",
"0.5045565",
"0.50452226",
"0.5034421",
"0.50263256",
"0.50193846",
"0.5009361",
"0.49941224",
"0.49921134",
"0.498266... | 0.70379955 | 0 |
Returns recipe does not exist message | def _does_not_exist():
response_payload = dict(
message="Recipe does not exist!"
)
response_payload = jsonify(response_payload)
return make_response(response_payload, 404) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def non_existing_recipe_error_test(self):\n client = TestClient()\n error = client.run(\"upload Pkg/0.1@user/channel\", ignore_error=True)\n self.assertTrue(error)\n self.assertIn(\"ERROR: There is no local conanfile exported as Pkg/0.1@user/channel\",\n client.user... | [
"0.67053497",
"0.638858",
"0.6320744",
"0.63052964",
"0.609179",
"0.60616803",
"0.6032747",
"0.6016889",
"0.6012378",
"0.5950096",
"0.5946541",
"0.5898837",
"0.5846728",
"0.582731",
"0.58167356",
"0.5800994",
"0.5702433",
"0.56634784",
"0.56365335",
"0.5624497",
"0.5620596",
... | 0.7538943 | 0 |
Parse the traceroute result | def parseTraceroute(self, stdoutputdata):
itemlist = stdoutputdata.split("\n")
res = defaultdict(list)
for item in itemlist:
re_ip = re.search(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', item)
if re_ip:
ip = re_ip.group(0)
res["route"].append(ip)
res["route"].append(self.task["destination"])
res["des... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_traceroute_output(self):\n url = self.source['url']\n if 'post_data' in self.source:\n context = self.source['post_data']\n else:\n context = None\n status_code, content = self.urlopen(url, context=context)\n content = content.strip()\n regex ... | [
"0.6905173",
"0.6265325",
"0.6184163",
"0.6166134",
"0.60980153",
"0.6027709",
"0.6013491",
"0.59370697",
"0.5883287",
"0.5868269",
"0.5859081",
"0.58563274",
"0.5829786",
"0.5819288",
"0.5764864",
"0.56720495",
"0.5631726",
"0.5578696",
"0.5578418",
"0.5531463",
"0.5482655",... | 0.7362002 | 0 |
Symmetric decorrelation i.e. W < (W W.T) ^{1/2} W | def _sym_decorrelation(W):
s, u = linalg.eigh(np.dot(W, W.T))
# Avoid sqrt of negative values because of rounding errors. Note that
# np.sqrt(tiny) is larger than tiny and therefore this clipping also
# prevents division by zero in the next step.
s = np.clip(s, a_min=np.finfo(W.dtype).tiny, a_max=No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gs_decorrelation(w, W, j):\n w -= np.linalg.multi_dot([w, W[:j].T, W[:j]])\n return w",
"def _symmetric(updates):\n sym_updates = updates[:-1] + [updates[-1]] + updates[:-1][::-1]\n coeff = [0.5]*(len(updates)-1) + [1.0] + [0.5]*(len(updates) - 1)\n return ExplicitIntegrator(coeff... | [
"0.68297875",
"0.58642405",
"0.5714483",
"0.56672794",
"0.56156206",
"0.55587417",
"0.5539916",
"0.55214864",
"0.54957104",
"0.548836",
"0.54881096",
"0.5487721",
"0.54838127",
"0.54819167",
"0.5476712",
"0.54497755",
"0.54356843",
"0.5432515",
"0.5406844",
"0.53943413",
"0.5... | 0.7474815 | 0 |
Grab the name of the binary we're running in. | def get_binary_name():
return os.path.basename(inspect.stack()[-1][1])[:16] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_program_name():\n program_path = os.path.abspath(sys.argv[0])\n if os.path.exists(program_path):\n return os.path.basename(program_path)\n else:\n match = re.match(r\"^.*(?:\\.egg|\\.tar|\\.tar\\.gz)(?=/)\", program_path, re.IGNORECASE)\n if (match is not None) and os.pat... | [
"0.72268015",
"0.72012603",
"0.7187184",
"0.7005614",
"0.69355136",
"0.67844146",
"0.67611265",
"0.6756073",
"0.66813314",
"0.66522294",
"0.6628342",
"0.6627381",
"0.6627222",
"0.6603379",
"0.6576827",
"0.65747535",
"0.6540388",
"0.6478583",
"0.64458454",
"0.6427517",
"0.6400... | 0.8264518 | 0 |
Adds a named chain to the table. The chain name is wrapped to be unique for the component creating it, so different components of Nova can safely create identically named chains without interfering with one another. At the moment, its wrapped name is , so if novacompute creates a chain named 'OUTPUT', it'll actually en... | def add_chain(self, name, wrap=True):
if wrap:
self.chains.add(name)
else:
self.unwrapped_chains.add(name)
self.dirty = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain_name(self) -> str:\n return pulumi.get(self, \"chain_name\")",
"def addChain(self, chain):\n\n\t\tself.chain.append(chain)\n\t\tchain.parentMolecule = self",
"def add_chain(self, chain, delay_sort = True):\n assert isinstance(chain, Chain)\n\n try:\n model = self.model... | [
"0.65356433",
"0.6292502",
"0.5971866",
"0.58491284",
"0.5739743",
"0.56037813",
"0.5452546",
"0.5436754",
"0.5386792",
"0.5381447",
"0.52454704",
"0.5211677",
"0.51958865",
"0.51822054",
"0.5169344",
"0.5091612",
"0.50894535",
"0.50690097",
"0.5043837",
"0.5038757",
"0.50186... | 0.7146354 | 0 |
Remove named chain. This removal "cascades". All rule in the chain are removed, as are all rules in other chains that jump to it. If the chain is not found, this is merely logged. | def remove_chain(self, name, wrap=True):
if wrap:
chain_set = self.chains
else:
chain_set = self.unwrapped_chains
if name not in chain_set:
return
self.dirty = True
# non-wrapped chains and rules need to be dealt with specially,
# so... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(ctx, schain_name):\n skale = ctx.obj['skale']\n skale.manager.delete_schain(schain_name, wait_for=True,\n gas_price=4500000000)\n print(f'sChain {schain_name} removed!')",
"def removeChain(self, mychain):\n\n\t\tichain = self.getChain(mychain)\t\n\t\tif ichain =... | [
"0.66127115",
"0.6543583",
"0.65178925",
"0.63441426",
"0.6132853",
"0.5970545",
"0.59696996",
"0.59487593",
"0.59189224",
"0.5915002",
"0.5893214",
"0.58134645",
"0.5795842",
"0.57516927",
"0.5745285",
"0.5725543",
"0.5719747",
"0.56921446",
"0.55726975",
"0.54871327",
"0.54... | 0.7302495 | 0 |
Add a rule to the table. This is just like what you'd feed to iptables, just without the 'A ' bit at the start. However, if you need to jump to one of your wrapped chains, prepend its name with a '$' which will ensure the wrapping is applied correctly. | def add_rule(self, chain, rule, wrap=True, top=False):
if wrap and chain not in self.chains:
raise ValueError(_('Unknown chain: %r') % chain)
if '$' in rule:
rule = ' '.join(map(self._wrap_target_chain, rule.split(' ')))
rule_obj = IptablesRule(chain, rule, wrap, top)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_rule(self, rule):\n self.rule.append(rule)",
"def add_rule(self, rule) -> None:\n self.add_rules([rule])",
"def add_rule(self, rule):\n \n self.rules.append(rule)",
"def add_rule(self, rule: Rule):\n self.rules.append(rule)",
"def add_rule(self, rule: interpreter.... | [
"0.69831085",
"0.6929167",
"0.69029045",
"0.6722005",
"0.66983014",
"0.6664679",
"0.66394943",
"0.66027844",
"0.65009797",
"0.647024",
"0.64614254",
"0.62848955",
"0.6235584",
"0.61647195",
"0.6121893",
"0.6088669",
"0.6055803",
"0.59040135",
"0.58810866",
"0.5879263",
"0.587... | 0.72605485 | 0 |
Remove a rule from a chain. | def remove_rule(self, chain, rule, wrap=True, top=False):
try:
self.rules.remove(IptablesRule(chain, rule, wrap, top))
if not wrap:
self.remove_rules.append(IptablesRule(chain, rule, wrap, top))
self.dirty = True
except ValueError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeRule(self, *args):\n return _libsbml.Model_removeRule(self, *args)",
"def remove_chain(self, chain):\n assert isinstance(chain, Chain)\n self.model_dict[chain.model_id].remove_chain(chain)",
"def remove_chain(self, chain):\n assert isinstance(chain, Chain)\n self.ch... | [
"0.7424913",
"0.74110746",
"0.73149914",
"0.6947874",
"0.6896175",
"0.6762595",
"0.6747168",
"0.66540754",
"0.65364784",
"0.65273917",
"0.6346213",
"0.6327616",
"0.6307949",
"0.62569445",
"0.6254516",
"0.62401545",
"0.62105507",
"0.61818945",
"0.613633",
"0.61205137",
"0.6113... | 0.8184237 | 0 |
Remove all rules matching regex. | def remove_rules_regex(self, regex):
if isinstance(regex, six.string_types):
regex = re.compile(regex)
num_rules = len(self.rules)
self.rules = filter(lambda r: not regex.match(str(r)), self.rules)
removed = num_rules - len(self.rules)
if removed > 0:
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eliminateRules(self):\n deleteKey = []\n for key,value in self._rules.items():\n if value[0] < self._minConfidence:\n deleteKey.append(key)\n \n for key in deleteKey:\n del self._rules[key]",
"def _remove_regex(regex, text) -> StyledStr:\n t... | [
"0.64303595",
"0.616448",
"0.6031216",
"0.6028709",
"0.602167",
"0.6004168",
"0.59537715",
"0.59090513",
"0.5879021",
"0.57283556",
"0.57130945",
"0.56602484",
"0.56581986",
"0.5656981",
"0.56460613",
"0.5560527",
"0.55123913",
"0.551106",
"0.55080414",
"0.550569",
"0.5490603... | 0.8198133 | 0 |
Remove all rules from a chain. | def empty_chain(self, chain, wrap=True):
chained_rules = [rule for rule in self.rules
if rule.chain == chain and rule.wrap == wrap]
if chained_rules:
self.dirty = True
for rule in chained_rules:
self.rules.remove(rule) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self):\n\n\t\tfor chain in self.chain:\n\t\t\tchain.clear()\n\n\t\tself.chain = []\n\t\tself.remark = []",
"def remove_chain(self, chain):\n assert isinstance(chain, Chain)\n self.model_dict[chain.model_id].remove_chain(chain)",
"def flushRules(self):\n self.chain.flush()",
"de... | [
"0.6976301",
"0.67297375",
"0.6681245",
"0.6644196",
"0.6428264",
"0.6263099",
"0.6163615",
"0.6119698",
"0.60656494",
"0.60592926",
"0.59872264",
"0.59622675",
"0.59342986",
"0.5900307",
"0.5847478",
"0.58297676",
"0.58181685",
"0.5774099",
"0.57378364",
"0.5725818",
"0.5698... | 0.8091868 | 0 |
Apply the current inmemory set of iptables rules. This will blow away any rules left over from previous runs of the same component of Nova, and replace them with our current set of rules. This happens atomically, thanks to iptablesrestore. | def _apply(self):
s = [(iptables_save, iptables_restore, self.ipv4)]
if self.use_ipv6:
s += [(ip6tables_save, ip6tables_restore, self.ipv6)]
for save, restore, tables in s:
all_tables, _err = save()
all_lines = all_tables.split('\n')
for table_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def iptables_apply():\n\n with settings(warn_only=True):\n run(\"sudo iptables-restore < /etc/iptables.rules\")",
"def update_rules():\n update_all_rules()\n return \"OK\"",
"def update_all_rules():\n try:\n for i in range(1, len(RULES_FOR_BRANCHES)):\n set_next_rule_to_red... | [
"0.74310803",
"0.6443475",
"0.6198638",
"0.61369956",
"0.58547723",
"0.5850812",
"0.575473",
"0.57367265",
"0.5676085",
"0.5482839",
"0.5477452",
"0.5454835",
"0.5432685",
"0.5365001",
"0.53534245",
"0.53432953",
"0.5276151",
"0.5262996",
"0.5246209",
"0.52433085",
"0.5233582... | 0.7693331 | 0 |
Instantiates a finite grid. The limits are specified as a list of tuples of (low, high) values, one for each grid vector. | def __init__(self, origin, grid_vectors, limits):
assert len(grid_vectors) == len(limits)
Grid.__init__(self, origin, grid_vectors)
self._Limits = limits | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid(gmin, gmax, gstep):\n n_vals = int((gmax - gmin)/gstep + 1)\n my_grid = linspace(gmin, gmax, n_vals)\n return my_grid",
"def create_grid(xlim, ylim, step):\n x_range = np.arange(xlim[0], xlim[1], step)\n y_range = np.arange(ylim[0], ylim[1], step)\n return x_range, y_range",
"def mak... | [
"0.6845707",
"0.68128675",
"0.6641913",
"0.6626282",
"0.64288163",
"0.63951415",
"0.63662404",
"0.6347766",
"0.63329864",
"0.63275075",
"0.63241917",
"0.63241917",
"0.6310568",
"0.6308185",
"0.6199303",
"0.6160781",
"0.61287147",
"0.60951614",
"0.60779905",
"0.6064125",
"0.60... | 0.6917152 | 0 |
Returns the number of grid intervals in each direction. | def grid_point_count(self):
return pytools.product(self.grid_point_counts()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_tiles(grid_bbox, dxy): \r\n xmin, xmax, ymin, ymax = grid_bbox\r\n return (int(np.abs(ymax-ymin)/dxy), int(np.abs(xmax-xmin)/dxy))",
"def getNumGrids(self):\n c = list(self.gridVars.keys())\n return len(list(self.gridVars[c[0]].values()))",
"def getNumTiles(self):\n retur... | [
"0.72868717",
"0.72172505",
"0.71965694",
"0.7155208",
"0.70913154",
"0.7022597",
"0.6997481",
"0.6893928",
"0.68832994",
"0.6877992",
"0.6820697",
"0.68062395",
"0.6802767",
"0.679377",
"0.6784351",
"0.6742068",
"0.67137444",
"0.6681955",
"0.66590667",
"0.6619721",
"0.661945... | 0.74237925 | 0 |
Const method for initializing the applet | def init(self):
# Configuration interface support comes with plasma
self.setHasConfigurationInterface(False)
# Aspect ratio defined in Plasma
self.setAspectRatioMode(Plasma.IgnoreAspectRatio)
# Theme is a const variable holds Applet Theme
self.theme = Plasma.Svg(self)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():",
"def init():\n pass",
"def do_init(self):\n\n pass",
"def Init(self, config):\r\n pass",
"def initialize(self, application):",
"def init(self):\n pass",
"def init(self):\n pass",
"def init(self):\n pass",
"def init(self):\n pass",
"def init(s... | [
"0.6560639",
"0.64750546",
"0.63915706",
"0.62873834",
"0.62607515",
"0.621026",
"0.621026",
"0.621026",
"0.621026",
"0.621026",
"0.621026",
"0.621026",
"0.621026",
"0.619076",
"0.6180176",
"0.6179248",
"0.61707896",
"0.6163452",
"0.6160528",
"0.6155465",
"0.6152029",
"0.61... | 0.7120899 | 0 |
Adds a data point to the logger object. Datapoints are added sequentially, so add your variables in the same sequence that you want them to show up in on the CSV | def addDataPoint(self, variableName):
if self.initialized == False:
if str(variableName) in self.currentLog:
raise IndexError("datapoiont already initialized")
else:
self.variables += 1
self.variableDescriptions.append(variableName)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recordVariable(self, variableName, data):\n if str(variableName) in self.currentLog:\n # if self.currentLog[str(variableName)] != None:\n # raise Warning(f'data point {str(variableName)} is being overwritten!')\n self.currentLog[str(variableName)] = data\n els... | [
"0.6582924",
"0.6551948",
"0.6459278",
"0.6246846",
"0.6219666",
"0.6097625",
"0.60864437",
"0.5971872",
"0.59315133",
"0.58834726",
"0.5853392",
"0.5843727",
"0.5807153",
"0.57972455",
"0.57885456",
"0.5764661",
"0.5758678",
"0.5758131",
"0.5752304",
"0.57509875",
"0.5749811... | 0.70670587 | 0 |
records a variable to the current log, DOES NOT LOG AUTOMATICALLY | def recordVariable(self, variableName, data):
if str(variableName) in self.currentLog:
# if self.currentLog[str(variableName)] != None:
# raise Warning(f'data point {str(variableName)} is being overwritten!')
self.currentLog[str(variableName)] = data
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_example(var):\n\n log.info('example code started')\n log.debug('calling settings')\n test_settings()\n log2.error('there is no error this is example ')\n log2.info('finished')",
"def log_debug(var):\n\n GPS.Logger('testsuite').log(\"%s\" % (var, ))",
"def logger(self, value):\n ... | [
"0.6800775",
"0.67926866",
"0.67613137",
"0.673412",
"0.66907656",
"0.6625186",
"0.6596223",
"0.6494363",
"0.6444782",
"0.6422716",
"0.64064705",
"0.6392706",
"0.6374291",
"0.6330466",
"0.63255125",
"0.6305311",
"0.6288462",
"0.62827843",
"0.6263191",
"0.6250232",
"0.6246383"... | 0.70800555 | 0 |
Initializes the CSV file and prepares it for writing. | def initCSV(self, makeFile, overWrite):
self.initialized = True
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if os.path.exists(str(self.fileName)):
f = open(str(self.fileName), "r")
if not f.read():
f.close()
f = open(str(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __open_csv(self):\n self.__csv_file = open(self.__csv_file_name, 'w', encoding='utf-8')\n self.__csv_writer = csv.writer(self.__csv_file, delimiter=',', )",
"def init_csv_file(self):\n folder = \"/home/pi/data/\" + datetime.now().strftime(\"%Y_%m_%d\") + \"/\"\n if not os.path.isdir(folde... | [
"0.76741135",
"0.74255097",
"0.7329993",
"0.7243945",
"0.7048726",
"0.7034279",
"0.6956366",
"0.673258",
"0.67240673",
"0.6676092",
"0.6603313",
"0.6579222",
"0.65732867",
"0.65732867",
"0.6540106",
"0.6471683",
"0.6458733",
"0.64487153",
"0.64303035",
"0.6368172",
"0.6349897... | 0.78837293 | 0 |
Test stripping the line | def test_line_strip():
for _x in range(100):
l_str = " ".join([random_str(5, 10) for x in range(30)])
l_str = (" " * randint(0, 10)) + l_str + (" " * randint(0, 10))
line = Line(l_str, random_str(10, 20), randint(1, 10000))
# Strip the string
l_stripped = line.strip()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_line(line):\r\n if not line.strip():\r\n return False # if the last line is blank\r\n if line.startswith(\"#\"):\r\n return False # comment line\r\n if line.startswith(\" #\"):\r\n return False # comment line\r\n return line",
"def rstrip_line(line):\n return li... | [
"0.7250562",
"0.71768016",
"0.7084123",
"0.6787665",
"0.6771485",
"0.67688704",
"0.6600255",
"0.65247554",
"0.65227586",
"0.6483088",
"0.64529765",
"0.6417862",
"0.6400912",
"0.6377311",
"0.6369888",
"0.6362237",
"0.6348878",
"0.6332042",
"0.62773633",
"0.6241648",
"0.6229595... | 0.7533331 | 0 |
Test concatenating different lines | def test_line_concat():
for _x in range(100):
strings = [random_str(30, 50) for _x in range(10)]
l_file = random_str(10, 20)
l_num = randint(1, 10000)
lines = [Line(x, l_file, l_num) for x in strings]
# Concatenate the lines
l_full = lines[0]
for line in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_with_2_lines():\n line = \"n\" * 15 + \"\\n\" + \"n\" * 60 + \" \" + \"n\" * 10\n assert wrap_line(line) == \"n\" * 15 + \" \" + \"n\" * 60 + \"\\n\" + \"n\" * 10",
"def test_writer_linebreak():\n GCMT(write=\"on\")\n write_message(100 * \"test\")\n write_message(100 * \" \")",
"def tes... | [
"0.67595047",
"0.6424525",
"0.6362578",
"0.6216905",
"0.61788297",
"0.61623013",
"0.61015594",
"0.60790586",
"0.6044751",
"0.60344905",
"0.6002795",
"0.5997416",
"0.5959322",
"0.59512234",
"0.5943323",
"0.5936905",
"0.5928723",
"0.5908358",
"0.5903566",
"0.58914983",
"0.58786... | 0.7924718 | 0 |
Run code quality check | def codeqa():
try:
sh('flake8 h5_validator')
except BuildFailure:
pep8_fail = True
else:
pep8_fail = False
try:
sh("pydocstyle h5_validator")
except BuildFailure:
docstring_fail = True
else:
docstring_fail = False
if pep8_fail or docstring_f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n coverage = calculate_code_coverage()\n platform = os.uname()[0]\n if coverage < CODE_COVERAGE_GOAL[platform]:\n data = {\n 'expected': CODE_COVERAGE_GOAL[platform],\n 'observed': coverage,\n }\n print '\\033[91mFAIL: %(observed).2f%% does not meet g... | [
"0.690629",
"0.68706906",
"0.6722863",
"0.65503937",
"0.65005994",
"0.6477863",
"0.63772184",
"0.634831",
"0.6311739",
"0.62938887",
"0.62822163",
"0.6276711",
"0.622485",
"0.6216071",
"0.61776257",
"0.61024976",
"0.6045385",
"0.6026006",
"0.60110664",
"0.6001104",
"0.5978099... | 0.7629032 | 0 |
Build the Sphinx documentation | def docs():
sh('sphinx-build -W -b html docs docs/_build/html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buildDocumentation():\n helptext = 'usage: build_doc.py <output format> <type of documentation>' \\\n '\\n - html: for html output' \\\n '\\n - pdf: for pdf output' \\\n '\\n\\n - all: complete documentation' \\\n '\\n - dev: only developer documentati... | [
"0.82856005",
"0.8182243",
"0.8095304",
"0.7946425",
"0.7832293",
"0.7674444",
"0.7616823",
"0.75381774",
"0.75381774",
"0.740071",
"0.73747015",
"0.73051",
"0.71761566",
"0.71276677",
"0.70834404",
"0.7048519",
"0.7046627",
"0.7035853",
"0.70308214",
"0.7026935",
"0.7019487"... | 0.8379351 | 0 |
Update an existing asset. | def update_asset(cls, id, asset_data):
return ph_base._update_record('asset', id, asset_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self) -> requests.request:\n # Check if id is set\n if self.args.id is None:\n raise Exception('Provide id of asset you want to update')\n\n # Check URL validity\n if self.args.url is not None and self.check_url_invalidity():\n raise Exception('Provided ... | [
"0.69374233",
"0.68586016",
"0.67037857",
"0.67037857",
"0.6641486",
"0.65909207",
"0.653334",
"0.63545084",
"0.6239145",
"0.61992556",
"0.6113949",
"0.60676587",
"0.60544235",
"0.6035436",
"0.59977174",
"0.59583884",
"0.593529",
"0.5906767",
"0.5901882",
"0.58826965",
"0.579... | 0.81140244 | 0 |
Checks if the number of images is equal to the number of labels in the path. Input | def _check_images_and_labels(self, image_dir, label_dir):
return len(os.listdir(image_dir))==len(os.listdir(label_dir)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_images_a_valid():\r\n counter = 0\r\n with os.scandir(os.path.join(dir_path, \"inputs\", \"type_a\")) as filepaths:\r\n for path in filepaths:\r\n extension = os.path.splitext(path)[1].lower()\r\n if extension == \".png\" or extension == \".jpg\":\r\n ... | [
"0.6857187",
"0.6778049",
"0.6608997",
"0.6470868",
"0.6470868",
"0.6470868",
"0.64671683",
"0.63645536",
"0.6209617",
"0.6172412",
"0.6172412",
"0.6160495",
"0.61398166",
"0.6118098",
"0.60889083",
"0.6088829",
"0.60738635",
"0.6062706",
"0.60482156",
"0.60111576",
"0.601115... | 0.7553603 | 0 |
Given the file handle of the file containing image data, it returns a list of the objects contained in the image. Returns objects (list(object)), where object is a dict. Currently, object has only one key, namely 'polygon' which is a list of points in clockwise order. | def _get_objects(self,label_fh):
objects = []
for line in label_fh.readlines():
try:
object = {}
line = line.replace(u'\ufeff', '')
if line != '':
x1, y1, x2, y2, x3, y3, x4, y4= [int(i) for i in line.split(',')[:-1]]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocessing_objects(img_data, hierarchy_mapping, object_file_name='objects.p'):\n\n object_path_token = \"{0}.{1}.{2}\".format(DATA, VISUAL_GENOME, get_name_from_file(object_file_name))\n\n # Check if pickles are already created\n objects_path = FilesManager().get_file_path(object_path_token)\n\n ... | [
"0.62237",
"0.61571246",
"0.5929641",
"0.59224886",
"0.58840525",
"0.5877584",
"0.5760753",
"0.57414246",
"0.56997913",
"0.56704485",
"0.5646486",
"0.5590826",
"0.55823386",
"0.5573562",
"0.5562786",
"0.5545621",
"0.55408007",
"0.5518088",
"0.5517315",
"0.5512284",
"0.5482167... | 0.69687027 | 0 |
Given the list of objects, it returns an array mapping object ids to their respective classes. Background has class 0 and text has class 1. | def _get_object_classes(self,objects):
object_class = [1 for object in objects]
object_class.insert(0, 0)
return object_class | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_class_list(self):\n t = []\n for cls in self.classes:\n if not self.is_opaque(cls.classobj):\n t.append(cls)\n elif cls.parents or cls.childs:\n t.append(cls)\n \n return t",
"def process_class_list(self, module, classes)... | [
"0.6236715",
"0.6033983",
"0.60268164",
"0.6010577",
"0.59391886",
"0.59230375",
"0.58449787",
"0.5836437",
"0.5769628",
"0.5737785",
"0.5726809",
"0.567599",
"0.5665862",
"0.56647223",
"0.56467086",
"0.55916905",
"0.55804026",
"0.55234677",
"0.55206275",
"0.5503181",
"0.5483... | 0.64411694 | 0 |
Make an Orders request, store the page count and process the response data. | def first_request(self):
response_data = self.make_order_request(1)
self.page_count = response_data[self.DATA][self.LAST_PAGE]
self.add_orders(response_data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def request_orders(self):\r\n if self.use_http():\r\n self.enqueue_http_request(\"money/orders\", {}, \"orders\")\r\n else:\r\n self.send_signed_call(\"private/orders\", {}, \"orders\")",
"def make_order_request(self, page):\n return api_methods.Orders(\n pag... | [
"0.68570167",
"0.6552971",
"0.61255354",
"0.60908",
"0.60400605",
"0.5982922",
"0.584163",
"0.58357054",
"0.5809135",
"0.56956005",
"0.56678724",
"0.565327",
"0.5648753",
"0.5642741",
"0.56354815",
"0.5604037",
"0.556626",
"0.5559942",
"0.5542466",
"0.5541483",
"0.55298144",
... | 0.68449026 | 1 |
Add the orders from a the response to an Orders request to self.orders. | def add_orders(self, response_data):
orders = response_data[self.DATA][self.DATA]
for order in orders:
self.orders.append(self.process_order_data(order)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _handle_orders(self, response):\n response_type = response['type']\n state_updated = False\n if response_type == \"subscription_ack\":\n # Insure the subscription details are expected. Don't do anything.\n account_id = response['accountId']\n # TODO: should... | [
"0.69409347",
"0.6667287",
"0.6545564",
"0.6545564",
"0.6460046",
"0.63917613",
"0.6235419",
"0.61754966",
"0.6097969",
"0.60590065",
"0.6050112",
"0.6049591",
"0.60148126",
"0.5854137",
"0.5701919",
"0.5696883",
"0.5695405",
"0.56953824",
"0.56910616",
"0.56895924",
"0.56578... | 0.8209479 | 0 |
Return the response to an Orders request for a page of orders. | def make_order_request(self, page):
return api_methods.Orders(
page=page,
per_page=self.PER_PAGE,
from_date=self.from_date,
start_date=self.start_date,
end_date=self.end_date,
deal_id=self.deal_id,
).call() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_orders(self, **kwargs) -> ApiResponse:\n return self._request(kwargs.pop('path'), params={**kwargs})",
"def request_orders(self):\r\n if self.use_http():\r\n self.enqueue_http_request(\"money/orders\", {}, \"orders\")\r\n else:\r\n self.send_signed_call(\"privat... | [
"0.6947997",
"0.65630955",
"0.6448705",
"0.63800734",
"0.63783544",
"0.6324955",
"0.6280075",
"0.6280075",
"0.6201901",
"0.6172101",
"0.6155729",
"0.61465985",
"0.60682786",
"0.6010717",
"0.59935415",
"0.5976142",
"0.5967135",
"0.5932509",
"0.59092224",
"0.58723015",
"0.58581... | 0.72716135 | 0 |
Test case for tarfile bundling and unbundling | def testTarBundling(self):
try:
tP = os.path.join(self.__workPath, "t0.tar.gz")
dirPath = os.path.join(self.__inpDirPath, "topdir")
ok = self.__fileU.bundleTarfile(tP, [dirPath], mode="w:gz", recursive=True)
self.assertTrue(ok)
numBytes = self.__file... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unpack(self):\n if not os.path.isfile(akrr_tar_gz):\n raise Exception(\"Should do test_packager first\")\n \n if os.path.exists(cfg.akrr_home):\n shutil.rmtree(cfg.akrr_home)\n \n if verbosity>=3: print \"\\n\"+\"~\"*80\n \n #start... | [
"0.70526093",
"0.6616482",
"0.6440095",
"0.6328305",
"0.6312369",
"0.62404823",
"0.6202618",
"0.6194006",
"0.6173202",
"0.61719835",
"0.6164269",
"0.6147481",
"0.6141193",
"0.6137979",
"0.61363333",
"0.6133573",
"0.60993564",
"0.60972047",
"0.6089963",
"0.6070059",
"0.6045629... | 0.81422436 | 0 |
Test case for copying ("put") and moving ("replace") local files | def testMoveAndCopyFile(self):
try:
remoteLocator = self.__pathPdbxDictionaryFile
fn = self.__fileU.getFileName(remoteLocator)
# _, fn = os.path.split(remoteLocator)
lPath = os.path.join(self.__workPath, fn)
ok = self.__fileU.get(remoteLocator, lPath)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self, src_path: str, tgt_path: str) -> None:",
"def _test_upload_dir_contents(self, filenames):\n local_src_dir = self._local_tempdir\n remote_dest_dir = 'remote_dest_dir'\n for filename in filenames:\n self._expected_commands.append('%s cp -a public %s %s' % (\n GSUTIL_LOCATION,\... | [
"0.704788",
"0.69124776",
"0.68739474",
"0.668043",
"0.6659431",
"0.6645383",
"0.6571377",
"0.65401155",
"0.6499919",
"0.64861435",
"0.6444862",
"0.643904",
"0.6436059",
"0.6417866",
"0.6415396",
"0.6408028",
"0.6362181",
"0.6331619",
"0.63206327",
"0.63206327",
"0.6296442",
... | 0.76052755 | 0 |
Test case for downloading remote zip file and extracting contents. | def testZipUrl(self):
try:
remoteLocator = self.__zipFileUrl
# fn = self.__fileU.getFileName(remoteLocator)
ok = self.__fileU.isLocal(remoteLocator)
self.assertFalse(ok)
#
lPath = os.path.join(self.__workPath, self.__fileU.getFileName(self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(file_url, file_path):\n\n # extract file from the link\n\n if not os.path.exists(file_path):\n os.makedirs(file_path, exist_ok=True)\n \n r = requests.get(str(file_url))\n\n #unzip the zip file\n z = zipfile.ZipFile(io.BytesIO(r.content))\n z.extractall(path = file_path)",
"d... | [
"0.7220446",
"0.67840797",
"0.6767943",
"0.67551804",
"0.6672871",
"0.6658233",
"0.6643665",
"0.66261744",
"0.6577798",
"0.65612066",
"0.6509779",
"0.6480301",
"0.6463164",
"0.64614177",
"0.6453328",
"0.6448785",
"0.64273727",
"0.63947684",
"0.6382506",
"0.6374403",
"0.635807... | 0.7367263 | 0 |
Test case for downloading remote file ftp protocol and extracting contents. | def testFtpUrl(self):
try:
remoteLocator = self.__ftpFileUrl
# fn = self.__fileU.getFileName(remoteLocator)
ok = self.__fileU.isLocal(remoteLocator)
self.assertFalse(ok)
#
dirPath = os.path.join(self.__workPath, "chem_comp_models")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_download(ftp):\n # Active (PORT), Passive (PASV), ExtActive (EPRT), or ExtPassive (EPSV)?\n output, sock, transfer_type = get_transfer_output_and_socket(ftp)\n print_debug(output + \"\\n\")\n\n # What file to download?\n path = raw_input(\"What file do you want to download?\\n> \")\n while... | [
"0.6999721",
"0.67185104",
"0.66923946",
"0.66601884",
"0.65115726",
"0.64415693",
"0.63941395",
"0.6366749",
"0.63455987",
"0.630195",
"0.62936544",
"0.6291365",
"0.62748814",
"0.62570983",
"0.6231759",
"0.62223476",
"0.619586",
"0.61891216",
"0.61566657",
"0.6152847",
"0.61... | 0.70737445 | 0 |
Test case for extracting contents from xz file | def testXzFile(self):
try:
remoteLocator = self.__xzFile
fn = self.__fileU.getFileName(remoteLocator)
lPath = os.path.join(self.__workPath, fn)
ok = self.__fileU.get(remoteLocator, lPath)
self.assertTrue(ok)
ok = self.__fileU.exists(lPath)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unzip_file(self):\n\n # Path to the compressed file\n zipped_file = os.path.join(self.xmlfilepath, \"DLTINS_20210117_01of01.zip\")\n # Test for correct data\n # NOTE : For this test case to pass the source xml zipped file\n # should be present in the download path\n ... | [
"0.62932056",
"0.62829584",
"0.6257688",
"0.6187469",
"0.61508626",
"0.5973567",
"0.5958874",
"0.5951237",
"0.5783568",
"0.56802505",
"0.5677763",
"0.56722355",
"0.56672055",
"0.56611294",
"0.56451595",
"0.5629609",
"0.5598541",
"0.5586034",
"0.5574584",
"0.55610496",
"0.5551... | 0.7376655 | 0 |
Activation function of hidden layers. | def forward_hidden_activation(self, X):
return np.tanh(X) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_layer_activation(x):\n return x",
"def compute_activation(self):\r\n\r\n x=0\r\n edges=self.in_edges\r\n for edge in edges:\r\n x+= edge.source.activation*edge.weight\r\n self.activation=1/(1+exp(-x))",
"def __call__(self, inputs):\n return self._hidd... | [
"0.7260774",
"0.7122866",
"0.7001082",
"0.6929951",
"0.69202",
"0.68869704",
"0.68860483",
"0.6844513",
"0.66774213",
"0.66773957",
"0.6666057",
"0.6664862",
"0.66458833",
"0.6635408",
"0.6609628",
"0.6577476",
"0.6565831",
"0.6560835",
"0.65351784",
"0.6441285",
"0.6438028",... | 0.71660954 | 1 |
Derivative of the activation function of hidden layers. | def backward_hidden_activation(self, Y, d):
# y = tanh(x) ==> dy/dx = (1 - tanh(x)^2) = (1 - y^2)
return d * (1 - Y ** 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative_activation(z):\n return activation(z) * (1 - activation(z))",
"def gradient_hidden(self, h):\n if self.relu:\n return 1.0*(h > 0)\n else:\n return 1 - h * h",
"def sigmoid_gradient(z):\n #derivative of sigmoid\n return z * (1 - z)",
"def cost_deriva... | [
"0.7980077",
"0.6814162",
"0.6745424",
"0.67276245",
"0.6709438",
"0.6657668",
"0.66385204",
"0.66385204",
"0.66385204",
"0.66385204",
"0.66360676",
"0.6593483",
"0.6587966",
"0.65865093",
"0.65624034",
"0.6561811",
"0.6504623",
"0.6504623",
"0.6497736",
"0.6481813",
"0.64783... | 0.72875506 | 1 |
Test the gradient of the activation function. | def test_activation_gradient():
np.random.seed(7477)
cnn = CNNTanh([1, 1])
X = np.random.randn(10, 1)
Y = cnn.forward_hidden_activation(X)
eps = 1e-7
Y1 = cnn.forward_hidden_activation(X + eps)
D = cnn.backward_hidden_activation(Y, np.ones_like(Y))
D1 = (Y1 - Y) / eps
error = np.abs(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gradient_convergence(self):\n pass",
"def check_layer_gradient(layer, x, delta=1e-5, tol=1e-4):\n output = layer.forward(x)\n np.random.seed(10)\n #output_weight = np.random.randn(*output.shape)\n output_weight = np.ones_like(output)\n #print('output_weight',output_weight)\n\n d... | [
"0.71142787",
"0.70332646",
"0.6905601",
"0.6849363",
"0.6837006",
"0.68183017",
"0.6813721",
"0.676131",
"0.6752075",
"0.6721996",
"0.66837656",
"0.66234875",
"0.6619323",
"0.6608141",
"0.6590701",
"0.6554544",
"0.65324926",
"0.6527291",
"0.648666",
"0.6469905",
"0.6446868",... | 0.78597736 | 0 |
Test the gradient of the loss wrt the parameters. | def test_parameter_gradients(net, X, Y, name, p, grad_p, loss, index):
eps = 1e-7
backup = p[index]
p[index] += eps
A1 = net.forward(X)
loss1 = net.loss(Y, A1[-1])
ratio = (loss1 - loss) / eps
assert np.isclose(grad_p[index], ratio)
p[index] = backup | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_layer_gradient(layer, x, delta=1e-5, tol=1e-4):\n output = layer.forward(x)\n np.random.seed(10)\n #output_weight = np.random.randn(*output.shape)\n output_weight = np.ones_like(output)\n #print('output_weight',output_weight)\n\n def helper_func(x):\n output = layer.forward(x)\n ... | [
"0.74941343",
"0.7425341",
"0.7355039",
"0.7324828",
"0.7287194",
"0.72620076",
"0.7215311",
"0.71104115",
"0.71081114",
"0.7087239",
"0.7085801",
"0.70754427",
"0.697028",
"0.6940578",
"0.69372624",
"0.68951434",
"0.68781227",
"0.68604034",
"0.68522644",
"0.6837919",
"0.6836... | 0.7573967 | 0 |
Swaps elements A and B in a list. | def listSwapElement(lst, indexa, indexb):
temp = lst[indexa]
lst[indexa] = lst[indexb]
lst[indexb] = temp | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _swap(mylist, a, b):\n temp = mylist[a]\n mylist[a] = mylist[b]\n mylist[b] = temp",
"def swap(lst, a, b):\r\n temp = lst[a]\r\n lst[a] = lst[b]\r\n lst[b] = temp",
"def swap(self, index_a:int, index_b:int):\n if not index_a == index_b:\n self.list[index_a], self.list[in... | [
"0.74426883",
"0.72412217",
"0.7158518",
"0.70567393",
"0.67977434",
"0.6741206",
"0.67259157",
"0.6641364",
"0.653265",
"0.6483142",
"0.6444933",
"0.64251614",
"0.64234024",
"0.6352456",
"0.632575",
"0.6301343",
"0.6298016",
"0.6295743",
"0.6288338",
"0.62535304",
"0.6230418... | 0.73260695 | 1 |
Execute a list of plans, this list is returned when solving a task. | def execute_plans(robot, plans):
# make sure the robot is actually in the home position
# before executing a plan
robot.mg.set_joint_value_target(
plans[0].joint_trajectory.points[0].positions)
robot.mg.go(wait=True)
print("Moved to home, start executing task.")
# TODO quick fix, add fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def executePlans(update):\n out.header('Executing plans %r\\n' % (update))\n # Finding the functions to call is actually done by a 'iterator' like function in the plangraph module\n while(True):\n # This function either returns None or a tuple just like generate added to it\n p = update.plan... | [
"0.671764",
"0.6583761",
"0.6341465",
"0.6332959",
"0.6236808",
"0.6156332",
"0.6097737",
"0.608058",
"0.59968126",
"0.59372807",
"0.5844701",
"0.58349496",
"0.58101356",
"0.5794742",
"0.5718878",
"0.5680914",
"0.5639629",
"0.5627402",
"0.5588373",
"0.55457616",
"0.55041856",... | 0.7731418 | 1 |
Deletes a business_report from the table with the specified id | def delete_by_id(id: int) -> List:
business_report = BusinessNotificationService.get_by_id(id)
if not business_report:
return []
db.session.delete(business_report)
db.session.commit()
return [id] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_incident(self, id):\n sql = f\"DELETE FROM incidences WHERE incidences.id ={id}\"\n conn = Db().con\n curr = conn.cursor()\n curr.execute(sql)\n conn.commit()",
"def storage_delete_report(self, report_id):\n self._get_queryset(report_id=report_id).delete()",
... | [
"0.6651148",
"0.6608701",
"0.64136994",
"0.63094574",
"0.6274263",
"0.61082935",
"0.60701895",
"0.60681254",
"0.6067816",
"0.6066621",
"0.60407543",
"0.6026496",
"0.6005154",
"0.59901506",
"0.59645677",
"0.5961449",
"0.5950091",
"0.5949197",
"0.59486943",
"0.5945033",
"0.5929... | 0.69790393 | 0 |
uses list1 as the reference, returns list of items not in list2 | def list_difference(list1, list2):
diff_list = []
for item in list1:
if not item in list2:
diff_list.append(item)
return diff_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_l2_from_l1(l1, l2):\r\n return [element for element in l1 if element not in l2]",
"def list_difference(l1: List[Any], l2: List[Any]) -> List[Any]:\n return [item for item in l1 if item not in l2]",
"def list_difference(list1, list2):\r\n diff_list = []\r\n for item in list1:\r\n i... | [
"0.79822516",
"0.7981959",
"0.77709067",
"0.7688654",
"0.7456978",
"0.74536794",
"0.73608845",
"0.7324599",
"0.72618556",
"0.7249769",
"0.7235629",
"0.7190773",
"0.71434844",
"0.70034856",
"0.6966538",
"0.6920006",
"0.69053674",
"0.6897035",
"0.6892836",
"0.68181765",
"0.6813... | 0.8260505 | 0 |
Create a new SDGraphObjectFrame instance in the specified graph | def sNew(sdGraph):
outSDGraphObjectFrame = ctypes.c_void_p()
_res = sd.getContext().SDGraphObjectFrame_sNew(sdGraph.mHandle, ctypes.byref(outSDGraphObjectFrame))
if _res != SDApiError.NoError.value:
if _res == SDApiError.NoErrorOutputParamNotSet.value:
return None
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def graph_with_graph(cls, graph):\n new = cls()\n new.nx_graph = graph.nx_graph.copy()\n new.max_date = graph.max_date\n new.min_date = graph.min_date\n return new",
"def __init__(self, graph=None): # noqa: E501\n self.openapi_types = {\n 'graph': Neo4jGraphG... | [
"0.6099084",
"0.595656",
"0.5864762",
"0.5828153",
"0.5798196",
"0.57338095",
"0.5618525",
"0.5582457",
"0.5571058",
"0.5561344",
"0.5512142",
"0.54885",
"0.5407223",
"0.53947866",
"0.53532344",
"0.5335441",
"0.52873886",
"0.52579653",
"0.52570146",
"0.5252456",
"0.52443326",... | 0.70377195 | 0 |
Get the SDGraphObjectFrame title | def getTitle(self):
outValue = ctypes.c_char_p()
_res = self.mAPIContext.SDGraphObjectFrame_getTitle(self.mHandle, ctypes.byref(outValue))
if _res != SDApiError.NoError.value:
if _res == SDApiError.NoErrorOutputParamNotSet.value:
return None
raise APIExcep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def title(self):\n return self._frame._title",
"def get_title(self):\n return self.metadata['title']",
"def get_title():",
"def title(self):\n return self.container['title']",
"async def title(self):\n if not hasattr(self, \"_title\"):\n self._title = await Stack.fetc... | [
"0.7783941",
"0.7328815",
"0.726359",
"0.72170377",
"0.7165904",
"0.71523243",
"0.7066919",
"0.70472175",
"0.7046419",
"0.7003007",
"0.7003007",
"0.7003007",
"0.70027757",
"0.70027757",
"0.70027757",
"0.69826674",
"0.69338393",
"0.69271576",
"0.68917066",
"0.68917066",
"0.689... | 0.80401707 | 0 |
Get the SDGraphObjectFrame color | def getColor(self):
outValue = ColorRGBA()
_res = self.mAPIContext.SDGraphObjectFrame_getColor(self.mHandle, ctypes.byref(outValue))
if _res != SDApiError.NoError.value:
if _res == SDApiError.NoErrorOutputParamNotSet.value:
return None
raise APIException(S... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_graph_color ( self, object ):\n return self.graph_color_",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def getColor(self):\r\n ... | [
"0.76436764",
"0.713944",
"0.713944",
"0.713944",
"0.713944",
"0.7060627",
"0.7057942",
"0.70264846",
"0.7010687",
"0.6968809",
"0.6927457",
"0.69249076",
"0.68727857",
"0.6870275",
"0.6870275",
"0.68354243",
"0.68354243",
"0.68354243",
"0.6835348",
"0.6824584",
"0.6767909",
... | 0.765588 | 0 |
Set the SDGraphObjectFrame color | def setColor(self, value):
_res = self.mAPIContext.SDGraphObjectFrame_setColor(self.mHandle, ctypes.byref(value))
if _res != SDApiError.NoError.value:
if _res == SDApiError.NoErrorOutputParamNotSet.value:
return None
raise APIException(SDApiError(_res))
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_color(self, color):\n\t\tpass",
"def set_color(self, color):\n pass",
"def set_color(self, new_color):\n self.color = new_color",
"def colorFrame(self, _color):\n\t\tif self.frame:\n\t\t\tfor nr, i in enumerate(self.frame):\n\t\t\t\tself.frame[nr][1] = _color",
"def colorFrame(sel... | [
"0.70018196",
"0.6966884",
"0.68272316",
"0.6800456",
"0.6800456",
"0.6735271",
"0.6730594",
"0.67269",
"0.6688919",
"0.6627748",
"0.6626664",
"0.6562067",
"0.65328383",
"0.64631224",
"0.6437765",
"0.6426548",
"0.6391508",
"0.6391476",
"0.6377652",
"0.62837225",
"0.6264317",
... | 0.785959 | 0 |
Get the SDGraphObjectFrame size | def getSize(self):
outSize = float2()
_res = self.mAPIContext.SDGraphObjectFrame_getSize(self.mHandle, ctypes.byref(outSize))
if _res != SDApiError.NoError.value:
if _res == SDApiError.NoErrorOutputParamNotSet.value:
return None
raise APIException(SDApiErr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSize(self):\n\n return self.size",
"def getSize(self):\n return GDimension(frameWidth, frameHeight)",
"def getSize(self):\r\n return self.size",
"def getFrameSize(self):\n \n return self.frame_size",
"def getSize(self):\n return self.size",
"def fl_get_objec... | [
"0.7424616",
"0.74093646",
"0.7397733",
"0.73387116",
"0.7282922",
"0.7269103",
"0.7247958",
"0.7237671",
"0.72307",
"0.72290355",
"0.7214162",
"0.72126585",
"0.72106576",
"0.71800494",
"0.7156522",
"0.7156451",
"0.715393",
"0.715393",
"0.715393",
"0.7151215",
"0.71424764",
... | 0.82977587 | 0 |
Set the SDGraphObjectFrame size | def setSize(self, value):
_res = self.mAPIContext.SDGraphObjectFrame_setSize(self.mHandle, ctypes.byref(value))
if _res != SDApiError.NoError.value:
if _res == SDApiError.NoErrorOutputParamNotSet.value:
return None
raise APIException(SDApiError(_res))
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setFrameSize(self, frame_size):\n \n self.frame_size = frame_size",
"def set_size(self, size):\n self.dtSize = size",
"def set_size(self, size):\n \n self.width = size[0]\n self.height = size[1]",
"def setDescriptorSize(self, dsize): # real signature unknown; res... | [
"0.7229462",
"0.71947026",
"0.7075671",
"0.70734507",
"0.7000243",
"0.6931248",
"0.6931248",
"0.6877675",
"0.6803384",
"0.6802796",
"0.6758983",
"0.67472947",
"0.656778",
"0.6560254",
"0.6538937",
"0.64847857",
"0.64384997",
"0.6386987",
"0.63508207",
"0.63508207",
"0.6350820... | 0.7277744 | 0 |
Test working ssdp flow. | async def test_flow_ssdp(hass):
result = await hass.config_entries.flow.async_init(
DOMAIN, context={"source": SOURCE_SSDP}, data=SSDP_DATA,
)
assert result["type"] == "form"
assert result["step_id"] == "init"
assert result["description_placeholders"] == {
CONF_NAME: FRIENDLY_NAME,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_flow_ssdp_discovery(opp, aioclient_mock):\n result = await opp.config_entries.flow.async_init(\n DECONZ_DOMAIN,\n data={\n ATTR_SSDP_LOCATION: \"http://1.2.3.4:80/\",\n ATTR_UPNP_MANUFACTURER_URL: DECONZ_MANUFACTURERURL,\n ATTR_UPNP_SERIAL: BRIDGEID,... | [
"0.69209915",
"0.6228882",
"0.6222382",
"0.62218183",
"0.6128936",
"0.6066502",
"0.6031052",
"0.5905359",
"0.58518237",
"0.5829707",
"0.5796335",
"0.5789207",
"0.5749608",
"0.5732316",
"0.5731994",
"0.57290465",
"0.57289624",
"0.57172656",
"0.5697027",
"0.56848615",
"0.568139... | 0.7182019 | 0 |
Compile a model of URI's and Curies and then test the various types | def test_uri_and_curie(self):
self.single_file_generator('py', PythonGenerator, filtr=metadata_filter,
comparator=lambda exp, act: compare_python(exp, act, self.env.expected_path('foo.py')))
# Check that the interpretations are correct
self.single_file_generat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_resnet18():\n model = RestNet18()\n assert type(model) == RestNet18",
"def __init__(self, model_uri: str = None, method: str = \"predict\", modelUri: str = None, type: str = None):\n super().__init__()\n print(model_uri, modelUri, type)\n self.model_uri = model_uri\n self.method = met... | [
"0.57247853",
"0.56253564",
"0.54596573",
"0.535612",
"0.53386253",
"0.52941513",
"0.5280008",
"0.5215472",
"0.509851",
"0.5070356",
"0.50533646",
"0.49833405",
"0.49626672",
"0.49501526",
"0.49251255",
"0.49251255",
"0.49180833",
"0.49138975",
"0.4904311",
"0.49033374",
"0.4... | 0.67043126 | 0 |
Splits document text into a list of sentences, given some model. | def get_sentences_list(text: str, model_type: str) -> t.List[str]:
sentences = []
sent_offsets = []
stok = SentenceTokenizer.from_type(model_type)
if isinstance(text, list):
sentences, sent_offsets = list(zip(*map(stok.tokenize, text)))
elif isinstance(text, str):
sentences, sent_off... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(text):\n doc = nlp(text)\n sentences = [x.text_with_ws for x in doc.sents]\n return sentences",
"def get_sentences(text):\n \n return text.split('.')",
"def sentence_split(self, text):\n return split_into_sentences(text)",
"def split_sentences(self, text):\n ... | [
"0.7736216",
"0.7252213",
"0.7082826",
"0.70524997",
"0.6805155",
"0.67981815",
"0.6738876",
"0.6737422",
"0.67177343",
"0.6689931",
"0.666789",
"0.66164446",
"0.65894055",
"0.6582415",
"0.6578306",
"0.655155",
"0.65042615",
"0.6432492",
"0.641784",
"0.638252",
"0.638045",
... | 0.75723946 | 1 |
creates a vertical line in the diagram, reaching from the xaxis to the plot at a given time t | def create_time_line(self, axes, t, y, time_value, label):
# don't create lines on the very left
if time_value == t[-1]:
return
# create timeLine
time_line = Line2D([time_value, time_value],
[np.min(y), y[t.index(time_value)]],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertical_line(t, n):\n lt(t)\n fd(t,n)\n rt(t)",
"def plotvertlines(self, ax, time, color='k', label=None):\n if isinstance(time, list):\n t = time.pop()\n ax = self.plotvertlines(ax, t, color=color)\n\n # plot vertical lines of 'predicted' onset/offset\n a... | [
"0.68938607",
"0.6757993",
"0.64868546",
"0.6453914",
"0.6393406",
"0.63680446",
"0.6361839",
"0.6274058",
"0.62633324",
"0.61774045",
"0.6162524",
"0.61366385",
"0.61149967",
"0.604295",
"0.5982257",
"0.59538084",
"0.5947142",
"0.59383583",
"0.5909579",
"0.5906619",
"0.58933... | 0.7260301 | 0 |
Generate a coordinate moved by the provided `shift` parameters from the current Coordinate. | def move_to(self, shift: Move) -> Coordinate:
if shift.direction == "U":
new_coordinate = Coordinate(x=self.x, y=self.y + shift.dist)
elif shift.direction == "D":
new_coordinate = Coordinate(x=self.x, y=self.y - shift.dist)
elif shift.direction == "L":
new_coo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shifted(self, shift):\n new_location = None if self.location is None else self.location + shift\n reference = None if self.reference is None else self.reference + shift\n return self.copy_with_changes(\n location=new_location, reference=reference, derived_from=self,\n )",... | [
"0.70026237",
"0.6079565",
"0.59989953",
"0.5997494",
"0.59189904",
"0.58717406",
"0.5802957",
"0.57956624",
"0.5785818",
"0.5776062",
"0.573016",
"0.5704016",
"0.5698707",
"0.56430995",
"0.56295216",
"0.5617708",
"0.5577262",
"0.5573564",
"0.553183",
"0.54844093",
"0.5453127... | 0.7632833 | 0 |
Return True if segments share start & end points, accounting for flipping. | def __eq__(self, other: Segment) -> bool:
return any(
(
self.start == other.start and self.end == other.end,
self.start == other.end and self.end == other.start,
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def does_overlap(self, start, stop):\n\n ranges = [list(range(key, self.map[key] + 1)) for key in self.map]\n all_coords = [item for sublist in ranges for item in sublist]\n # removing all_coords implementation until we write some tests\n for i in range(start, stop + 1):\n if... | [
"0.6702536",
"0.6660691",
"0.65623313",
"0.65462446",
"0.6517798",
"0.6488373",
"0.64770776",
"0.6293366",
"0.62791336",
"0.62655747",
"0.62616754",
"0.62436944",
"0.6191759",
"0.6159941",
"0.6140473",
"0.6125066",
"0.6124695",
"0.60969627",
"0.60839266",
"0.607093",
"0.60593... | 0.6908634 | 0 |
Wire a segment from the end of the current Segment using the provides `shift`. | def wire_to(self, shift: Move) -> Segment:
return Segment(self.end, self.end.move_to(shift)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shift(self, shift_vec: np.ndarray) -> None:\n if len(shift_vec) != 3:\n raise ValueError(\"`shift_vec` must be a three dimensional vector\")\n shift = np.argmax(shift_vec) - 1\n self._head += shift\n if self._head < 0:\n new_buffer = np.zeros_like(self._buffer)... | [
"0.59277046",
"0.5857198",
"0.5500183",
"0.5026484",
"0.50250506",
"0.49946907",
"0.49946907",
"0.49397922",
"0.49365884",
"0.49150783",
"0.4914794",
"0.49120414",
"0.49022216",
"0.48939252",
"0.48647368",
"0.48530436",
"0.48466676",
"0.48441014",
"0.48221606",
"0.4820676",
"... | 0.7589725 | 0 |
Build wire segments from the internal wiring diagram. | def build_wires(self) -> List[Segment]:
segments = [Segment(self.ORIGIN, self.ORIGIN.move_to(self._diagram[0]))]
for step in self._diagram[1:]:
segments.append(segments[-1].wire_to(step))
return segments | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_segments(self):\n for strand in self.strand_list:\n strand.construct_segment()",
"def generate(self, diagram):",
"def build_microtrips(self, segment_lenght):\n seg_count = 0\n for data in self.clean_data:\n seg_count = data.segment_all(segment_lenght, se... | [
"0.627155",
"0.5714515",
"0.5531439",
"0.53391623",
"0.5144474",
"0.5128602",
"0.5128105",
"0.5107117",
"0.5049788",
"0.50365037",
"0.50336444",
"0.50184613",
"0.500898",
"0.49955854",
"0.4993949",
"0.49708354",
"0.4966822",
"0.49333",
"0.49315196",
"0.49184826",
"0.4903525",... | 0.7345104 | 0 |
Find the closest intersection to the origin, by Manahattan distance, of two Wires. | def closest_intersect_manhattan(self, other: Wire) -> Tuple[Coordinate, int]:
intersection = sorted(self.intersect(other), key=lambda x: self.ORIGIN.dist(x.location))[0]
return intersection, self.ORIGIN.dist(intersection.location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def findIntersect(wires):\n allSets = list(map(lambda w: coordsFor(w), wires))\n baseSet = allSets[0]\n for s in allSets[1:]:\n baseSet.intersection_update(s)\n central = (0, 0)\n distances = list(map(lambda c: manhattan(central, c), baseSet))\n return min(distances)",
"def get_closest_i... | [
"0.73668647",
"0.71624225",
"0.6995059",
"0.688957",
"0.6259799",
"0.6222615",
"0.6161806",
"0.6148054",
"0.5992006",
"0.5981919",
"0.5977006",
"0.59560627",
"0.59306633",
"0.59270483",
"0.59255",
"0.5852488",
"0.58326423",
"0.5826113",
"0.58249897",
"0.5812551",
"0.5808463",... | 0.78951204 | 0 |
Find the closest intersection to the origin, by step distance, of two Wires. | def closest_intersect_steps(self, other: Wire) -> Tuple[Intersection, int]:
intersections = self.intersect(other)
# For each intersection, iterate along each wire's path until the intersection is
# encountered, keeping track of the number of steps taken
distances = []
for inters... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_closest_intersection(wire1, wire2):\n pass",
"def findIntersect(wires):\n allSets = list(map(lambda w: coordsFor(w), wires))\n baseSet = allSets[0]\n for s in allSets[1:]:\n baseSet.intersection_update(s)\n central = (0, 0)\n distances = list(map(lambda c: manhattan(central, c), ... | [
"0.7209214",
"0.63660127",
"0.62385994",
"0.6171734",
"0.59056085",
"0.5888943",
"0.5881519",
"0.586255",
"0.5790623",
"0.5756521",
"0.57293314",
"0.57029945",
"0.5671344",
"0.5662922",
"0.56311053",
"0.56151825",
"0.5565326",
"0.55585504",
"0.5547729",
"0.55357975",
"0.55354... | 0.7036371 | 1 |
Parse the input wiring diagram into a list of Move named tuples. Wiring diagrams are assumed to be of the form "R8,U15,L5,D23" | def _parse_diagram(wiring_diagram: str) -> List[Move]:
return [
Move(direction=shift[0], dist=int(shift[1:])) for shift in wiring_diagram.split(",")
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parse_move_line(self, line):\n parts = re.sub('\\(.*?\\)', '', line).split()\n x, y = None, None\n for part in parts[:0:-1]:\n axis = part.upper()[0]\n value = float(part[1:])\n if axis in ['Z', 'F']:\n parts.remove(part)\n elif ... | [
"0.62569845",
"0.6113737",
"0.60215795",
"0.6006309",
"0.5862436",
"0.5765197",
"0.5751924",
"0.5724444",
"0.5700855",
"0.5651036",
"0.562076",
"0.5336469",
"0.52793014",
"0.5259579",
"0.5231833",
"0.51468825",
"0.5125433",
"0.5125381",
"0.5124578",
"0.5118541",
"0.51147455",... | 0.7860054 | 0 |
Simulates a smooth mouse drag | def drag(source, dest, speed=1000):
m = PyMouse()
m.press(*source)
time.sleep(0.1)
# number of intermediate movements to make for our given speed
npoints = int(sqrt((dest[0]-source[0])**2 + (dest[1]-source[1])**2 ) / (speed/1000))
for i in range(npoints):
x = int(source[0] + ((dest[0]-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mouseDragged():\n if mousePressed:\n mousePressed()",
"def mouseDragged(self, point, delta):\n pass",
"def _on_mouse(self, event):\n x, y = event.GetPosition()\n if self._drag_mode == DepthCanvas.SASH_DRAG_NONE: \n self._canvas_hit_test(x, y) \n ... | [
"0.6801119",
"0.664212",
"0.6326401",
"0.6171946",
"0.6171946",
"0.6129287",
"0.6114349",
"0.5991088",
"0.5924613",
"0.58440715",
"0.58440715",
"0.58381003",
"0.58319557",
"0.58042",
"0.5794935",
"0.57604647",
"0.57600874",
"0.5743456",
"0.57369435",
"0.572792",
"0.5670328",
... | 0.6645221 | 1 |
Simulates a mouse double click | def doubleclick(point):
m = PyMouse()
m.press(*point)
m.release(*point)
m.press(*point)
m.release(*point) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mouse_click(self,x,y,button,double_click):\n raise NotImplementedError(\"ERROR: Unimplemented function.\")",
"def double_click(self, *args):\n return _ida_hexrays.Hexrays_Hooks_double_click(self, *args)",
"def double_clicked(mouse):\n global state, current_action\n\n smallest_el... | [
"0.7985254",
"0.7950458",
"0.7732801",
"0.759767",
"0.7337703",
"0.723603",
"0.7195858",
"0.69655806",
"0.6576329",
"0.64840645",
"0.6409206",
"0.63825154",
"0.62824076",
"0.6248159",
"0.6243938",
"0.6222214",
"0.62110955",
"0.61339504",
"0.61338806",
"0.6060498",
"0.6041223"... | 0.81779 | 0 |
Stimulates typing a string of characters | def type_msg(string):
k = PyKeyboard()
k.type_string(string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def characters(self, data):\n pass",
"def type_out(text):\n disable_typing.start()\n text = text + \"\\n\"\n for c in text:\n sys.stdout.write(c)\n sys.stdout.flush()\n time.sleep(0.01)\n disable_typing.stop()",
"def _type_text(text):\n FlaUIKeyboard.Type(str(text... | [
"0.57233626",
"0.57059294",
"0.5684674",
"0.5682626",
"0.5663008",
"0.564662",
"0.5634049",
"0.56116927",
"0.55977404",
"0.5592762",
"0.55882055",
"0.5541043",
"0.547264",
"0.5471724",
"0.5471444",
"0.54415923",
"0.53935754",
"0.53798544",
"0.53640604",
"0.53581715",
"0.53409... | 0.5819586 | 0 |
Simulates a mouse wheel movement | def wheel(ticks):
m = PyMouse()
m.scroll(ticks) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ev_mousewheel(self, event: MouseWheel) -> None:",
"def on_mouse_wheel(self, e): # pragma: no cover\n super(TraceView, self).on_mouse_wheel(e)\n if e.modifiers == ('Alt',):\n start, end = self._interval\n delay = e.delta * (end - start) * .1\n self.shift(-delay)... | [
"0.70724034",
"0.6867929",
"0.6845834",
"0.6725395",
"0.6706772",
"0.66839576",
"0.66106194",
"0.64879376",
"0.6433302",
"0.6428224",
"0.6424929",
"0.63497424",
"0.6329097",
"0.62871855",
"0.62500674",
"0.62429804",
"0.62024975",
"0.61738163",
"0.6163825",
"0.6155793",
"0.613... | 0.79435927 | 0 |
Compresses a byte array with the xz binary | def compress(value):
process = Popen(["xz", "--compress", "--force"], stdin=PIPE, stdout=PIPE)
return process.communicate(value)[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_byte(byte_array, index):\n\n if byte_array[index] == 0:\n changed_byte_array = byte_array[0:index] + b\"\\xff\" + byte_array[index + 1 :]\n changed_byte_array = byte_array[0:index] + b\"\\x00\" + byte_array[index + 1 :]\n return changed_byte_array",
"def test_compress_2(self):\n t... | [
"0.5709028",
"0.56780964",
"0.5647832",
"0.5616013",
"0.56071866",
"0.55910605",
"0.55739576",
"0.55164623",
"0.5504677",
"0.5499852",
"0.5489234",
"0.5489234",
"0.5486275",
"0.5466205",
"0.54346704",
"0.54300076",
"0.540067",
"0.53756106",
"0.53609854",
"0.53576124",
"0.5354... | 0.5999412 | 1 |
Compress the file at 'path' with the xz binary | def compress_file(path):
process = Popen(["xz", "--compress", "--force", "--stdout", path], stdout=PIPE)
return process.communicate()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zip_file(file_path: str) -> str:\n zip_file_path: str = file_path + \".gz\"\n\n print(f\"Compressing {file_path} into {zip_file_path}\")\n timestamp=path.getmtime(file_path)\n with open(file_path, \"rb\") as read_stream:\n with gzip.open(zip_file_path, \"wb\") as write_stream:\n s... | [
"0.7248893",
"0.6594647",
"0.6594647",
"0.64348674",
"0.64283776",
"0.6283818",
"0.62432826",
"0.6221492",
"0.6214257",
"0.6159141",
"0.6146967",
"0.6120605",
"0.6105703",
"0.60970914",
"0.6093049",
"0.6085339",
"0.6084827",
"0.6059032",
"0.6022121",
"0.60189515",
"0.59890485... | 0.7983229 | 1 |
Shows a specific plane within 3D data. | def show_plane(axis, plane, cmap="gray", title=None):
axis.imshow(plane, cmap=cmap)
axis.set_xticks([])
axis.set_yticks([])
if title:
axis.set_title(title)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_plane(unit_normal, x_array, y_array, fore):\n # print'unit normal = ', unit_normal\n z = (((unit_normal[0] * (fore[0] - x_array)) + (unit_normal[1] * (fore[1] - y_array))) / unit_normal[2]) + fore[2]\n # print 'plane numbers\\n', z\n return z",
"def plane(self):\r\n from lsst.analysis... | [
"0.6780227",
"0.666365",
"0.6577502",
"0.6563549",
"0.63409144",
"0.624834",
"0.6219757",
"0.6199828",
"0.6173089",
"0.6126187",
"0.6115501",
"0.6100461",
"0.6099733",
"0.6040154",
"0.6024716",
"0.6006487",
"0.5987519",
"0.59277785",
"0.5921929",
"0.5920941",
"0.5902615",
"... | 0.67553663 | 1 |
Allows to explore 2D slices in 3D data. | def slice_explorer(data, cmap='gray'):
data_len = len(data)
@interact(plane=(0, data_len-1), continuous_update=False)
def display_slice(plane=data_len/2):
fig, axis = plt.subplots(figsize=(20, 7))
axis_3d = fig.add_subplot(133, projection='3d')
show_plane(axis, data[plane], title='P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def take_slice(img_3D, view):\n input_type = isinstance(img_3D, np.ndarray)\n if input_type:\n img_3D = [img_3D]\n img_shape = img_3D[0].shape\n if view == \"sag\":\n slice_pos = np.random.randint(int(0.2 * img_shape[0]), int(0.8 * img_shape[0]))\n imgs_2D = [imgg_3D[slice_pos, :, ... | [
"0.7107621",
"0.6738053",
"0.6709929",
"0.6706025",
"0.6513878",
"0.64924455",
"0.6423735",
"0.63151467",
"0.63149804",
"0.6307343",
"0.62615204",
"0.6126598",
"0.6090667",
"0.607543",
"0.6070433",
"0.60660744",
"0.60097694",
"0.6005962",
"0.5995597",
"0.597353",
"0.59621847"... | 0.7134606 | 0 |
Generates a 3D surface plot for the specified region. | def plot_3d_surface(data, labels, region=3, spacing=(1.0, 1.0, 1.0)):
properties = measure.regionprops(labels, intensity_image=data)
# skimage.measure.marching_cubes expects ordering (row, col, plane).
# We need to transpose the data:
volume = (labels == properties[region].label).transpose(1, 2, 0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_surface(self):\n X, Y = np.meshgrid(self.x, self.y)\n fig = plt.figure()\n ax = fig.add_subplot(111, projection='3d')\n ax.plot_surface(X=X, Y=Y, Z=self.z)\n plt.show()",
"def plot3d(data):\n assert span1 == span2\n span = span1\n # ---------------------- crea... | [
"0.6976554",
"0.68625677",
"0.6843619",
"0.6560246",
"0.6512885",
"0.6510929",
"0.6456214",
"0.63602376",
"0.63443196",
"0.63097036",
"0.6258106",
"0.62344956",
"0.61818576",
"0.61670333",
"0.61499923",
"0.6146061",
"0.6144096",
"0.61362255",
"0.60683507",
"0.60314703",
"0.60... | 0.7583633 | 0 |
Connect current container to the environment containers network. | def connect_to_containers_network():
logging.info("Connecting to the environment network")
container_id = get_current_container_id()
subprocess.check_output(
'docker network connect subsystem_tests-network {container_id}'.format(container_id=container_id),
shell=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self, container_name: str, aliases: list[str] = None,\n ipv4: str | None = None) -> None:\n self.log.debug(\n f\"Connecting {container_name} to network '{self.network_name}'\")\n self.network.connect(\n container_name, aliases=aliases, ipv4_address=ipv... | [
"0.68715274",
"0.6033247",
"0.5958551",
"0.5952797",
"0.5917014",
"0.5764563",
"0.57549083",
"0.57498366",
"0.57448465",
"0.573062",
"0.57062066",
"0.5695735",
"0.5688441",
"0.5684623",
"0.56554174",
"0.56166863",
"0.56042194",
"0.5562665",
"0.5559789",
"0.5551756",
"0.552874... | 0.83500123 | 0 |
Overrides Die.roll() so that in addition to rolling the dice, it sets the die's value based on the currentValue. | def roll(self):
self.currentValue = choice(self.possibleValues)
self.value = AngryDie.ANGRY_VALUES[self.currentValue]
return self.currentValue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll_dice(self):\n self.roll = (random.randint(1,6), random.randint(1,6))\n return self.roll",
"def roll(self):\n #dieValue = [] \n self._value = random.randrange(Die.SIDES) + 1\n self._update()\n #dieValue.append(self._value)\n #print(dieValue)\n #p... | [
"0.72756755",
"0.72380686",
"0.71869373",
"0.71206564",
"0.70240617",
"0.69059175",
"0.68994266",
"0.685288",
"0.682175",
"0.67554736",
"0.66809267",
"0.66572595",
"0.66572595",
"0.6561393",
"0.64926106",
"0.6468559",
"0.6467723",
"0.6460948",
"0.64546245",
"0.64188683",
"0.6... | 0.7436479 | 0 |
A helper method that, given a valid faceValue, will update the die's currentValue and value to match the passed faceValue. | def setDieFaceValue(self, faceValue):
if faceValue in AngryDie.ANGRY_VALUES:
self.currentValue = faceValue
self.value = AngryDie.ANGRY_VALUES[faceValue] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setFace(self, value):\n self.face = value",
"def setFace(self, value):\n self.face = value",
"def test_currentValue_is_updated_to_roll_value(self):\n rolled_value = self.new_die.roll()\n if rolled_value == self.new_die.currentValue:\n self.assertTrue(True, \"currentVa... | [
"0.568083",
"0.568083",
"0.5458344",
"0.54526615",
"0.52289414",
"0.5217452",
"0.5184717",
"0.5160611",
"0.51151603",
"0.511195",
"0.50905704",
"0.506557",
"0.50020486",
"0.49880826",
"0.49478003",
"0.49093857",
"0.4904442",
"0.48498568",
"0.48484898",
"0.4839955",
"0.4830702... | 0.81279725 | 0 |
Roll the dice passed in the list. | def roll_the_dice(self, dice):
if type(dice) == list:
for die in dice:
die.roll() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll(dice):\n rolled_dice = []\n for die in dice[1]:\n rolled_dice.append(randint(1, CUBE_DICE_MAX_VALUE()))\n dice[1] = rolled_dice\n return dice",
"def roll_the_dice(self, index):\n # first roll\n first_roll_result = self._rolls_list[index].roll_dice()\n print(f'FIRS... | [
"0.78297305",
"0.76451164",
"0.76148355",
"0.7406287",
"0.73938185",
"0.73751354",
"0.7322575",
"0.7311594",
"0.7302911",
"0.72434473",
"0.7187141",
"0.71589607",
"0.7152758",
"0.71263856",
"0.7106611",
"0.7098338",
"0.7085768",
"0.70856994",
"0.7061517",
"0.70429206",
"0.704... | 0.8384107 | 0 |
Print both die values, as well as the current stage. | def print_dice(self):
stage_to_print = 3 if self.current_stage == 4 else self.current_stage
print("You rolled:\n a = [ {} ]\n b = [ {} ]\n\nYou are in Stage {}"
.format(self.die_a, self.die_b, stage_to_print)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_current_dice(self):\n print(\"You rolled:\\n a = [ {} ]\\n b = [ {} ]\\n\".\n format(self.die_a, self.die_b))",
"def print_hand(self):\n if self.cheating:\n print(\"You're cheating!\")\n print(\"until you reroll it!\")\n print(\"\"\"\nYo... | [
"0.6175284",
"0.5993719",
"0.5895301",
"0.5708749",
"0.56729364",
"0.5624648",
"0.5600944",
"0.55977625",
"0.55730206",
"0.5530365",
"0.5493459",
"0.5430469",
"0.538948",
"0.53874636",
"0.5384385",
"0.53282684",
"0.52871954",
"0.5283577",
"0.527334",
"0.52729154",
"0.5268641"... | 0.7377811 | 0 |
Prompt the user for input, and return the dice they want to roll. | def determine_roll(self):
dice_to_roll = []
to_roll = input("Roll dice: ")
if 'a' in to_roll:
dice_to_roll.append(self.die_a)
if 'b' in to_roll:
dice_to_roll.append(self.die_b)
return dice_to_roll | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll_dice(player: int) -> int:\n sides = 6\n roll_again = input(\"Player {}: Press ENTER to roll your dice...\".format(player))\n num_rolled = roll(sides)\n print(\"You rolled {}.\".format(num_rolled))\n return num_rolled",
"def dice_roller():\n\n print('Use the xDy+z format to roll the dic... | [
"0.75145817",
"0.73645425",
"0.73168164",
"0.71421844",
"0.71233743",
"0.7100476",
"0.70834786",
"0.7075699",
"0.7033684",
"0.70306945",
"0.70136887",
"0.7012352",
"0.692733",
"0.6923469",
"0.68955934",
"0.6895005",
"0.6886274",
"0.68699884",
"0.6821573",
"0.6815672",
"0.6813... | 0.75796336 | 0 |
Check the state of the game and if conditions are met to advance the player to the next stage. | def check_stage(self):
#Initalize target and goal_stage to stage1 values
target = 3
goal_stage = 2
# Set target and goal_stage if current stage is not 1
if self.current_stage == 2:
target = 7
goal_stage = 3
elif self.current_stage == 3:
target = 11
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance_check(self):\n values = [self.die_a.value, self.die_b.value]\n if self.stage == 3:\n if not self.cheating and \"5\" in values and \"6\" in values:\n return True\n if self.stage == 2 and \"ANGRY\" in values and \"4\" in values:\n self.stage = 3\n... | [
"0.6904773",
"0.680145",
"0.6782129",
"0.6746176",
"0.672846",
"0.67035085",
"0.6647363",
"0.66338056",
"0.660885",
"0.65491366",
"0.6462665",
"0.6453733",
"0.6429156",
"0.6387714",
"0.63038003",
"0.62731713",
"0.62604964",
"0.6260225",
"0.621723",
"0.62048525",
"0.6200238",
... | 0.7219316 | 0 |
Checks to see if both dice are Angry, if so, sets current_stage to 1 | def check_angry(self):
if self.die_a.value == 3 and self.die_b.value == 3:
print("WOW, you're ANGRY!\nTime to go back to Stage 1!")
self.current_stage = 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_angry_dice(self):\n if self.die_a.current_value == \"ANGRY\" and self.die_b.current_value == \"ANGRY\":\n print(\"WOW, you're ANGRY!\\nTime to go back to Stage 1!\")\n self.game_stage = 1",
"def check_stage(self):\n\n #Initalize target and goal_stage to stage1 values\... | [
"0.7947746",
"0.68952584",
"0.67912954",
"0.66577834",
"0.657209",
"0.65228903",
"0.6070311",
"0.6039068",
"0.5986948",
"0.58281",
"0.57704735",
"0.5715772",
"0.5712143",
"0.5680398",
"0.56088614",
"0.5588602",
"0.55773765",
"0.5547491",
"0.55223674",
"0.5517609",
"0.5482465"... | 0.74593896 | 1 |
In Stage 3, they can only hold a 5 valued die. If they hold a 6, they'll be found cheating and thus, cannot win, or advance to the next stage. | def check_cheating(self, dice=[]):
#Assume they're not cheating until proven guilty
self.cheating = False
if self.current_stage == 3:
if self.die_a not in dice and (self.die_a.value == 6):
print("You're cheating! You cannot lock a 6! You cannot win "
"until you... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance_check(self):\n values = [self.die_a.value, self.die_b.value]\n if self.stage == 3:\n if not self.cheating and \"5\" in values and \"6\" in values:\n return True\n if self.stage == 2 and \"ANGRY\" in values and \"4\" in values:\n self.stage = 3\n... | [
"0.7061071",
"0.6833772",
"0.6340773",
"0.63359606",
"0.6290116",
"0.628443",
"0.6203253",
"0.6173044",
"0.6135499",
"0.61070085",
"0.61038446",
"0.60700893",
"0.6055959",
"0.60029256",
"0.59974277",
"0.5941838",
"0.5928955",
"0.59277576",
"0.590705",
"0.5904662",
"0.5890709"... | 0.7265603 | 0 |
This function locates all nearby cities within num_hops from the given city. It maintains a set of all the cities visited from the starting city at each hop. After completion, it removes the original city from the list of results | def find_nearby_cities(graph: TeleportGraph, city: str, num_hops: int = 1) -> set:
if num_hops == 0:
return set()
start_city_node = graph.find_city_node(city)
city_nodes = {start_city_node}
for i in range(num_hops):
related_cities = set()
# for every city in the current set,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def FindDHopCities(self, X, d):\n # G = nx.Graph()\n # G.add_nodes_from(self.nodes)\n # G.add_edges_from(self.edges)\n\n # airports_id_in_city = self.airports.loc[self.airports['city'] == X, 'airport_id'].to_list()\n\n # cities_h_hop = set()\n # for airport in airports_id_... | [
"0.6298028",
"0.60487",
"0.58636826",
"0.58009905",
"0.558688",
"0.5529587",
"0.5491075",
"0.54383576",
"0.54128426",
"0.5362866",
"0.5285198",
"0.5187931",
"0.5150512",
"0.5140834",
"0.5108585",
"0.5091598",
"0.506311",
"0.5040769",
"0.503374",
"0.4991658",
"0.49839562",
"... | 0.73122805 | 0 |
This function determines if two cities can be reached in the graph. This algorithm uses a breadthfirst search approach | def does_route_exist(graph: TeleportGraph, start_city: str, end_city: str) -> bool:
queue = Queue()
start_city_node = graph.find_city_node(start_city)
queue.put(start_city_node)
# keep track of the nodes we've visited - if we do not do this, we'll wind up in an infinite loop because since
# we're ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def are_connected(self, person1, person2):\n\n possible_nodes = Queue()\n seen = set()\n possible_nodes.enqueue(person1)\n seen.add(person1)\n\n while not possible_nodes.is_empty():\n person = possible_nodes.dequeue()\n print(\"checking\", person)\n ... | [
"0.67384744",
"0.6349388",
"0.63051564",
"0.6257954",
"0.6152257",
"0.6132436",
"0.6108083",
"0.60494477",
"0.60445905",
"0.59779936",
"0.59365493",
"0.5929931",
"0.59287775",
"0.5921574",
"0.58920145",
"0.58911324",
"0.58680403",
"0.5858796",
"0.58010995",
"0.57815397",
"0.5... | 0.67146933 | 1 |
Takes a list of words as input and returns a list of the n most frequently occurring words ordered from most to least frequently occurring. | def get_top_n_words(word_list, n):
#Uses Counter function to create tuples of words and number of instances of word
wordCount = Counter(word_list)
topWords = []
orderedByFrequency = sorted(wordCount, key=wordCount.get, reverse=True)
#create list of inputted 'n' top words
for i in range (0 , n):
topWords.app... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_top_n_words(word_list, n):\n d = dict()\n for w in word_list:\n d[w] = d.get(w, 0) + 1\n ordered_by_frequency = sorted(d, key=d.get, reverse=True)\n return ordered_by_frequency[0:n]",
"def get_top_n_words(word_list, n):\n word_counts = dict()\n\n for word in word_list:\n f... | [
"0.83019364",
"0.8259304",
"0.82464784",
"0.8063228",
"0.8041614",
"0.7969055",
"0.79085237",
"0.78822184",
"0.77217156",
"0.7661636",
"0.7626515",
"0.75896144",
"0.755189",
"0.7525962",
"0.748399",
"0.7470999",
"0.7364696",
"0.71175003",
"0.70950264",
"0.70950264",
"0.706640... | 0.8294504 | 1 |
Convert hex colorrange to RGBA. | def hex2rgba(colors):
if 'str' in str(type(colors)):
colors = np.array([colors])
rgbcolors = list(map(lambda x: matplotlib.colors.to_rgba(x), colors))
return np.array(rgbcolors) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hex_to_rgba(h, alpha):\n return tuple([int(h.lstrip('#')[i:i + 2], 16) for i in (0, 2, 4)] + [alpha])",
"def normalize_rgb_colors_to_hex(css):\n log.debug(\"Converting all rgba to hexadecimal color values.\")\n regex = re.compile(r\"rgb\\s*\\(\\s*([0-9,\\s]+)\\s*\\)\")\n match = regex.search(css)... | [
"0.74167764",
"0.70776886",
"0.6812988",
"0.6806883",
"0.66850585",
"0.66562873",
"0.66246355",
"0.66192836",
"0.6602443",
"0.6597313",
"0.6596636",
"0.65546227",
"0.65298957",
"0.6514845",
"0.6510283",
"0.65088314",
"0.64748806",
"0.6454721",
"0.6445255",
"0.64353675",
"0.64... | 0.71970624 | 1 |
Generate colors from input list. This function creates unique colors based on the input list y and the cmap. When the gradient hex color is defined, such as '000000', a gradient coloring space is created between two colors. The start color of the particular y, using the cmap and The end color is the defined gradient, s... | def fromlist(y, X=None, cmap='Set1', gradient=None, method='matplotlib', scheme='rgb', opaque_type='per_class', verbose='info'):
# Set the logger
set_logger(verbose=verbose)
# make unique
y = np.array(y)
uiy = np.unique(y)
# Get colors
colors_unique = generate(len(uiy), cmap=cmap, method=me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_color_gradient():\n colors = []\n step = 10\n for red, green in zip(range(255,-step, -step), range(0, 255, step)):\n colors.append({'red': red, 'green': green, 'blue': 0})\n for green, blue in zip(range(255,-step, -step), range(0, 255, step)):\n colors.append({'red': 0, 'green'... | [
"0.69815975",
"0.6241875",
"0.608826",
"0.6028528",
"0.5951059",
"0.58788097",
"0.58780885",
"0.58316827",
"0.5818387",
"0.5781078",
"0.56648606",
"0.5645055",
"0.5637384",
"0.56352425",
"0.56185704",
"0.55861217",
"0.5581655",
"0.5577476",
"0.5556196",
"0.5546131",
"0.554457... | 0.7146094 | 0 |
Return a gradient list of (n) colors between two hex colors. start_hex and finish_hex should be the full sixdigit color string, inlcuding the number sign ("FFFFFF") | def linear_gradient(start_hex, finish_hex="#FFFFFF", n=10):
if finish_hex=='opaque': finish_hex=start_hex
# Starting and ending colors in RGB form
s = _hex2rgb(start_hex)
f = _hex2rgb(finish_hex)
# Initilize a list of the output colors with the starting color
RGB_list = [s]
# Calcuate a colo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_color_gradient():\n colors = []\n step = 10\n for red, green in zip(range(255,-step, -step), range(0, 255, step)):\n colors.append({'red': red, 'green': green, 'blue': 0})\n for green, blue in zip(range(255,-step, -step), range(0, 255, step)):\n colors.append({'red': 0, 'green'... | [
"0.7464628",
"0.730974",
"0.6747355",
"0.64438266",
"0.6420821",
"0.6330026",
"0.6233631",
"0.61494654",
"0.614863",
"0.60044503",
"0.5992193",
"0.5977377",
"0.59677243",
"0.5953647",
"0.5910034",
"0.590775",
"0.59075046",
"0.58731186",
"0.58708364",
"0.586321",
"0.5853994",
... | 0.7984741 | 0 |
Color to dictionary. Takes in a list of RGB sublists and returns dictionary of colors in RGB and hex form for use in a graphing function defined later on. | def _color_dict(gradient):
hex_colors = [_rgb2hex(RGB) for RGB in gradient]
rgb_colors = np.c_[[RGB[0] for RGB in gradient], [RGB[1] for RGB in gradient], [RGB[2] for RGB in gradient]]
return {'hex': hex_colors, 'rgb': rgb_colors} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assigning_colors():\n rgb_colors = {}\n for name, hex in matplotlib.colors.cnames.items():\n color = []\n # So the values are from 0-255 and not 0-1\n for i in matplotlib.colors.to_rgb(hex):\n color.append(int(i * 255))\n\n color = tuple(color)\n rgb_colors[n... | [
"0.72993577",
"0.7166082",
"0.71234846",
"0.7105684",
"0.67915034",
"0.66504467",
"0.6633686",
"0.6622999",
"0.656271",
"0.65496135",
"0.6542531",
"0.64886117",
"0.64846194",
"0.63931656",
"0.63931257",
"0.6381189",
"0.6377055",
"0.6372067",
"0.62352693",
"0.62340975",
"0.623... | 0.7698112 | 0 |
Set gradient on density color. This function determines the density of the data and adds a transparency column. If samples are in dense areas, transparency values are towards 1 (visible), whereas isn nonedense areas, the transparency values are towards 0 (not visible). | def gradient_on_density_color(X, c_rgb, labels, opaque_type='per_class', showfig=False, verbose='info'):
# Set the logger
set_logger(verbose=verbose)
if labels is None: labels = np.repeat(0, X.shape[0])
from scipy.stats import gaussian_kde
uilabels = np.unique(labels)
# Add the transparency col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isothermal_depth_wyrtki1964_gradient(da_PT):\n\n # make land mask based on surface layer\n da_mask = da_PT.isel(z=0)*0.+1.\n\n # calculate drho/dz\n da_PT_dz = da_PT.differentiate('z') # kg/m^4\n\n # interpolate to finer vertical resolution (2.5m)\n da_interp = da_PT_dz.interp(z=np.arange(0,d... | [
"0.57073355",
"0.57073355",
"0.56205153",
"0.5285244",
"0.52843755",
"0.5108466",
"0.5072132",
"0.50284564",
"0.49939755",
"0.49933887",
"0.49889076",
"0.4987362",
"0.4982678",
"0.4981954",
"0.49721134",
"0.49690628",
"0.49479908",
"0.49206397",
"0.4919995",
"0.49167046",
"0.... | 0.65256983 | 0 |
Convert old verbosity to the new one. | def convert_verbose_to_new(verbose):
# In case the new verbosity is used, convert to the old one.
if verbose is None: verbose=0
if not isinstance(verbose, str) and verbose<10:
status_map = {
'None': 'silent',
0: 'silent',
6: 'silent',
1: 'critical',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verbosity(v):\n assert v in [0,1,2] # debug, warn, info\n GLOBAL['VERBOSITY'] = v",
"def test_increase_verbosity(self):\n # Start from a known state.\n set_level(logging.INFO)\n assert get_level() == logging.INFO\n # INFO -> VERBOSE.\n increase_verbosity()\n ... | [
"0.6408217",
"0.6038145",
"0.60295814",
"0.5947771",
"0.5929938",
"0.5909877",
"0.5623561",
"0.5614202",
"0.55986595",
"0.55324614",
"0.55215126",
"0.55148864",
"0.54819477",
"0.5481862",
"0.5461689",
"0.5380808",
"0.53354967",
"0.531541",
"0.52798617",
"0.52721906",
"0.52597... | 0.74339193 | 0 |
Return size of folder at path. | def folder_size(path):
return sum(getsize(f) for f in os.listdir('.') if isfile(f)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def folder_size(path: str) -> str:\r\n return (\r\n subprocess.check_output([\"du\", \"-sh\", \"-B1\", path]).split()[0].decode(\"utf-8\")\r\n )",
"def get_size_from_path(path):\n if not os.path.isdir(path):\n return os.path.getsize(path)\n\n size = 0\n\n for dirname, dirs, files in ... | [
"0.8283314",
"0.8165242",
"0.80046517",
"0.78010786",
"0.77946424",
"0.7767517",
"0.77278864",
"0.77143127",
"0.77143127",
"0.769937",
"0.7691966",
"0.7543926",
"0.7538644",
"0.7486155",
"0.7480786",
"0.7466756",
"0.74297",
"0.74095184",
"0.73598933",
"0.7322922",
"0.7322922"... | 0.8572386 | 0 |
Print out debugging information string string to be printed (in) | def debug(string):
if verbose:
print string
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def debug(string):\n if conf.DEBUG:\n outputs.print_debug(string)",
"def output_debug_info(self):",
"def debugPrint(text: str):\r\n if DEBUG:\r\n print(text)",
"def debug_string(self):\n\n raise NotImplementedError",
"def debug():",
"def debug_print(text):\r\n if settings.de... | [
"0.76916933",
"0.7513169",
"0.7507592",
"0.73979014",
"0.73887455",
"0.7374867",
"0.7366604",
"0.7354347",
"0.7354347",
"0.7234283",
"0.7234283",
"0.71581537",
"0.70975",
"0.7073775",
"0.7070248",
"0.7070248",
"0.7016923",
"0.6961993",
"0.6890409",
"0.68704146",
"0.6854564",
... | 0.7761138 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.