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 |
|---|---|---|---|---|---|---|
Recupera do servidor a lista de servidores associados a guilda consultada | def get_list_servers(p_id_guilda):
server_list = select_data.get_guild_servers(p_id_guilda)
#css_mensagem = '```css\n####### SERVERS ################'
list_server = []
for server in server_list:
if server['description'] != None:
description_server = server['description']
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def redis_client_list(self):\n def func(server):\n return server.server.client_list()\n self.__run_redis_cmd(func)",
"def load_servers_from_db(self):\r\n db = self.getDB()\r\n cursor = db.cursor()\r\n\r\n res = cursor.execute(\"\"\"SELECT * FROM `IRC_servers` WHERE `... | [
"0.68262804",
"0.66768247",
"0.6599744",
"0.65755504",
"0.64908904",
"0.6244407",
"0.6241114",
"0.61838216",
"0.61600584",
"0.60755295",
"0.6030671",
"0.59916914",
"0.5982203",
"0.59614354",
"0.5943407",
"0.5913406",
"0.58924514",
"0.58590823",
"0.5850152",
"0.5847823",
"0.58... | 0.6723718 | 1 |
Given a graph, G and a source and sink (background and foreground), FF will use the FordFulkerson to find the max flow of the graph = min cut | def FF(G):
# create index for background and foreground
back = len(G)-2
fore = len(G)-1
# create empty path to start (will be filled by one iteration of BFS)
# BFS will check all nodes (filling the path completely) and will update path
path = [-1]*len(G)
max_flow = 0
# while a path ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ford_fulkerson_algorithm(graph: np.ndarray, source: int, sink: int) -> np.ndarray:\r\n\r\n residual_graph = copy.deepcopy(graph)\r\n row = len(residual_graph)\r\n parent = [-1] * row\r\n max_flow = 0\r\n\r\n if source == sink or sink < 0 or source < 0 or source >= row or sink >= row:\r\n ... | [
"0.7220995",
"0.6513646",
"0.63755757",
"0.63598967",
"0.6199371",
"0.6149783",
"0.59793204",
"0.5815335",
"0.57068366",
"0.56810206",
"0.5614138",
"0.5564206",
"0.5473571",
"0.54486114",
"0.5408489",
"0.54058605",
"0.5382023",
"0.53799087",
"0.53791517",
"0.53403616",
"0.532... | 0.6811761 | 1 |
Lists all modules enabled for reading | def modules_enabled(self, c):
modules = []
for name, module in self.modules.iteritems():
modules.append( (name, module.__class__.__name__) )
return modules | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enabled_modules(self):\n return [scomp for scomp in self.modules()\n if getattr(scomp, 'enabled', True)]",
"def showModules():\n keys, values = sys.modules.keys(), sys.modules.values()\n keys.sort()\n modulesList = ''\n for key in keys:\n modulesList += key+' '\n\n ... | [
"0.73525804",
"0.7195542",
"0.70797795",
"0.69543386",
"0.69462514",
"0.6944474",
"0.68327576",
"0.67939305",
"0.67652476",
"0.67583793",
"0.6754832",
"0.6685438",
"0.6677347",
"0.6613316",
"0.660625",
"0.6601403",
"0.6578693",
"0.65483433",
"0.6507556",
"0.65029275",
"0.6494... | 0.7321039 | 1 |
Get the core plugin should be implemented by each driver | def core_plugin(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_plugin_interface(self):",
"def get_plugin_classes():\n\n # Force the selection of a toolkit:\n from enthought.traits.ui.api import toolkit\n toolkit()\n from enthought.etsconfig.api import ETSConfig\n try_use_ipython = preference_manager.root.use_ipython\n use_ipython = False\n if ET... | [
"0.6962008",
"0.6383961",
"0.6339505",
"0.62795734",
"0.6274229",
"0.61346227",
"0.61232555",
"0.6111184",
"0.60962766",
"0.60188365",
"0.59543604",
"0.5934437",
"0.58710885",
"0.585612",
"0.5822372",
"0.5810339",
"0.5796572",
"0.57886827",
"0.57826865",
"0.5768762",
"0.57596... | 0.73781383 | 0 |
Validate NSX backend supports FWaaS Can be implemented by each driver | def validate_backend_version(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_supported_features(self):",
"def verify_support():\n ostype, majorrelease, _ = get_os_release_data()\n if ostype not in _supported_os:\n _logger.info('OS type %s is not supported.', ostype)\n return False\n if majorrelease not in _supported_release:\n _logger.info('OS %s %... | [
"0.66586536",
"0.6007394",
"0.5991885",
"0.5941555",
"0.5941555",
"0.5880553",
"0.5739063",
"0.5629603",
"0.56251514",
"0.56069356",
"0.5590402",
"0.552187",
"0.55049",
"0.54795337",
"0.5479011",
"0.5474474",
"0.54678535",
"0.54673284",
"0.54668057",
"0.5445871",
"0.5434607",... | 0.6062802 | 1 |
Return True if the firewall rules should be added the router | def should_apply_firewall_to_router(self, router_data):
if not router_data.get('external_gateway_info'):
LOG.info("Cannot apply firewall to router %s with no gateway",
router_data['id'])
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_router(self):\n # @todo: Rewrite\n return self.address_set.count() > 1",
"def should_apply_firewall_to_router(self, context, router_id):\n if not super(Nsxv3FwaasCallbacksV1,\n self).should_apply_firewall_to_router(context,\n ... | [
"0.6369625",
"0.63313717",
"0.60524714",
"0.6008175",
"0.5844205",
"0.5764158",
"0.55678964",
"0.55205417",
"0.5501063",
"0.54529506",
"0.5423895",
"0.5395422",
"0.53850245",
"0.53648263",
"0.53387725",
"0.5338227",
"0.53378403",
"0.5306474",
"0.5290564",
"0.52862334",
"0.528... | 0.69393283 | 0 |
Compare two images, expecting a particular RMS error. im1 and im2 are filenames relative to the baseline_dir directory. tol is the tolerance to pass to compare_images. expect_rms is the expected RMS value, or None. If None, the test will succeed if compare_images succeeds. Otherwise, the test will succeed if compare_im... | def image_comparison_expect_rms(im1, im2, tol, expect_rms):
im1 = os.path.join(baseline_dir, im1)
im2_src = os.path.join(baseline_dir, im2)
im2 = os.path.join(result_dir, im2)
# Move im2 from baseline_dir to result_dir. This will ensure that
# compare_images writes the diff file to result_dir, inste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compare_images(self, ax, filename, tol=10):\n assert isinstance(ax, Artist)\n if GENERATE_BASELINE:\n savefig(os.path.join(BASELINE_DIR, filename))\n savefig(os.path.join(self.tempdir, filename))\n err = compare_images(os.path.join(BASELINE_DIR, filename),\n ... | [
"0.6774918",
"0.6166663",
"0.60055065",
"0.58556736",
"0.57545406",
"0.57281005",
"0.56910443",
"0.5681535",
"0.56446886",
"0.5560447",
"0.5496189",
"0.5476247",
"0.5460852",
"0.5297204",
"0.52855736",
"0.52817315",
"0.5193507",
"0.51113427",
"0.50988805",
"0.5091349",
"0.501... | 0.8803048 | 0 |
Renames the remote object `source` as `filename`. | def mv(self, source: str, filename: str) -> None:
self.cp(source, filename)
self.rm(source) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def renamed(self, source, dest):\r\n self.__close_and_reload(source, new_filename=dest)",
"def rename(self, src, dst):\n os.rename(src, dst)",
"def rename(self, name=None, destination=None):\n raise NotImplementedError\n return None",
"def rename(self, target):\n target = o... | [
"0.66736585",
"0.61954975",
"0.6188893",
"0.61185676",
"0.6105106",
"0.6065581",
"0.60061115",
"0.5984833",
"0.5973025",
"0.59440464",
"0.59394705",
"0.5743361",
"0.56863225",
"0.56793886",
"0.56793886",
"0.56656957",
"0.5629569",
"0.5627689",
"0.5606619",
"0.55541617",
"0.54... | 0.67396265 | 0 |
Get the mean pixel values across the dataset for all coordinates Will return a [C,H,W] shaped torch.tensor | def get_mean_coord(self):
# load dataset in a dummy manner
dataset = torchvision.datasets.MNIST('../../data/MNIST_data/', train=True, download=False)
mean = (dataset.data.float().mean(0) / 255).unsqueeze(0) # [1,28,28]
return mean | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mean_coord(self):\n # load dataset in a dummy manner\n dataset = torchvision.datasets.CIFAR10('../../data/CIFAR_data/', train=True, download=False)\n data = torch.FloatTensor(dataset.data).permute(0, 3, 1, 2) # shape [num_img, 3, 32, 32]\n mean = data.mean(0) / 255 # [3,32,32]... | [
"0.755946",
"0.6978839",
"0.6882663",
"0.6746081",
"0.6654038",
"0.6605897",
"0.6583859",
"0.65773165",
"0.6476074",
"0.6457095",
"0.64478827",
"0.6445506",
"0.64343315",
"0.6434308",
"0.6434166",
"0.6421386",
"0.6399245",
"0.6388089",
"0.6370936",
"0.63649416",
"0.6344257",
... | 0.7259522 | 1 |
Get the mean pixel values across the dataset for all coordinates Will return a [C,H,W] shaped torch.tensor | def get_mean_coord(self):
# load dataset in a dummy manner
dataset = torchvision.datasets.CIFAR10('../../data/CIFAR_data/', train=True, download=False)
data = torch.FloatTensor(dataset.data).permute(0, 3, 1, 2) # shape [num_img, 3, 32, 32]
mean = data.mean(0) / 255 # [3,32,32]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mean_coord(self):\n # load dataset in a dummy manner\n dataset = torchvision.datasets.MNIST('../../data/MNIST_data/', train=True, download=False)\n mean = (dataset.data.float().mean(0) / 255).unsqueeze(0) # [1,28,28]\n return mean",
"def mean_allcnnc():\n # TODO implement ... | [
"0.72589284",
"0.6978652",
"0.6880891",
"0.6747932",
"0.6652633",
"0.6604227",
"0.6583818",
"0.6574959",
"0.647404",
"0.6456031",
"0.64457744",
"0.64428407",
"0.6433864",
"0.64326847",
"0.64324236",
"0.6419911",
"0.63975173",
"0.63865525",
"0.6368913",
"0.63662386",
"0.634220... | 0.75593 | 0 |
function to get the similarity matrix specific for the test case. The instances that we map the distance to are the provided train instances. | def getSimilarityMatrixTest(testBags, trainInstances, labels):
similarityMatrix = np.zeros([testBags.shape[0], trainInstances.shape[0]])
#print(similarityMatrix.shape)
for bagInd in range(0, testBags.shape[0]):
#print(labels[bagInd])
#get the average of all instances in this test patient bag
testInstances =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDistanceM(self, test, train):\n p = 2 # TUNE currently euclidian distance\n distanceM = pd.DataFrame(index=test.index.values, columns=train.index.values)\n for testrow, testing in test.iterrows():\n for trainrow, training in train.iterrows():\n tot = 0\n ... | [
"0.6784363",
"0.6022616",
"0.5967267",
"0.59669846",
"0.58467686",
"0.58432096",
"0.581799",
"0.58019656",
"0.57023007",
"0.5694741",
"0.56717575",
"0.5650801",
"0.5608074",
"0.55852276",
"0.55694515",
"0.5533678",
"0.5530354",
"0.55099696",
"0.54819864",
"0.5478882",
"0.5475... | 0.73847157 | 0 |
get club player number | def get_club_player_number(club_id, type):
cursor = connection.cursor()
try:
sql = "select number from btp_player%s where ClubID = %s " % (type, club_id)
cursor.execute(sql)
infos = cursor.fetchall()
numbers = set()
if infos:
for info in infos:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_player_num(self):\r\n return self.player_control.get_player_num()",
"def info_player_id(self, playername):\r\n number = 0\r\n name = playername.title().replace(\" \", \"+\")\r\n headers = {\"Content-type\": \"application/x-www-form-urlencoded\", \"Accept\": \"text/plain\",\r\n... | [
"0.76977646",
"0.7178991",
"0.69293433",
"0.6737305",
"0.66757345",
"0.65458876",
"0.6466579",
"0.6436842",
"0.64020866",
"0.6390754",
"0.6387966",
"0.63808894",
"0.6292459",
"0.6177683",
"0.61504906",
"0.6141488",
"0.6079721",
"0.6079721",
"0.60252047",
"0.5968486",
"0.59073... | 0.73717844 | 1 |
Create unique and secure filename is field name of current data now. | def unique_filename(data):
file = data
get_ext = file.filename.split(".")[-1]
new_name = "%s.%s" % (uuid.uuid4().hex, get_ext)
return new_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_file_name(self):\n # create a unique id for the file name\n index = self.helpers.alpha_uuid()\n\n filename = self.form['FieldStorage'][self.image_cid].filename\n extension = guess_extension(guess_type(filename)[0])\n return ( # concatenates the following data\n ... | [
"0.7432633",
"0.73596436",
"0.72354007",
"0.72344303",
"0.7162284",
"0.700368",
"0.6998772",
"0.696573",
"0.69122726",
"0.68828297",
"0.68639725",
"0.68490016",
"0.6805709",
"0.6797652",
"0.67734665",
"0.67452866",
"0.67387444",
"0.67148685",
"0.671018",
"0.6706373",
"0.66949... | 0.77626705 | 0 |
The name of the connector. | def connector_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "connector_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connector_mapping_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"connector_mapping_name\")",
"def connection_name(self) -> str:\n return pulumi.get(self, \"connection_name\")",
"def getConnectionName(self):\n return self.system",
"def connection_name(self) -> pulumi.Ou... | [
"0.7337074",
"0.732946",
"0.73207146",
"0.7130238",
"0.70410424",
"0.70390975",
"0.70390975",
"0.703408",
"0.69587594",
"0.69246274",
"0.6804043",
"0.6703014",
"0.6703014",
"0.6581841",
"0.6571527",
"0.6548757",
"0.6536891",
"0.6471821",
"0.644584",
"0.64090055",
"0.64068276"... | 0.86829066 | 0 |
The name of the hub. | def hub_name(self) -> pulumi.Input[str]:
return pulumi.get(self, "hub_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hub_name(self):\n return self._props[\"persistent_identifiers\"].get(self._hub_name_prop)",
"def hub(self) -> str:\n return self._db_data.hub",
"def name(self):\n return f'{self._vehicle.name} {self.wan_name} Signal'",
"def name(self):\n return \"{} {}\".format(self._clientname, s... | [
"0.86040986",
"0.7757109",
"0.7266456",
"0.7262012",
"0.72566485",
"0.7248894",
"0.7248894",
"0.7248894",
"0.72286797",
"0.72268325",
"0.7159816",
"0.71467173",
"0.7144651",
"0.7131295",
"0.7124113",
"0.7124113",
"0.7124113",
"0.7124113",
"0.7106911",
"0.7100647",
"0.70927584... | 0.8609149 | 0 |
Get an existing ConnectorMapping resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None) -> 'ConnectorMapping':
opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))
__props__ = ConnectorMappingArgs.__new__(ConnectorMappingArgs)
__props__.__d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None) -> 'EventSourceMapping':\n opts = pulumi.ResourceOptions.merge(opts, pulumi.ResourceOptions(id=id))\n\n __props__ = EventSourceMappingArgs.__new__(EventSourceMappingArgs)\n\n ... | [
"0.5439401",
"0.50408334",
"0.4999506",
"0.4942603",
"0.4843693",
"0.4836924",
"0.48336312",
"0.480726",
"0.47471997",
"0.47456554",
"0.47390932",
"0.47378042",
"0.4714236",
"0.47014263",
"0.4654256",
"0.46435213",
"0.46350497",
"0.46056616",
"0.4586789",
"0.45752186",
"0.457... | 0.7106133 | 0 |
The connector mapping name | def connector_mapping_name(self) -> pulumi.Output[str]:
return pulumi.get(self, "connector_mapping_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connector_name(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"connector_name\")",
"def mapping_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"mapping_name\")",
"def schema_mappings(self):\n pass",
"def configuration_configmap_name(self) -> Optional[st... | [
"0.71356994",
"0.6227197",
"0.6107515",
"0.60861796",
"0.5903945",
"0.583965",
"0.5805953",
"0.5772707",
"0.5756182",
"0.5756182",
"0.5708169",
"0.5708169",
"0.5677598",
"0.56659704",
"0.56199807",
"0.5613059",
"0.5612902",
"0.5589546",
"0.5584832",
"0.5576773",
"0.5560229",
... | 0.8594048 | 0 |
The next run time based on customer's settings. | def next_run_time(self) -> pulumi.Output[str]:
return pulumi.get(self, "next_run_time") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next(self):\n\n crontab = self._crontab\n return math.ceil(crontab.next(default_utc=False))",
"def get_nightly_start_time():\n return 14 # 2PM local Tucson time",
"def time_run(self):\n if self._time_run is None:\n self._time_run = datetime.now(timezone.utc)\n ret... | [
"0.6682652",
"0.6635397",
"0.65648395",
"0.64742404",
"0.64222664",
"0.6402251",
"0.6375578",
"0.62770134",
"0.6224094",
"0.62018615",
"0.62018615",
"0.61462617",
"0.6141664",
"0.60939384",
"0.60898864",
"0.6061057",
"0.6052802",
"0.60277456",
"0.60277456",
"0.6014334",
"0.60... | 0.76147455 | 1 |
print a 2x2 grid with squares of size x/2 by x/2 | def print_grid(x):
row = int(x/2)
if x % 2 == 0:
col = x
else:
col = x - 1
for i in range(2):
prow(row)
for i in range(row):
pcolumn(col)
prow(row) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_square(size):\n if not isinstance(size, int):\n raise ValueError(\"size must be an integer\")\n if size < 0:\n raise ValueError(\"size must be >= 0\")\n if size == 0:\n return\n for row in range(int(size)):\n for col in range(int(size)):\n print(\"{:s}\"... | [
"0.7685149",
"0.7678649",
"0.7626484",
"0.749714",
"0.74652517",
"0.7443684",
"0.7438695",
"0.738604",
"0.7335196",
"0.7323832",
"0.7323042",
"0.7318823",
"0.71894294",
"0.7176586",
"0.7169575",
"0.7140502",
"0.7096254",
"0.70879203",
"0.70642245",
"0.70536673",
"0.7047173",
... | 0.814317 | 0 |
print a y by y grid with squares of size z by z | def print_grid2(y, z):
for i in range(y):
prow(z, y)
for i in range(z):
pcolumn(z*2, y)
prow(z, y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_grid(grid):\n\n\tprint(\"\"\"\n 0 1 2 3 4 5 6 7\n\t \n ▼ ▼ ▼ ▼ ▼ ▼ ▼ ▼ \"\"\", colors.BOLD + \"(X)\" + colors.STOP, end = '')\n\n\tprint('\\n\\n')\n\n\trow = 0\n\n\tfor i in range(8):\n\t\tprint(' ', row, ' ▶ ', end = ' ... | [
"0.72268575",
"0.71651113",
"0.71262723",
"0.7122105",
"0.71041363",
"0.70922005",
"0.7041609",
"0.69977385",
"0.6995312",
"0.69859946",
"0.69331205",
"0.6890829",
"0.6885073",
"0.68819237",
"0.6870847",
"0.68504167",
"0.68301773",
"0.68297184",
"0.6766032",
"0.67587227",
"0.... | 0.8213835 | 0 |
Generate raw data for deepmd | def deepmd_raw_generate(vasp_dir: str, deepmd_dir: str, deepmd_data: Dict):
vasp_set_list = [
os.path.join(vasp_dir, vasp_set_dir_name)
for vasp_set_dir_name in os.listdir(vasp_dir)
if vasp_set_dir_name.startswith('set')
]
vasp_set_list_absolute = [
os.path.abspath(vasp_set) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateDerivedData():\n # Empty all derivied tables, in reverse order that they are populated.\n PartOfPerspectives.deleteAll()\n PartOfs.deleteAll()\n RelationshipsTransitive.deleteAll()\n\n # Derive the transitive closure of the relationship graph\n RelationshipsTransitive.regenerateTable(... | [
"0.6110141",
"0.58401746",
"0.5788994",
"0.5770835",
"0.5721246",
"0.570747",
"0.5629988",
"0.5628113",
"0.55555266",
"0.5409818",
"0.54081583",
"0.54050696",
"0.53423834",
"0.5333344",
"0.53151476",
"0.530112",
"0.5297523",
"0.5295706",
"0.52634424",
"0.5261391",
"0.525146",... | 0.6375107 | 0 |
Remove extra test_configs and raw file | def deepmd_clear_raw_test_configs(deepmd_dir: str):
with auxiliary.cd(deepmd_dir):
raw_file_list = [raw for raw in os.listdir('.') if raw.endswith('raw')]
for raw_file in raw_file_list:
os.remove(raw_file)
test_configs = 'test.configs'
os.remove(test_configs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_test_files():\n a_copy = PY_FILES[::]\n for f in a_copy:\n if 'test' in f:\n TEST_FILES.append(f)\n PY_FILES.remove(f)",
"def tearDown():\n for output_file_path in Path(output_dir).glob(\"test_voting_learner_cross_validate*\"):\n output_file_path.unlink()\n\... | [
"0.6716044",
"0.63534313",
"0.62878484",
"0.61727023",
"0.6160238",
"0.61546147",
"0.6109537",
"0.606747",
"0.6036883",
"0.6019035",
"0.5984001",
"0.5983336",
"0.5980338",
"0.59782064",
"0.5963823",
"0.59259063",
"0.5925412",
"0.5915584",
"0.5912946",
"0.59095067",
"0.5907634... | 0.74847734 | 0 |
Generate json file for deepmd training | def deepmd_json_param(deepmd_graph_dir: str, deepmd_data: Dict,
iter_index: int):
# Specify more parameter option from json file
# specify json file path
deepmd_json_path = os.path.join(deepmd_graph_dir, 'deepmd.json')
# Generate a random number as a random seed
deepmd_data['... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_dataset_description(out_file, model_level):\n repo_url = \"https://github.com/nilearn/nilearn\"\n dataset_description = {\n \"GeneratedBy\": {\n \"Name\": \"nilearn\",\n \"Version\": nilearn.__version__,\n \"Description\": (\n \"A Nilearn \... | [
"0.6295783",
"0.6254815",
"0.6219662",
"0.6149883",
"0.6143432",
"0.6131629",
"0.6117298",
"0.6104919",
"0.60421896",
"0.60385656",
"0.60048807",
"0.59764755",
"0.59588426",
"0.5954378",
"0.59526527",
"0.5946836",
"0.59187007",
"0.58729535",
"0.5863106",
"0.58422536",
"0.5841... | 0.6611401 | 0 |
Train and freeze the graph in the deepmd_graph_dir | def deepmd_run(iter_index: int, deepmd_graph_dir: str, deepmd_data: Dict,
need_continue: bool):
dp_train_path = os.path.join(deepmd_data['deepmd_bin_path'], 'dp_train')
dp_frz_path = os.path.join(deepmd_data['deepmd_bin_path'], 'dp_frz')
print(f'Now start training in the deepmd_graph_dir {dee... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_on_whole_data(self):\n save_model_path = './savedModel/cnn-model'\n self.build_graph(save_model_path)\n\n tf.reset_default_graph()\n with tf.Session(graph=tf.get_default_graph()) as sess:\n try:\n graph = self.__load_graph(sess, save_model_path)\n ... | [
"0.6872082",
"0.6623188",
"0.63124806",
"0.62768054",
"0.6256553",
"0.623286",
"0.6227331",
"0.6225679",
"0.62129956",
"0.62015235",
"0.61930925",
"0.6157583",
"0.61469805",
"0.61318874",
"0.6128298",
"0.6120909",
"0.6104487",
"0.6077759",
"0.60667485",
"0.60667485",
"0.60514... | 0.7235948 | 0 |
deepmd_single_process function for continue mode | def deepmd_single_process_continue_iter(deepmd_graph_dir: str,
deepmd_data: Dict,
iter_index: int,
need_continue: bool):
# Training and freezing the model
deepmd_run(iter_index, deepmd_graph_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deepmd_single_process_initial_iter(graph_index: int, deepmd_graph_dir: str,\n deepmd_data: Dict, iter_index: int,\n need_continue: bool):\n # Generate json\n deepmd_json_param(deepmd_graph_dir, deepmd_data, iter_index)\n # mov... | [
"0.5820932",
"0.5736894",
"0.5658012",
"0.54358",
"0.53977996",
"0.5313565",
"0.528704",
"0.5198629",
"0.51655215",
"0.50905365",
"0.5083622",
"0.503704",
"0.50110036",
"0.5008158",
"0.4999751",
"0.49736997",
"0.49736997",
"0.49691606",
"0.493694",
"0.49172115",
"0.48817807",... | 0.67583585 | 0 |
Deepmd update the checkpoint | def deepmd_update_checkpoint(iter_index: int):
# Now update will preserve the previous steps information
with open('generator_checkpoint.json', 'r') as generate_ckpt:
ckpt = json.load(generate_ckpt)
ckpt['status'] = 'deepmd'
ckpt['config_index'] = 0 # multiprocessing don't need graph_in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkpoint():",
"def checkpoint(self):\n save()",
"async def update_checkpoint_async(self, lease, checkpoint):",
"async def checkpoint(cls) -> None:",
"def save_to_checkpoint(self, chkpt):\n chkpt[self.name] = self.state_dict()",
"def checkpoint( self ):\n last_saved = self.get_s... | [
"0.743215",
"0.7121438",
"0.6961666",
"0.6648132",
"0.62487",
"0.6226256",
"0.6076932",
"0.5967478",
"0.5961249",
"0.5960711",
"0.59606856",
"0.58850557",
"0.58401895",
"0.58247083",
"0.5819275",
"0.58082265",
"0.5802997",
"0.579261",
"0.5781037",
"0.576055",
"0.57508475",
... | 0.7607544 | 0 |
Sends priority message to either Nexmo or Africas Talking | def send_message(self):
priority_message = self.message_queue.pop(0)
# send this message to Africa's Talking or NexmoClient
response = nexmo.send_message(priority_message)
# response = africas_talking.send_message(priority_message)
print(response);
return response['message'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetPriority(self, priority=1, interruptMenuAfter=3, timeoutAfter=2):\n self.ListenToMenu(interruptMenuAfter) # listen to 'To sent with normal priority...'\n self.SipPhone.SendDTMF(str(priority))\n self.ListenToMenu(timeoutAfter) # listen to 'Message Sent'\n mailbox = self.getMailB... | [
"0.6324",
"0.59750456",
"0.5759524",
"0.5687916",
"0.5597825",
"0.5597825",
"0.55825335",
"0.5531191",
"0.5528984",
"0.54893994",
"0.54370934",
"0.5426119",
"0.54159474",
"0.54159474",
"0.5370475",
"0.5329592",
"0.53249246",
"0.5290757",
"0.5282707",
"0.525808",
"0.52420247",... | 0.67188764 | 0 |
Generates the C++ bindings for the Pawn include |filename|. | def GenerateBindings(filename, path):
name = filename[0:-4]
if name.startswith('a_'):
name = name[2:]
input = path
output_header = os.path.join(os.path.dirname(path), '%s.h' % name)
output_impl = os.path.join(os.path.dirname(path), '%s.cpp' % name)
write_bindings.WriteBindings(input, o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_cpp():\n cpp_file = AUTOGEN_WARNING\n cpp_file += \"// Implements basic nuclear data functions.\\n\"\n cpp_file += \"#ifndef PYNE_IS_AMALGAMATED\\n\"\n cpp_file += '#include \"atomic_data.h\"\\n'\n cpp_file += '#include \"nucname.h\"\\n'\n cpp_file += \"#endif\\n\"\n cpp_file += \... | [
"0.5898096",
"0.5688383",
"0.54618686",
"0.53356934",
"0.53198254",
"0.5304615",
"0.5217018",
"0.5214677",
"0.5185232",
"0.51728207",
"0.5164098",
"0.51559216",
"0.50681734",
"0.50602496",
"0.5058907",
"0.49814364",
"0.49792537",
"0.49706864",
"0.4962642",
"0.49357608",
"0.49... | 0.6694012 | 0 |
get_error function computes the error for a line passing through a given set of points (x, y) | def get_error(intercept, slope, points):
error_value = 0
for i in range(0, len(points)):
error_value += (points[i].y - (slope * points[i].x + intercept)) ** 2
return error_value / float(len(points)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(line, data): # error function\n # Metric: Sum of squared Y-axis differences\n err = np.sum((data[:, 1] - (line[0] * data[:, 0] + line[1])) ** 2)\n return err",
"def error(Y, X):\n return (Y - X) ** 2",
"def _getErrorFunction(self):\n\n\t\treturn (self._setpoint - self._current)",
"def e... | [
"0.7197733",
"0.6690909",
"0.6569207",
"0.64633626",
"0.6383084",
"0.63033307",
"0.61226016",
"0.6122066",
"0.60519934",
"0.59815365",
"0.5977717",
"0.5972937",
"0.5963946",
"0.59486765",
"0.5942314",
"0.593651",
"0.59318626",
"0.5928876",
"0.5925868",
"0.5876266",
"0.5866912... | 0.74685186 | 0 |
Create new instance of Edge(id, start_node, end_node, cost, reverse_cost, reversed) | def __new__(_cls, id, start_node, end_node, cost, reverse_cost, reversed=False):
return tuple.__new__(_cls, (id, start_node, end_node, float(cost), float(reverse_cost), reversed)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, start_node, label, end_node, properties=None, **kwargs):\r\n\t\tif properties is None:\r\n\t\t\tproperties = {}\r\n\t\tedge = Edge(self._nextid, start_node, label, end_node, properties, **kwargs)\r\n\t\tself._edges[self._nextid] = edge\r\n\t\tself._nextid += 1\r\n\t\treturn edge",
"def reverse... | [
"0.6723898",
"0.6434462",
"0.63660467",
"0.6310684",
"0.62606514",
"0.62528133",
"0.6212426",
"0.61914283",
"0.61631",
"0.61101496",
"0.60671425",
"0.59764946",
"0.5926465",
"0.59022355",
"0.58873934",
"0.5849658",
"0.58319587",
"0.5810866",
"0.57978505",
"0.5756255",
"0.5747... | 0.6954029 | 0 |
Create a new edge which is reverse to self. | def reversed_edge(self):
reverse = Edge(id=self.id,
start_node=self.end_node,
end_node=self.start_node,
cost=self.reverse_cost,
reverse_cost=self.cost,
reversed=not self.reversed)
return re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse(edge):\n return Edge(orig=edge.dest, dest=edge.orig, orig_id=edge.dest_id, dest_id=edge.orig_id)",
"def reverse(self):\n H = DiGraph(multiedges=self.allows_multiple_edges(), loops=self.allows_loops())\n H.add_vertices(self)\n H.add_edges( [ (v,u,d) for (u,v,d) in self.edge_ite... | [
"0.82042795",
"0.7715635",
"0.6969293",
"0.6935056",
"0.6888703",
"0.6801891",
"0.6788504",
"0.67265826",
"0.6673056",
"0.6654561",
"0.6641547",
"0.6504055",
"0.6466905",
"0.64531726",
"0.6414732",
"0.6414527",
"0.6390156",
"0.63744956",
"0.6365106",
"0.63299966",
"0.6312733"... | 0.85291636 | 0 |
Test if it is the same edge with the other. While comparing costs, if their difference is under the precision, then they are considered as the same edge. | def same_edge(self, other, precision=0):
return self.id == other.id \
and self.start_node == other.start_node \
and self.end_node == other.end_node \
and abs(self.cost - other.cost) <= precision \
and abs(self.reverse_cost - other.reverse_cost) <= precision \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\r\n return abs(self.x - other.x) + abs(self.y - other.y) < Vertex.epsilon",
"def __eq__(self, other):\n return abs(self - other) < 10e-10",
"def same(self, other, epsilon_=None):\n if epsilon_ is None:\n return self-other < epsilon\n else:\n ... | [
"0.6727692",
"0.6505541",
"0.6498408",
"0.64822954",
"0.6417987",
"0.6393962",
"0.6364372",
"0.62917227",
"0.6288815",
"0.626958",
"0.6238322",
"0.6234916",
"0.62137187",
"0.61908233",
"0.6114228",
"0.61046827",
"0.6092138",
"0.6084756",
"0.6081539",
"0.60792655",
"0.60791814... | 0.8797289 | 0 |
Sets the id of this VirtualService. | def id(self, id):
if id is not None and not re.search(r'^\\d{1,}-virtualservice-[a-z0-9_\\-]{36}$', id): # noqa: E501
raise ValueError(r"Invalid value for `id`, must be a follow pattern or equal to `/^\\d{1,}-virtualservice-[a-z0-9_\\-]{36}$/`") # noqa: E501
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_id(self, id):\n self.__id = id",
"def SetId(self, id):\n self.id = int(id)",
"def set_id(self, id_):\n\n self.id_ = id_",
"def set_id(self, id):\n self.data['id'] = id",
"def setID(self, id):\n self._id = id\n return self.callRemote('setID', id)",
"def se... | [
"0.7246792",
"0.71348435",
"0.7120083",
"0.69750094",
"0.6951778",
"0.68095964",
"0.6804247",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.6741579",
"0.67225677",
"0.6702289",
"0.6702289",
"0.6702289",... | 0.80658674 | 0 |
Sets the site_id of this VirtualService. | def site_id(self, site_id):
self._site_id = site_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_site_id(self):\n self.site_id = entities.sites['next id']\n entities.sites['object list'].append(self)\n entities.sites['next id'] += 1",
"def web_site_id(self, web_site_id):\n\n self._web_site_id = web_site_id",
"def setSiteids(self):\n self.siteids = []\n for... | [
"0.68784183",
"0.6602689",
"0.6414411",
"0.6092146",
"0.6034268",
"0.5990248",
"0.591408",
"0.57976866",
"0.57383054",
"0.5552645",
"0.53509086",
"0.53509086",
"0.53118485",
"0.5262215",
"0.5254939",
"0.5238961",
"0.5229057",
"0.5209056",
"0.5209056",
"0.5199387",
"0.51953393... | 0.80494 | 1 |
Sets the segment_id of this VirtualService. | def segment_id(self, segment_id):
self._segment_id = segment_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vat_id(self, vat_id: str):\n\n self._vat_id = vat_id",
"def vat_id(self, vat_id):\n\n self._vat_id = vat_id",
"def vpd_id(self, vpd_id):\n\n self._vpd_id = vpd_id",
"def update(self,\n segment_id,\n segment,\n ):\n return self._invoke(... | [
"0.5838757",
"0.5825565",
"0.57639927",
"0.5708378",
"0.5702347",
"0.5625416",
"0.5533488",
"0.55170035",
"0.5496307",
"0.5465427",
"0.5459022",
"0.545264",
"0.5423617",
"0.5415335",
"0.53778774",
"0.5375813",
"0.5352305",
"0.532604",
"0.53248763",
"0.53109074",
"0.5306134",
... | 0.8330469 | 0 |
Sets the vip of this VirtualService. | def vip(self, vip):
self._vip = vip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virtual_router_ip(self, virtual_router_ip):\n self._virtual_router_ip = virtual_router_ip",
"def add_virtualip(self, vip):\n return self.manager.add_virtualip(self, vip)",
"def ip(self, ip):\n\n self._ip = ip",
"def ip(self, ip):\n\n self._ip = ip",
"def SetVMIPaddressIntoTe... | [
"0.72838145",
"0.6761916",
"0.6458198",
"0.6458198",
"0.64527357",
"0.63842404",
"0.63458145",
"0.63456166",
"0.6233729",
"0.6120147",
"0.60259",
"0.6014182",
"0.5945362",
"0.59351707",
"0.5823485",
"0.58097166",
"0.58031166",
"0.57778704",
"0.5750117",
"0.57091725",
"0.57091... | 0.82228744 | 0 |
Sets the nat of this VirtualService. | def nat(self, nat):
self._nat = nat | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_nat(self, natgw, **attrs):\n return self._update(_gw.Service, natgw, **attrs)",
"def set_natserver_enabled(self, bEnabled):\n\t\tcall_sdk_function('PrlVirtNet_SetNATServerEnabled', self.handle, bEnabled)",
"def set_virtual_node(self, virtRoot):\n self.virtRoot = virtRoot",
"def nic_n... | [
"0.628742",
"0.611881",
"0.57433975",
"0.55193835",
"0.5486674",
"0.54130983",
"0.53863645",
"0.5378961",
"0.53111404",
"0.5289651",
"0.52655697",
"0.5224805",
"0.5176909",
"0.5152209",
"0.50901914",
"0.50557125",
"0.5051199",
"0.50365",
"0.4989037",
"0.49518487",
"0.49272317... | 0.74795645 | 0 |
Sets the server_pool of this VirtualService. | def server_pool(self, server_pool):
self._server_pool = server_pool | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def server(self, server):\n\n self._server = server",
"def update_listener_pool(self, service, name, bigips):\n vip = self.service_adapter.get_virtual_name(service)\n if vip:\n vip[\"pool\"] = name\n for bigip in bigips:\n v = bigip.tm.ltm.virtuals.virtua... | [
"0.5971407",
"0.5879605",
"0.5761809",
"0.54552734",
"0.54371893",
"0.54270303",
"0.54200625",
"0.53819776",
"0.5322363",
"0.5322363",
"0.531683",
"0.5273689",
"0.52584356",
"0.52292633",
"0.5185671",
"0.518415",
"0.5183671",
"0.5172391",
"0.51120234",
"0.50874215",
"0.506536... | 0.8254317 | 0 |
Sets the modified_at of this VirtualService. | def modified_at(self, modified_at):
self._modified_at = modified_at | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_modified(self, dt):\n self.modified = dt_to_iso(dt)",
"def set_modified(self, dt):\n self.modified = dt_to_iso(dt)",
"def modified_date(self, modified_date):\n\n self._modified_date = modified_date",
"def modified_date(self, modified_date):\n\n self._modified_date = modifi... | [
"0.6695722",
"0.6695722",
"0.65469223",
"0.65469223",
"0.64611924",
"0.6390162",
"0.6373553",
"0.6373553",
"0.6373553",
"0.6373553",
"0.6373553",
"0.6373553",
"0.6373553",
"0.6273601",
"0.6273601",
"0.6273601",
"0.5977197",
"0.5977197",
"0.5970284",
"0.5956164",
"0.5956164",
... | 0.78778386 | 0 |
Sets the deployment_status of this VirtualService. | def deployment_status(self, deployment_status):
allowed_values = ["deploy_pending", "deploy_in_progress", "deploy_failed", "deployed", "delete_pending", "delete_in_progress", "delete_failed", "deleted"] # noqa: E501
if deployment_status not in allowed_values:
raise ValueError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_deployment_status():\n reset_query = dep_table.update().values(deployment_status=None)\n db.session.execute(reset_query)\n\n in_progress_condition = exc_table.c.status.in_(\n execution_states[DeploymentState.IN_PROGRESS])\n req_attention_condition = or_(\n dep_table.c.installatio... | [
"0.67861205",
"0.65088254",
"0.6331958",
"0.6331958",
"0.6331958",
"0.62717587",
"0.6136346",
"0.61323804",
"0.61323804",
"0.6127772",
"0.6103353",
"0.6027898",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066",
"0.5961066"... | 0.72562563 | 0 |
Expand the HRP into values for checksum computation. | def bech32_hrp_expand(hrp):
return [ord(x) >> 5 for x in hrp] + [0] + [ord(x) & 31 for x in hrp] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _expand(self):\n cilm = SHExpandDH(self.data)\n coeffs = SHCoeffs.from_array(cilm, kind='DH')\n return coeffs",
"def bech32_create_checksum(hrp, data):\n values = bech32_hrp_expand(hrp) + data\n polymod = bech32_polymod(values + [0, 0, 0, 0, 0, 0]) ^ 1\n return [(polymod >> 5 * ... | [
"0.5692708",
"0.5370606",
"0.495138",
"0.49316415",
"0.4826316",
"0.47964844",
"0.47361484",
"0.47303766",
"0.47205597",
"0.4685879",
"0.46665284",
"0.4651518",
"0.46514586",
"0.46187925",
"0.46125764",
"0.45802903",
"0.45793587",
"0.45672297",
"0.4549622",
"0.4540971",
"0.45... | 0.6247475 | 0 |
Verify a checksum given HRP and converted data characters. | def bech32_verify_checksum(hrp, data):
return bech32_polymod(bech32_hrp_expand(hrp) + data) == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _verify_checksum(data, checksum):\n sha256_hash = hashlib.sha256(data).hexdigest().encode()\n return to_bin(sha256_hash)[0 : len(data) * 8 // 32] == checksum",
"def checksum(data: str):\n if len(data) % 2 == 1:\n return data\n it = iter(data)\n new_data = ''\n for bit in it:\n ... | [
"0.6515915",
"0.6268514",
"0.6224985",
"0.616817",
"0.6161122",
"0.61255074",
"0.6124343",
"0.60680276",
"0.6064342",
"0.60614634",
"0.60459036",
"0.6045096",
"0.60214597",
"0.601725",
"0.59537625",
"0.5929504",
"0.59187376",
"0.5909802",
"0.59042305",
"0.58797485",
"0.587966... | 0.73980343 | 0 |
Compute the checksum values given HRP and data. | def bech32_create_checksum(hrp, data):
values = bech32_hrp_expand(hrp) + data
polymod = bech32_polymod(values + [0, 0, 0, 0, 0, 0]) ^ 1
return [(polymod >> 5 * (5 - i)) & 31 for i in range(6)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcChecksum(self, data, length):\n checksum = 0\n\n for i in range(length//2):\n checksum = checksum ^ (data[i*2] | (data[i*2+1] << 8)) #xor-ing\n return 0xffff & (checksum ^ 0xffff) #inverting",
"def compute_checksum(data):\n\tif len(data) & 1:\n\t\tdata = data + ... | [
"0.6945937",
"0.67816573",
"0.6694316",
"0.6647137",
"0.65975803",
"0.65780365",
"0.6523341",
"0.6485252",
"0.64537305",
"0.6414892",
"0.6185845",
"0.6126715",
"0.6082316",
"0.60333925",
"0.5961999",
"0.5940083",
"0.59072703",
"0.5840192",
"0.57219166",
"0.5718942",
"0.568102... | 0.7084495 | 0 |
Compute a Bech32 string given HRP and data values. | def bech32_encode(hrp, data):
combined = data + bech32_create_checksum(hrp, data)
return hrp + '1' + ''.join([CHARSET[d] for d in combined]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bech32_create_checksum(hrp, data):\n values = bech32_hrp_expand(hrp) + data\n polymod = bech32_polymod(values + [0, 0, 0, 0, 0, 0]) ^ 1\n return [(polymod >> 5 * (5 - i)) & 31 for i in range(6)]",
"def bcur_encode(data):\n cbor = cbor_encode(data)\n enc = bc32encode(cbor)\n h = hashlib.sha2... | [
"0.6180152",
"0.59803236",
"0.59652334",
"0.59291404",
"0.56749326",
"0.56541854",
"0.5602964",
"0.55900097",
"0.5575147",
"0.5510494",
"0.54423493",
"0.5397543",
"0.53948313",
"0.5313692",
"0.52766794",
"0.52306104",
"0.51750374",
"0.5160554",
"0.5155315",
"0.51535434",
"0.5... | 0.7195933 | 0 |
Validate a Bech32 string, and determine HRP and data. | def bech32_decode(bech):
if ((any(ord(x) < 33 or ord(x) > 126 for x in bech)) or
(bech.lower() != bech and bech.upper() != bech)):
return (None, None)
bech = bech.lower()
pos = bech.rfind('1')
if pos < 1 or pos + 7 > len(bech): #or len(bech) > 90:
return (None, None)
if n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkDataType(self,str):\n accepted_vals = [\"HEXA\",\"NEHU\",\"NEDS\",\"NEDU\",\"NDHU\",\"NDDU\"]\n assert str in accepted_vals, \"Error: Data Type not accepted: \" + str\n if (str == 'HEXA') | (str[2] == 'H'):\n self.base = 16\n if str[3] == 'S':\n self.signed = True",
"def is_valid_a... | [
"0.632021",
"0.58705276",
"0.58341265",
"0.5811494",
"0.57285565",
"0.57082236",
"0.5613003",
"0.55415183",
"0.5499696",
"0.54304606",
"0.54039085",
"0.53765565",
"0.5374732",
"0.53599584",
"0.5302655",
"0.52568835",
"0.5249464",
"0.524831",
"0.5240656",
"0.52291",
"0.5218948... | 0.62150854 | 1 |
Constructor pip reference to the master object (Pip) plugin reference to the plugin object (ToolPipPlugin) parent reference to the parent widget (QWidget) | def __init__(self, pip, plugin, parent=None):
super(PipSearchDialog, self).__init__(parent)
self.setupUi(self)
self.setWindowFlags(Qt.Window)
self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(False)
self.__installButton = self.buttonBox.addButton(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, plugin):\n\n QgsMapTool.__init__(self, plugin.iface.mapCanvas())\n\n self.plugin = plugin\n self.double_click = False\n\n self.plugin.iface.mainWindow().statusBar().showMessage(self.tr(\"Click on a parcel!\"))\n\n self.current_dialog = None\n self.dialog... | [
"0.68881553",
"0.6291952",
"0.62415355",
"0.6189922",
"0.6097188",
"0.60794055",
"0.60542935",
"0.5995019",
"0.59779817",
"0.59704363",
"0.59477806",
"0.5928814",
"0.5920071",
"0.5913141",
"0.5913141",
"0.5913141",
"0.59094864",
"0.5890799",
"0.58740675",
"0.5873307",
"0.5849... | 0.7563393 | 0 |
Private slot handling a press of the search button. | def on_searchButton_clicked(self):
self.__search() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_btn_clicked(self, widget, data=None):\n # Method to handle search here.\n search_text = self.get_text(\"txt_search\")\n print search_text",
"def on_buttonBox_clicked(self, button):\n if button == self.findButton:\n self.__doSearch()\n elif button == self.s... | [
"0.787465",
"0.7454312",
"0.70616204",
"0.68871343",
"0.68181986",
"0.6760889",
"0.67045516",
"0.6505925",
"0.64427584",
"0.64369637",
"0.6414263",
"0.63818145",
"0.6349521",
"0.63222706",
"0.62287897",
"0.62203604",
"0.62094444",
"0.61999077",
"0.61627203",
"0.6162478",
"0.6... | 0.87299025 | 0 |
Private slot called by a button of the button box clicked. button button that was clicked (QAbstractButton) | def on_buttonBox_clicked(self, button):
if button == self.buttonBox.button(QDialogButtonBox.Close):
self.close()
elif button == self.buttonBox.button(QDialogButtonBox.Cancel):
self.__client.abort()
self.__canceled = True
elif button == self.__installButton:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec_(self):\n super().exec_()\n return self.clicked_button",
"def clickEvent(self):\n self.emit(QtCore.SIGNAL('activated(QString &)'), self.text())",
"def on_buttonBox_clicked(self, button):\n if button == self.buttonBox.button(QDialogButtonBox.Save):\n self.on_saveB... | [
"0.7814205",
"0.7070584",
"0.69642556",
"0.68384516",
"0.67798644",
"0.6768343",
"0.6768343",
"0.67607236",
"0.67205596",
"0.6709458",
"0.6689524",
"0.6659822",
"0.6606926",
"0.66062105",
"0.660225",
"0.6546234",
"0.6541225",
"0.6532168",
"0.6531234",
"0.6516813",
"0.65039927... | 0.7210921 | 1 |
Private method to process the search result data from PyPI. data result data (tuple) with hits in the first element | def __processSearchResult(self, data):
if data:
packages = self.__transformHits(data[0])
if packages:
self.infoLabel.setText(self.tr("%n package(s) found.", "",
len(packages)))
wrapper = textwrap.TextWrapper(width=80)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def processSearchResult(self):",
"def getResults():",
"def handle_result(self, results: List[Dict], **info):\n pass",
"def parse_results(self, result):\n\n interesting = []\n for item in result[\"hits\"][\"hits\"]:\n source = item[\"_source\"]\n meta = source.get(\"... | [
"0.68465793",
"0.60578465",
"0.5932964",
"0.59307265",
"0.59071136",
"0.58819073",
"0.574606",
"0.5692038",
"0.56663704",
"0.56574595",
"0.56306523",
"0.55775577",
"0.5571338",
"0.55618376",
"0.55480283",
"0.5539446",
"0.5500595",
"0.5470933",
"0.54691875",
"0.54479104",
"0.5... | 0.7630216 | 0 |
Private method handling a search error. errorCode code of the error (integer) errorString error message (string) | def __searchError(self, errorCode, errorString):
self.__finish()
E5MessageBox.warning(
self,
self.tr("Search PyPI"),
self.tr("""<p>The package search failed.</p><p>Reason: {0}</p>""")
.format(errorString))
self.infoLabel.setText(self.tr("Error: {0}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_invalid_parameters(error):\n current_app.logger.info(str(error))\n return render_template(\"search.html\", query=error.query, error=error), 400",
"def __init__(self, error_search=\"error\"):\n self.error_search = error_search",
"def not_found(error):\n pass",
"def search_bad_query(... | [
"0.6526044",
"0.6315798",
"0.60930365",
"0.609029",
"0.6039893",
"0.59139246",
"0.58703196",
"0.5868383",
"0.58507913",
"0.58359665",
"0.5817767",
"0.58024484",
"0.57093686",
"0.56727254",
"0.56263053",
"0.55985034",
"0.5585837",
"0.55695426",
"0.5524106",
"0.5516786",
"0.547... | 0.754049 | 0 |
Private method to calculate some score for a search result. name name of the returned package str summary summary text for the package str score value int | def __score(self, name, summary):
score = 0
for queryTerm in self.__query:
if queryTerm.lower() in name.lower():
score += 4
if queryTerm.lower() == name.lower():
score += 4
if queryTerm.lower() in summary.lower():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_score(result):\n sample1=result['Sample1']\n sample2=result['Sample2']\n string1=paragraph_to_list(sample1)\n string2=paragraph_to_list(sample2)\n \n return round( strings_similarity(string1, string2), 2)\n #method_dict=strings_count_compare(string1, string2)/ max(len(string1), l... | [
"0.6388174",
"0.6375168",
"0.6337434",
"0.6309232",
"0.62848437",
"0.61819446",
"0.6150316",
"0.6061966",
"0.60612357",
"0.6000565",
"0.5980575",
"0.5880881",
"0.5871269",
"0.58405083",
"0.58331317",
"0.5757562",
"0.5753757",
"0.57525665",
"0.5744831",
"0.57435524",
"0.572693... | 0.67483026 | 0 |
Private slot to install the selected packages. | def __install(self):
command = self.pipComboBox.currentText()
if command == self.__default:
command = ""
packages = []
for itm in self.resultList.selectedItems():
packages.append(itm.text(0).strip())
if packages:
self.__pip.installPack... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post_install(self, installable_pkgs):\n pass",
"def install(self, *packages):\n raise NotImplementedError",
"def install_package(self, package):\n raise NotImplementedError(\"install_package not implemented!\")",
"def install(self):\n raise NotImplementedError",
"def _instal... | [
"0.7001624",
"0.6993284",
"0.68159723",
"0.67730206",
"0.6733573",
"0.6620806",
"0.66078526",
"0.65957123",
"0.6587987",
"0.65526897",
"0.652802",
"0.65253454",
"0.6520522",
"0.64047605",
"0.6254468",
"0.6160361",
"0.6121888",
"0.61139154",
"0.60733545",
"0.6006703",
"0.60025... | 0.784766 | 0 |
Private slot to show details about the selected package. | def __showDetails(self):
self.buttonBox.button(QDialogButtonBox.Close).setEnabled(False)
self.buttonBox.button(QDialogButtonBox.Cancel).setEnabled(True)
self.buttonBox.button(QDialogButtonBox.Cancel).setDefault(True)
self.__showDetailsButton.setEnabled(False)
QApplication.setOver... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __displayPackageDetails(self, data):\n self.__finish()\n self.__showDetailsButton.setEnabled(True)\n from .PipPackageDetailsDialog import PipPackageDetailsDialog\n dlg = PipPackageDetailsDialog(self.__detailsData, data[0], self)\n dlg.exec_()",
"def print_package_info(packa... | [
"0.7484296",
"0.6527179",
"0.6382961",
"0.6051693",
"0.5973608",
"0.5905206",
"0.5886441",
"0.5858872",
"0.58353835",
"0.581935",
"0.5806822",
"0.5795656",
"0.5776238",
"0.5761457",
"0.57599133",
"0.57599133",
"0.57353157",
"0.56632274",
"0.5651795",
"0.5611291",
"0.56077147"... | 0.74342203 | 1 |
Private method to store the details data and get downloads information. packageVersion version info str data result data with package details in the first element tuple | def __getPackageDownloadsData(self, packageVersion, data):
if data and data[0]:
self.__detailsData = data[0]
itm = self.resultList.selectedItems()[0]
packageName = itm.text(0)
self.__client.call(
"release_urls",
(packageName, packag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_download_info(self, data_url):\n elem = (DOM.DownloadManager.download_entry_info[0],\n DOM.DownloadManager.download_entry_info[1].format(data_url))\n return self.UTILS.element.getElement(elem, \"Obtain the info for: {}\".format(data_url))",
"def _pypi_details(self) -> Tuple[s... | [
"0.65480614",
"0.6343934",
"0.6293053",
"0.62138385",
"0.6165813",
"0.60201085",
"0.58764493",
"0.5875832",
"0.58752453",
"0.58528614",
"0.5842319",
"0.577861",
"0.5753511",
"0.57315415",
"0.5729206",
"0.570555",
"0.56985503",
"0.5697138",
"0.568847",
"0.5661068",
"0.56441635... | 0.7705288 | 0 |
Private method to display the returned package details. data result data (tuple) with downloads information in the first element | def __displayPackageDetails(self, data):
self.__finish()
self.__showDetailsButton.setEnabled(True)
from .PipPackageDetailsDialog import PipPackageDetailsDialog
dlg = PipPackageDetailsDialog(self.__detailsData, data[0], self)
dlg.exec_() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getPackageDownloadsData(self, packageVersion, data):\n if data and data[0]:\n self.__detailsData = data[0]\n itm = self.resultList.selectedItems()[0]\n packageName = itm.text(0)\n self.__client.call(\n \"release_urls\",\n (packa... | [
"0.74666506",
"0.66988295",
"0.66282576",
"0.6621933",
"0.637445",
"0.6101264",
"0.60497206",
"0.6043906",
"0.60221356",
"0.6019666",
"0.5838681",
"0.5817405",
"0.58156484",
"0.5796491",
"0.57407945",
"0.57351774",
"0.5727137",
"0.56660646",
"0.56522846",
"0.5626147",
"0.5617... | 0.7029175 | 1 |
Private method handling a details error. errorCode code of the error (integer) errorString error message (string) | def __detailsError(self, errorCode, errorString):
self.__finish()
self.__showDetailsButton.setEnabled(True)
E5MessageBox.warning(
self,
self.tr("Search PyPI"),
self.tr("""<p>Package details info could not be retrieved.</p>"""
"""<p>Reason: ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_error_details(code, desc):\n MDC.put('errorCode', code)\n MDC.put('errorDescription', desc)",
"def process_error(self, id, code, error):\n raise NotImplementedError('process_error not implemented in BaseService')",
"def error_details(self, error_details):\n self._error_details = err... | [
"0.66811025",
"0.65098435",
"0.64526945",
"0.6302421",
"0.62795705",
"0.6217456",
"0.620963",
"0.61615944",
"0.6157748",
"0.6041889",
"0.6012321",
"0.5997784",
"0.5996566",
"0.5996499",
"0.5980564",
"0.5967807",
"0.59412086",
"0.5934131",
"0.5933618",
"0.59326905",
"0.5930968... | 0.7208053 | 0 |
This function is used for data analysis. Retrieve image information (num_entities, average linear/angular distance and timestamp). | def get_image_information(client):
pipeline = [{"$match": {"camera_views": {"$exists": 1}}}, {"$unwind": {"path": "$camera_views"}}, {"$addFields": {
"camera_views.average_linear_distance": {
"$divide": [
"$camera_views.total_linear_distance",
"$camera_views.num_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_image_info(image):\n image = ee.Image(image)\n image_vis = image.visualize(**{\n 'min': image_min,\n 'max': image_max,\n 'palette': image_palette\n })\n\n print(image_min, image_max)\n\n if 'hillshade' in r and r['hillshade']:\n ... | [
"0.59846336",
"0.596467",
"0.58719707",
"0.57998466",
"0.5790845",
"0.57607836",
"0.57037693",
"0.5697984",
"0.5685285",
"0.56846684",
"0.5681115",
"0.56708336",
"0.56348175",
"0.56285685",
"0.5623849",
"0.56236106",
"0.5615736",
"0.5592469",
"0.5587834",
"0.55773443",
"0.555... | 0.6152008 | 0 |
Private helper for setting the report date. | def __findReportDate(self):
dateList = ConfigHelper.parseConfigList(self.props.get('fereport',
'dateList'))
today = datetime.date.today()
for dateStr in dateList:
mon, day, year = dateStr.split('/')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_date(self, date):\n self.date = date",
"def set_date(self, date):\n self.date = date\n return",
"def get_fw_date(self, rec, report):\n rec.VAL = self.crate.mch_fw_date[self.slot]",
"def _date(self, _date):\n\n self.__date = _date",
"def _date(self, _date):\n\n ... | [
"0.68500936",
"0.6819773",
"0.67678994",
"0.6745662",
"0.6745662",
"0.67073405",
"0.67064464",
"0.66813374",
"0.6613077",
"0.6609463",
"0.6539059",
"0.6511554",
"0.6468202",
"0.64567244",
"0.64510125",
"0.6412121",
"0.6394894",
"0.63170654",
"0.6302688",
"0.6285003",
"0.62818... | 0.71019334 | 0 |
Request and save csv export of the report | def dlCsvReport(self):
requestElems = {'xf': 'csv'}
requestElems.update(self.getReportConfig())
csvdata = self.sendRequest(self.reportFormURL, self.fileOpener,
requestElems, 'POST').read()
self.writeExportFile('csv', csvdata) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_report():\n entities = get_names()\n save_csv(entities)",
"def export_csv(self):\n outputfile = tkinter.filedialog.asksaveasfilename(\n defaultextension=\".csv\",\n filetypes=((\"comma seperated values\", \"*.csv\"),\n (\"All Files\", \"*.*\")... | [
"0.80409896",
"0.76050204",
"0.7361398",
"0.73084444",
"0.7019261",
"0.6913584",
"0.6864677",
"0.6839728",
"0.6778433",
"0.67154855",
"0.67032295",
"0.66978914",
"0.6692166",
"0.6682622",
"0.66775554",
"0.666771",
"0.661355",
"0.6595593",
"0.6573942",
"0.657209",
"0.6565159",... | 0.7874193 | 1 |
Write contents fileData to file at exportPath. Overwrite any file that may exist at that path. | def writeExportFile(self, fileExtension, fileData):
targetDate = "%s%s%s" %(self.reportDate['year'],
self.reportDate['mon'],
self.reportDate['day'])
exportFname = "%s_%s.%s" %(self.exportBaseFname, targetDate,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_file(self, file_path, data):\n self._ensure_directory(os.path.dirname(file_path))\n with open(file_path, \"wb\") as f:\n f.write(data)",
"def write_file(self, path, data):\n _url = f\"{self.connector.base_url}/projects/{self.project_id}/files/{path}\"\n\n self.con... | [
"0.6847993",
"0.6833154",
"0.6802418",
"0.6674435",
"0.66702807",
"0.6617719",
"0.6616045",
"0.64740944",
"0.63244647",
"0.63027203",
"0.622513",
"0.62166715",
"0.6184663",
"0.61101717",
"0.6079351",
"0.6047553",
"0.60379374",
"0.6027775",
"0.6003779",
"0.59943545",
"0.598101... | 0.71769786 | 0 |
Reads in the spotipy query results for user top songs and returns a DataFrame with track_name,track_id, artist,album,duration,popularity | def create_df_top_songs(api_results):
#create lists for df-columns
track_name = []
track_id = []
artist = []
album = []
duration = []
popularity = []
#loop through api_results
for items in api_results['items']:
try:
track_name.append(items['name'])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_artists_from_API(api_results):\r\n df = pd.DataFrame(api_results[\"items\"])\r\n cols = [\"name\",\"id\",\"genres\",\"popularity\",\"uri\"]\r\n return df[cols]",
"def get_top_artist_tracks(session, number_of_artist):\n try:\n if not issubclass(type(session), sqlalchemy.orm.session.Sess... | [
"0.69811374",
"0.6699098",
"0.66560555",
"0.65576893",
"0.64863986",
"0.64474547",
"0.6371338",
"0.6334062",
"0.63221335",
"0.6296572",
"0.6261828",
"0.6221661",
"0.6220186",
"0.6189797",
"0.61722445",
"0.61599994",
"0.6155433",
"0.6114755",
"0.5938691",
"0.5933267",
"0.58908... | 0.7533467 | 0 |
Reads in the spotipy query results for user saved songs and returns a DataFrame with track_name,track_id, artist,album,duration,popularity | def create_df_saved_songs(api_results):
#create lists for df-columns
track_name = []
track_id = []
artist = []
album = []
duration = []
popularity = []
#loop through api_results
for items in api_results["items"]:
try:
track_name.append(items["track"]['n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_df_top_songs(api_results):\r\n #create lists for df-columns\r\n track_name = []\r\n track_id = []\r\n artist = []\r\n album = []\r\n duration = []\r\n popularity = []\r\n #loop through api_results\r\n for items in api_results['items']:\r\n try:\r\n track_name... | [
"0.70953184",
"0.6983967",
"0.69435596",
"0.6915536",
"0.66690826",
"0.666754",
"0.65074974",
"0.6507288",
"0.6480557",
"0.6400821",
"0.63706774",
"0.6331801",
"0.62969965",
"0.62750673",
"0.62064695",
"0.618582",
"0.6146519",
"0.6093236",
"0.6091046",
"0.60655224",
"0.601125... | 0.74175096 | 0 |
Reads in the spotipy query results for user top artists and returns a DataFrame with name, id, genres, popularity and uri | def top_artists_from_API(api_results):
df = pd.DataFrame(api_results["items"])
cols = ["name","id","genres","popularity","uri"]
return df[cols] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_df_top_songs(api_results):\r\n #create lists for df-columns\r\n track_name = []\r\n track_id = []\r\n artist = []\r\n album = []\r\n duration = []\r\n popularity = []\r\n #loop through api_results\r\n for items in api_results['items']:\r\n try:\r\n track_name... | [
"0.6749099",
"0.67400587",
"0.64649457",
"0.639353",
"0.6372961",
"0.62815857",
"0.62591445",
"0.62485987",
"0.6230613",
"0.6223021",
"0.6130078",
"0.61162484",
"0.6092042",
"0.60743445",
"0.6073669",
"0.60620964",
"0.601939",
"0.5930538",
"0.5926596",
"0.5926028",
"0.5909494... | 0.80026734 | 0 |
Reads in the spotipy query results for spotify recommended songs and returns a DataFrame with track_name,track_id,artist,album,duration,popularity | def create_df_recommendations(api_results):
track_name = []
track_id = []
artist = []
album = []
duration = []
popularity = []
for items in api_results['tracks']:
try:
track_name.append(items['name'])
track_id.append(items['id'])
artist.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_tracks_from_albums(sp, album_uri_list):\n\n track_list = [[\"track_name\", \"track_uri\", \"track_release_date\"]]\n\n print(\"Log: Pulling data from Spotify. This can take a while...\")\n\n for album_uri in album_uri_list:\n album_tracks = sp.album_tracks(album_uri, limit=50, offset=0)[\"i... | [
"0.6814398",
"0.6796387",
"0.6767215",
"0.67084277",
"0.6635598",
"0.6573595",
"0.6545475",
"0.64103746",
"0.6346779",
"0.63356996",
"0.627508",
"0.62113595",
"0.61474127",
"0.61378634",
"0.6125327",
"0.61115545",
"0.6046814",
"0.60272753",
"0.6005331",
"0.5990789",
"0.597234... | 0.68723744 | 0 |
Reads in the spotipy query results for a playlist and returns a DataFrame with track_name,track_id,artist,album,duration,popularity and audio_features unless specified otherwise. | def create_df_playlist(api_results,sp = None, append_audio = True):
df = create_df_saved_songs(api_results["tracks"])
if append_audio == True:
assert sp != None, "sp needs to be specified for appending audio features"
df = append_audio_features(df,sp)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_playlist_tracks(playlist):\n track_ids = [id for id in load_from_json(f\"playlist_{playlist}.json\") if id is not None]\n tracks = []\n\n for i in range(0, len(track_ids), 50):\n tracks_info = sp.tracks(track_ids[i: i+50])['tracks']\n for track in tracks_info:\n if track:\... | [
"0.7261001",
"0.67370754",
"0.6705537",
"0.6686362",
"0.66803616",
"0.6676746",
"0.6595131",
"0.6555134",
"0.6174791",
"0.61648434",
"0.61014676",
"0.6018592",
"0.593523",
"0.5921884",
"0.5910994",
"0.5907739",
"0.5896782",
"0.5857289",
"0.5855081",
"0.58021855",
"0.57907724"... | 0.7140388 | 1 |
Fetches the audio features for all songs in a DataFrame and appends these as rows to the DataFrame. Requires spotipy to be set up with an auth token. | def append_audio_features(df,spotify_auth, return_feat_df = False):
audio_features = spotify_auth.audio_features(df["track_id"][:])
#catch and delete songs that have no audio features
if None in audio_features:
NA_idx=[i for i,v in enumerate(audio_features) if v == None]
df.drop(NA_idx,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_audio_features(self, sp, trackids):\n\n cols = ['acousticness', 'danceability', 'duration_ms', 'energy',\n 'instrumentalness', 'key', 'liveness', 'loudness', 'mode',\n 'speechiness', 'tempo', 'time_signature', 'valence', 'id']\n\n total_track = len(trackids)\n ... | [
"0.72734356",
"0.6587091",
"0.64254206",
"0.63319993",
"0.63076264",
"0.6237071",
"0.6106666",
"0.6090266",
"0.6030595",
"0.5984066",
"0.5975257",
"0.5961235",
"0.5942549",
"0.5933294",
"0.5843309",
"0.58238524",
"0.57739335",
"0.56598234",
"0.5612531",
"0.5556799",
"0.554721... | 0.8000351 | 0 |
Finds rows which are different between two DataFrames. | def dataframe_difference(df1, df2, which=None):
comparison_df = df1.merge(
df2,
indicator=True,
how='outer'
)
if which is None:
diff_df = comparison_df[comparison_df['_merge'] != 'both']
else:
diff_df = comparison_df[comparison_df['_merge'] == which]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataframe_diff(xxa,xxb):\n\n xa=pd.DataFrame(xxa)\n xb=pd.DataFrame(xxb)\n merged = xa.merge(xb, indicator=True, how='outer')\n\n diff=merged[merged['_merge'] != 'both']\n\n return diff",
"def isLessEqual(df1, df2):\n indices = list(set(df1.index).intersection(df2.index))\n dff1 = df1.loc[in... | [
"0.7803869",
"0.6995879",
"0.6965345",
"0.6879113",
"0.67469674",
"0.65898186",
"0.6549119",
"0.65145093",
"0.6361907",
"0.63117826",
"0.629948",
"0.62905806",
"0.6156689",
"0.61474556",
"0.6043507",
"0.59707797",
"0.59524006",
"0.5915726",
"0.5877942",
"0.58593184",
"0.58216... | 0.73627996 | 1 |
Creates a similarity matrix for the audio features (except key and mode) of two Dataframes. | def create_similarity_score(df1,df2,similarity_score = "cosine_sim"):
assert list(df1.columns[6:]) == list(df2.columns[6:]), "dataframes need to contain the same columns"
features = list(df1.columns[6:])
features.remove('key')
features.remove('mode')
df_features1,df_features2 = df1[featur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare():\n data = request.get_json()\n res_sim = audio_featurizer.compare_two_features_sets(data['features_1'], data['features_2'])\n result = dict(similarity=res_sim)\n return jsonify(result)",
"def to_similarity(num_frames, gt_data, pr_data):\n gt_data_in_frame = split_into_frames(num_frames... | [
"0.61106133",
"0.6102003",
"0.575739",
"0.57292634",
"0.57210094",
"0.564439",
"0.56403285",
"0.56156737",
"0.56010723",
"0.55707866",
"0.55285054",
"0.549576",
"0.547676",
"0.54722166",
"0.54632",
"0.54632",
"0.5447425",
"0.5444294",
"0.54368526",
"0.5428084",
"0.5406614",
... | 0.6558798 | 0 |
Creates a dataframe of final recommendations filtered with a "mean" song from a playlist. | def filter_with_meansong(mean_song,recommendations_df, n_recommendations = 10):
features = list(mean_song.columns[6:])
features.remove("key")
features.remove("mode")
mean_song_feat = mean_song[features].values
mean_song_scaled = MinMaxScaler().fit_transform(mean_song_feat.reshape(-1,1))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suggest_songs(source_song, songs_df, y, model):\n source_song = preprocess(source_song)\n recommendations = model.kneighbors(source_song)[1][0]\n # normalize dataset, our graph likes normalized data\n numeric_cols = songs_df.select_dtypes(include=np.number).columns\n df_num = songs_df.select_dty... | [
"0.5832328",
"0.5796316",
"0.5668893",
"0.565352",
"0.55372804",
"0.5467602",
"0.5454571",
"0.5408461",
"0.5392319",
"0.5323091",
"0.52779627",
"0.5273057",
"0.5253437",
"0.5243496",
"0.51954097",
"0.5133213",
"0.5107601",
"0.51065266",
"0.50642806",
"0.50602126",
"0.5047967"... | 0.6814532 | 0 |
Creates a dataframe of final recommendations filtered by a given feature and whether a high or low value is wanted. | def feature_filter(df,feature, high = True):
assert feature in ["speechiness",
"acousticness",
"instrumentalness",
"liveness"], "feature must be one of the following: speechiness,acousticness,instrumentalness,liveness"
#more features may ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_active_features(summary_df, slots_offered): # prev -> getActiveFeatures\n disc_cols = [col+'_Discount' for col in slots_offered]\n eco_cols = [col+'_Eco' for col in slots_offered]\n gr_cols = [col+'_Eco' for col in slots_offered]\n features = summary_df.loc[:, disc_cols+... | [
"0.58443344",
"0.5821084",
"0.5789811",
"0.57810664",
"0.57256854",
"0.56218714",
"0.56099474",
"0.56072265",
"0.5601768",
"0.5588304",
"0.5585128",
"0.5567165",
"0.55657196",
"0.5565339",
"0.55552304",
"0.55424345",
"0.5533143",
"0.54980946",
"0.5436976",
"0.5403029",
"0.540... | 0.7660822 | 0 |
Gives top num_recommends recommendations for a song based on a similarity_score or matrix | def get_recommendations(df,song_title, similarity_score, num_recommends = 5):
indices = pd.Series(df.index, index = df['track_name']).drop_duplicates()
idx = indices[song_title]
sim_scores = list(enumerate(similarity_score[idx]))
sim_scores = sorted(sim_scores, key = lambda x: x[1],reverse = True)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_5_similar_2(list_string, my_nlp=nlp1, model_type=my_model, doc_topic=my_doc_topic):\n vec = my_nlp.transform(list_string)\n vtrans = model_type.transform(vec)\n array_5 = pairwise_distances(vtrans, doc_topic, metric='cosine').argsort()[0][0:5]\n # result_df = df_reviews[['game_link']].iloc[arra... | [
"0.69403774",
"0.6708428",
"0.66361177",
"0.66208243",
"0.66061056",
"0.64581853",
"0.64331615",
"0.6422014",
"0.6418242",
"0.63883686",
"0.63695747",
"0.6348622",
"0.63314646",
"0.6330419",
"0.6316701",
"0.6284902",
"0.6264998",
"0.6257891",
"0.62459356",
"0.6227139",
"0.622... | 0.74992377 | 0 |
Return +1, 0, or 1 if the unit cube is above, below, or intersecting the plane. | def UnitCubeTest(P):
above = 0
below = 0
for (a,b,c) in [(0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1)]:
s = P.test(a, b, c)
if s > 0:
above = 1
elif s < 0:
below = 1
return above - below | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hitTest( a, b ):\n r = a.radius + b.radius\n x = abs( a.x - b.x )\n y = abs( a.y - b.y )\n if x <= r and y <= r and x*x + y*y <= r*r:\n return 1\n return 0",
"def isInPlane(self, p) -> bool:\n # Testing for zero is done with math.isclose, to avoid rounding/floating point errors.\... | [
"0.6006958",
"0.5900927",
"0.5759193",
"0.5713522",
"0.5660144",
"0.56555474",
"0.56256115",
"0.56209445",
"0.5612326",
"0.5611536",
"0.5605023",
"0.55960155",
"0.55666924",
"0.55626243",
"0.5540222",
"0.55394",
"0.55347407",
"0.55283034",
"0.5525503",
"0.55229247",
"0.550887... | 0.6731846 | 0 |
Function to sample n numbers using parameters in l | def random_sample(l, n):
assert len(l) > 1
assert n
if l[0] == "int":
if len(l) == 3:
return np.random.randint(l[1], l[2] + 1, n, dtype="int32")
elif len(l) == 2:
return np.random.randint(l[1], l[1] + 1, n, dtype="int32")
else:
return np.random.uni... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, n, include=True):\n return [self(t / n) for t in range(n + int(include))]",
"def sample(self, n):\n ret = []\n for i in range(n):\n for j in range(n):\n ret.append(self.a + (((0.5 + i) / n) * self.l1) + (((0.5 + j) / n) * self.l2))\n return r... | [
"0.74199224",
"0.7406717",
"0.72772586",
"0.72482455",
"0.71520865",
"0.71470773",
"0.71248704",
"0.69935256",
"0.6898351",
"0.68867844",
"0.6823116",
"0.6823116",
"0.6820484",
"0.67658585",
"0.67542326",
"0.67369694",
"0.66240114",
"0.6598932",
"0.65872574",
"0.65802604",
"0... | 0.76497614 | 0 |
use ArmSettings to set misty's arm positions | async def _move_arms_via_settings(self, increment=False, *settings: ArmSettings):
if increment:
act_vals = await self.get_actuator_values(Actuator.left_arm, Actuator.right_arm)
settings = [s.increment(act_vals) for s in settings]
for s in settings:
_actuator_cache.up... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_armed(self, arm):\n pin = 0 if arm else 1\n self.mcp_misc[0].output(pin, MCP23008.LOW)\n self.mcp_misc[0].output(pin, MCP23008.HIGH)\n self.mcp_misc[0].output(pin, MCP23008.LOW)",
"def set_right_arm(self, joint_vals):\n joint_nums = []\n for i in range(1, 8):\n ... | [
"0.6547637",
"0.64687747",
"0.64340824",
"0.60914147",
"0.60654134",
"0.60138893",
"0.59958744",
"0.5948498",
"0.5896378",
"0.58270556",
"0.58270556",
"0.58222634",
"0.57513046",
"0.5742643",
"0.5727624",
"0.57268363",
"0.5720622",
"0.56888384",
"0.5683123",
"0.5671134",
"0.5... | 0.6481327 | 1 |
stop motion if `everything` is set, will stop everything (i.e. halt) | async def stop(self, *, everything=False):
if everything:
return await self.halt()
return await self._post('drive/stop') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopMovementAll(self):\n self.stopMovementX()\n self.stopMovementY()\n self.stopMovementZ()",
"def stop_all():\r\n motors.stop_all_motors()\r\n led.set_colour_solid(0)\r\n display.clear()",
"def _stop_all(self):\n # LEDs\n self.cam_led.off\n self.analysis_... | [
"0.6458159",
"0.6419564",
"0.64075524",
"0.62799674",
"0.6278357",
"0.6228199",
"0.62213844",
"0.6205745",
"0.60997784",
"0.60664624",
"0.60289675",
"0.60289675",
"0.60289675",
"0.60289675",
"0.6011918",
"0.60026646",
"0.59904975",
"0.5956328",
"0.59468657",
"0.5929406",
"0.5... | 0.7449722 | 0 |
Determine whether elements in a list are monotonic. ie. unique elements are clustered together. ie. [5,5,3,4] is, [5,3,5] is not. | def is_monotonic(items: Sequence) -> bool:
prev_elements = set({items[0]})
prev_item = items[0]
for item in items:
if item != prev_item:
if item in prev_elements:
return False
prev_item = item
prev_elements.add(item)
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkmonotonic(iterable, piecewise=False):\n monotonic = [True] + [x < y for x, y in zip(iterable, iterable[1:])]\n if piecewise is True:\n return monotonic\n else:\n return all(monotonic)",
"def is_unique_and_sorted(self):\n return all((self(i) < self(i+1) for i in range(len(se... | [
"0.6754721",
"0.62469804",
"0.6069717",
"0.60431504",
"0.6037963",
"0.601249",
"0.5946327",
"0.5945903",
"0.59423465",
"0.588357",
"0.587069",
"0.58562666",
"0.58260524",
"0.58257693",
"0.57807654",
"0.57767946",
"0.57500005",
"0.57214695",
"0.571543",
"0.57055587",
"0.570405... | 0.7788266 | 0 |
Round up to nearest . | def upround(x, base):
return base * math.ceil(float(x) / base) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roundUP(x):\n\treturn int(ceil(x / 10.0)) * 10",
"def round_up(number, decimals=0):\n multiplier = 10 ** decimals\n return math.ceil(number * multiplier) / multiplier",
"def _round_to_nearest_multiple_up(x, n=5):\n return n * math.ceil(float(x) / n)",
"def round_up(amount: Decimal) -> De... | [
"0.7775397",
"0.7578685",
"0.7482397",
"0.7408641",
"0.73013836",
"0.72726816",
"0.7230321",
"0.7196287",
"0.71550983",
"0.712848",
"0.71170646",
"0.71084553",
"0.69919866",
"0.69717807",
"0.69040406",
"0.6871906",
"0.6868747",
"0.6845126",
"0.6818186",
"0.6784912",
"0.674665... | 0.7694207 | 1 |
Given two collections of integer ranges, return a list of ranges in which both input inputs overlap. | def overlapping_ranges(
ranges_1: Sequence[Tuple[int, int]],
ranges_2: Sequence[Tuple[int, int]],
) -> List[Tuple[int, int]]:
return [
(max(first[0], second[0]), min(first[1], second[1]))
for first in ranges_1
for second in ranges_2
if max(first[0], second[0]) < min(first[1],... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range_overlap(range1, range2):\n return range(max(range1[0], range2[0]), min(range1[1], range2[1]))",
"def ranges_overlap(start1, end1, start2, end2):\n return start1 <= end2 and end1 >= start2",
"def find_common_bounds(bounds_1, bounds_2):\n new_bounds = []\n for (lower_1, upper_1), (lower_2, ... | [
"0.8035099",
"0.75984454",
"0.73328453",
"0.7216684",
"0.71589375",
"0.7155597",
"0.7152191",
"0.70526004",
"0.7042103",
"0.7029379",
"0.69834244",
"0.6971435",
"0.6906623",
"0.6870648",
"0.6858326",
"0.67309386",
"0.6729278",
"0.6715122",
"0.6676067",
"0.66637343",
"0.665156... | 0.8585493 | 0 |
The purpose of this function is to process 3d MRI images of mouse skulls, package the files and send to google cloud storage for a machine learning model to fetch and predict facial keypoints on. The .mnc files are the image arrays and the .tag files are the corresponding facial keypoints. | def main():
skulls_folder = os.listdir(RAW_IMAGE_DIRECTORY)
# fetch and sort the .mnc and .tag files
mnc_files = [f for f in skulls_folder if 'mnc' in f]
tag_files = [f for f in skulls_folder if 'tag' in f]
mnc_names = [i.split('.mnc')[0] for i in mnc_files]
mnc_files.sort()
tag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _preprocess(self):\n print(\"Note: if root path is changed, the previously generated json files need to be re-generated (delete them first)\")\n if osp.exists(self.imgs_labeled_dir) and \\\n osp.exists(self.imgs_detected_dir) and \\\n osp.exists(self.split_classic_det_json_pat... | [
"0.6201955",
"0.6036239",
"0.6035186",
"0.5952722",
"0.5932819",
"0.5930254",
"0.59231067",
"0.5875409",
"0.586604",
"0.5855777",
"0.58320963",
"0.58187795",
"0.5815014",
"0.57761997",
"0.57627916",
"0.5759528",
"0.57473373",
"0.5740311",
"0.57236683",
"0.5693929",
"0.5691488... | 0.7702474 | 0 |
Scales an cubic image to a certain number of voxels. This function relies on numpy's ndimage.zoom function | def scale(self, size=128):
scale_factor = size / max(self.voxels.shape)
self.voxels = ndimage.zoom(self.voxels, scale_factor)
self.point_position = self.point_position * scale_factor
self.voxel_size = False # To ignore this
return(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resize3D(img, target_size, bspline_order=3, mode='constant'): \n # compute zoom values\n target_size = np.array(target_size, dtype=float)\n image_shape = np.array(img.shape, dtype=float)\n zoom_factors = np.divide(target_size,image_shape)\n print \"Target Size\"\n ... | [
"0.65019464",
"0.63492495",
"0.6301837",
"0.612139",
"0.60350764",
"0.5970467",
"0.5939783",
"0.5828498",
"0.5821332",
"0.57809144",
"0.57622355",
"0.5758738",
"0.5750291",
"0.57458144",
"0.57279766",
"0.56705326",
"0.56545484",
"0.56350017",
"0.56083345",
"0.55590546",
"0.55... | 0.65824926 | 0 |
Test that the pesummary.core.reweight.rejection_sampling works as expected | def test_rejection_sampling():
# Check that it works with a numpy array
original_samples = np.random.uniform(0, 10, (n_samples, n_params))
weights = np.random.uniform(0, 5, n_samples)
new_samples = rejection_sampling(original_samples, weights)
# new_samples should have less samples than what we star... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_does_not_sample_twice_ppswor(self):\n with self.assertRaises(ValueError):\n s = private_sampling.ThresholdSample(\n 1.0, private_sampling.PpsworSamplingMethod)\n s.process(\"a\", math.log(FAILURE_PROBABILITY_INVERSE, math.e))\n s.process(\"a\", 1)",
"def test_does_not_sample_n... | [
"0.6902385",
"0.67308843",
"0.67236114",
"0.66180545",
"0.6555439",
"0.63935053",
"0.6354483",
"0.6283435",
"0.62815934",
"0.6279335",
"0.60121846",
"0.59245867",
"0.5919744",
"0.59115124",
"0.59114724",
"0.5748331",
"0.57358813",
"0.57063603",
"0.5699293",
"0.5692468",
"0.56... | 0.7511275 | 0 |
Test that the pesummary.gw.reweight.uniform_in_comoving_volume_from_uniform_in_volume function works as expected | def test_uniform_in_comoving_volume_from_uniform_in_volume():
original_samples = SamplesDict(
{param: np.random.uniform(0, 10, n_samples) for param in gw_parameters()}
)
new_samples = uniform_in_comoving_volume_from_uniform_in_volume(
original_samples
)
assert new_samples.number_of_s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_volume():\n structure = Material(input)\n assert (structure.volume == 90.725624999999965)",
"def test_for_arbitrarily_complicated_substance():\n verify_atomic_weight_for_substance(\"Al4O2H2\", 141.94015428)",
"def test_uniform(self):\n # some reproducible arbitrariness\n np.random.seed(... | [
"0.68578726",
"0.63723814",
"0.6354876",
"0.62236947",
"0.61338544",
"0.6127688",
"0.6097099",
"0.5850792",
"0.5831654",
"0.57379633",
"0.57359594",
"0.57206374",
"0.5676544",
"0.5635987",
"0.5625465",
"0.5582712",
"0.5577558",
"0.5575191",
"0.55607986",
"0.5552567",
"0.55507... | 0.78548443 | 0 |
A tag is a string of length greater than 1 starting with but not . | def is_tag(t):
return len(t) > 1 and t.startswith('#') and not t.startswith('##') and t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unknown_starttag(self, tag, attrs):\n if tag in self.valid_tags:\n self.result.append('<' + tag)\n for k, v in attrs:\n if string.lower(k[0:2]) != 'on' and",
"def is_tag(value):\r\n tag_names = parse_tag_input(value)\r\n ... | [
"0.6300984",
"0.62361676",
"0.62319434",
"0.62009877",
"0.61545885",
"0.61463207",
"0.6131712",
"0.61184245",
"0.6023833",
"0.6015184",
"0.60081524",
"0.5920608",
"0.591738",
"0.5891422",
"0.5878843",
"0.5873668",
"0.5853209",
"0.5814497",
"0.5764625",
"0.57616985",
"0.576019... | 0.671756 | 0 |
If the first value in this list is a tag, pop and return it. | def pop_tag(data):
if data and is_tag(data[0]):
return data.pop(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):\n while not self.queue[self.tag].empty():\n temp = self.queue[self.tag].get()\n if not self.queue[self.tag].empty():\n self.queue[1 - self.tag].put(temp)\n else:\n self.tag = 1 - self.tag\n return temp",
"def pop(... | [
"0.73780775",
"0.71970713",
"0.700163",
"0.69585055",
"0.69546187",
"0.6942529",
"0.69298804",
"0.6921087",
"0.69165844",
"0.69013816",
"0.6838649",
"0.6807731",
"0.6806792",
"0.67973435",
"0.67922765",
"0.6770666",
"0.67601925",
"0.67588156",
"0.6755501",
"0.6738713",
"0.673... | 0.8173029 | 0 |
Download the COCO dataset | def download_coco_dataset():
# Create file structure
os.makedirs(os.path.join("data", "coco", "train"), exist_ok=True)
os.makedirs(os.path.join("data", "coco", "dev"), exist_ok=True)
os.makedirs(os.path.join("data", "coco", "test"), exist_ok=True)
# Download the train, dev and test datasets
prin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_coco(): \n file_type = '.zip'\n img_to_download = ['val','test','train']\n ann_to_download = ['annotations_trainval','image_info_test']\n base_url_images = 'http://images.cocodataset.org/zips/'\n base_url_ann = 'http://images.cocodataset.org/annotations/'\n\n\n click.echo(click.styl... | [
"0.7337057",
"0.7103282",
"0.70431393",
"0.6646939",
"0.66247356",
"0.652305",
"0.6369042",
"0.63372713",
"0.63305813",
"0.6327974",
"0.62980855",
"0.628331",
"0.6242413",
"0.61973923",
"0.6178355",
"0.61595905",
"0.61565197",
"0.611133",
"0.61082715",
"0.60795313",
"0.607768... | 0.8114325 | 0 |
Check whether vote generator generates 6 votes | def test_vote_generator(self):
self.assertEqual(len(self.vote_ballot), 6) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def result_poll(votes):\n return sum(votes) >= 2 / 3 * len(votes)",
"def Vote(i, j, budget, count):\r\n if(count < budget):\r\n if(random.uniform(0, i+j) < i):\r\n return True\r\n else:\r\n return False\r\n else:\r\n if(random.uniform(0, 1) < 0.5):\r\n ... | [
"0.6676807",
"0.6540372",
"0.630108",
"0.6265139",
"0.61997306",
"0.6176548",
"0.6131795",
"0.60507333",
"0.6007827",
"0.5923374",
"0.5891573",
"0.5854174",
"0.5840629",
"0.5838884",
"0.5776376",
"0.57043755",
"0.5663822",
"0.5648873",
"0.5608658",
"0.5601602",
"0.5601602",
... | 0.77197534 | 0 |
Unit test case for kingdom_result method. Used in Problem1 | def test_kingdom_result(self):
voting_machine = VotingMachine()
vote_ballot = []
all_kingdoms = ['land', 'air', 'ice']
competing_kingdoms = {'space': []}
for name in all_kingdoms:
sender = Kingdom.get_kingdom('space')
receiver = Kingdom.get_kingdom(name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_result(self):\n result = compute()\n self.assertEqual(result, '4782')\n print(\"eulpy25Test passed\")",
"def test_initialization_of_homework_result_solution():\n assert result_1.solution == \"I have done this hw\"",
"def test_goldbach(n, result):\n from goldbach import goldb... | [
"0.64322424",
"0.62916774",
"0.6290475",
"0.6263768",
"0.6191611",
"0.617668",
"0.6162487",
"0.6086435",
"0.60824585",
"0.60282415",
"0.60280466",
"0.59648955",
"0.59591895",
"0.5949394",
"0.59443086",
"0.59283173",
"0.591891",
"0.5888462",
"0.5880813",
"0.5860383",
"0.582683... | 0.7432416 | 0 |
Test to ensure we can retrieve the leaders list from leaderboard.json | def test_get_leaders(self):
leaders = app.get_leaders()
self.assertEqual(len(leaders), 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(self, request):\n team_leaders = self.controller.retrieve_all_teams_leaders()\n serializer = data_serializers.TeamLeaderPresenterSerializer(team_leaders, many=True)\n return Response(serializer.data)",
"def test_03_leaderboard(self):\r\n # As Anonymou user\r\n url = \"... | [
"0.6381545",
"0.6360777",
"0.63352084",
"0.6237816",
"0.6234864",
"0.6102163",
"0.6041341",
"0.5974139",
"0.59478533",
"0.5893005",
"0.58824646",
"0.58673745",
"0.58673745",
"0.58460206",
"0.58338076",
"0.58337706",
"0.5821925",
"0.5797607",
"0.579719",
"0.5778626",
"0.575144... | 0.7366307 | 0 |
For now, the string method simply returns the topology of the network. | def __str__(self):
return "Network: {0}".format(self.topology) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def network(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"network\")",
"def __str__(self):\n return ('NodesNetwork('\n f'uris: {self.uris.array}, '\n f'sockets: {self.sockets.array})')",
"def network(self) -> str:\n return pulumi.get(self, \"network\")",
... | [
"0.70776266",
"0.7034348",
"0.6924842",
"0.67171836",
"0.6608755",
"0.6608755",
"0.65742755",
"0.6554554",
"0.6553372",
"0.6523976",
"0.64513",
"0.641888",
"0.6392012",
"0.638203",
"0.636719",
"0.63357216",
"0.6312321",
"0.63068455",
"0.6295409",
"0.6251271",
"0.62105703",
... | 0.8206173 | 0 |
Returns the number of features or synapses (connections) present in the network. | def get_num_connections(self):
synapses = 0
for mat in self.weights:
synapses += mat.size
return synapses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNeuronCount(self):\n\t\treturn self.loader.getNeuronCount()",
"def num_node_features(self):\n return self[0].num_node_features",
"def num_features(self) -> Dict[NodeType, int]:\n return self.num_node_features",
"def get_num_features(self):\r\n \r\n return len(self[0]['x'])"... | [
"0.7547738",
"0.73359764",
"0.7307265",
"0.72956717",
"0.7176172",
"0.712794",
"0.7111971",
"0.71068484",
"0.7103375",
"0.70746815",
"0.7061183",
"0.7060888",
"0.7045565",
"0.7018414",
"0.7011767",
"0.698772",
"0.6983539",
"0.6975411",
"0.6970141",
"0.6951382",
"0.6929856",
... | 0.7790741 | 0 |
Like the feedforward function but reversed. It takes an output or target vector, and returns the corresponding input vector. Nothing is stored by this function. | def reversed_feed(self, outIn):
I = np.array(outIn)
for W in self.weights[::-1]: # We traverse backwards through the weight matrices
I = np.dot(W,I)[:-1] #The dot product of the two numpy arrays will have one extra element, corresponding to the bias node, but w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward(self, x_out, x_target):\r\n return 2*(x_out - x_target)",
"def reverse(self, y, *args, **kwargs):\n if self.memory_free:\n if isinstance(y, list):\n n_args = len(y)\n y = list(itertools.chain(*y))\n else:\n n_args = 1\n... | [
"0.7287039",
"0.67654866",
"0.6600392",
"0.65811574",
"0.654743",
"0.64547324",
"0.63930595",
"0.6372981",
"0.6336604",
"0.6294984",
"0.62903523",
"0.62878835",
"0.6214021",
"0.6207465",
"0.6194195",
"0.6163077",
"0.612815",
"0.6098429",
"0.60826397",
"0.6078447",
"0.60556835... | 0.68784493 | 1 |
Computes the error for the network output. | def _compute_error(self,expected_out,actual_out,error_func):
error = error_func(expected_out,actual_out)
return error | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error(input_, output):\n global number_of_neurons_by_layer\n if len(output) != number_of_neurons_by_layer[-1]:\n raise IndexError(\n f\"\\033[91mDesired output length is incorrect. It must be {number_of_neurons_by_layer[-1]}.\\033[m\")\n output = np.array(output).reshape(len(output),... | [
"0.7844051",
"0.7378653",
"0.70772296",
"0.7048775",
"0.700349",
"0.6880271",
"0.687721",
"0.6814743",
"0.6809733",
"0.67768127",
"0.6671029",
"0.6610069",
"0.65781933",
"0.6498636",
"0.6493377",
"0.6410907",
"0.6401569",
"0.6319782",
"0.62156636",
"0.62088066",
"0.6189162",
... | 0.7385006 | 1 |
Prints the current state of the training process, such as the epoch, current error. | def print_training_state(self,epoch,error,finished=False):
#print("Epoch:",iterCount)
if finished:
print("Network has reached a state of minimum error.")
#print("Error: {0}\tEpoch {1}".format(error,iterCount))
print("""Epoch {0} completed""".format(epoch),'Error:',error) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_status(self, epoch, iteration, prefix=\"\",\n mode=\"train\", is_main_net=True):\n if mode == \"train\":\n log = getattr(self.logger[\"train\"], \"info\")\n else:\n log = getattr(self.logger[\"train\"], \"debug\")\n\n if is_main_net:\n ... | [
"0.72262985",
"0.7183004",
"0.7071686",
"0.6913451",
"0.6806319",
"0.6769184",
"0.6690559",
"0.65998715",
"0.6593775",
"0.65109324",
"0.6402722",
"0.6387626",
"0.63702345",
"0.6350585",
"0.62587076",
"0.6226373",
"0.62072736",
"0.6168022",
"0.6164347",
"0.61623514",
"0.614860... | 0.7943574 | 0 |
Will create a new EclGrid instance from grdecl file. This function will scan the input file and look for the keywords required to build a grid. The following keywords | def loadFromGrdecl(cls , filename):
if os.path.isfile(filename):
with open(filename) as f:
specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclTypeEnum.ECL_INT_TYPE, strict=False)
zcorn = EclKW.read_grdecl(f, "ZCORN")
coord = EclKW.read_grdecl(f, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_from_file(self,grd_fn):\n self.grd_fn = grd_fn\n self.fp = open(self.grd_fn,'rt')\n hdr = self.fp.readline().strip() #header &GRD_2008 or &LISTGRD\n\n if hdr == self.hdr_08:\n print( \"Will read 2008 format for grid\" )\n n_parms = 11\n elif hdr == ... | [
"0.6322648",
"0.62795305",
"0.6265699",
"0.6259004",
"0.59612995",
"0.58936375",
"0.5617548",
"0.56006193",
"0.55665076",
"0.54528695",
"0.5436702",
"0.5436639",
"0.5416839",
"0.53553003",
"0.5331694",
"0.5330871",
"0.53176844",
"0.5292191",
"0.5279908",
"0.52744323",
"0.5264... | 0.7024199 | 0 |
Will convert either active_index or (i,j,k) to global index. | def global_index( self , active_index = None, ijk = None):
return self.__global_index( active_index = active_index , ijk = ijk ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __global_index( self , active_index = None , global_index = None , ijk = None):\n\n set_count = 0\n if not active_index is None:\n set_count += 1\n\n if not global_index is None:\n set_count += 1\n\n if ijk:\n set_count += 1\n \n if... | [
"0.75835437",
"0.70099026",
"0.6881584",
"0.6451329",
"0.6263909",
"0.62555516",
"0.61454946",
"0.602932",
"0.6009992",
"0.5978144",
"0.59321",
"0.5818314",
"0.57944906",
"0.57812554",
"0.57411104",
"0.5684214",
"0.56785935",
"0.5664866",
"0.5656509",
"0.5655089",
"0.5635291"... | 0.7180106 | 1 |
Will convert or to global_index. This method will convert or to a global index. Exactly one of the arguments , or must be supplied. The method is used extensively internally in the EclGrid class; most methods which take coordinate input pass through this method to normalize the coordinate representation. | def __global_index( self , active_index = None , global_index = None , ijk = None):
set_count = 0
if not active_index is None:
set_count += 1
if not global_index is None:
set_count += 1
if ijk:
set_count += 1
if not set_count ==... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def global_index(self):\n raise NotImplementedError",
"def global_index( self , active_index = None, ijk = None):\n return self.__global_index( active_index = active_index , ijk = ijk )",
"def position_to_index(self, position, grid_size):\n x, y = position\n return x * grid_size + y... | [
"0.64048535",
"0.58219904",
"0.5818594",
"0.5818252",
"0.5786247",
"0.5762174",
"0.5650124",
"0.55458665",
"0.5530507",
"0.54503554",
"0.54221517",
"0.5288694",
"0.5283449",
"0.5277573",
"0.52770066",
"0.52442706",
"0.5210543",
"0.5206184",
"0.51815325",
"0.51768124",
"0.5117... | 0.6640061 | 0 |
Lookup active index based on ijk or global index. Will determine the active_index of a cell, based on either = (i,j,k) or . If the cell specified by the input arguments is not active the function will return 1. | def get_active_index( self , ijk = None , global_index = None):
gi = self.__global_index( global_index = global_index , ijk = ijk)
return self._get_active_index1( gi) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __global_index( self , active_index = None , global_index = None , ijk = None):\n\n set_count = 0\n if not active_index is None:\n set_count += 1\n\n if not global_index is None:\n set_count += 1\n\n if ijk:\n set_count += 1\n \n if... | [
"0.72220266",
"0.67399526",
"0.6588938",
"0.657614",
"0.65294176",
"0.64901483",
"0.6479824",
"0.6127703",
"0.59284616",
"0.59080535",
"0.5897826",
"0.58777493",
"0.5840648",
"0.5834276",
"0.57921964",
"0.5760958",
"0.57434833",
"0.57338476",
"0.5721414",
"0.5609708",
"0.5569... | 0.7030846 | 1 |
For dual porosity get the active fracture index. | def get_active_fracture_index( self , ijk = None , global_index = None):
gi = self.__global_index( global_index = global_index , ijk = ijk)
return self._get_active_fracture_index1( gi ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_global_index1F( self , active_fracture_index):\n return self._get_global_index1F( active_fracture_index )",
"def getNumActiveFracture(self):\n return self._get_active_fracture( )",
"def get_index(self):\n return (np.sqrt(self.dielectric))",
"def get_spectral_index(self):\n ... | [
"0.6997283",
"0.69108033",
"0.64579755",
"0.63483775",
"0.6228953",
"0.61389655",
"0.5921288",
"0.5858171",
"0.58559376",
"0.58210796",
"0.5810789",
"0.58045286",
"0.5769987",
"0.5764283",
"0.56984854",
"0.5679604",
"0.5670899",
"0.566244",
"0.5644965",
"0.56232315",
"0.56101... | 0.69569004 | 1 |
Will return the global index corresponding to active fracture index. | def get_global_index1F( self , active_fracture_index):
return self._get_global_index1F( active_fracture_index ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_active_fracture_index( self , ijk = None , global_index = None):\n gi = self.__global_index( global_index = global_index , ijk = ijk)\n return self._get_active_fracture_index1( gi )",
"def global_index( self , active_index = None, ijk = None):\n return self.__global_index( active_ind... | [
"0.81322634",
"0.7880399",
"0.78281593",
"0.7697947",
"0.7535059",
"0.71836853",
"0.67078066",
"0.6659681",
"0.63780624",
"0.62409",
"0.6091238",
"0.59864235",
"0.59864235",
"0.5970467",
"0.5953205",
"0.5949563",
"0.5941727",
"0.5938283",
"0.5936778",
"0.59265053",
"0.5893494... | 0.84458816 | 0 |
Tries to check if a cell is invalid. Cells which are used to represent numerical aquifers are typically located in UTM position (0,0); these cells have completely whacked up shape and size, and should NOT be used in calculations involving real world coordinates. To protect against this a heuristic is used identify such... | def cell_invalid( self , ijk = None , global_index = None , active_index = None):
gi = self.__global_index( global_index = global_index , ijk = ijk , active_index = active_index)
return self._invalid_cell( gi ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_valid(self):\n for cell in self._cells_iterable():\n if cell not in self._valid_elements:\n return False\n return True",
"def verify_cell_details(app, style, color, cell):\n error = ''\n found_cell = find_cell(app, cell)\n if found_cell is None:\n r... | [
"0.7039616",
"0.6568949",
"0.6549772",
"0.65140575",
"0.6419735",
"0.6371772",
"0.63522184",
"0.6340446",
"0.63166225",
"0.62470424",
"0.6218878",
"0.62010264",
"0.61809516",
"0.6105728",
"0.60955465",
"0.60486126",
"0.60447174",
"0.6013415",
"0.6009598",
"0.600179",
"0.59797... | 0.69550496 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.