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 |
|---|---|---|---|---|---|---|
Get a codecs registry entry for this codec | def getregentry():
return codecs.CodecInfo(
name=ENCODING_NAME,
encode=Codec().encode,
decode=Codec().decode,
incrementalencoder=IncrementalEncoder,
incrementaldecoder=IncrementalDecoder,
streamreader=StreamReader,
streamwriter=StreamWriter,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_codec():\n codecs.register(lambda s: getregentry() if s == ENCODING_NAME else None)",
"def registry(self):\n return self._registry",
"def _find_ebcdic_codec(code_name):\n return _codec_name_to_info_map.get(code_name)",
"def internal_registry(self) -> Dict[str, Resource]:\n re... | [
"0.6240712",
"0.58522475",
"0.5817025",
"0.5813902",
"0.57982886",
"0.5798157",
"0.57939136",
"0.5732457",
"0.57202977",
"0.5657296",
"0.5654182",
"0.5644674",
"0.5565561",
"0.55271125",
"0.5409903",
"0.5362628",
"0.5227791",
"0.51994514",
"0.51977164",
"0.5164919",
"0.516188... | 0.75918514 | 0 |
Register the 'pdf_doc' codec in the codec registry. | def register_codec():
codecs.register(lambda s: getregentry() if s == ENCODING_NAME else None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def registerEncoder (encoder):\n assert False, \"TODO:\"",
"def register():\n \n global _registered\n if not _registered:\n _registered = True\n sys.path_hooks.insert(0, VFSImporter)",
"def codec(self):\n raise NotImplementedError",
"def pdf(self, pdf):\n\n self._pdf =... | [
"0.51747286",
"0.4840066",
"0.47816825",
"0.46726602",
"0.45896292",
"0.45558062",
"0.4525837",
"0.4525837",
"0.45258164",
"0.445992",
"0.44480228",
"0.443422",
"0.4403697",
"0.43858114",
"0.43478054",
"0.43399096",
"0.43346575",
"0.43302205",
"0.43157902",
"0.43155",
"0.4311... | 0.6544622 | 0 |
Reads out the device information from the first of the module's parameters. If the module does not have any parameters, return None. | def get_device_from_parameters(module: torch.nn.Module) -> Optional[torch.device]:
try:
first_parameter = next(module.parameters())
return first_parameter.device
except StopIteration:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDevice(driver):\n devices = list(listDevices(driver))\n if not devices:\n print('No devices found. Ensure your camera is connected.')\n elif len(devices) != 1:\n print('Too many devices found. Only one camera is supported')\n else:\n return devices[0]",
"def get_device_information(self):\n retur... | [
"0.6326248",
"0.631275",
"0.62375796",
"0.6188889",
"0.6153064",
"0.6135334",
"0.6130941",
"0.6130941",
"0.6130941",
"0.6130941",
"0.6130941",
"0.6108385",
"0.6040274",
"0.60273564",
"0.6005924",
"0.6005415",
"0.6001323",
"0.59857756",
"0.59857756",
"0.59416413",
"0.59239733"... | 0.73609 | 0 |
Groups layers in the model in a balanced way as such each group has similar size of memory requirement | def group_layers_with_balanced_memory(inputs: List[torch.nn.Module],
num_groups: int,
summary: Optional[OrderedDict]) -> Generator:
class Group:
def __init__(self) -> None:
self.length = 0
self.memory_mbytes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_multi_blocks_models(feature_dim, feat_group_start_end_dict, output_scheme=\"regression\", num_classes=num_classes):\n\tdivan_feat_dim = feature_dim\n\tfor k in feat_group_start_end_dict:\n\t\tdivan_feat_dim = divan_feat_dim - feat_group_start_end_dict[k][2]\n\tinput_atac = keras.layers.Input(shape=[feat_... | [
"0.63599455",
"0.61726034",
"0.61726034",
"0.60829276",
"0.60690314",
"0.60093844",
"0.6004388",
"0.60020727",
"0.5925123",
"0.59172267",
"0.59123576",
"0.5899615",
"0.58735824",
"0.5866229",
"0.58662134",
"0.58585405",
"0.58555126",
"0.58437675",
"0.58316606",
"0.5809916",
"... | 0.7181105 | 0 |
Finds the next available group to store input layer which is represented in terms of its memory (`mem_to_be_allocated`). The algorithm assigns the object to the current group if it is empty or it has enough capacity to store the layer. Otherwise the rest of groups are enquired. If none of the groups accept the incoming... | def find_available_group(group_id: int,
groups: List[Group],
mem_to_be_allocated: float,
max_mem_allowed: float) -> int:
num_groups = len(groups)
available_groups = [True for _ in range(num_groups)]
group_mem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_layers_with_balanced_memory(inputs: List[torch.nn.Module],\n num_groups: int,\n summary: Optional[OrderedDict]) -> Generator:\n\n class Group:\n def __init__(self) -> None:\n self.length = 0\n self.m... | [
"0.6704369",
"0.5840597",
"0.57946587",
"0.57193464",
"0.5376643",
"0.5200926",
"0.5190515",
"0.51667017",
"0.50521237",
"0.49076462",
"0.4878574",
"0.48258126",
"0.48139504",
"0.47529766",
"0.4752658",
"0.46838558",
"0.46750402",
"0.4658914",
"0.4649196",
"0.46488628",
"0.46... | 0.6511956 | 1 |
In PR, when some test failed, update failure info and | def test_progress(token, issue_number, actor, commit, run_id):
success_or_only_flakiness, log_summary = _get_summary_table(token, run_id)
if success_or_only_flakiness and not log_summary:
# succeeded (without flakiness)
return
else:
if success_or_only_flakiness:
# all failures/errors are due to ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_end(token, issue_number, actor, commit, run_id, new_token):\n success_or_only_flakiness, log_summary = _get_summary_table(token, run_id)\n if success_or_only_flakiness and not log_summary:\n # succeeded (without flakiness)\n firebase_github.add_label(token, issue_number, _LABEL_SUCCEED)\n comme... | [
"0.6629107",
"0.64125353",
"0.6265404",
"0.6164626",
"0.6164114",
"0.6142817",
"0.61417073",
"0.60975266",
"0.6085702",
"0.6060706",
"0.6050941",
"0.6033663",
"0.6033662",
"0.6024136",
"0.60240334",
"0.60127",
"0.6012129",
"0.60027826",
"0.59806305",
"0.59771895",
"0.5968333"... | 0.65900344 | 1 |
Test Result Report Body, which is failed test table with markdown format | def _get_summary_table(token, run_id):
# return (success_or_only_flakiness, failed_test_summary_table)
return summarize.summarize_logs(dir=_LOG_OUTPUT_DIR, markdown=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_report(self):\n total_duration = 0.0\n total_nb_tests = 0\n total_nb_success = 0\n nb_modules = 0\n payload = []\n\n res_table = prettytable.PrettyTable(\n padding_width=2,\n field_names=['Module', 'Duration', 'nb. Test Run', 'Success'])... | [
"0.6793846",
"0.614379",
"0.6125151",
"0.6079817",
"0.6059698",
"0.60589916",
"0.60430926",
"0.60227",
"0.59781134",
"0.59455276",
"0.5940313",
"0.59397197",
"0.5935205",
"0.5933212",
"0.59252673",
"0.5917846",
"0.59128636",
"0.5910134",
"0.5877482",
"0.5872497",
"0.5821992",... | 0.62092406 | 1 |
Test setting a cbsa and getting the msa_id | def test_set_and_get(self):
CbsaMsaIdMapTest.cbsa_map.set(CbsaMsaIdMapTest.cbsa, CbsaMsaIdMapTest.msa_id)
self.assertEqual(CbsaMsaIdMapTest.msa_id, CbsaMsaIdMapTest.cbsa_map.get(CbsaMsaIdMapTest.cbsa)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_multi_ap_wps_shared_csa(dev, apdev):\n ssid = \"multi-ap-wps-csa\"\n passphrase = \"12345678\"\n params = hostapd.wpa2_params(ssid=ssid, passphrase=passphrase)\n params.update({\"multi_ap\": \"3\",\n \"multi_ap_backhaul_ssid\": '\"%s\"' % ssid,\n \"multi_ap_... | [
"0.56998867",
"0.5533876",
"0.54796267",
"0.541728",
"0.54162717",
"0.53723705",
"0.5367956",
"0.5312781",
"0.52783227",
"0.5256221",
"0.52355975",
"0.5213506",
"0.5191955",
"0.51784897",
"0.5171489",
"0.51688206",
"0.51608294",
"0.51569664",
"0.5128075",
"0.5108576",
"0.5102... | 0.6489525 | 0 |
Test asking for a nonexisting cbsa | def test_get_if_non_existant_cbsa(self):
self.assertIsNone(CbsaMsaIdMapTest.cbsa_map.get(CbsaMsaIdMapTest.cbsa_not_loaded)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ap_csa_invalid(dev, apdev):\n csa_supported(dev[0])\n ap = connect(dev[0], apdev)\n\n vals = [ 2461, 4900, 4901, 5181, 5746, 5699, 5895, 5899 ]\n for val in vals:\n if \"FAIL\" not in ap.request(\"CHAN_SWITCH 1 %d\" % val):\n raise Exception(\"Invalid channel accepted: %d\" %... | [
"0.6486969",
"0.6345942",
"0.6185136",
"0.5947708",
"0.57924765",
"0.57621646",
"0.57470465",
"0.5719105",
"0.57064945",
"0.569102",
"0.5580299",
"0.5537412",
"0.55085766",
"0.55047816",
"0.54890877",
"0.5487662",
"0.54717183",
"0.54620546",
"0.5457307",
"0.545542",
"0.545369... | 0.67666256 | 0 |
Reads the DayCentformatted soils.in file for the specified SSURGO mukey, and computes the corresponding total water holding capacity for the full soil profile in cm. | def whc_tot(mukey, layers=''):
#read appropriate soils.in content to a python list
mukey = str(mukey)
soil_path = "/data/paustian/ernie/SSURGO_master_script/soil_test2/"
soil_fpath = soil_path+mukey[:-3]+"/"+mukey+".in"
cont = [[]]
data_input = open(soil_fpath, 'r')
for line in data_input:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_h_sen(dry_bulb_C):\n\n h_kJ_kg = dry_bulb_C * CPA_kJ_kgC\n\n return h_kJ_kg",
"def load_SCF_wealth_weights():\n with open(DATASETS + \"SCFwealthDataReduced.txt\") as f:\n SCF_reader = csv.reader(f, delimiter=\"\\t\")\n SCF_raw = list(SCF_reader)\n SCF_wealth = np.zeros(len(SCF_... | [
"0.51410556",
"0.5066481",
"0.49922672",
"0.49805102",
"0.4931313",
"0.49293408",
"0.48856175",
"0.48788616",
"0.48518452",
"0.48325932",
"0.48125324",
"0.4797802",
"0.47672376",
"0.47509813",
"0.47070748",
"0.47070652",
"0.47070652",
"0.47017273",
"0.46981642",
"0.46871534",
... | 0.6603799 | 0 |
Reads the DayCentformatted soils.in file for the specified SSURGO mukey, and computes the corresponding depthweighted average soil texture. | def avg_text(mukey, layers):
#read appropriate soils.in content to a python list
mukey = str(mukey)
soil_path = "/data/paustian/ernie/SSURGO_master_script/soil_test2/"
soil_fpath = soil_path+mukey[:-3]+"/"+mukey+".in"
cont = [[]]
data_input = open(soil_fpath, 'r')
for line in data_input:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def whc_tot(mukey, layers=''):\n #read appropriate soils.in content to a python list\n mukey = str(mukey)\n soil_path = \"/data/paustian/ernie/SSURGO_master_script/soil_test2/\"\n soil_fpath = soil_path+mukey[:-3]+\"/\"+mukey+\".in\"\n cont = [[]]\n data_input = open(soil_fpath, 'r')\n for lin... | [
"0.56125915",
"0.55218",
"0.50745",
"0.49961472",
"0.49782276",
"0.4971676",
"0.49686965",
"0.4934698",
"0.4933849",
"0.49016955",
"0.48967728",
"0.48707932",
"0.4847659",
"0.48051497",
"0.47826073",
"0.47754717",
"0.47541964",
"0.472834",
"0.47113448",
"0.46922725",
"0.46910... | 0.6769672 | 0 |
Fill out the specified .100 file templates based on parameters read from the specified parameter .csv file. | def param_100(param_fpath, template_path, target_path, version=-999):
# save the column names and read the last line of parameters in a params.csv file
params_csv_object = open(param_fpath, 'rU')
lines = csv.reader(params_csv_object)
keys = lines.next() # save column names as keys
for line in lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __fill_template__(self,template_file,output_fname):\n dictionary = {}\n for k,v in self.__dict__.iteritems():\n if k == 'sample_key':\n try:\n int(v)\n new_sample_key = \"Sample_\" + str(v)\n dictionary.update({k:n... | [
"0.6192257",
"0.5982712",
"0.5760338",
"0.5730748",
"0.56628907",
"0.5660077",
"0.56506324",
"0.5564521",
"0.5551236",
"0.55260736",
"0.5523214",
"0.5508473",
"0.54485226",
"0.5446436",
"0.54388964",
"0.541922",
"0.5415378",
"0.5414238",
"0.53587383",
"0.5350438",
"0.53370273... | 0.68315625 | 0 |
Routine for summarizing visualizing seasonal soil moisture dynamics from a vswc.out file. The routine sums up daily total root zone volumetric water content, and plots it relative to water holding capacity limits for the wettest and driest year in the file. | def soil_h2o_detail(vswc_fpath, mukey, layer_lim, cwscoef11, cwscoef12, start_year, end_year):
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt
# define soils.in layer depth structure and layer water holding capacities
depths = [2, 3, 5, 10, 10, 15, 15, 15, 15, 15, 15, 30, 30... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_vis():\n dataroot = 'solar_data.txt'\n debug = False \n diff = False\n X, y = read_data(dataroot, debug, diff)\n\n # First plot the original timeseries\n fig = plt.figure(figsize=(40,40))\n\n fig.add_subplot(3,3,1)\n plt.plot(y)\n plt.title('Avg Global PSP (vent/cor) [W/m^2]')... | [
"0.5996422",
"0.5601317",
"0.55962616",
"0.55856466",
"0.55798155",
"0.5569622",
"0.5524244",
"0.550611",
"0.5432939",
"0.542689",
"0.5375278",
"0.53202987",
"0.530399",
"0.5297987",
"0.5281773",
"0.52813363",
"0.5279896",
"0.5264938",
"0.5264046",
"0.5254911",
"0.52491754",
... | 0.67246544 | 0 |
List data for each caption on one video | def list_video_captions_data(youtube=None, video_id=""):
# fetch transcriptions data
captions_data = youtube.captions().list(
part = "snippet",
videoId = video_id
).execute()
# create a list of video captions data snippets
return [snippet['snippet'] for snippet in captions_data['items']] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_channel_captions_data(youtube=None, channel=\"\", max_results=100):\n\n # fetch data for all channel videos up to max results\n videos_data = youtube.search().list(\n part = \"snippet\",\n #forMine = True,\n channelId = \"UCMk_WSPy3EE16aK5HLzCJzw\",\n maxResults = max_results,\n q = \"*\"... | [
"0.64856374",
"0.6384933",
"0.62142056",
"0.6097786",
"0.6045972",
"0.60276836",
"0.60010743",
"0.5976193",
"0.5975031",
"0.5915524",
"0.57886523",
"0.577944",
"0.57791126",
"0.57624453",
"0.5759638",
"0.5734242",
"0.57268405",
"0.5720044",
"0.5709618",
"0.56985027",
"0.56855... | 0.64735806 | 1 |
Search channel videos for captions and return a list of dicts with video ids, titles and languages with captions. | def list_channel_captions_data(youtube=None, channel="", max_results=100):
# fetch data for all channel videos up to max results
videos_data = youtube.search().list(
part = "snippet",
#forMine = True,
channelId = "UCMk_WSPy3EE16aK5HLzCJzw",
maxResults = max_results,
q = "*",
type = "video"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_videos():\n channels = get_channels_from_file()\n\n channels_request = service.channels().list(\n part='id, contentDetails',\n forUsername=channels[0]['channelUsername'] # first channel for now\n )\n\n video_list = []\n\n channels_response = channels_request.execute()\n f... | [
"0.6672792",
"0.66025126",
"0.6401475",
"0.631096",
"0.6276193",
"0.6272215",
"0.6266598",
"0.626461",
"0.6232918",
"0.6198788",
"0.6198546",
"0.6120364",
"0.61087054",
"0.6080867",
"0.6030194",
"0.59919685",
"0.59917164",
"0.58906364",
"0.5884111",
"0.5864239",
"0.58473945",... | 0.7898906 | 0 |
Add a new shelf in Maya with all the tools that are provided in the SHELF_TOOLS variable. If the tab exists it will be deleted and recreated from scratch. | def execute():
shelf_main = mel.eval("$tmpVar=$gShelfTopLevel")
shelves = cmds.tabLayout(shelf_main, query=True, childArray=True)
if SHELF_NAME in shelves:
cmds.deleteUI(SHELF_NAME)
cmds.shelfLayout(SHELF_NAME, parent=shelf_main)
for tool in SHELF_TOOLS:
if tool.get("image1"):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def install_shelf():\n maya_shelf = mel.eval(\"$tempngSkinToolsVar=$gShelfTopLevel\")\n existing_shelves = cmds.shelfTabLayout(maya_shelf, q=True, tabLabel=True)\n\n parent_shelf = 'ngSkinTools'\n\n if parent_shelf in existing_shelves:\n return\n\n mel.eval('addNewShelfTab ' + parent_shelf)\n... | [
"0.7348468",
"0.5869069",
"0.5763022",
"0.5711703",
"0.5682173",
"0.55651426",
"0.55235505",
"0.5483279",
"0.5465631",
"0.5386956",
"0.5385866",
"0.52880234",
"0.51370215",
"0.49776036",
"0.4947929",
"0.49314138",
"0.4916171",
"0.49059182",
"0.48962995",
"0.4884695",
"0.48540... | 0.64665353 | 1 |
This method returns the next connector object in the teskit algorithm sequence after this very object if any | def next(self, value):
if self.is_threshold_true(value): #testing if the threshold condition is met
try: #trying to be sure that such connector even exist before attempting to return it
connector = self.connector_set.filter(connector_type=True)
return connector
except:
return None
else:
try: #t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next(self):\n return self.next",
"def get_next(self):\n return self.next",
"def getNext(self):\n\t\t\treturn self.next",
"def getNext(self):\n return self.__next__",
"def next(self) -> object:\n return self._next",
"def getNext(self):\n return self.__next",
"d... | [
"0.6667575",
"0.6667575",
"0.6581225",
"0.6569843",
"0.651619",
"0.6464815",
"0.64620394",
"0.6419521",
"0.6400295",
"0.6381093",
"0.6275631",
"0.6264676",
"0.6262058",
"0.6255166",
"0.62266165",
"0.6217963",
"0.6217963",
"0.6217963",
"0.6217963",
"0.6217963",
"0.6217963",
... | 0.6760909 | 0 |
This method returns the api url for the next connector object in the testkit algorithm sequence after this very object if any | def next_api_url(self, value):
if self.next(): #checking if there is a next in the first place
return self.next().get_api_url
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nextURL(self):\n return self.wizard.nextURL",
"def next_url(self) -> str:\n return 'https://www.mta-dialog.de/stellenmarkt.html?tx_jobs_pi1[action]=next'",
"def next_link(self) -> str:\n return pulumi.get(self, \"next_link\")",
"def _get_next_url(self):\n pool = []\n fo... | [
"0.6355624",
"0.62565655",
"0.6117926",
"0.6102838",
"0.5896334",
"0.5888752",
"0.58713835",
"0.5719341",
"0.5593303",
"0.5549709",
"0.5522231",
"0.5480497",
"0.54710716",
"0.54385555",
"0.54216886",
"0.5418205",
"0.5382161",
"0.5382161",
"0.5344841",
"0.53212667",
"0.5318106... | 0.7048083 | 0 |
A version of dir that excludes clutter and private names. | def _dir(obj='__secret', _CLUTTER=dir()):
if obj == '__secret':
names = globals().keys()
else:
names = dir(obj)
return [n for n in names if n not in _CLUTTER and not n.startswith('_')] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dir_filter(item):\n return not item.startswith(\"_\")",
"def _dirn(_CLUTTER=dir()):\n return dict([\n (n, v) for (n, v) in globals().items()\n if not n in _CLUTTER and not n.startswith('_')])",
"def dir_noaccess(self,fullname):\n pass",
"def __dir__():\n import pkgutil\n\n ... | [
"0.6533623",
"0.6329262",
"0.62499356",
"0.6149142",
"0.60733247",
"0.60031474",
"0.59987855",
"0.59783155",
"0.59513783",
"0.59284276",
"0.59084743",
"0.5867484",
"0.5800164",
"0.57731885",
"0.5727569",
"0.57178134",
"0.56976724",
"0.5670575",
"0.5668918",
"0.559673",
"0.559... | 0.6706606 | 0 |
Update the scroll position of the currentlypointedto history item. | def update_scroll_position(self, new_scroll_position):
if not self._items:
raise ValueError("Empty navigation history")
self._items[self._pointer].scroll_position = new_scroll_position | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n top, bottom = self.margins\n\n if self.cursor.y == bottom:\n self.history.top.append(self.buffer[top])\n\n super(CustomHistoryScreen, self).index()",
"def __window_scrollTo(self, x, y):\n pass",
"def reverse_index(self):\n top, bottom = self.marg... | [
"0.6806531",
"0.65859413",
"0.62565744",
"0.60841846",
"0.6055153",
"0.6053185",
"0.59955984",
"0.59780854",
"0.59322625",
"0.5923856",
"0.5863968",
"0.5787758",
"0.573177",
"0.5705429",
"0.56724614",
"0.56617993",
"0.5650068",
"0.5628003",
"0.5584823",
"0.5573465",
"0.555710... | 0.7638569 | 0 |
Test whether client can go back one place. | def can_go_back(self):
return self._pointer >= 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isGoBack(self, timeout=20.0, commandId=None):\n TestAdapterLib.check_timeout(caller=TestAdapterLib.caller(), timeout=timeout)\n \n return self.isActionAccepted(timeout=timeout, commandName=Command.GO_BACK, commandId=commandId)",
"def step_back(self):\n if not self.allow_step_back:... | [
"0.6665028",
"0.64017504",
"0.62264645",
"0.61997616",
"0.61917716",
"0.61772394",
"0.6159616",
"0.6137817",
"0.60885566",
"0.6082613",
"0.60386944",
"0.5987497",
"0.5980198",
"0.5949045",
"0.58809614",
"0.5816876",
"0.5798248",
"0.5797882",
"0.5775089",
"0.57735527",
"0.5768... | 0.7672083 | 0 |
Test whether client can go forward one place. | def can_go_forward(self):
return self._pointer + 1 < len(self._items) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_channel_forward_agent_request(self, channel):\n return False",
"def test_forward(self):\n validate_forward()",
"def isGoForward(self, timeout=20.0, commandId=None):\n TestAdapterLib.check_timeout(caller=TestAdapterLib.caller(), timeout=timeout)\n \n return self.isAc... | [
"0.68426156",
"0.6817086",
"0.66326785",
"0.6381285",
"0.6371428",
"0.61772406",
"0.61503625",
"0.6129383",
"0.6129383",
"0.60725206",
"0.6036844",
"0.6018369",
"0.6000302",
"0.5947335",
"0.59292316",
"0.58719516",
"0.5820861",
"0.5796933",
"0.57013935",
"0.56897193",
"0.5674... | 0.7383435 | 0 |
New columns that match the 'polling_location.txt' template are inserted into the DataFrame, apply() is used to run methods that generate the values for each row of the new columns. | def build_polling_location_txt(self):
self.base_df['address_line'] = self.base_df.apply(
lambda row: self.get_address_line(row['index'], row['address1'], row['address2'], row['city'],
row['state'], row['zip_code']), axis=1)
self.base_df['directi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_wcfat_results(filename, locations=[\"LPH Weld\", \"HPH Weld\", \"BOP Connector\"]):\n\n df = pd.read_csv(filename, skiprows=8, header=None, sep=\"\\t\")\n\n # Drop the event length column and last column, which is just redundant \",\"\n df = df.drop([1, 5], axis=1)\n df.columns = [\"Timestamp\... | [
"0.5854593",
"0.5561146",
"0.55155444",
"0.5368228",
"0.53599024",
"0.52924305",
"0.5226497",
"0.52157193",
"0.51637715",
"0.515269",
"0.5102951",
"0.5088901",
"0.5059832",
"0.50585777",
"0.5036256",
"0.5029913",
"0.50016177",
"0.49439794",
"0.4931451",
"0.49197435",
"0.49093... | 0.7467405 | 0 |
Build village of maximum size (can be 0) | def look_for_biggest_structure(game, chunk, imgs, hmap, nmax, type_):
for n in range(nmax,0,-1):
i = 0
m = parameters.MAX_VILLAGE_WIDTH * n / parameters.MAX_VILLAGE_SIZE
while i < parameters.VILLAGE_TRY:
chunkpos = np.random.randint(0,parameters.S,2)
cx,cy = chunkpos
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build(self, block_size):",
"def _generate_building(self, min_size, max_size, modulo_rest=2, name=None, one_connection=False):\n size_x = random.randint(min_size[0], max_size[0])\n size_y = random.randint(min_size[1], max_size[1])\n if modulo_rest < 2:\n while size_x % 2 != mod... | [
"0.60114944",
"0.5984556",
"0.58561355",
"0.5770638",
"0.5668718",
"0.5655863",
"0.56078124",
"0.55946255",
"0.55496067",
"0.5528949",
"0.5518236",
"0.548083",
"0.5474485",
"0.54733527",
"0.54623634",
"0.54475987",
"0.5425183",
"0.5388836",
"0.53629535",
"0.53522325",
"0.5324... | 0.63852817 | 0 |
given an undirected graph G and source vertex, performs a DFS from the source and returns the arrays d, f and pi with pi[source)=1 | def dfs(G, source):
V, E = G
#initialize arrays as dictionaries and time as 2
global d, f, pi, col, time
d, f, pi, col = {}, {}, {}, {}
for u in V:
pi[u] = 0
col[u] = 'white'
pi[source], d[source] = -1, 1
time = 0
#insert code here
dfs_visit(G,source)
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dfs(self, starting_vertex, destination_vertex):\n # create an empty stack \n stack = Stack()\n #push the starting vertex ID as list\n stack.push([starting_vertex])\n # create an empty Set to store the visited vertices\n visited = set()\n # while the stack is no... | [
"0.6950275",
"0.68566966",
"0.68281335",
"0.6768615",
"0.6726244",
"0.67021096",
"0.66570944",
"0.6629446",
"0.66260487",
"0.6615985",
"0.6604302",
"0.6557835",
"0.6517618",
"0.6517618",
"0.6507736",
"0.6503237",
"0.64964354",
"0.64865136",
"0.64652216",
"0.6457868",
"0.64275... | 0.8085134 | 0 |
given a graph and output d, f, pi from dfs, prints arrays in columns | def print_dfs_output(G, d, f, pi):
V = G[0]
print (" d f pi")
for v in V:
print (" {: <5}{: <5}{: <5}{: <5}".format(v, d[v], f[v], pi[v])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dfs(G, source):\n V, E = G\n #initialize arrays as dictionaries and time as 2\n global d, f, pi, col, time\n d, f, pi, col = {}, {}, {}, {}\n for u in V:\n pi[u] = 0\n col[u] = 'white'\n pi[source], d[source] = -1, 1\n time = 0\n \n #insert code here\n dfs_visit(G,so... | [
"0.6065468",
"0.6052442",
"0.55416894",
"0.5508474",
"0.5489255",
"0.54395497",
"0.54038125",
"0.5382878",
"0.536173",
"0.5353325",
"0.53138006",
"0.5267003",
"0.52467453",
"0.5223501",
"0.51640546",
"0.51475644",
"0.5146783",
"0.51306176",
"0.51181257",
"0.5103317",
"0.50862... | 0.7356017 | 0 |
Returns balance minus any active withdrawal amount | def balance(self) -> Decimal:
withdrawals = self.withdrawal_requests.filter(
status=WithdrawalStatus.open,
)
if len(withdrawals) == 0:
return self.internal_balance
else:
withdrawal_total = sum(map(lambda w: w.amount, withdrawals))
return se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def withdraw(self, amount):\r\n balance = self['get']('balance')\r\n if amount > balance:\r\n return 'Insufficient funds'\r\n self['set']('balance', balance - amount)\r\n return self['get']('balance')",
"def withdraw(self, amount):\n if amount > self.balance:\n ... | [
"0.7545731",
"0.74802",
"0.7438588",
"0.738342",
"0.73672754",
"0.7358471",
"0.735411",
"0.735411",
"0.73130894",
"0.72578347",
"0.70434666",
"0.70174164",
"0.7014208",
"0.700096",
"0.697131",
"0.69198126",
"0.6865932",
"0.68468297",
"0.6812948",
"0.68069994",
"0.67279094",
... | 0.7726188 | 0 |
Tries to extract the status code from the return value and add it as a metadata field | def _add_status_code(runner, return_value):
if isinstance(return_value, Mapping):
status_code = return_value.get('statusCode')
if status_code:
runner.resource['metadata']['status_code'] = status_code | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def status(self, code, content_length=None):",
"def get_status_code(self, response):\r\n if hasattr(response, 'status_int'):\r\n return response.status_int\r\n else:\r\n return response.status_code",
"def get_status_code(self, response):\r\n if hasattr(response, 'stat... | [
"0.7027837",
"0.6647166",
"0.6647166",
"0.6573774",
"0.6548376",
"0.6536617",
"0.6507966",
"0.64426726",
"0.6416891",
"0.64121974",
"0.63894176",
"0.6385831",
"0.6381601",
"0.63567704",
"0.6346389",
"0.6345818",
"0.6317092",
"0.63105464",
"0.6274337",
"0.62632453",
"0.6262542... | 0.77212465 | 0 |
Return a list of payload dictionaries to ignore, if any. | def _get_ignored_payloads():
ignored_payloads = os.environ.get('EPSAGON_PAYLOADS_TO_IGNORE')
if ignored_payloads:
return json.loads(ignored_payloads)
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getIgnoredDict(self):\n return self.ignored",
"def remove_skip_values(self, data):\n return {\n key: value for key, value in data.items()\n if value not in self.__skipvalues\n }",
"def excluded(cls):\n return []",
"def ignored_values(self):\r\n ret... | [
"0.65182656",
"0.6287411",
"0.6153952",
"0.6013248",
"0.5954365",
"0.59384096",
"0.5920959",
"0.5896081",
"0.58398336",
"0.57838005",
"0.5780179",
"0.5748123",
"0.5733911",
"0.5657544",
"0.5637441",
"0.5622359",
"0.56156284",
"0.5560999",
"0.5552071",
"0.5525323",
"0.5524777"... | 0.81555736 | 0 |
Epsagon's Step Lambda wrapper. | def step_lambda_wrapper(func):
@functools.wraps(func)
def _lambda_wrapper(*args, **kwargs):
"""
Generic Step Function wrapper
"""
cold_start_duration = time.time() - constants.COLD_START_TIME
trace = epsagon.trace.trace_factory.get_or_create_trace()
trace.prepare... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step(self, step=None):\n pass",
"def _step(self) -> None:",
"def step(self, action):\n pass",
"def step(self, action):\n pass",
"def step_impl(context):\n pass",
"def step_impl(context):\n pass",
"def Step(observation, reward, done, **kwargs): # noqa: N802\n return _Step(obse... | [
"0.6772875",
"0.6754047",
"0.67446685",
"0.67446685",
"0.67184097",
"0.67184097",
"0.66899043",
"0.6681387",
"0.6515447",
"0.65004325",
"0.6372977",
"0.63582736",
"0.6355663",
"0.6346706",
"0.6330008",
"0.63198245",
"0.6272956",
"0.6215336",
"0.6210946",
"0.6208847",
"0.61933... | 0.6929115 | 0 |
Update animations of bombs and get rid of old bombs | def update_bombs(wof_settings,screen,bombs,explosions,sound_bomb,stats):
bombs.update()
# Get rid of bombs that have exploded
for bomb in bombs.copy():
if bomb.counter == wof_settings.bomb_timer:
sound_bomb.play()
bomb.counter = 0
new_explosion = Explosion(wof_set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_animations(self):\n self.animate_bloop(700, 160, 50)",
"def remove_all_animations(self):\n\t\tself.animations = {}",
"def tick(self):\n\n #tick each animation, and remember any animations which have finished\n #remove any finished ones from the dictionary\n finished = []\n for... | [
"0.6729816",
"0.6359442",
"0.6288313",
"0.6272816",
"0.61174",
"0.6096827",
"0.6006386",
"0.6003412",
"0.5989934",
"0.5973152",
"0.58997357",
"0.5863157",
"0.58260584",
"0.58232635",
"0.58090824",
"0.5737791",
"0.56900597",
"0.5665252",
"0.5658468",
"0.5632853",
"0.56282866",... | 0.72191495 | 0 |
Destroy objects if the explosion hits them | def destroy(explosions,inkblots,hero,deaths,stats):
explosion_hits_inkblot = pygame.sprite.groupcollide(explosions,inkblots,False,True,pygame.sprite.collide_mask)
explosion_hits_hero = pygame.sprite.spritecollideany(hero,explosions,pygame.sprite.collide_mask)
explosion_hits_death = pygame.sprite.groupcollid... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_explosions(explosions,diamonds,hero,deaths,stats):\n explosions.update()\n \n # Get rid of explosions\n for explosion in explosions.copy():\n if explosion.done == True:\n explosion.counter = 0\n explosion.done = False # Check if there is an explosion \"process\" ... | [
"0.66618055",
"0.6501148",
"0.643593",
"0.6300602",
"0.6273755",
"0.62730515",
"0.62656397",
"0.6217252",
"0.62142104",
"0.62125814",
"0.6165429",
"0.61223274",
"0.61019087",
"0.60874456",
"0.60613865",
"0.6043767",
"0.6031043",
"0.597638",
"0.5922128",
"0.5877534",
"0.585845... | 0.7978088 | 0 |
Create a set of diamonds | def create_diamonds(wof_settings,screen,diamonds,levelMap):
diamond_width = wof_settings.element_width
diamond_height = wof_settings.element_height
# Place the diamonds to the field
for diamond_position in levelMap['diamond']:
diamond = Diamond(screen)
diamond.x = diamond_po... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diamonds(self):\n return sorted(tuple([v for v in self if v.suit == 'diamonds']), reverse=True)",
"def drink_make(drink_styles): \n # Define empty list for drink\n drink_ingredients = [] \n # Loop through styles and add random ingredient to drink list\n for style, selected in drink_styles.iterit... | [
"0.66519195",
"0.5873986",
"0.57025313",
"0.54980445",
"0.5444328",
"0.54374826",
"0.5436626",
"0.5411429",
"0.5403904",
"0.540223",
"0.5373233",
"0.5338672",
"0.53331107",
"0.5325148",
"0.53159904",
"0.5308167",
"0.52709144",
"0.5270524",
"0.5252554",
"0.5218396",
"0.5210879... | 0.6537086 | 1 |
Create a set of deaths | def create_deaths(wof_settings,screen,deaths,levelMap):
death_width = wof_settings.element_width
death_height = wof_settings.element_height
# Create deaths
for death_position in levelMap['death']:
death = Death(wof_settings,screen)
death.x = death_position[1] * death_wi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_deaths(self, deaths):\n self.last_generation[\"deaths\"] = list()\n for death in deaths:\n self.last_generation[\"deaths\"].append(death)",
"def deaths(self, deaths):\n\n self._deaths = deaths",
"def player_deaths(self):\n return self.deaths.filter(and_(Death.mind... | [
"0.69126964",
"0.6423102",
"0.63939184",
"0.63260484",
"0.630812",
"0.61267436",
"0.59445316",
"0.589744",
"0.5846209",
"0.58281595",
"0.5765575",
"0.56714314",
"0.5668342",
"0.56601316",
"0.56195265",
"0.5614451",
"0.5611607",
"0.5541159",
"0.55381864",
"0.55021995",
"0.5489... | 0.6884478 | 1 |
Finds a service registered with the provided interface. This can be used to locate services registered either as a utility or factory service. If no service exists for either of the categories an error is thrown. | def find_service(iface, context, name): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_service(self, iface, context=None, name=''):\n service = self._component.queryUtility(iface, name=name)\n if not service:\n service = self._component.queryAdapter(context, iface, name=name)\n\n if not service:\n msgfmt = \"No utility or factory service found for ... | [
"0.7543488",
"0.61746585",
"0.60825074",
"0.6015296",
"0.5783703",
"0.5666336",
"0.56272876",
"0.55858886",
"0.5487621",
"0.54315615",
"0.5388736",
"0.52984273",
"0.5294561",
"0.5276688",
"0.5200757",
"0.518314",
"0.5156216",
"0.5112601",
"0.50743806",
"0.5061724",
"0.5060974... | 0.75261295 | 1 |
Registers a service factory. | def register_factory(factory, iface, requires, name): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, factory):\n self._factories.append(factory)",
"def register_service(service, iface, name):",
"def register(self, property, factory, *factory_args, **factory_kw):\n if (factory_args or factory_kw) and not callable(factory):\n raise ValueError(\n \"Only c... | [
"0.6555481",
"0.64893425",
"0.63371223",
"0.6287613",
"0.6203681",
"0.61990553",
"0.6077394",
"0.60455745",
"0.5988732",
"0.592225",
"0.58712536",
"0.58205867",
"0.57869333",
"0.57507706",
"0.5732183",
"0.55614704",
"0.5543281",
"0.5487775",
"0.544057",
"0.5422042",
"0.540729... | 0.7044506 | 0 |
Finds a service registered with the provided interface. This can be used to locate services registered either as a utility or factory service. If no service exists for either of the categories an error is thrown. | def find_service(self, iface, context=None, name=''):
service = self._component.queryUtility(iface, name=name)
if not service:
service = self._component.queryAdapter(context, iface, name=name)
if not service:
msgfmt = "No utility or factory service found for {}"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_service(iface, context, name):",
"def locate(self, interface, depth=1, _default=object()):\n key = qual(interface)\n currentContext = self\n while True:\n if depth < 0:\n full = []\n while True:\n try:\n ... | [
"0.7524992",
"0.61740446",
"0.60803884",
"0.6013305",
"0.5779945",
"0.56632525",
"0.5623387",
"0.5582428",
"0.54842234",
"0.54290843",
"0.5389383",
"0.5295174",
"0.5295049",
"0.5273305",
"0.5203032",
"0.51807594",
"0.51527077",
"0.51133347",
"0.5074078",
"0.5059686",
"0.50592... | 0.75433296 | 0 |
Registers a singleton utility service. A callable serving as a factory to lazily create the utility service can be provided in place of the service instance. | def register_service(self, service, iface, name=''):
key = 'component' if not callable(service) else 'factory'
kwargs = {'provided': iface, key: service, 'name': name}
self._component.registerUtility(**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeService_Utility(self, options):\n\n def toolServiceCreator(pool, store, ignored, storageService):\n return config.UtilityServiceClass(store)\n\n uid, gid = getSystemIDs(config.UserName, config.GroupName)\n return self.storageService(\n toolServiceCreator, None, ui... | [
"0.56608474",
"0.5557284",
"0.548377",
"0.54204714",
"0.53755003",
"0.53755003",
"0.53311414",
"0.53152543",
"0.5313566",
"0.5254963",
"0.51949126",
"0.5180315",
"0.5149657",
"0.5137851",
"0.50832653",
"0.50832653",
"0.49918297",
"0.49868014",
"0.4980406",
"0.49757096",
"0.49... | 0.5605437 | 1 |
In the left zone we have headline of the wave and monsters' info. | def init_left_zone(self):
self.left_zone_rect = pg.rect.Rect(0, 0, 275, 80)
self.left_zone_image = pg.Surface(self.left_zone_rect.size).convert()
self.left_zone_image.fill(pg.Color('#82A6CB'))
self.left_zone_bottom_rect = pg.rect.Rect(0, 70, 265, 10)
self.left_zone_bottom_image =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_left_zone(self, screen):\n screen.blit(self.left_zone_image, self.left_zone_rect)\n screen.blit(self.left_zone_bottom_image, self.left_zone_bottom_rect)\n screen.blit(self.left_zone_side_image, self.left_zone_side_rect)\n\n screen.blit(self.headline_text, self.headline_rect)\n ... | [
"0.6814521",
"0.5566169",
"0.54503036",
"0.5416255",
"0.53566724",
"0.5349143",
"0.53237826",
"0.5269778",
"0.52560896",
"0.5220104",
"0.5213546",
"0.51396525",
"0.5105154",
"0.50689894",
"0.5068862",
"0.50043726",
"0.49968618",
"0.49535596",
"0.49333438",
"0.49151117",
"0.49... | 0.6758233 | 1 |
Update wave_info, number of wave + number/images of monsters. | def update_wave_info(self, headline, monsters_list):
self.monsters_images.empty()
self.monsters_list = []
self.headline_text = self.font_23.render(
headline, True, pg.Color('black'))
self.headline_rect = self.headline_text.get_rect(
topleft=self.headline_pos)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updateweigths():\n for i_lay in range(1, len(layers)):\n layers[i_lay][\"weigths\"] += layers[i_lay][\"Delta_w\"]",
"def set_wave(self, wave, waves_cnt):\n\n wave_str = \"WAVE {0}/{1}\".format(wave, waves_cnt)\n self.wave_label.element.text = wave_str",
"def next_wave(self):\n ... | [
"0.59063715",
"0.5772449",
"0.5755189",
"0.5453878",
"0.5381271",
"0.5216533",
"0.5139013",
"0.5130818",
"0.5059093",
"0.5055675",
"0.50010204",
"0.49805906",
"0.49706832",
"0.49287516",
"0.49157923",
"0.49115905",
"0.4904711",
"0.48837292",
"0.48837292",
"0.48621118",
"0.484... | 0.70400804 | 0 |
Updates all the variables about tower. (image, name, level, damage, cooldown, description) | def update_selection_tower(self, tower):
self.tower_image = tower.image
self.tower_image_rect = self.tower_image.get_rect(
topleft=self.selected_image_pos)
pos = list(self.selected_name_pos)
self.tower_name = self.bold_font.render(
tower.name, True, pg.Color('bla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Ork(self):\n self.type = \"Ork\"\n self.image = pygame.image.load(\"Ork.gif\")\n self.cost = 2\n self.health = 40\n self.max_health = self.health\n self.base_damage = 3\n self.damagedice = (4,2)\n self.base_defense = 1\n self.defensedice = (3,1)\n ... | [
"0.595399",
"0.5945418",
"0.57966363",
"0.5749849",
"0.5739909",
"0.56314516",
"0.56002957",
"0.55074584",
"0.5467641",
"0.5467257",
"0.5445289",
"0.54220295",
"0.54024756",
"0.5400333",
"0.5361031",
"0.5349155",
"0.5347333",
"0.5329291",
"0.5327866",
"0.5325788",
"0.5314958"... | 0.62516993 | 0 |
Updates all the variables about monster. (image, name, health, speed) real is True, when it is monster and False when it's monster_image. | def update_selection_monster(self, monster, real=True):
self.monster_image = monster.image
self.monster_image_rect = self.monster_image.get_rect(
topleft=self.selected_image_pos)
pos = list(self.selected_name_pos)
self.monster_name = self.bold_font.render(
monste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, player):\n self.updateAnimation()\n #TODO: check if the monster can see the player. (using sightdist)\n #TODO: check if the monster is hostile the player.\n #TODO: figure out a better way to assosciate the monster with its udpate action \n # (probably a dic... | [
"0.61570114",
"0.61531246",
"0.574586",
"0.57282543",
"0.57099915",
"0.5646997",
"0.5505052",
"0.54113036",
"0.53608453",
"0.5351911",
"0.5323387",
"0.5315895",
"0.53141826",
"0.53127444",
"0.5310274",
"0.5258912",
"0.5234584",
"0.52310026",
"0.5220375",
"0.52146304",
"0.5196... | 0.6757832 | 0 |
On the left zone we have wave headline + info about monsters. | def draw_left_zone(self, screen):
screen.blit(self.left_zone_image, self.left_zone_rect)
screen.blit(self.left_zone_bottom_image, self.left_zone_bottom_rect)
screen.blit(self.left_zone_side_image, self.left_zone_side_rect)
screen.blit(self.headline_text, self.headline_rect)
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_left_zone(self):\n self.left_zone_rect = pg.rect.Rect(0, 0, 275, 80)\n self.left_zone_image = pg.Surface(self.left_zone_rect.size).convert()\n self.left_zone_image.fill(pg.Color('#82A6CB'))\n self.left_zone_bottom_rect = pg.rect.Rect(0, 70, 265, 10)\n self.left_zone_bott... | [
"0.6764049",
"0.55565816",
"0.54635966",
"0.5396933",
"0.5366653",
"0.53141946",
"0.5202636",
"0.51971173",
"0.51955134",
"0.51940554",
"0.51370025",
"0.51221377",
"0.5044935",
"0.5003351",
"0.49832606",
"0.4970592",
"0.4946996",
"0.49209464",
"0.4908198",
"0.4901877",
"0.488... | 0.69545096 | 0 |
Test the HTTP request handler class. This runs an HTTP server on port 8000 (or the first command line argument). | def test(HandlerClass = server.BaseHTTPRequestHandler,
ServerClass = server.HTTPServer, protocol="HTTP/1.0", port=8000):
server_address = ('', port)
HandlerClass.protocol_version = protocol
httpd = ServerClass(server_address, HandlerClass)
sa = httpd.socket.getsockname()
print("Serving HTTP on", sa[0]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n host = ''\n port = 8088\n HTTPServer((host, port), HandleRequests).serve_forever()",
"def _serve(path, port):\n print(\"running HTTP server on port %d...\" % port)\n print('use Ctrl-Break to stop webserver')\n os.chdir(path)\n handler = http.server.SimpleHTTPRequestHandler\n ... | [
"0.7938545",
"0.70685446",
"0.7043873",
"0.6987995",
"0.6957307",
"0.69422096",
"0.691234",
"0.69121593",
"0.69098675",
"0.6821198",
"0.68190205",
"0.6807012",
"0.67938685",
"0.6768953",
"0.67378384",
"0.6726004",
"0.66539854",
"0.66390616",
"0.66264343",
"0.6623826",
"0.6623... | 0.8446536 | 0 |
Search through past sold items, includes pagination | def search_past_items(request):
query = request.GET.get('q')
if query:
results = PastSold.objects.filter(Q(name__icontains=query) | Q(description__icontains=query))
else:
results = PastSold.objects.all()
pages = pagination(request, results, num=4)
context = {
'items': pages... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def searchItems(name, allPages = False):\n return Gw2Spidy._paginatedRequest(allPages, 'item-search', name)",
"def shop_items(request):\n\n items = Item.objects.all()\n\n query = None\n\n \"\"\" Used Code Institute Search logic from Tutorial \"\"\"\n if 'query' in request.GET:\n query =... | [
"0.6541923",
"0.6198307",
"0.6062998",
"0.601071",
"0.5948904",
"0.5892803",
"0.589241",
"0.5856469",
"0.5821692",
"0.5787105",
"0.57600296",
"0.5754254",
"0.5747222",
"0.57359624",
"0.5735551",
"0.5724682",
"0.57239646",
"0.56967026",
"0.5690279",
"0.56811845",
"0.5675917",
... | 0.798783 | 0 |
Search through current items up for auction, includes pagination | def search_current_auctions(request):
query = request.GET.get('q')
auction = Auction.objects.all()
if query:
results = auction.filter(Q(antiques__name__icontains=query) | Q(antiques__description__icontains=query))
else:
results = Auction.objects.all()
pages = pagination(request, r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fetch_items(self):\n url = self._api.router.publication['search'].format(\n project_id=self.project_id\n )\n res_data = self._api.post(url, data=self.search_param)\n self.total = res_data['total']\n self._items = (\n Publication(item, self.project_id)\n... | [
"0.66070586",
"0.6516762",
"0.6303546",
"0.62699556",
"0.6116621",
"0.61033994",
"0.61033994",
"0.60449606",
"0.6008939",
"0.5937827",
"0.59331375",
"0.58962756",
"0.5720947",
"0.5621883",
"0.56182057",
"0.55845016",
"0.5563692",
"0.5562401",
"0.5549474",
"0.5539571",
"0.5534... | 0.7199818 | 0 |
group_id, int indicating the id of the group btn_id, json button id to remove | def _remove_button(group_id, btn_id):
# select
group_record = GroupRepository().getById(group_id)
welcome_btns = group_record['welcome_buttons']
welcome_btns = json.loads(welcome_btns)['buttons']
new_welcome_btns = [btn for btn in welcome_btns if btn['id'] != int(btn_id)]
# insert
welcome_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_group():\n _id = request.form['_id']\n data, code, message = FIELD_SERVICE.remove_group(_id)\n return __result(data, code, message)",
"def delete_group():\n incoming = request.get_json()\n Chatroom.delete_chatroom_with_room_id(incoming['room_id'])\n return jsonify(results = incoming[... | [
"0.66278625",
"0.6538843",
"0.64447075",
"0.62608594",
"0.6166148",
"0.6109838",
"0.6109838",
"0.6109058",
"0.6075437",
"0.6020538",
"0.5985676",
"0.59855103",
"0.597395",
"0.5937345",
"0.5916756",
"0.58881545",
"0.5865757",
"0.5858068",
"0.57839996",
"0.578177",
"0.5767138",... | 0.7565339 | 0 |
group_id, int indicating the id of the group btn, dict representing a json button | def _add_button(group_id, btn):
# select
group_record = GroupRepository().getById(group_id)
welcome_btns = group_record['welcome_buttons']
welcome_btns = (json.loads(welcome_btns))['buttons']
# add
if len(welcome_btns) == 0:
btn['id'] = 0
else:
btn['id'] = welcome_btns[-1]['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slotGroupChange(self, trackFramePool):\n id = self.id(trackFramePool)\n button = self.findButton(trackFramePool)\n group_id = trackFramePool.getGlobalGroup()\n color = Globals.group_colors[group_id]\n if button.__class__ == PovWidgets.PushButton:\n button.setColor(... | [
"0.6095019",
"0.59203666",
"0.58317256",
"0.57971096",
"0.577177",
"0.5767405",
"0.5681496",
"0.56249833",
"0.561293",
"0.55767494",
"0.5484245",
"0.547548",
"0.5473733",
"0.5461828",
"0.5435767",
"0.5423002",
"0.54140335",
"0.5401033",
"0.5393463",
"0.538689",
"0.537597",
... | 0.6331045 | 0 |
S3Bucket gets object content. | def test_s3_gets_object_content(self):
mock_s3 = Mock()
mock_s3_object = Mock()
s3_response = {'Body': mock_s3_object}
mock_s3_object.read.return_value = "file content"
mock_s3.get_object.return_value = s3_response
s3_bucket = S3Bucket('bucket_name', s3_client=mock_s3)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_bucket_objects(bucket_name):\n s3 = boto3.resource('s3')\n bucket = s3.Bucket(bucket_name)\n for obj in bucket.objects.all():\n response = obj.get()\n body = response['Body'].read().decode('utf-8')\n print(body)",
"def get_s3_content(bucket, key, access_id, access_secret):\... | [
"0.7805469",
"0.7710362",
"0.76047933",
"0.7502207",
"0.75000346",
"0.7316007",
"0.7309681",
"0.72925884",
"0.7199889",
"0.7184133",
"0.7060693",
"0.703954",
"0.7029422",
"0.70138997",
"0.69947565",
"0.68899024",
"0.68543965",
"0.6842453",
"0.6814544",
"0.6781708",
"0.6754048... | 0.78690326 | 0 |
Method that print the victory message on the window | def victory(self):
font = pygame.font.Font(None, CASE_SIZE)
text = font.render('You Win!', True,(255, 255, 255), (0, 0, 0))
self.screen.blit(text,(CASE_SIZE * 6, CASE_SIZE * 7))
self.try_again()
pygame.display.flip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __window_print(self):\n pass",
"def display():\n screen.addch(head[0],head[1],'x')",
"def showMessage(self):",
"def display(self):\n\t\tprint('The button in the window was clicked!')",
"def __window_dump(self, text):\n self.alert(text)",
"def info(msg):\n click.secho(msg, fg='... | [
"0.6462396",
"0.6374186",
"0.6300585",
"0.6270995",
"0.6235216",
"0.6127003",
"0.6074383",
"0.60367715",
"0.60246617",
"0.6004438",
"0.6000357",
"0.59782135",
"0.59518856",
"0.59322745",
"0.5865074",
"0.58463895",
"0.58461034",
"0.576341",
"0.57511234",
"0.574665",
"0.5745482... | 0.66963094 | 0 |
Invalid artist raises HTTPError | def test_invalid_artist(self):
self.assertRaises(HTTPError, lambda: self.d.artist(0).name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_artist(self):\n response = self.client.get(reverse('exordium:artist', args=('notfound',)))\n self.assertEqual(response.status_code, 404)",
"def test_artist_uri_exception(self):\n with mock.patch(\"spotlogin_api.get_artists_call\", self.mock_key):\n result = spotif... | [
"0.77871203",
"0.69068086",
"0.6647509",
"0.62083054",
"0.6118325",
"0.6058497",
"0.60388744",
"0.6029916",
"0.5921708",
"0.58648336",
"0.58529735",
"0.5817768",
"0.5804598",
"0.57488704",
"0.5716384",
"0.56914425",
"0.56799126",
"0.5641943",
"0.5592134",
"0.558944",
"0.55789... | 0.84983057 | 0 |
Invalid release raises HTTPError | def test_invalid_release(self):
self.assertRaises(HTTPError, lambda: self.d.release(0).title) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_release_tag_for_invalid_version(self) -> None:\n with self.assertRaisesRegexp(ValueError, \"Unable to parse version foo.bar.ba\"):\n release_tag()",
"def softwareReleaseError(self, url, computer_id, error_log):\n return self._softwareReleaseError(url, computer_id, error_log)",
"de... | [
"0.6346252",
"0.6317068",
"0.60366005",
"0.5923198",
"0.5885341",
"0.5841424",
"0.5758252",
"0.5751254",
"0.5720429",
"0.5718253",
"0.56364137",
"0.5615844",
"0.5604759",
"0.55811286",
"0.5564855",
"0.55620265",
"0.5560299",
"0.55250484",
"0.5504077",
"0.5491693",
"0.5486643"... | 0.78101814 | 0 |
Test parent_label / sublabels relationship | def test_parent_label(self):
l = self.d.label(1)
l2 = self.d.label(31405)
self.assertTrue(l.parent_label is None)
self.assertTrue(l2 in l.sublabels)
self.assertEqual(l2.parent_label, l) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_parent_of(self):\n return self.hasLabel('parent_of')",
"def is_labelled_parent(elm):\n klass = elm.attrib.get('class')\n if klass in widgets_toplevel:\n return True\n if klass == 'GtkShortcutsGroup':\n children = elm.findall(\"property[@name='title']\")\n if len(childr... | [
"0.6248901",
"0.6209689",
"0.61390406",
"0.607035",
"0.6042563",
"0.60018927",
"0.59673154",
"0.59663063",
"0.5937988",
"0.58891976",
"0.5871884",
"0.58668494",
"0.5861766",
"0.5839116",
"0.582024",
"0.582024",
"0.5807268",
"0.579377",
"0.5792115",
"0.57816166",
"0.5740722",
... | 0.8443482 | 0 |
Test main_release / versions relationship | def test_master_versions(self):
m = self.d.master(4242)
r = self.d.release(79)
v = m.versions
self.assertEqual(len(v), 2)
self.assertTrue(r in v)
self.assertEqual(r.master, m)
r2 = self.d.release(3329867)
self.assertTrue(r2.master is None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_version(self):\n pass",
"def test_release(self):\n r = self.d.release(1)\n self.assertEqual(r.title, 'Stockholm')",
"def test_get_version(self):\n pass",
"def test_pre_release(scraper, version_parts):\n\n new_version_parts = list(version_parts)\n if len(new_version_... | [
"0.70611316",
"0.70087665",
"0.69780046",
"0.68437153",
"0.67887336",
"0.6767312",
"0.67335194",
"0.6731524",
"0.669257",
"0.6646281",
"0.6641185",
"0.66321737",
"0.6593295",
"0.6592753",
"0.6552657",
"0.65442705",
"0.65435386",
"0.65283024",
"0.65050346",
"0.64805704",
"0.64... | 0.7466025 | 0 |
Warn if dataset has existing field with same id. | def has_field_warning(meta, field_id):
if meta.has_field(field_id):
print("WARN: Field \'%s\' is already present in dataset, not overwriting." % field_id)
print("WARN: Use '--replace' flag to overwrite existing field.")
return 1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dataset_duplicate_ids(self, dataset):\n ids = [a['_id'] for a in dataset]\n # Construct list of duplicates\n dupe_ids = [a for n, a in enumerate(ids) \n if a in ids[:n]]\n if len(dupe_ids) > 0:\n # Get list of names for the duplicate pandas\n ... | [
"0.6720956",
"0.6335891",
"0.62887913",
"0.61362606",
"0.6133507",
"0.6022987",
"0.59594166",
"0.58729535",
"0.5871784",
"0.5795687",
"0.57457983",
"0.56992257",
"0.56977475",
"0.5685958",
"0.5646299",
"0.5624518",
"0.5621023",
"0.5593675",
"0.5581955",
"0.55676335",
"0.55635... | 0.7893367 | 0 |
Generates list of dictionaries with setting summary for pipeline. | def get_pipeline_summary(pipeline):
confounds = {"wm": "WM",
"csf": "CSF",
"gs": "GS",
"acompcor": "aCompCor",
"aroma": "ICA-AROMA",
"spikes": "Spikes"}
pipeline_list = []
for conf, conf_name in confounds.items():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def summary_parameters(self):\n return {'filters': ', '.join(self.getOption('filters'))}",
"def summaries(self):\n return [ self.__class__(sets=[x]) for x in self.sets ]",
"def get_all_summaries() -> Dict[str, CBSummary]:\n return _SUMMARIES",
"def summaries_parts(self):\n return list... | [
"0.63479286",
"0.6299865",
"0.60430753",
"0.598095",
"0.59000915",
"0.5780944",
"0.5775636",
"0.5722007",
"0.57200015",
"0.5664811",
"0.55705696",
"0.55692047",
"0.5561404",
"0.55573136",
"0.55525273",
"0.5546761",
"0.5528816",
"0.54955304",
"0.54569155",
"0.54299647",
"0.542... | 0.6594214 | 0 |
Predicts the decimal digit in the given image array. | def predict(self, image_array):
probabilities = self.model.predict(image_array, verbose=0)
prediction = int(np.argmax(probabilities))
return {'prediction': prediction, 'probabilities': probabilities.tolist()[0]} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_num(self):\n if self.file_name:\n img_array = self.read_img(self.file_name)\n # plt.imshow(de_noise(img_array), cmap='gray')\n\n # isDigit = model2.predict(np.array([tf.cast(img_array, tf.float32)]))[0]\n # print(isDigit)\n isDigit = 1\n ... | [
"0.68403935",
"0.63739485",
"0.6342652",
"0.6319576",
"0.62438583",
"0.6189592",
"0.61735195",
"0.61632323",
"0.61275136",
"0.60726327",
"0.60364044",
"0.6021909",
"0.5960806",
"0.5960806",
"0.59316164",
"0.59154934",
"0.58932257",
"0.5844416",
"0.5824438",
"0.58087796",
"0.5... | 0.64093375 | 1 |
Converts a base64 encoded canvas PNG to a 4D tensor for Keras | def convert_canvas_image_to_array(image_data):
# Split the image data from the metadata
split_str = b'base64,'
index = image_data.find(split_str) + len(split_str)
# Decode the image data from base64
png_data = base64.b64decode(image_data[index:])
# Create a PIL image from the bytes
image = P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode(base64img, size):\n # the bytes of the image ---> np array\n image_64_decode = base64.decodebytes(base64img.encode('utf-8'))\n image = Image.open(BytesIO(image_64_decode))\n\n # resize, and convert to RGB\n image = image.resize(size, Image.ANTIALIAS)\n image = image.convert('RGB')\n\n ... | [
"0.6385384",
"0.6270741",
"0.6243338",
"0.60081506",
"0.59616596",
"0.58866876",
"0.58115983",
"0.5804369",
"0.579719",
"0.56684",
"0.56611043",
"0.56289434",
"0.56226295",
"0.5600289",
"0.55838037",
"0.55553293",
"0.5552939",
"0.55498064",
"0.55475366",
"0.5497715",
"0.54907... | 0.6500634 | 0 |
Load the bundled default configurations and specifications. If the ``userconfig`` provided, the user configurations is also loaded, validated, and merged. | def __init__(self, userconfig=None):
configspec = _get_configspec()
self._configspec = ConfigObj(configspec, interpolation=False,
list_values=False, _inspec=True)
configs_default = ConfigObj(interpolation=False,
configspec=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_default_user_configs(args):\n # Skip any imported keys from future\n import __future__ as ff\n future_keys = dir(ff)\n # Load default settings\n import pythiaplotter.default_config as dc\n default_settings = {k: getattr(dc, k) for k in dir(dc)\n if k not in future_... | [
"0.6937068",
"0.6139326",
"0.6063314",
"0.6040931",
"0.60165954",
"0.59623826",
"0.5879237",
"0.5792416",
"0.5771059",
"0.5767199",
"0.5762034",
"0.57246566",
"0.571912",
"0.5663795",
"0.56600714",
"0.56332",
"0.56290865",
"0.5594446",
"0.55854255",
"0.5569079",
"0.55525976",... | 0.6660707 | 1 |
Read, validate and merge the input config. | def read_config(self, config):
try:
newconfig = ConfigObj(config, interpolation=False,
configspec=self._configspec)
except ConfigObjError as e:
raise ConfigError(e)
newconfig = self._validate(newconfig)
self._config.merge(newconfi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_config(self):\n # TODO: parse config file\n pass",
"def read_config(self) -> None:\n\n if self.parsing_finished is True:\n return\n\n default_config_file = self.get_config_file_path(default_config_file_path)\n\n # check if default config file actually exist... | [
"0.68005484",
"0.65945137",
"0.65455925",
"0.64417887",
"0.64258784",
"0.63828",
"0.63812304",
"0.63317657",
"0.62994623",
"0.6288914",
"0.62813085",
"0.6214071",
"0.61895114",
"0.6185276",
"0.617184",
"0.6163294",
"0.616106",
"0.61449087",
"0.6120139",
"0.61114395",
"0.61107... | 0.72164285 | 0 |
Read user configuration file, validate, and merge into the default configurations. | def read_userconfig(self, userconfig):
if hasattr(self, "userconfig"):
raise ConfigError('User configuration already loaded from "%s"' %
self.userconfig)
#
try:
config = open(userconfig).read().split("\n")
except IOError:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_default_user_configs(args):\n # Skip any imported keys from future\n import __future__ as ff\n future_keys = dir(ff)\n # Load default settings\n import pythiaplotter.default_config as dc\n default_settings = {k: getattr(dc, k) for k in dir(dc)\n if k not in future_... | [
"0.71124154",
"0.7062521",
"0.6904651",
"0.6894641",
"0.66362196",
"0.66160107",
"0.6613065",
"0.6516891",
"0.64535606",
"0.6403305",
"0.639973",
"0.63703305",
"0.63275295",
"0.6315178",
"0.6289062",
"0.62817806",
"0.6280346",
"0.6276032",
"0.627465",
"0.6255732",
"0.6240052"... | 0.72936755 | 0 |
Validate the config against the specification using a default validator. The validated config values are returned if success, otherwise, the ``ConfigError`` raised with details. | def _validate(self, config):
validator = Validator()
try:
results = config.validate(validator, preserve_errors=True)
except ConfigObjError as e:
raise ConfigError(e.message)
if results is not True:
error_msg = ""
for (section_list, key, res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_config(self):\n pass",
"def validate_config(self):\n pass",
"def _validate_config(self):\n pass",
"def validate_config(config: Dict) -> None:\n\n # For validating with pydantic\n config_flattened = format_config_for_validation(config)\n user_defined_sets = get_all_s... | [
"0.67165244",
"0.67165244",
"0.6633132",
"0.6449351",
"0.6323576",
"0.62830544",
"0.62270415",
"0.6160143",
"0.61504245",
"0.612289",
"0.6109577",
"0.607783",
"0.6070739",
"0.605938",
"0.60570157",
"0.60516196",
"0.60473037",
"0.60461205",
"0.60302436",
"0.6029793",
"0.601934... | 0.6777404 | 0 |
Return the absolute path of the file/directory specified by the config keys. | def get_path(self, key):
value = self.getn(key)
if value is None:
logger.warning("Specified config '%s' is None or not exist" % key)
return None
if not isinstance(value, str):
msg = "Specified config '%s' is non-string: %s" % (key, value)
logger.er... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAsAbsolutePath(self, key, default=None):\n\n filename = self.get(key, default)\n if filename is None:\n raise KeyError('Config key [%s] not found' % (key,))\n\n return self._getAbsolutePath(filename)",
"def get_config_path(config):\n section = config.sections()[0]\n r... | [
"0.7428259",
"0.73378736",
"0.70733976",
"0.69686306",
"0.6822606",
"0.6696372",
"0.6615707",
"0.6570572",
"0.6502956",
"0.6499773",
"0.6483655",
"0.6482812",
"0.6471269",
"0.64680964",
"0.64604485",
"0.64524436",
"0.6431519",
"0.6394553",
"0.63905644",
"0.63615614",
"0.63600... | 0.74589443 | 0 |
Get or calculate if ``frequency/type = custom`` the frequencies where to perform the simulations. Returns | def frequencies(self):
if self.getn("frequency/type") == "custom":
# The value is validated to be a float list
frequencies = self.getn("frequency/frequencies")
else:
# Calculate the frequency values
start = self.getn("frequency/start")
stop = s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_custom(self, custom=None):\n if custom:\n self.custom_freq = custom\n else:\n self.custom_freq = self.__yago_counts()\n\n print(\"Computing p(e|m)\")\n for mention in self.custom_freq:\n total = len(self.custom_freq[mention])\n\n #... | [
"0.5906615",
"0.58213913",
"0.58213913",
"0.5816854",
"0.57678807",
"0.574401",
"0.5686303",
"0.56503874",
"0.5646439",
"0.5625367",
"0.56058764",
"0.5534204",
"0.553181",
"0.5504192",
"0.54998827",
"0.54987645",
"0.5493391",
"0.5493391",
"0.54636043",
"0.54609793",
"0.544043... | 0.631163 | 0 |
Generate a random nXn matrix | def generate_random_matrix(n):
return [[random.randint(1, 50) for i in range(n)] for j in range(n)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_matrix(rows, cols):\n return np.random.randn(rows, cols)",
"def generate_matrix(size) -> np.ndarray:\n np.random.seed(1)\n return np.random.rand(size, size) - 0.5",
"def generate_matrix(rows, cols):\n matrix_random = np.random.rand(rows, cols)\n return matrix_random",
"def matrix_ge... | [
"0.81710565",
"0.792287",
"0.79113024",
"0.7722165",
"0.76615596",
"0.7660074",
"0.7519301",
"0.75128853",
"0.7285101",
"0.7154303",
"0.70088404",
"0.692316",
"0.6916966",
"0.69070524",
"0.6871379",
"0.68288565",
"0.6783224",
"0.67630124",
"0.66785693",
"0.6670763",
"0.665719... | 0.8402434 | 0 |
Compute internal factorization of A. | def factor(self, A):
self.m, self.n = A.shape
if self.use_sub_factor:
self.sub_factor(A)
else:
self.A_factorized = spla.factorized(A)
#if self.A_factorized is not None:
# self.A_factorized.free()
#self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sub_factor(self, A):\n \n #\n # In general, to slice a sparse matrix use:\n #\n # indices = np.where(bool_vect)[0]\n # out1 = M.tocsc()[:,indices] # for column slices\n # out2 = M.tocsr()[indices,:] # for row slices\n #\n \n print \"Running ... | [
"0.6696457",
"0.6036952",
"0.6000477",
"0.59810436",
"0.5980811",
"0.5938352",
"0.583887",
"0.57243985",
"0.5719933",
"0.56961846",
"0.567211",
"0.5667485",
"0.56575215",
"0.5635122",
"0.5610304",
"0.56082004",
"0.5534551",
"0.5493407",
"0.5474667",
"0.5468504",
"0.54657674",... | 0.75610596 | 0 |
Return the model Jacobian evaluated at theta. | def jacobian(self, theta, force=False):
# Update the internal solution
self.solution_update(theta, force)
# Run the internal jacobian calculation
return self.compute_jacobian() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jacobian(theta, event, parameters_to_fit):\n for (key, val) in enumerate(parameters_to_fit):\n setattr(event.model.parameters, val, theta[key])\n return event.chi2_gradient(parameters_to_fit)",
"def jacobian(self, x):\n pass",
"def jacobian_g(self, x, out=None, *... | [
"0.7237154",
"0.70675814",
"0.7052069",
"0.7045349",
"0.69009084",
"0.6900545",
"0.6890314",
"0.6890314",
"0.6851998",
"0.6849562",
"0.684422",
"0.68383247",
"0.68183655",
"0.6817251",
"0.6697173",
"0.66462696",
"0.664224",
"0.6609753",
"0.6602943",
"0.6585404",
"0.65727574",... | 0.8372631 | 0 |
Update internal solution at input theta. | def solution_update(self, theta, force=False):
self.x = self.eval(theta, force)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def theta(self, theta):\n n_theta_avail = self.n_theta\n n_theta_suggest = len(theta)\n if(n_theta_avail != n_theta_suggest):\n raise ValueError(\"theta has not the correct number of entries.\"\n \" Should be %d; given are %d\"\n ... | [
"0.68202573",
"0.67513645",
"0.6675147",
"0.65144724",
"0.6319021",
"0.622946",
"0.62129796",
"0.6209693",
"0.61695",
"0.61535627",
"0.61477053",
"0.61318564",
"0.612391",
"0.60817987",
"0.6050935",
"0.60432184",
"0.60409904",
"0.6040873",
"0.59618926",
"0.59514374",
"0.59276... | 0.8436528 | 0 |
Evaluate A, b, and factorize A if theta has changed. | def update_A_b(self, theta, force=False):
theta = numpy.array(theta).ravel()
# Note: evaluating a numpy array with a mask of None just
# returns the full array, i.e., if a = numpy.array([1,2,3])
# then a[None] is [1,2,3].
if force or (self.theta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_A(self, theta, force=False):\n self.A = self.eval_A(self.theta)\n self.solver.factor(self.A)\n self.A_eval_cnt += 1\n self.factor_cnt += 1",
"def update_b(self, theta, force=False):\n self.b = self.eval_b(self.theta)\n self.b_eval_cnt += 1",
"def eval(self, ... | [
"0.63773674",
"0.62277013",
"0.6035114",
"0.5976879",
"0.56455714",
"0.55966467",
"0.5562991",
"0.5496752",
"0.5428111",
"0.53576857",
"0.52815324",
"0.5240091",
"0.5229573",
"0.52233493",
"0.5209916",
"0.52017623",
"0.5193425",
"0.5192514",
"0.517405",
"0.51534116",
"0.51491... | 0.67068535 | 0 |
Estimate "brownian" model parameters | def estimate_brownian_model(trials):
trials = tuple(trials) # Required for numba
@jit
def loglikelihood(m_0, m_t, v_0, v_t, v_n):
total = 0.0
for trial_i in numba.prange(len(trials)):
trial = trials[trial_i]
total += trial_loglikelihood(trial, m_0, m_t, v_0, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_Bernoulli_NB_estimators():",
"def obtain_training_parameters(para, x, y, alg = 'LR'):\n \n \n global omega\n \n # Iterate to find the optimal parameters\n if alg == 'LR': # logistic regression\n omega = np.zeros((3, 1))\n alpha = para.step_size # step size\n for i ... | [
"0.63222694",
"0.63025373",
"0.62575924",
"0.6220644",
"0.6176585",
"0.6156066",
"0.60621077",
"0.6053568",
"0.60430485",
"0.6013353",
"0.59980613",
"0.5938014",
"0.59215117",
"0.59134716",
"0.59048945",
"0.5899498",
"0.5893625",
"0.5891419",
"0.588734",
"0.58873194",
"0.5887... | 0.67783254 | 0 |
Checks readings against defined upper and lower bounds. Returns which points outside bounds and how often data crosses with at least cushion consecutive points out of bounds | def out_of_range(data, upper_threshold, lower_threshold, cushion=3):
above = (data > upper_threshold) * 1 # *1 --> int
below = (data < lower_threshold) * 1
out = above + (below * -1)
index_backdown = [i + 1 for i, x in enumerate(np.diff(above)) if x == -1]
step_down = np.diff(np.concatenate(([0.],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetchbounds(self):\n pnts = [x for x in [self.out_start, self.start, self.in_start, \\\n self.in_end, self.end, self.out_end] \\\n if x is not None]\n return min(pnts), max(pnts)",
"def _in_bounds(self, x, y):\r\n return 0 <= x < 8 an... | [
"0.6751668",
"0.66825074",
"0.6546206",
"0.65407026",
"0.65355146",
"0.6504048",
"0.64847946",
"0.64671123",
"0.64666265",
"0.646322",
"0.6362104",
"0.63568527",
"0.6325737",
"0.6324205",
"0.6310966",
"0.6301764",
"0.6297676",
"0.6249771",
"0.6238202",
"0.6220549",
"0.6194786... | 0.6922795 | 0 |
Forecasts the remaining time before a threshold is crossed | def time_to_threshold(data, threshold, above=True, forecast_length=3600, interval_width=.95):
# needs other input format: dataframe with two columns, ds and y
model = Prophet(interval_width=interval_width)
try:
data.columns = ['ds', 'y']
model.fit(data)
except:
print("Input must ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evap(self, lai, tl, ta, qa):#average ta and tl!!\n\t fsev = max(self.TAI*self.GA*1000.*RHO_A/RHO_W*((.622*esat((tl+ta)/2)/P_ATM)-qa), 0.)\n\t\t#if the amount of water in tank is less than amount that will evaporate in timestep dt, then what's left will evaporate \n\t if self.tx*self.ZT*self.TAI*10**6 <= ... | [
"0.5581515",
"0.556688",
"0.55509067",
"0.553664",
"0.5531756",
"0.54948306",
"0.54929805",
"0.54476595",
"0.54468876",
"0.54232085",
"0.5418643",
"0.5415557",
"0.5411314",
"0.5375366",
"0.53643113",
"0.53469944",
"0.5320445",
"0.5299393",
"0.5296873",
"0.5294325",
"0.5293730... | 0.6544643 | 0 |
Sends an activation key within templated email to the user | def activation_email_template(cls, user_id):
user = get_user_model().objects.get(id=user_id)
email = user.e_mail
activation_key = user.activation_key
htmly = get_template('activation.html')
context_kw = Context({'user': {'email': email, 'activation_key': activation_key}})
email_subjec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_activation_key_via_email(user, signup_key):\n subject = '[%s]Verify your email.' % (settings.ORGANIZATION_NAME)\n from_email = settings.DEFAULT_FROM_EMAIL\n to = [user.email, ]\n activation_link = '%s%s' % (settings.HOSTNAME_URL,\n reverse('activation_verify',\n ... | [
"0.80178654",
"0.7734176",
"0.7472549",
"0.73853165",
"0.7293716",
"0.72841245",
"0.7275149",
"0.7113237",
"0.706976",
"0.7043169",
"0.6936015",
"0.6907361",
"0.68972003",
"0.6894603",
"0.68182164",
"0.6728767",
"0.67283875",
"0.6703236",
"0.66742027",
"0.6656132",
"0.6607312... | 0.8089802 | 0 |
Instead of running the actual traceroute command, we will fetch standard traceroute results from several publicly available webpages that are listed at traceroute.org. For each hop, we will then attach geolocation information to it. | def __run_traceroute(self):
self.print_debug("ip_address={0}".format(self.ip_address))
filename = "{0}.{1}.txt".format(self.ip_address, self.country)
filepath = os.path.join(self.tmp_dir, filename)
if not os.path.exists(filepath):
if self.country == "LO":
st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traceroute(host, unique_id=None, index=None, sourcetype=\"traceroute\",\n source=\"traceroute_search_command\", logger=None, include_dest_info=True,\n include_raw_output=False):\n\n if system_name().lower() == \"windows\":\n cmd = [\"tracert\"]\n else:\n cmd = [\... | [
"0.7044641",
"0.6719916",
"0.6546032",
"0.63312966",
"0.6210339",
"0.6075751",
"0.5840896",
"0.5816968",
"0.57866997",
"0.55758756",
"0.55310786",
"0.54669744",
"0.5435599",
"0.53983074",
"0.534886",
"0.5345458",
"0.53182924",
"0.52868116",
"0.5246468",
"0.5216357",
"0.516595... | 0.76384574 | 0 |
Fetches traceroute output from a webpage. | def get_traceroute_output(self):
url = self.source['url']
if 'post_data' in self.source:
context = self.source['post_data']
else:
context = None
status_code, content = self.urlopen(url, context=context)
content = content.strip()
regex = r'<pre.*?>(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traceroute(self,dest):\n\t\tself.tn.write('traceroute %s\\n'%(dest))\n\t\tself.tn.write('exit\\n')\n\t\tresp = self.tn.read_all()\n\t\treturn resp",
"def __run_traceroute(self):\n self.print_debug(\"ip_address={0}\".format(self.ip_address))\n\n filename = \"{0}.{1}.txt\".format(self.ip_address,... | [
"0.62293917",
"0.6225725",
"0.5661149",
"0.5621296",
"0.5611744",
"0.56092465",
"0.5431229",
"0.541722",
"0.5381834",
"0.5288725",
"0.52628595",
"0.52462715",
"0.5196124",
"0.51028085",
"0.5084061",
"0.50566596",
"0.5027701",
"0.50191134",
"0.5010555",
"0.49974945",
"0.496710... | 0.76078683 | 0 |
Returns hops from traceroute output in an array of dicts each with hop number and the associated hosts data. hop_context = { | def __get_hops(self, traceroute):
# This breaks up the line into hop num => host data
#hop_pattern = '^(?P<hop_num>\w+)\s+(?P<hosts>.*)'
hop_pattern = '^(?P<hop_num>[0-9]+)\s+(?P<hosts>.*)'
# This matches hosts which are ip or dns mapped
host_pattern = '([\d\w.-]+\s+\(\d{1,3}\.\... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def traceroute(host, unique_id=None, index=None, sourcetype=\"traceroute\",\n source=\"traceroute_search_command\", logger=None, include_dest_info=True,\n include_raw_output=False):\n\n if system_name().lower() == \"windows\":\n cmd = [\"tracert\"]\n else:\n cmd = [\... | [
"0.6046468",
"0.60165465",
"0.56349564",
"0.5454527",
"0.53351873",
"0.5296172",
"0.5234558",
"0.51950216",
"0.51757354",
"0.5087286",
"0.5075315",
"0.50619894",
"0.5056522",
"0.5052566",
"0.50485164",
"0.49651936",
"0.49537843",
"0.48973733",
"0.48582795",
"0.4783349",
"0.47... | 0.733032 | 0 |
return true if hop time exceeds specified latency threshold | def _exceeds_hop_latency(self,ping_time):
# remote ' ms' from ping time
ping_as_float = float(ping_time.replace(" ms",""))
print "Compare {0} to {1}".format(ping_as_float, self.LATENCY_THRESHOLD)
return ping_as_float >= self.LATENCY_THRESHOLD | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pingLatencyThresholdExceeded(self):\n\n return self.latency_exceeded",
"def within_threshold(self, other):\n if abs(other.ts - self.ts) < TIME_THRESHOLD:\n return True\n return False",
"def ShouldTrackThroughput(self, cur_time):\n return cur_time - self.start_time >= self... | [
"0.66330487",
"0.638862",
"0.6386065",
"0.6127473",
"0.60456294",
"0.6044701",
"0.59980893",
"0.5937124",
"0.58637697",
"0.569312",
"0.564793",
"0.56410444",
"0.5611241",
"0.5592029",
"0.5534342",
"0.55174714",
"0.55040354",
"0.54891306",
"0.54802597",
"0.5468375",
"0.5465336... | 0.82171345 | 0 |
Retrieve public IP of this instance by calling ipify webservice | def __lookup_public_ip(self):
response = requests.get('https://api.ipify.org?format=json', timeout=self.timeout)
if response.status_code == 200:
ip_data = response.json()
if 'ip' not in ip_data.keys():
return 'Unable to determine IP'
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_public_ip():\n public_ip = get('https://api.ipify.org').text\n return public_ip",
"def publicIP(self):\n return self.query('https://plex.tv/:/ip')",
"def obtain_public_ip():\n from urllib2 import urlopen\n my_ip = urlopen('http://ip.42.pl/raw').read()\n logger.debug('The public ip... | [
"0.8237399",
"0.78108096",
"0.75417304",
"0.7474292",
"0.73264223",
"0.72466105",
"0.7242845",
"0.7227741",
"0.7157957",
"0.7085789",
"0.70788515",
"0.70788515",
"0.7067549",
"0.700771",
"0.6988411",
"0.6988411",
"0.6985239",
"0.6980101",
"0.6974398",
"0.69332534",
"0.6932716... | 0.79085517 | 1 |
Fetches response in chunks. A signal handler is attached to abort reading after set timeout. | def chunked_read(self, response):
content = ""
max_bytes = 1 * 1024 * 1024 # Max. page size = 1MB
read_bytes = 0
bytes_per_read = 64 # Chunk size = 64 bytes
try:
signal.signal(signal.SIGALRM, self.signal_handler)
signal.alarm(self.timeout)
wh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def test_get_chunked_response(app, aiohttp_server):\n server = await aiohttp_server(app)\n url = \"http://localhost:%d/chunked\" % server.port\n\n async with aiosonic.HTTPClient() as client:\n res = await client.get(url)\n assert res.connection\n assert res.status_code == 200\n\... | [
"0.61439437",
"0.60653824",
"0.6050782",
"0.59710574",
"0.5729564",
"0.57216555",
"0.5706145",
"0.5535871",
"0.54798263",
"0.5426873",
"0.5386762",
"0.53736615",
"0.53563356",
"0.5317602",
"0.5292901",
"0.52758455",
"0.5269388",
"0.5248844",
"0.5211626",
"0.5201916",
"0.51841... | 0.7120292 | 0 |
Raises exception when signal is caught. | def signal_handler(self, signum):
raise Exception("Caught signal {0}".format(signum)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def signal_handler(sig, frame):\n raise ExitException()",
"def handler(signum, frame):\n print(\"Signal handler called with signal %i\" % signum)\n sys.exit(-1)",
"def signal_handler(signum, frame):\n sys.exit(0)",
"def handler(signum, frame):\n m.signal()",
"def _signal_handler(signum, ... | [
"0.803553",
"0.7288612",
"0.72802746",
"0.72309834",
"0.7150111",
"0.7031913",
"0.7030082",
"0.6936306",
"0.6909322",
"0.6847184",
"0.6838435",
"0.6838435",
"0.6838435",
"0.67732227",
"0.67535293",
"0.6732183",
"0.66868037",
"0.6624515",
"0.66071534",
"0.6565179",
"0.6563606"... | 0.846375 | 0 |
Function to check if a webhook host is responding. Not 100% sure this will work... | def webhook_available(webhook_url):
try:
data = urllib.urlopen(webhook_url)
return True
except Exception,e:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def health_check():\n # TODO: implement any other checking logic.\n return '', 200",
"def healthcheck(url):\n try:\n r = requests.get('http://localhost:5000/healthcheck')\n output = r.json()\n _ = output['Success']\n return True\n except:\n return False",
"def che... | [
"0.6538219",
"0.6474535",
"0.63755906",
"0.63575816",
"0.62816197",
"0.62704533",
"0.62274534",
"0.62244165",
"0.61951745",
"0.61951745",
"0.61951745",
"0.61951745",
"0.6184189",
"0.6140373",
"0.6077467",
"0.6055918",
"0.60510623",
"0.60488474",
"0.60394526",
"0.60317606",
"0... | 0.69039196 | 0 |
check if cache contains webhook records | def cacheFull(webhook_cache):
return webhook_cache.__len__() > 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def data_ready(req, cache):\n if not isinstance(req, list):\n req = [req]\n return all([r in cache for r in req])",
"def _check_cache(self):\n return os.path.exists(self._cache_key)",
"def needs_update(self, cache_key):\r\n return self._read_sha(cache_key) != cache_key.hash",
"def _cac... | [
"0.67980397",
"0.67874515",
"0.6698906",
"0.6586043",
"0.64829695",
"0.63593197",
"0.634683",
"0.6314407",
"0.62954384",
"0.62493676",
"0.62301904",
"0.6208536",
"0.618851",
"0.6148772",
"0.61471283",
"0.61179924",
"0.61052877",
"0.6030703",
"0.60292405",
"0.59897023",
"0.598... | 0.7811155 | 0 |
Read in the cities from the given `file_name`, and return | def read_cities(file_name):
stream = open(file_name)
data = stream.readlines()
stream.close()
roadmap = []
for city_info in data: # For each record in data file
if city_info != "\n": # Ignore new line characters
city_info = clean_data(city_info) # Clean the record
roa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_cities(filename):\n reader = csv.reader(open(filename, \"rb\")) # may raise IOError\n rows = [line for line in reader]\n cities = [City(r[2], index, r[3], float(r[0]), float(r[1])) for index, r in enumerate(rows[1:])]\n return cities",
"def load_cities (filename):\n if not os.path.isfile(... | [
"0.72439307",
"0.6996731",
"0.67822164",
"0.6532059",
"0.6417192",
"0.6333964",
"0.6256211",
"0.6219066",
"0.620637",
"0.6139866",
"0.60558707",
"0.6044223",
"0.60296524",
"0.5995132",
"0.5983866",
"0.59469134",
"0.5945272",
"0.5927988",
"0.59210974",
"0.59153545",
"0.5894373... | 0.77218175 | 0 |
Returns, as a floating point number, the sum of the distances of all the connections in the`road_map`. Remember that it's a cycle, so that (for example) in the initial `road_map`, Wyoming connects to Alabama... | def compute_total_distance(road_map):
distance = 0 # Assume starting distance is zero
i = 0 # Assume starting city is first city
while i < len(road_map):
a = i # Current city record
b = (i+1) % len(road_map) # Next city record
# Add the distance between current and next city to total... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_total_distance(road_map):\n \n try:\n distances = distances_and_limits(road_map)[0]\n return round(sum(distances),2)\n except Exception as e:\n print(str(e))",
"def route_distance(self, route):\n\n dist = 0\n src = route[0]\n\n if src not in self.G:\... | [
"0.76559687",
"0.6652124",
"0.6620934",
"0.65206414",
"0.64695156",
"0.63711315",
"0.6335806",
"0.6236584",
"0.616901",
"0.6113202",
"0.6080335",
"0.6056743",
"0.6051259",
"0.6049719",
"0.60322714",
"0.60083234",
"0.5994389",
"0.5942035",
"0.5896963",
"0.58883363",
"0.5869564... | 0.7853009 | 0 |
Take the city at location `index` in the `road_map`, and the city at location `index+1` (or at `0`, if `index` refers to the last element in the list), swap their positions in the `road_map`, compute the new total distance, and return the tuple (new_road_map, new_total_distance) | def swap_adjacent_cities(road_map, index):
# Index of next city record
next_index = (index + 1) % len(road_map)
# Swap cities adjacent in list
road_map[index], road_map[next_index] = swap(road_map[index], road_map[next_index])
# Calculate the new total distance after swapping adjacent cities
new... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_cities(road_map, index1, index2):\n \n new_road_map = road_map\n \n try:\n new_road_map[index1], new_road_map[index2] = \\\n new_road_map[index2], new_road_map[index1]\n return (new_road_map, compute_total_distance(new_road_map))\n \n except Exception as e:\n ... | [
"0.76736784",
"0.74458104",
"0.63561344",
"0.63140756",
"0.6208328",
"0.5913631",
"0.5604202",
"0.5589126",
"0.5545075",
"0.544258",
"0.53763044",
"0.53314894",
"0.5149896",
"0.51446813",
"0.5140692",
"0.50834876",
"0.5061894",
"0.5060054",
"0.5037708",
"0.5026234",
"0.498433... | 0.81807053 | 0 |
Take the city at location `index` in the `road_map`, and the city at location `index2`, swap their positions in the `road_map`, compute the new total distance, and return the tuple (new_road_map, new_total_distance) Allow for the possibility that `index1=index2`, and handle this case correctly. | def swap_cities(road_map, index1, index2):
# index1 and index2 are not the same, then the records at those indices are
# swapped. If they are the same, no swap needs to take place, so nothing happens
if index1 != index2:
road_map[index1], road_map[index2] = swap(road_map[index1], road_map[index2])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def swap_cities(road_map, index1, index2):\n \n new_road_map = road_map\n \n try:\n new_road_map[index1], new_road_map[index2] = \\\n new_road_map[index2], new_road_map[index1]\n return (new_road_map, compute_total_distance(new_road_map))\n \n except Exception as e:\n ... | [
"0.84133",
"0.77255523",
"0.6697679",
"0.56326914",
"0.56053174",
"0.55218035",
"0.5458247",
"0.5458247",
"0.54249436",
"0.5410191",
"0.53582215",
"0.5347274",
"0.53253174",
"0.5320039",
"0.52558106",
"0.52557606",
"0.5224326",
"0.5178354",
"0.5166681",
"0.5165461",
"0.516546... | 0.8132816 | 1 |
Using a combination of `swap_cities` and `swap_adjacent_cities`, try `10000` swaps, and each time keep the best cycle found so far. After `10000` swaps, return the best cycle found so far. | def find_best_cycle(road_map):
#Assume the best_cycle is the initial road map and calculate total distance
best_cycle = road_map
best_cycle_dist = compute_total_distance(road_map)
best_attempts = [best_cycle_dist]
# For each city in the road map
for i in range(len(road_map)):
for swaps ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_best_cycle(road_map):\n \n best_cycle = road_map\n best_dist = compute_total_distance(best_cycle)\n i = 0\n \n try: \n while i < 10000:\n attempt_map = shift_cities(best_cycle)\n rand_idx1 = random.randint(0, len(best_cycle)-1)\n rand_idx2 = ran... | [
"0.72458845",
"0.67092997",
"0.65292084",
"0.6267644",
"0.6142434",
"0.61354655",
"0.60492456",
"0.60107154",
"0.59841084",
"0.57791156",
"0.56441015",
"0.5638855",
"0.5590253",
"0.545325",
"0.5415052",
"0.5410125",
"0.53259945",
"0.5317228",
"0.5300528",
"0.52971405",
"0.527... | 0.7708961 | 0 |
Reads in, and prints out, the city data, then creates the "best" cycle and prints it out. | def main():
try_again = 'y'
road_map = read_cities("city-data.txt")
while try_again in {'y', 'Y', 'yes', 'Yes'}:
print("City data")
print("=========")
print_cities(road_map)
print('\n')
print('Searching for best solution...')
print('\n')
best_cycle, be... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n # create graph\n city = create_city()\n\n # create costs cities\n costs = create_costs()\n\n # create min path to city\n path = create_min_path()\n\n # create list not check city\n list_cities = ['biysk', 'barnaul', 'novosibirsk', 'belokurikha',\n 'tomsk', 'k... | [
"0.6353105",
"0.5945568",
"0.5775325",
"0.5695793",
"0.5682968",
"0.5631257",
"0.56272423",
"0.56174856",
"0.5595019",
"0.5594466",
"0.557142",
"0.5470627",
"0.53852445",
"0.5357324",
"0.5356361",
"0.5340294",
"0.533276",
"0.5296885",
"0.5294828",
"0.52794826",
"0.5271222",
... | 0.68590987 | 0 |
Only show LuxRender panel if luxrender_texture.type in LUX_COMPAT | def poll(cls, context):
tex = context.texture
if not tex:
return False
if context.texture.luxrender_texture.type == 'BLENDER':
return tex and \
(context.scene.render.engine in cls.COMPAT_ENGINES) and \
context.texture.type in cls.BL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_texture_mode():\n for area in bpy.context.screen.areas:\n if area.type == \"VIEW_3D\":\n for space in area.spaces:\n if space.type == \"VIEW_3D\":\n space.viewport_shade = \"TEXTURED\"\n return",
"def texture_mode_enabled():\n for area in bp... | [
"0.6023356",
"0.5980958",
"0.5532867",
"0.5357013",
"0.5289452",
"0.5277539",
"0.5256092",
"0.5245391",
"0.5209757",
"0.51528955",
"0.5142654",
"0.51215154",
"0.5114279",
"0.509669",
"0.5091106",
"0.5084364",
"0.507169",
"0.5029793",
"0.49978572",
"0.49526116",
"0.4941895",
... | 0.6526276 | 0 |
>>> coin_values(0) set([0]) >>> coin_values(1) set([1, 10]) >>> coin_values(2) set([2, 11, 20]) >>> coin_values(3) set([3, 12, 21, 30]) >>> coin_values(11) set([65, 101, 38, 74, 11, 110, 47, 83, 20, 56, 92, 29]) | def coin_values(num_coins):
# purse = [1 for x in range(nums)]
values = [num_coins]
for i in range(num_coins):
values.append((values[-1]) + 9)
# print values
return set(values) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square():\n square_list = set()\n for seed_value in range(1, 101):\n square_list.add(int(math.pow(seed_value, 2)))\n return set(square_list)",
"def gen_all_holds(hand):\r\n possible_holds = set([()])\r\n \r\n for dice in hand:\r\n temp_holds = possible_holds.copy()\r\n ... | [
"0.59053606",
"0.5728425",
"0.57054996",
"0.5641704",
"0.5633233",
"0.5595103",
"0.5584083",
"0.5504031",
"0.5502492",
"0.5469065",
"0.5362648",
"0.5350322",
"0.5339916",
"0.53298897",
"0.5325901",
"0.53060514",
"0.529437",
"0.526106",
"0.52455795",
"0.52302414",
"0.5205886",... | 0.8361852 | 0 |
this function works recursively by appending taking a list and appending the last element in the list reflected over the incoming or outgoing understrand alternating you initialize with inout_strands_index as either zero or one which indictes if you are reflecting over the incoming understrand inout_strands[0] or the o... | def reflect_list( wall_1side_list , inout_strands , inout_strands_index , p ):
if len(wall_1side_list)==((p-1)/2)+1: # base case
return wall_1side_list #return
else:
if inout_strands_index == 0:
wall_color = wall_1side_list[-1] # bottom universe at crossing
wall_1side_li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reflect_list(wall_1side_list, inout_strands, inout_strands_index, p):\n if len(wall_1side_list) == ((p-1)/2)+1: # base casep\n return wall_1side_list # return\n else:\n if inout_strands_index == 0:\n wall_color = wall_1side_list[-1] # bottom universe at crossing\n #... | [
"0.544504",
"0.5269664",
"0.52664673",
"0.5246358",
"0.51794237",
"0.50628406",
"0.5027323",
"0.4993085",
"0.49869806",
"0.49188158",
"0.48741582",
"0.4809533",
"0.4718145",
"0.47074604",
"0.46947247",
"0.46799713",
"0.46788383",
"0.46590352",
"0.4639226",
"0.46202534",
"0.46... | 0.5615725 | 0 |
The surpluss of bus feed summed over all buses always has to be equal to the sum of losses in all branches. | def branch_loss_consistent_with_bus_feed_in(net, atol=1e-2):
# Active Power
bus_surplus_p = -net.res_bus.p_mw.sum()
bus_surplus_q = -net.res_bus.q_mvar.sum()
branch_loss_p = net.res_line.pl_mw.values.sum() + net.res_trafo.pl_mw.values.sum() + \
net.res_trafo3w.pl_mw.values.sum... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_loss_consistent_with_bus_feed_in_3ph(net, atol=1e-2):\r\n bus_surplus_p = -net.res_bus_3ph[[\"p_a_mw\", \"p_b_mw\", \"p_c_mw\"]].sum().sum()\r\n bus_surplus_q = -net.res_bus_3ph[[\"q_a_mvar\", \"q_b_mvar\", \"q_c_mvar\"]].sum().sum()\r\n\r\n\r\n branch_loss_p = net.res_line_3ph.p_a_l_mw.sum() +... | [
"0.58292574",
"0.56602716",
"0.5566185",
"0.54782647",
"0.54704815",
"0.5439919",
"0.5434204",
"0.541722",
"0.5402526",
"0.5385841",
"0.53645575",
"0.5361313",
"0.5354627",
"0.53530455",
"0.5347496",
"0.53444093",
"0.53249437",
"0.53206193",
"0.5312479",
"0.52976394",
"0.5292... | 0.6127412 | 0 |
The surpluss of bus feed summed over all buses always has to be equal to the sum of losses in all branches. | def branch_loss_consistent_with_bus_feed_in_3ph(net, atol=1e-2):
bus_surplus_p = -net.res_bus_3ph[["p_a_mw", "p_b_mw", "p_c_mw"]].sum().sum()
bus_surplus_q = -net.res_bus_3ph[["q_a_mvar", "q_b_mvar", "q_c_mvar"]].sum().sum()
branch_loss_p = net.res_line_3ph.p_a_l_mw.sum() + net.res_trafo_3ph.p_a_l_mw... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def branch_loss_consistent_with_bus_feed_in(net, atol=1e-2):\r\n # Active Power\r\n bus_surplus_p = -net.res_bus.p_mw.sum()\r\n bus_surplus_q = -net.res_bus.q_mvar.sum()\r\n\r\n branch_loss_p = net.res_line.pl_mw.values.sum() + net.res_trafo.pl_mw.values.sum() + \\\r\n net.res_trafo3... | [
"0.6126706",
"0.56610614",
"0.55678314",
"0.5478029",
"0.54704237",
"0.543905",
"0.54348576",
"0.5416796",
"0.54024583",
"0.5387109",
"0.53672194",
"0.5362199",
"0.53545314",
"0.53529966",
"0.5346962",
"0.5345048",
"0.53268874",
"0.53217334",
"0.5310922",
"0.52981484",
"0.529... | 0.5829145 | 1 |
Assert a number passed to tag with argument display_decimals False does not display decimals when 00. | def test_no_decimals_00(self):
self.assertEqual(currency(188.00, False), "$188") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_decimals_01(self):\n self.assertEqual(currency(188.01, False), \"$188.01\")",
"def test_number_simple(self):\r\n self.assertEquals(preview.latex_preview('3.1415'), '3.1415')",
"def test_wiki_toc_isfloat_false(self):\n from .wiki_toc import isfloat\n value = isfloat(value... | [
"0.61401683",
"0.57133216",
"0.5703246",
"0.56233907",
"0.5574115",
"0.5511028",
"0.550595",
"0.5451425",
"0.5396696",
"0.5382282",
"0.5381448",
"0.5380363",
"0.5376688",
"0.5369877",
"0.5342699",
"0.53198934",
"0.5292737",
"0.5273223",
"0.5248871",
"0.52488697",
"0.52481884"... | 0.61873174 | 0 |
r"""Returns the action space that policy performs on. | def action_space(self):
return self.env_spec.action_space | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def action_space(self):\n return self._action_wrapper.action_space",
"def get_action_space(self):\n return Discrete(len(self.get_actions()))",
"def action_space(self):\n return gym.spaces.Discrete(self._action_dim)",
"def action_space(self, agent: str) -> gymnasium.spaces.Space:\n war... | [
"0.7837048",
"0.7486192",
"0.74694705",
"0.73516476",
"0.7326134",
"0.72584546",
"0.71716523",
"0.7131896",
"0.7076131",
"0.6897297",
"0.67757976",
"0.67757976",
"0.6718645",
"0.67066896",
"0.6687041",
"0.66449946",
"0.65590596",
"0.6475917",
"0.6332233",
"0.6315486",
"0.6311... | 0.80745023 | 1 |
r"""Returns whether the policy is recurrent. | def recurrent(self):
if isinstance(self.network, BaseRNN):
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_reflexive(self):\n return self.prop.is_reflexive()",
"def can_reschedule(self) -> bool:\n return pulumi.get(self, \"can_reschedule\")",
"def recurrent(self):\n return False",
"def is_recurrent(self):\n G = self._get_recurrence_graph()\n # C = G.strongly_connected_com... | [
"0.6694336",
"0.6680432",
"0.66555315",
"0.62772393",
"0.62066406",
"0.61822164",
"0.61618847",
"0.6117372",
"0.59886795",
"0.5922258",
"0.5832822",
"0.57971984",
"0.57971984",
"0.5784836",
"0.5766871",
"0.56962794",
"0.5682805",
"0.564809",
"0.5638683",
"0.56207746",
"0.5568... | 0.7273399 | 0 |
r"""Reset the current RNN states. | def reset_rnn_states(self):
if self.recurrent:
self.rnn_states = self.network.init_hidden_states(config=self.config,
batch_size=self.env_spec.num_env)
else:
raise TypeError('the network must be BaseRNN type. ') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n self.train_loss.reset_states()\n self.train_accuracy.reset_states()\n self.val_loss.reset_states()\n self.val_accuracy.reset_states()\n self.train_mIoU.reset_states()\n self.val_mIoU.reset_states()",
"def reset_states(self):\n self.model.reset_s... | [
"0.8079816",
"0.80538666",
"0.79646987",
"0.77307993",
"0.7609432",
"0.7465221",
"0.74635816",
"0.745131",
"0.7450169",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7449714",
"0.7433669",
... | 0.83921635 | 0 |
Check if the actual dtype is in expected_dtypes tuple | def valid_dtype_assertion(expected_dtypes, actual_dtype, name):
assert (actual_dtype in expected_dtypes), "Invalid dtype of {} should be {}".format(name, str(expected_dtypes)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dtype_equality(self):\r\n dtypes = get_numeric_types(with_complex=True)\r\n # Perform all pairwise comparisons of dtypes, making sure comparing\r\n # their string representation yields the same result.\r\n for dtype1_idx, dtype1 in enumerate(dtypes):\r\n for dtype2 i... | [
"0.78190494",
"0.7479696",
"0.7407937",
"0.7095204",
"0.70427704",
"0.70244956",
"0.69943213",
"0.6901867",
"0.68711364",
"0.6862474",
"0.67503256",
"0.6712344",
"0.66905665",
"0.6676588",
"0.66409034",
"0.66302294",
"0.66069466",
"0.6569878",
"0.6553351",
"0.65489155",
"0.65... | 0.80109257 | 0 |
Check if the actual ndim is in expected ndim tuple | def valid_ndim_assertion(expected_dimentions, actual_dimention, name):
assert (actual_dimention in expected_dimentions), "Invalid ndim of {} should be {}".format(name, str(expected_dimentions)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_array_ndim(arr, name, expected_ndim=2):\n # We just need to check that the number of dimensions if equal to expected_ndim\n ndim = len(arr.shape)\n check_value(is_valid=(ndim == expected_ndim), error_msg=\n 'The number of dimension of ' + name\n + ' is ' + str(ndim)... | [
"0.71711177",
"0.71435803",
"0.70212257",
"0.700304",
"0.69926876",
"0.69876844",
"0.6861123",
"0.684691",
"0.6846467",
"0.68399537",
"0.6837438",
"0.683425",
"0.6826134",
"0.68195385",
"0.6801152",
"0.67770356",
"0.6753209",
"0.6751555",
"0.67428553",
"0.6703972",
"0.668648"... | 0.7787045 | 0 |
this is for check a ndarray has valid of dtype and ndim. Parematers ndarray ndarray numpy the ndarray form which the properties will be obtained expected_dtypes dtypes tuple this are the set of valid types. expected_dimentions int tuple this are the set of valid ndim. name string the name for the assertion error messag... | def validate_ndarray(ndarray, expected_dtypes, expected_dimentions, name):
valid_dtype_assertion(expected_dtypes, ndarray.dtype, name)
valid_ndim_assertion(expected_dimentions, ndarray.ndim, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def valid_ndim_assertion(expected_dimentions, actual_dimention, name):\n\tassert (actual_dimention in expected_dimentions), \"Invalid ndim of {} should be {}\".format(name, str(expected_dimentions))",
"def test_shape(self, varname, varshape, ndim): \n if len(varshape) != ndim:\n raise ShapeErro... | [
"0.7493631",
"0.7208451",
"0.7202041",
"0.71171033",
"0.70398784",
"0.6981742",
"0.696444",
"0.67768437",
"0.6616017",
"0.6589878",
"0.6572059",
"0.65380645",
"0.6445883",
"0.64455783",
"0.6427266",
"0.63516784",
"0.63156116",
"0.6310805",
"0.6304929",
"0.630264",
"0.630053",... | 0.84904623 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.