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 |
|---|---|---|---|---|---|---|
GetDefaultLayerProperties() > Layer Constructs a layer with the current default properties. The default layer | def GetDefaultLayerProperties():
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDefaultLayerName(self):\n\t\treturn self._fileSystem.getDefaultLayerName()",
"def createEmptyLayer(self):\n # , wt.greeting: False , wt.ects: False, wt.preReqs: False, wt.courseCodeMentioned: False\n layer = {wt.questionWord: \"\", wt.pronoun: \"\", wt.verb: \"\", wt.websiteName: \"\", wt.ti... | [
"0.66021854",
"0.5906231",
"0.56468445",
"0.5631335",
"0.56068",
"0.552935",
"0.5517866",
"0.5460957",
"0.54607713",
"0.54574144",
"0.54437965",
"0.5383196",
"0.52941656",
"0.528982",
"0.5280748",
"0.52542603",
"0.52485424",
"0.52455497",
"0.5240612",
"0.5239051",
"0.52322686... | 0.8021245 | 0 |
Get upper half of data | def testSliceUpperHalf(self):
inst = WireData(b'0123456789')
self.assertEqual(inst[5:], WireData(b'56789')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def middle(self):\n return (self.lo+self.hi)/2",
"def data_resolution_and_offset(data):\n res = (data[data.size - 1] - data[0]) / (data.size - 1.0)\n off = data[0] - 0.5 * res\n return numpy.asscalar(res), numpy.asscalar(off)",
"def upper_bound(height):\n tan_72 = math.tan(math.radians(72))\... | [
"0.6098547",
"0.6073213",
"0.60280687",
"0.59528",
"0.59505004",
"0.5943778",
"0.5916215",
"0.5874411",
"0.5850862",
"0.58468854",
"0.5822271",
"0.581006",
"0.57646763",
"0.57625425",
"0.57251567",
"0.5716223",
"0.5704054",
"0.5697968",
"0.5654104",
"0.562238",
"0.5613673",
... | 0.65170133 | 0 |
Overwrite targets for a single component. | def set_component(self, component, targets):
data = []
if targets:
data.append({
'targets': targets,
'labels': {'service': self.name, 'component': component},
})
with open(self.filename) as f:
old_data = json.load(f)
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_target(self):\n pass",
"def SetTarget(self, entity):\n\t\tself.target = entity",
"def update_targets(self):\n self.actor.update_target_network()\n self.critic.update_target_network()",
"def update(self, target):\n self.target = target.detach()",
"def targets_placehold... | [
"0.63572824",
"0.5849339",
"0.5827244",
"0.5730988",
"0.56796896",
"0.56685513",
"0.5648616",
"0.56449085",
"0.560857",
"0.56063944",
"0.5579322",
"0.5560201",
"0.5483544",
"0.5483544",
"0.54758435",
"0.546822",
"0.54226726",
"0.5392401",
"0.5376249",
"0.5372309",
"0.5371662"... | 0.6161021 | 1 |
Append to targets for a single component. | def add_component(self, component, targets):
data = [{
'targets': targets,
'labels': {'service': self.name, 'component': component},
}]
with open(self.filename) as f:
old_data = json.load(f)
for s in old_data:
if s['labels']['service'] == s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_link_to_targets(self, link):\n for target in self._selected_data():\n target.add_component_link(link)",
"def add_for_targets(self, targets, products):\n # FIXME: This is a temporary helper for use until the classpath has been split.\n for target in targets:\n self.add_for_ta... | [
"0.6670979",
"0.6489195",
"0.6483397",
"0.6378972",
"0.62221897",
"0.6216192",
"0.59322256",
"0.59227264",
"0.57226443",
"0.56756765",
"0.5585309",
"0.555611",
"0.55513865",
"0.5547835",
"0.5506351",
"0.5499414",
"0.5498866",
"0.54545045",
"0.545411",
"0.54319674",
"0.5376081... | 0.657948 | 1 |
r"""Unify embedding length of neighborhood information for efficiency consideration. Truncate the list if the length is larger than max_ner. Otherwise, pad it with 0. | def Max_ner(self, lst, max_ner):
for i in range(len(lst)):
if len(lst[i]) >= max_ner:
lst[i] = lst[i][:max_ner]
else:
length = len(lst[i])
for _ in range(max_ner - length):
lst[i].append(0)
return lst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_trunc(data, maxlen):\n new_data = []\n\n # Create a vector of 0's the length of our word vectors\n zero_vector = []\n for _ in range(len(data[0][0])):\n zero_vector.append(0.0)\n\n for sample in data:\n\n if len(sample) > maxlen:\n temp = sample[:maxlen]\n eli... | [
"0.6299047",
"0.62753916",
"0.610394",
"0.58518624",
"0.5850512",
"0.58389467",
"0.58048224",
"0.5799142",
"0.5701418",
"0.56909394",
"0.56868714",
"0.5674759",
"0.5644927",
"0.5635289",
"0.5606152",
"0.5547879",
"0.5541351",
"0.5525588",
"0.5488732",
"0.54763174",
"0.5468823... | 0.64033824 | 0 |
r"""Get neighborhood information using louvain algorithm. First, change the id of node, for example, the id of user node "1" will be set to "u_1" in order to use louvain algorithm. Second, use louvain algorithm to seperate nodes into different communities. Finally, find the community neighbors of each node with the sam... | def get_neigh_louvain(self):
inter_M = self.interaction_matrix
pairs = list(zip(inter_M.row, inter_M.col))
tmp_relation = []
for i in range(len(pairs)):
tmp_relation.append(
["user_" + str(pairs[i][0]), "item_" + str(pairs[i][1])]
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_neighbouring_nodes(node) :\r\n\r\n connected_nodes = [] #A list of the connected nodes\r\n\r\n #Checking if the node belongs to the 1st row\r\n if(node.coords[0] != 0) :\r\n connected_node = Node((node.coords[0] - 1, node.coords[1]), goal_pos, node.gn_value - 1)\r\n #Checking if the ... | [
"0.58988756",
"0.58500105",
"0.55939347",
"0.5578462",
"0.5571188",
"0.5499327",
"0.5490918",
"0.54556835",
"0.5422812",
"0.5419801",
"0.5419051",
"0.538365",
"0.5323658",
"0.5263833",
"0.52477914",
"0.52401143",
"0.5239627",
"0.5228102",
"0.5213099",
"0.5193898",
"0.5186829"... | 0.65656084 | 0 |
Display a page containing a list of all issues items for a given publisher | def publisher_issue_page(self, publisher_id):
c.publisher = model.Group.get(publisher_id)
q = """
SELECT table_id
FROM member
WHERE group_id='{gid}'
AND table_name='package'
AND state='active'
""".format(gid=c.publisher.id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def issueListing(self, v, i):\n #list of URLS within the issue\n# links = []\n issURL = self.link(vol = v, iss = i )\n html=urlopen(issURL)\n soup=BeautifulSoup(html,'html.parser')\n URLs = [] #Empty list\n \n# titles = soup.find_all('h5', class_=\"title\")\n... | [
"0.66525006",
"0.61869705",
"0.59438676",
"0.5933621",
"0.58923775",
"0.58833736",
"0.57707345",
"0.57317865",
"0.5456847",
"0.54415303",
"0.5419624",
"0.53739566",
"0.53459716",
"0.53225005",
"0.5321889",
"0.5314859",
"0.5295016",
"0.5293441",
"0.5279754",
"0.5265637",
"0.52... | 0.8031485 | 0 |
Display a page containing a list of all issues items, sorted by category. NB This doesn't seem to work no connection between issues and categories in the model | def all_issues_page(self):
# categories
categories = model.Session.query(
func.count(issuemodel.Issue.id).label('issue_count'),
issuemodel.Issue.issue_category_id)\
.filter(issuemodel.Issue.resolved == None)\
.group_by(issuemodel.Issue.issue_category_id)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allBroken(request, page=1):\n objects = im.Issue.objects.filter(resolved_state__isnull=True)\n args = utils.generatePageList(request, objects, page)\n args['issues'] = args['objects']\n issues_list = {'Issues on Unusable Machines':[]}\n for issue in args['issues']:\n iss_id = issue.item.i... | [
"0.62845093",
"0.6153223",
"0.61309993",
"0.61213243",
"0.6092204",
"0.60884356",
"0.60356814",
"0.5973066",
"0.5967434",
"0.59632665",
"0.58919924",
"0.5843283",
"0.58374083",
"0.5788498",
"0.57452506",
"0.5738671",
"0.5727811",
"0.5726845",
"0.56615317",
"0.5631422",
"0.560... | 0.81185937 | 0 |
Plot the time that it takes to get to work as a function of speed. | def task_1():
# To store the list of speeds to plot
list_of_speeds = []
list_of_times = []
# To go from 1 through 80
for i in range(LOW_SPEED, HIGH_SPEED + 1):
list_of_speeds.append(i)
time = (DISTANCE/i) * 60 * 60
list_of_times.append(time)
plt.plot(list_of_speeds, li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_running_time():\n global counter\n counter += 1\n running_time_targeted = []\n running_time_fast_targeted = []\n \n for node_number in range(10, 1000, 10):\n synthetic_undirected_graph = make_synthetic_undirected_graph(node_number, 5)\n\n start_time = time.time()\n a... | [
"0.70877206",
"0.70490026",
"0.70362264",
"0.70328856",
"0.67851293",
"0.65259343",
"0.6455701",
"0.6376265",
"0.63443184",
"0.63128775",
"0.62797326",
"0.62136763",
"0.61617917",
"0.61399204",
"0.6137049",
"0.6132508",
"0.6125544",
"0.6117221",
"0.6073252",
"0.6070048",
"0.6... | 0.71218544 | 0 |
To calculate the gear ratio | def calculate_gear_ratio(front_gear, back_gear):
return front_gear/back_gear | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adv_ratio(self): # XXX\r\n bw = StatsRouter.global_bw_mean\r\n if bw == 0.0: return 0\r\n else: return self.bw/bw",
"def getRatio(probe_num, position_vector, shot_range, dir, day ='050119r'):\n ratio_x = 0\n ratio_y = 0\n ratio_z = 0\n # helm_B = [0,0,0]\n divideby = 0\n for shot ... | [
"0.7065788",
"0.68763024",
"0.66672885",
"0.66644496",
"0.647073",
"0.6403412",
"0.6301645",
"0.62883854",
"0.6240632",
"0.6229216",
"0.6196526",
"0.6127566",
"0.6111923",
"0.60082084",
"0.59576005",
"0.5938981",
"0.593328",
"0.59320647",
"0.592565",
"0.5923481",
"0.59199065"... | 0.838587 | 0 |
Main game function. Takes in the dictCapitals from countries.py Creates a window with a question, four choices for the question and the current score of the player. | def game():
dictCapitals = countries.dictCountries
country = random.choice(list(dictCapitals.keys()))
window = Tk()
window.title("Do you know your capitals?")
window.geometry("500x250")
asktext = "%s) What is the capital of %s?" % (qno, country)
question = tkinter.Label(window, text=asktex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(self, win):\n\n # The rock, paper, scissor buttons\n rockButton = Button(white, 50, 400, 100, 50, 'ROCK')\n paperButton = Button(white, 200, 400, 100, 50, 'PAPER')\n scissorButton = Button(white, 350, 400, 100, 50, 'SCISSOR')\n\n # Player and computer scores\n pla... | [
"0.62329996",
"0.60966957",
"0.60630614",
"0.59620565",
"0.59380543",
"0.58837277",
"0.5848126",
"0.5843877",
"0.5805548",
"0.57711256",
"0.574825",
"0.5741571",
"0.5716169",
"0.5694558",
"0.5692534",
"0.56751484",
"0.56521857",
"0.5646317",
"0.56424445",
"0.56236213",
"0.561... | 0.78046966 | 0 |
Chooses a random number to be the correct answer, so that the correct asnwer is not always e.g. the second choice. | def choose_correct():
val = [0, 1, 2, 3]
correct = random.choice(val)
return correct | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def correctAnswer(randomNumberOne, randomNumberTwo, problemType):\n if problemType == \"*\":\n return randomNumberOne * randomNumberTwo\n elif problemType == \"-\":\n return randomNumberOne - randomNumberTwo\n else:\n return randomNumberOne + randomNumberTwo",
"def evaluate_my_numbe... | [
"0.71440387",
"0.7024754",
"0.69993585",
"0.6914446",
"0.6914446",
"0.6914446",
"0.6914446",
"0.67581326",
"0.6749477",
"0.6710949",
"0.6689745",
"0.666535",
"0.6637368",
"0.66317135",
"0.66116613",
"0.6566058",
"0.6514634",
"0.6404154",
"0.632766",
"0.63207775",
"0.63171786"... | 0.7509669 | 0 |
Construct an ndarray of x, y, and z coordinates from all residues in selection and atom names in from as rows and return it. | def pose_coords_as_rows(pack_or_pose, selection=list(), atom_names=list()):
import pyrosetta.distributed.packed_pose as packed_pose
import numpy as np
wpose = packed_pose.to_pose(pack_or_pose)
# default to all residues
if not selection:
selection = range(1, wpose.total_residue() + 1)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractCoords(self):\n if not self.rank:\n logging.info('Extracting atomic poitions')\n\n # Extract coordinates from liggghts\n self.lmp.command('variable x atom x')\n x = Rxn.lmp.extract_variable(\"x\", \"group1\", 1)\n\n self.lmp.command('variable y atom y')\n y = Rxn.lmp.extract_varia... | [
"0.6174947",
"0.5768576",
"0.5676368",
"0.5632993",
"0.5631109",
"0.55929625",
"0.5572965",
"0.54100746",
"0.5383707",
"0.53771704",
"0.53760475",
"0.5373231",
"0.53343093",
"0.52856094",
"0.52557695",
"0.52339303",
"0.5209516",
"0.51999474",
"0.5173438",
"0.51456636",
"0.514... | 0.69522864 | 0 |
Specify the guard you want to use | def guard(self, guard):
from .Guard import Guard
return Guard(self.app).make(guard) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_guard(self):\n raise NotImplementedError()",
"def get_guard(self, name: str) -> GuardInterface:\n return self.__guards[name] if name in self.__guards else NullGuard",
"def guard(cli, nick, chan, rest):\n if nick in GUARDED:\n pm(cli, nick, messages[\"already_protecting\"])\n ... | [
"0.68185496",
"0.5920525",
"0.5903156",
"0.54643375",
"0.53619206",
"0.53520066",
"0.5324586",
"0.5303647",
"0.52058554",
"0.5201462",
"0.5159062",
"0.51056707",
"0.50783026",
"0.5068449",
"0.5044221",
"0.498786",
"0.4903159",
"0.4887432",
"0.48528442",
"0.4844048",
"0.478944... | 0.71186763 | 0 |
Registers a new guard class. | def register_guard(self, key, cls=None):
from .Guard import Guard
if isinstance(key, dict):
return Guard.guards.update(key)
return Guard.guards.update({key: cls}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(cls, class_):\n cls._registered[class_.tag()] = class_",
"def register(cls):\n register(cls, cls.provided_class)",
"def register_class(cls):\n if cls is RegisteredType:\n raise \"Please do _not_ register RegisteredType!\"\n \n cid = RegisteredType.... | [
"0.6814839",
"0.6706418",
"0.6671669",
"0.6499343",
"0.63529325",
"0.6345642",
"0.6326796",
"0.6262941",
"0.6121408",
"0.6080356",
"0.60768956",
"0.5979376",
"0.59475553",
"0.5853703",
"0.57513314",
"0.5742407",
"0.57294697",
"0.57038367",
"0.5655719",
"0.564569",
"0.563108",... | 0.7089569 | 0 |
Registers a new driver with the current guard class. | def register_driver(self, key, cls):
self.drivers.update({key: cls}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_driver(self, driver, alias):\n return self._drivers.register(driver, alias)",
"def register(self, driver_class: Type[Driver]):\n\n if not inspect.isclass(driver_class):\n raise CommError(CommError.ERROR, f\"Registrant must be class, not instance: {type(driver_class)}\")\n\n ... | [
"0.68936753",
"0.661044",
"0.6508918",
"0.6256057",
"0.6187393",
"0.61852074",
"0.61852074",
"0.60228777",
"0.60184443",
"0.5825919",
"0.57579637",
"0.57563",
"0.5739101",
"0.56742686",
"0.5605367",
"0.55735165",
"0.5523443",
"0.5515529",
"0.55120367",
"0.55120367",
"0.549311... | 0.71675396 | 0 |
Show a single gun and all its info. | def gunview(request, gun_id):
guns = Gun.objects.filter(owner=request.user, id=gun_id).prefetch_related('bullets__results__velocity')
# Make sure the gun belongs to the current user.
for gun in guns:
if gun.owner != request.user:
raise Http404
context = {'guns': guns}
return r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show():\n info(str(Project))",
"def HellFire_ShotGuns(self):\n\t\tprint(self.name.title() + \" is now shotting.\")",
"def AddGun(request):\n if request.method != 'POST':\n # No data submitted; create a blank form.\n form = GunForm()\n else:\n # POST data submitted; process dat... | [
"0.57229",
"0.5588398",
"0.5550937",
"0.5399547",
"0.53548175",
"0.53304666",
"0.53285635",
"0.53071034",
"0.5297438",
"0.527408",
"0.5272316",
"0.52683187",
"0.5216605",
"0.5215122",
"0.52047205",
"0.51734424",
"0.5171177",
"0.5151973",
"0.5132073",
"0.5118412",
"0.5117209",... | 0.6497468 | 0 |
Add a new gun. | def AddGun(request):
if request.method != 'POST':
# No data submitted; create a blank form.
form = GunForm()
else:
# POST data submitted; process data.
form = GunForm(request.POST)
if form.is_valid():
new_gun = form.save(commit=False)
new_gun.owner... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addbullet(request, gun_id):\n gun = Gun.objects.get(id=gun_id)\n if request.method != 'POST':\n # No data submitted; create a blank form.\n form = BulletForm()\n else:\n # POST data submitted; process data.\n form = BulletForm(data=request.POST)\n if form.is_valid():... | [
"0.6368008",
"0.56201386",
"0.56171954",
"0.5587559",
"0.5560045",
"0.55319446",
"0.5479173",
"0.54610556",
"0.54501253",
"0.54199797",
"0.54197234",
"0.541627",
"0.5325442",
"0.5297029",
"0.52819395",
"0.52541983",
"0.52378875",
"0.51394504",
"0.5136434",
"0.51353484",
"0.51... | 0.69544053 | 0 |
Parses the query string of a URL and returns the value of a parameter. | def parse_query_param(url, param):
try:
return parse.parse_qs(parse.urlparse(url).query)[param][0]
except:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def url_query_parameter(url, parameter, default=None, keep_blank_values=0):\n\n queryparams = parse_qs(\n urlsplit(str(url))[3],\n keep_blank_values=keep_blank_values\n )\n return queryparams.get(parameter, [default])[0]",
"def _urlparse_splitquery(url):\r\n\r\n qpart = url.split(\"?\", 1... | [
"0.7562924",
"0.69105047",
"0.65407884",
"0.6460055",
"0.6450389",
"0.63939226",
"0.6316199",
"0.62906224",
"0.623679",
"0.62217206",
"0.6193717",
"0.61665684",
"0.61475265",
"0.6081217",
"0.60783446",
"0.60570395",
"0.6018337",
"0.60150254",
"0.5951291",
"0.5950106",
"0.5948... | 0.7826113 | 0 |
Extracts playlist ID from URL. | def get_playlist_id_from_url(url):
return match1(url, r'youku\.com/playlist_show/id_([a-zA-Z0-9=]+)') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _id_from_url(url):\n url = re.sub(r'\\?.*', '', url)\n video_id = url.split('/')[-2]\n return video_id",
"def parse_link_to_id(self, playlist_link: str) -> str:\n split_1 = playlist_link.split('/')[4]\n split_2 = split_1.split('?')\n return split_2[0]",
"def find_p... | [
"0.79475635",
"0.7792013",
"0.7235619",
"0.71647614",
"0.7086881",
"0.7061694",
"0.7037078",
"0.7035799",
"0.70044476",
"0.69504434",
"0.69365436",
"0.6880086",
"0.6839792",
"0.6803455",
"0.67705154",
"0.6764416",
"0.6723081",
"0.6707778",
"0.6607919",
"0.64947504",
"0.645438... | 0.8856763 | 0 |
Parses an entire Jeopardy! game and extract individual clues. | def parse_game(f, sql, gid):
bsoup = BeautifulSoup(f, "lxml")
# the title is in the format:
# J! Archive - Show #XXXX, aired 2004-09-16
# the last part is all that is required
airdate = bsoup.title.get_text().split()[-1]
if not parse_round(bsoup, sql, 1, gid, airdate) or not parse_round(bsoup, sql, 2, gid, airdat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseClues(self, clues):\n parses = []\n for clue in clues:\n klass = self.classifier.classify(self.findFeatures(clue))\n entities = self.findEntities(clue)\n parse = klass + \":\"\n if len(entities) != 0:\n parse += entities[-1]\n ... | [
"0.5712642",
"0.566904",
"0.566092",
"0.5573072",
"0.5486998",
"0.53480273",
"0.52242804",
"0.5214913",
"0.5204733",
"0.5155292",
"0.51019305",
"0.5069869",
"0.5042738",
"0.50369084",
"0.5002467",
"0.49987102",
"0.49979413",
"0.49972227",
"0.4960824",
"0.4959379",
"0.49587798... | 0.63239187 | 0 |
Parses and inserts the list of clues from a whole round. | def parse_round(bsoup, sql, rnd, gid, airdate):
round_id = "jeopardy_round" if rnd == 1 else "double_jeopardy_round"
r = bsoup.find(id = round_id)
# the game may not have all the rounds
if not r:
return False
# the list of categories for this round
categories = [c.get_text() for c in r.find_all("td", class_ = "... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parseClues(self, clues):\n parses = []\n for clue in clues:\n klass = self.classifier.classify(self.findFeatures(clue))\n entities = self.findEntities(clue)\n parse = klass + \":\"\n if len(entities) != 0:\n parse += entities[-1]\n ... | [
"0.63480055",
"0.5288681",
"0.52181405",
"0.5205444",
"0.5191068",
"0.5180316",
"0.5076733",
"0.50107956",
"0.4994105",
"0.49131033",
"0.48961562",
"0.48946518",
"0.48939037",
"0.48792502",
"0.48769587",
"0.484726",
"0.4825962",
"0.48227912",
"0.48216337",
"0.48191923",
"0.48... | 0.59417844 | 1 |
Inserts the given clue into the database. | def insert(sql, clue):
# clue is [game, airdate, round, category, value, clue, answer]
# note that at this point, clue[4] is False if round is 3
if "\\\'" in clue[6]:
clue[6] = clue[6].replace("\\\'", "'")
if "\\\"" in clue[6]:
clue[6] = clue[6].replace("\\\"", "\"")
if not sql:
print clue
return
sql.exec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, sql):\n try:\n # Execute the SQL command\n self.cursor.execute(sql)\n # Commit your changes in the database\n self.db.commit()\n except:\n # Rollback in case there is any error\n self.db.rollback()",
"def insert_to_d... | [
"0.69454503",
"0.6726373",
"0.66288406",
"0.65907836",
"0.6504625",
"0.6426997",
"0.6389092",
"0.6324358",
"0.6315158",
"0.6276437",
"0.62559795",
"0.6212727",
"0.6212443",
"0.62072796",
"0.6192248",
"0.61508995",
"0.6148774",
"0.6148774",
"0.6148774",
"0.61023676",
"0.610190... | 0.76964796 | 0 |
Returns a Gene object from the given ID and type. | def get_gene(self, gene_id, source="eid"):
gene_id = str(gene_id)
try:
valid_gene = self.gene_cache[self.source_cache[source][gene_id]]
return valid_gene
except KeyError:
pass
valid_eid = None
if source == "eid":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_gene(identifier):\n for store in [GENES, ALIASES]:\n genes = store.get(identifier, None)\n if genes and len(genes) == 1:\n return genes\n else:\n raise ValueError('gene reference does not exist or refers to multiple genes')",
"def get_gene_by_id(gene_query):\... | [
"0.5961231",
"0.5662687",
"0.5643379",
"0.5559565",
"0.5493846",
"0.5489511",
"0.54859185",
"0.5459926",
"0.54422474",
"0.54213154",
"0.541357",
"0.5393947",
"0.5349365",
"0.5329837",
"0.53297704",
"0.5316345",
"0.52902675",
"0.52730125",
"0.5265398",
"0.52517843",
"0.5234090... | 0.61168456 | 0 |
Finds a gene's official symbol (if it has one) given its Entrez ID. | def get_symbol(self, entrez_id):
try:
entrez_id = int(entrez_id)
except ValueError:
raise ValueError("entrez_id must be an integer")
self.cursor.execute("""
SELECT symbol
FROM genes
WHERE entrez_id = %(eid)s""", {'eid': entrez_id})
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_symbol_to_entrez_gene_id(row):\r\n\tgene_entry = annotation_client.get_entrez_gene_id_from_symbol(row['symb'])\r\n\t# import pdb; pdb.set_trace()\r\n\tegid = str(gene_entry['entrez_gene_id'][0]) if gene_entry is not None else \"0\"\r\n\treturn egid",
"def from_single_symbol_to_string_id(symb_series):\r\... | [
"0.6800354",
"0.6342648",
"0.6314558",
"0.62665135",
"0.6237379",
"0.60227257",
"0.59812385",
"0.596741",
"0.58410156",
"0.57624197",
"0.57538366",
"0.5702861",
"0.56877273",
"0.5655461",
"0.5648183",
"0.5622435",
"0.5616411",
"0.56086236",
"0.5586112",
"0.558189",
"0.5575233... | 0.7856473 | 0 |
Takes a function f that transforms a data argument, and returns a function that takes a filename and applies f to the contents, in place. | def apply_to_file(f):
@wraps(f)
def f_in_file(fname):
with open(fname, 'rb') as inf:
data = inf.read()
data = f(data)
with open(fname, 'wb+') as outf:
outf.write(data)
return f_in_file | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def F(f):\n return datafile(f, __name__)",
"def get_transform_fn():",
"def get_function_from_text(f):\n return lambda x: eval_expr(f, {'x': x}, numpy_dict)",
"def __call__(self, f):\n mod = f.__module__\n if self.file_name is not None:\n if isinstance(self.file_name, list):\n ... | [
"0.67895573",
"0.63386834",
"0.6062225",
"0.605303",
"0.6028013",
"0.5813414",
"0.58043444",
"0.57445425",
"0.57430196",
"0.5738358",
"0.57141614",
"0.56803274",
"0.5637444",
"0.56070995",
"0.56070995",
"0.54242474",
"0.5423634",
"0.5420308",
"0.5420179",
"0.5406441",
"0.5382... | 0.7593951 | 0 |
Runs a command inplace on a file. | def runinplace(command, infile):
if not isinstance(command, list):
command = shlex.split(command)
tmpdir = None
if "%2" in command:
tmpdir = tempfile.mkdtemp(prefix="nikola")
tmpfname = os.path.join(tmpdir, os.path.basename(infile))
try:
list_replace(command, "%1", in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_file(self, file=None): # pylint: disable=redefined-builtin\n if file is None:\n file = self.thisfile\n elif isinstance(file, str):\n file = File(os.path.expanduser(file))\n if file is None:\n return\n self.execute_file(file, label='editor')",
... | [
"0.5834852",
"0.57943606",
"0.5627703",
"0.55223316",
"0.5520923",
"0.5476161",
"0.53849196",
"0.5379589",
"0.53755707",
"0.5327222",
"0.53138316",
"0.5261916",
"0.5207656",
"0.52031815",
"0.5201871",
"0.5195541",
"0.5185492",
"0.51769054",
"0.51686203",
"0.51523703",
"0.5147... | 0.76176256 | 0 |
paint in the canvas a rectangle that will correspond to a dense or flatten layer. Each rectangle will have text above it with the name and dimension of the layer. | def paint_rectangle_layer(working_canvas, name, activation,
size, scaled_size, x_coordinate, config_window, canvas_colour_config):
y_middle = 350
y_start = y_middle - (scaled_size / 2)
y_end = y_middle + (scaled_size / 2)
Layer_rectangle = working_canvas.create_rectangle(x_coo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self, win):\n self.rect.draw(win)\n self.text.draw(win)",
"def draw(self):\n if self.master != None :\n outline = Cell.FILLED_COLOR_BORDER if self.fill else Cell.EMPTY_COLOR_BORDER\n\n xmin = self.abs * self.size\n xmax = xmin + self.size\n ymin = self.ord ... | [
"0.63622874",
"0.6352579",
"0.62399036",
"0.62166023",
"0.6214173",
"0.6056414",
"0.60192233",
"0.5880789",
"0.5803497",
"0.58007914",
"0.5772716",
"0.5760971",
"0.57506824",
"0.5742156",
"0.57319474",
"0.5727788",
"0.5702693",
"0.5685722",
"0.5683689",
"0.5681913",
"0.567867... | 0.69634235 | 0 |
Retrain a session specification with all the models in the model zoo. Report the one that achieves the lowest MAE. | def retrain_models_on_session(df, sess):
ff = df.loc[df.nodetype == sess.node_type]
def get_single_sess_regression(predict_type):
Y_column_names = [predict_type]
X_column_names = sess.input_feature_list
train_full_name, test_full_name, \
x_train, y_train, \
x_test, y_tes... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_session(self):\n self.model_dir = op.join('../logs', self.name, 'models')\n\n # Obtain the list for generator, local discriminator and global discriminator models\n gen_lungs_model_list = glob(op.join(self.model_dir, 'gen_lungs*'))\n disc_lungs_model_list = glob(op.join(self... | [
"0.5776099",
"0.5746422",
"0.5699666",
"0.5695022",
"0.5664474",
"0.5553187",
"0.55115694",
"0.550021",
"0.5471255",
"0.5439532",
"0.54041255",
"0.5376209",
"0.5333948",
"0.5327301",
"0.5322908",
"0.5318845",
"0.5308706",
"0.5303736",
"0.52744746",
"0.5246807",
"0.52462524",
... | 0.70605725 | 0 |
Generates a unique filename to store image. Also stores original filename. | def _gen_image_filename(instance, filename):
# First, store the original filename in the model
instance.original_filename = filename
return _unique_path(instance.owner.pk, filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_image_filename():\n now = datetime.now().strftime('%a-%w-%b-%H:%M:%S')\n return 'CCTV_{0}.jpg'.format(now)",
"def filename_generate(image_class, size=12, chars=string.ascii_uppercase + string.ascii_lowercase + string.digits):\n\tnew_filename = time.strftime(\"%d-%m-%Y_\")\n\tnew_filename = new... | [
"0.7982899",
"0.7708101",
"0.76466966",
"0.7639321",
"0.75900793",
"0.75539184",
"0.75164586",
"0.7424421",
"0.7408833",
"0.73893046",
"0.7331677",
"0.7297422",
"0.72926384",
"0.7260037",
"0.7200859",
"0.718217",
"0.7162352",
"0.7157697",
"0.7139449",
"0.7078593",
"0.7068687"... | 0.8410429 | 0 |
Generates a path to store thumbnail. | def _gen_thumbs_filename(instance, filename):
return _unique_path(instance.owner.pk, filename, category='thumbs') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def thumbnail_path(instance, filename):\n\n username = instance.user.username\n mainpath = os.path.join(\"infocomp\",username,\"thumbnails\",filename)\n return mainpath",
"def thumbnail_path(self, img_path):\n if isinstance(img_path, unicode):\n img_path = img_path.encode('utf-8')\n ... | [
"0.7429614",
"0.7250755",
"0.70532095",
"0.70304304",
"0.6963171",
"0.6787229",
"0.6679847",
"0.6665247",
"0.6663642",
"0.66502357",
"0.6646743",
"0.6643545",
"0.6579812",
"0.6544677",
"0.6485082",
"0.64743483",
"0.64735",
"0.64732325",
"0.6468191",
"0.6453461",
"0.6444095",
... | 0.7268037 | 1 |
Returns the fraction as a dictionary {'numerator', 'denominator'} | def get_as_dict(self):
return {'numerator': self.numerator,
'denominator': self.denominator} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def denominator(num):\n require_type(isa(num,fractions.Fraction) or isa(num,int),\n 'parameter of denominator must be a fraction or integer')\n return num.denominator",
"def fractions():\n\n pi = 22 / 7\n print(\"22/7\\n====\")\n print_as_text(pi)\n\n pi = 333 / 106\n print(\"333/... | [
"0.6438606",
"0.62397045",
"0.5990371",
"0.5919258",
"0.5893991",
"0.58902526",
"0.5841809",
"0.58400464",
"0.58375835",
"0.58252704",
"0.58110225",
"0.58078283",
"0.57062525",
"0.5699363",
"0.5684251",
"0.5673069",
"0.5646279",
"0.56348014",
"0.5617288",
"0.5609543",
"0.5594... | 0.7547878 | 0 |
Stores numerator and denominator by dict with keys 'numerator' and 'denominator' | def set_by_dict(self, dictionary):
assert 'numerator' in dictionary and 'denominator' in dictionary
self.numerator = int(dictionary['numerator'])
self.denominator = int(dictionary['denominator'])
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_as_dict(self):\n return {'numerator': self.numerator,\n 'denominator': self.denominator}",
"def __init__(self):\n self.numerator = 1\n self.denominator = 1",
"def __init__(self, numerator, denominator=1):\n common_div = gcd(numerator, denominator)\n if ... | [
"0.6435931",
"0.6356003",
"0.61798686",
"0.61720556",
"0.6108143",
"0.6054677",
"0.6034983",
"0.60310364",
"0.5872456",
"0.5798077",
"0.5758123",
"0.5752463",
"0.57098174",
"0.5663325",
"0.5634272",
"0.5634011",
"0.5629044",
"0.55384237",
"0.5533909",
"0.55161214",
"0.5501381... | 0.6718744 | 0 |
Store numerator and denominator by list [numerator, denominator] | def set_by_list(self, _list):
assert _list.length == 2
self.numerator = int(_list[0])
self.denominator = int(_list[1])
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, numerator: int, denominator: int):\n self._numerator = numerator\n self._denominator = denominator\n self._reduce()",
"def ratio_calculator(numerator, denominator):\n ratios = []\n for i in numerator:\n for j in denominator:\n if i[0] == j[0] and j[1] != 0:\n ... | [
"0.6443982",
"0.63548833",
"0.62294495",
"0.61889786",
"0.6119302",
"0.60671306",
"0.60494083",
"0.59935117",
"0.59810704",
"0.59530157",
"0.5915775",
"0.5895917",
"0.5892264",
"0.5830726",
"0.58059335",
"0.5803783",
"0.579535",
"0.57430613",
"0.57304007",
"0.5727271",
"0.566... | 0.6479135 | 0 |
Uses Pillow to determine image format | def get_format(self):
image = Image.open(self.image_data)
return image.format | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pic_format(file_head: bin):\n res = \"unknown\"\n if b'\\xff\\xd8\\xff' in file_head:\n res = 'jpg'\n elif b'\\x89PNG\\r\\n\\x1a\\n' in file_head:\n res = 'png'\n\n return res",
"def image_format(img_f):\n # First use the below explicit extensions to identify image file prospects... | [
"0.7308969",
"0.709198",
"0.7007209",
"0.6936277",
"0.6899331",
"0.6858787",
"0.68252236",
"0.6731155",
"0.6659447",
"0.6647652",
"0.658424",
"0.65410435",
"0.6514342",
"0.6434791",
"0.6417415",
"0.64156383",
"0.64156383",
"0.6360617",
"0.6358427",
"0.62867635",
"0.62716335",... | 0.7181378 | 1 |
Uses exifread to get Exif tags | def get_exif(self):
_tags = {}
image = Image.open(self.image_data)
exif = image._getexif()
if exif:
for tag, value in exif.items():
# Skip any tags we don't want
if tag not in IGNORE_TAGS:
decoded = TAGS.get(tag, tag)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_exif_tags(image, s3bucket):\n\n s3client = boto3.client('s3', region_name=AWS_REGION)\n\n useful_exif_tags = [ # List of useful EXIF tags as presented in ExifRead\n 'Image Make',\n 'Image Model',\n 'Image DateTime',\n # 'Image Orientation',\n 'EXIF LensModel',\n ... | [
"0.7284416",
"0.71184754",
"0.71067053",
"0.7094352",
"0.70216686",
"0.6906524",
"0.68825537",
"0.6784532",
"0.6741149",
"0.6631203",
"0.66071194",
"0.6567775",
"0.6559731",
"0.655083",
"0.6471642",
"0.6464325",
"0.63761294",
"0.62878084",
"0.62647253",
"0.6198665",
"0.609780... | 0.7351221 | 0 |
Generates a thumbnail image with Pillow, and saves it as a proxy image in the model. | def make_thumbnail(self):
# https://gist.github.com/valberg/2429288
# make sure image data is set
if not self.image_data:
return False
if self.proxy_data:
return True
# Create a resized version of the image
image = Image.open(self.image_data)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_thumbnail(self, target, format=None):",
"def save(self, *args, **kwargs):\n if not self.pk: # on create\n image = Image.open(self.file)\n image.thumbnail((400, 400), Image.ANTIALIAS)\n\n thumb = io.BytesIO()\n image.save(\n thumb, form... | [
"0.7031007",
"0.69964665",
"0.6872761",
"0.6871693",
"0.664278",
"0.65535223",
"0.6353922",
"0.6306219",
"0.6240337",
"0.6208376",
"0.6189123",
"0.6188355",
"0.614271",
"0.61387604",
"0.61026883",
"0.6077093",
"0.60654324",
"0.60324097",
"0.6031785",
"0.60304934",
"0.59931487... | 0.7481164 | 0 |
shortcut to fetch all toplevel clauses | def root_clauses(self):
return self.clauses.filter( parent=None ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clauses(knowledge_base):\n ATOM = r\"[a-z][a-zA-z\\d_]*\"\n HEAD = rf\"\\s*(?P<HEAD>{ATOM})\\s*\"\n BODY = rf\"\\s*(?P<BODY>{ATOM}\\s*(,\\s*{ATOM}\\s*)*)\\s*\"\n CLAUSE = rf\"{HEAD}(:-{BODY})?\\.\"\n KB = rf\"^({CLAUSE})*\\s*$\"\n\n assert re.match(KB, knowledge_base)\n\n for mo ... | [
"0.5571743",
"0.5489132",
"0.53899777",
"0.53689414",
"0.52473223",
"0.5151261",
"0.50971454",
"0.50951624",
"0.5090439",
"0.5088323",
"0.50688446",
"0.49823636",
"0.49412867",
"0.49410695",
"0.49084648",
"0.49017498",
"0.48826462",
"0.4879621",
"0.48663297",
"0.48471767",
"0... | 0.7249842 | 0 |
return time difference between offending article and decision being issued. Or None if unavailable. | def time_to_decision(self):
if self.offending_date is None or self.date_of_decision is None:
return None
else:
return self.date_of_decision - self.offending_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def response_time(self):\r\n if self.__arrival_time == INVALID_TIME:\r\n self.__logger.debug(\"Request %s missing arrival time\" % self.__id)\r\n return INVALID_TIME_DELTA\r\n completion_time = self.__arrival_time\r\n for task_id, task in self.__tasks.items():\r\n ... | [
"0.6443447",
"0.64026845",
"0.62711537",
"0.6178432",
"0.6161027",
"0.60152996",
"0.6009816",
"0.5983893",
"0.5979242",
"0.5951314",
"0.5947315",
"0.5930404",
"0.592996",
"0.5897178",
"0.58928937",
"0.5880102",
"0.5859752",
"0.5854782",
"0.5851343",
"0.5837037",
"0.5817873",
... | 0.79140884 | 0 |
ensure missing parent clauses are added | def fiddle_case_clauses(instance, action="post_add", reverse=False, pk_set=[], **kwargs ):
global fiddle_case_clauses_LOCK
if fiddle_case_clauses_LOCK:
# print "locked ",action, reverse,pk_set
return
# print "locked ",action, reverse,pk_set
if action == 'post_add':
existing_clau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_lacking_parent(self):\n pass",
"def has_parent(self):\n return False",
"def test_skirmish_parenting(self):\n root = SkirmishAction()\n a1 = SkirmishAction()\n a2 = SkirmishAction()\n self.sess.add_all([root, a1, a2])\n self.sess.commit()\n\n root... | [
"0.65599465",
"0.5832243",
"0.57768613",
"0.573823",
"0.56798875",
"0.5676168",
"0.56653297",
"0.5647081",
"0.5631454",
"0.5590537",
"0.5547911",
"0.55401313",
"0.55338997",
"0.5499722",
"0.54962003",
"0.5462508",
"0.54536736",
"0.5438709",
"0.5438409",
"0.5437383",
"0.542676... | 0.5921728 | 1 |
Remove a subset from given set. | def remove_subset(set_, subset):
ensure_set(set_)
ensure_iterable(subset)
for elem in subset:
set_.remove(elem) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_elements_from_set(s: set, *args) -> set:\n for _ in args:\n s.remove(_)\n return s",
"def removeFromSet(_session, _el, _set):\n it = _session.create_iterator(_session.sc_constraint_new(sc_constants.CONSTR_3_f_a_f,\n _set,\n ... | [
"0.76565677",
"0.7269447",
"0.721655",
"0.70406854",
"0.6924315",
"0.6688128",
"0.6567135",
"0.6541463",
"0.642889",
"0.64175636",
"0.6412749",
"0.64055073",
"0.6392075",
"0.6352167",
"0.6293471",
"0.62868404",
"0.6264715",
"0.6131888",
"0.6098359",
"0.60872626",
"0.604819",
... | 0.8888922 | 0 |
Return subsets of given set with given cardinality. | def k_subsets(set_, k):
ensure_countable(set_)
if not isinstance(k, Integral):
raise TypeError("subset cardinality must be a number")
if not (k >= 0):
raise ValueError("subset cardinality must be positive")
if not (k <= len(set_)):
raise ValueError("subset cardinality must not e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subsets(self):\n return set(self.subset_map.values())",
"def subset_gen(itemSet):\n subsets = []\n for i in range(1, len(itemSet)):\n c = combinations(itemSet, r=i)\n for cc in c:\n subsets.append(set(cc))\n return subsets",
"def subsets(x, k):\n sub_set = set()\... | [
"0.6460709",
"0.63815236",
"0.6362087",
"0.62269324",
"0.61488885",
"0.6115248",
"0.6115248",
"0.60829234",
"0.6082462",
"0.6061671",
"0.60024714",
"0.5912586",
"0.5882505",
"0.5873513",
"0.5846975",
"0.5791232",
"0.5790567",
"0.56715083",
"0.560521",
"0.55337197",
"0.5498086... | 0.68652916 | 0 |
Returns a parition of given set into 1element subsets. | def trivial_partition(set_):
ensure_countable(set_)
result = ((x,) for x in set_)
return _harmonize_subset_types(set_, result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subset_gen(itemSet):\n subsets = []\n for i in range(1, len(itemSet)):\n c = combinations(itemSet, r=i)\n for cc in c:\n subsets.append(set(cc))\n return subsets",
"def subsets(arr):\n return chain(*[combinations(arr, i + 1) for i, a in enumerate(arr)])",
"def subsets(a... | [
"0.6524879",
"0.6404305",
"0.6404305",
"0.6346707",
"0.6148725",
"0.6106482",
"0.6071216",
"0.60237634",
"0.59963006",
"0.5967916",
"0.5934778",
"0.5925831",
"0.59060997",
"0.5866715",
"0.5851465",
"0.5801485",
"0.5801485",
"0.5801485",
"0.57686454",
"0.5767794",
"0.57677335"... | 0.70085377 | 0 |
Possibly convert an iterable of tuples with subsets of given "set", | def _harmonize_subset_types(set_, subset_tuples):
# if argument is originally a set, return subsets also as sets;
# otherwise (for non-set collection), return subsets as tuples
if is_tuple(set_):
return subset_tuples
else:
subset_class = set_.__class__ if is_set(set_) else tuple
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def powerset(iterable):\r\n \r\n s = list(iterable)\r\n subsets = chain.from_iterable(combinations(s, r) for r in range(len(s)+1))\r\n tuples=list(subsets)\r\n tuples.remove(())\r\n return tuples",
"def powerset(iterable):\n\n \"powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,... | [
"0.71854764",
"0.6886097",
"0.6682969",
"0.6633675",
"0.6631383",
"0.6603633",
"0.657151",
"0.65711504",
"0.6562299",
"0.65162426",
"0.65162426",
"0.65162426",
"0.65130734",
"0.64591235",
"0.6455104",
"0.63842374",
"0.62119454",
"0.6196894",
"0.61531985",
"0.61401767",
"0.613... | 0.75992745 | 0 |
Adds the desired node w/type to a given tree with a userdefined tag. Note All except for 'tree' are strings. | def AddNodeWithTag(tree, nodepath, nodetype, tag):
tree.addNode(nodepath, usage=nodetype)
tempnode = tree.getNode(nodepath)
tempnode.addTag(tag) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_node(self, node):",
"def add_node(self, node):\n index = self._node_index.setdefault(node.ntype, dict())\n if node.ext_id not in index:\n index.setdefault(node.ext_id, node)\n self._type_list.setdefault(node.ntype, list()).append(node)",
"def addnode(self, uid, **att... | [
"0.62052304",
"0.62028265",
"0.61603963",
"0.6107577",
"0.597338",
"0.5940145",
"0.59289736",
"0.59009844",
"0.58482504",
"0.5814402",
"0.57647926",
"0.5761736",
"0.5704629",
"0.5686896",
"0.5682413",
"0.5645004",
"0.5639398",
"0.5503543",
"0.55015033",
"0.54840773",
"0.54562... | 0.7666763 | 0 |
Builds the node structure for the NI PXI6602 timing cards' channels. | def TIMEchannels(tree, TIMEnum, CHnum):
chanpath = ('.SETTINGS.NI.NI_6602_TIME.TCARD_'
+ str(TIMEnum) + '.CHANNEL_' + str(CHnum))
tree.addNode(chanpath)
AddNodeWithTag(tree, chanpath + ':ACTIVE', 'NUMERIC', 'TIMACTIVE_CARD' +
str(TIMEnum) + 'CH' + str(CHnum))
AddNodeW... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DIOchannels(tree, DAQcard, DIOnum):\n diocardpath = '.SETTINGS.NI.NI_6133_DIO.DAQ_' + str(DAQcard)\n diopath = diocardpath + '.CHANNEL_' + str(DIOnum)\n tree.addNode(diopath)\n AddNodeWithTag(tree, diopath + ':CHANNEL_NAME', 'TEXT',\n 'USERNAME_DIOCARD' + str(DAQcard) + 'CH' + str... | [
"0.57067704",
"0.56877726",
"0.56035584",
"0.555096",
"0.54627526",
"0.5449146",
"0.5365122",
"0.5361143",
"0.52987146",
"0.52967054",
"0.52516145",
"0.52383196",
"0.5234952",
"0.5209054",
"0.52051514",
"0.51985425",
"0.5188461",
"0.51585215",
"0.5144823",
"0.5134938",
"0.513... | 0.620556 | 0 |
This function creates the tree structure for all NI PXI6133 DAQ cards. | def DAQcards(tree, DAQnum):
cardpath = ('.NI_6133.DAQ_' + str(DAQnum) + '.DCARD_GLOBAL')
tree.addNode('.NI_6133.DAQ_' + str(DAQnum))
tree.addNode(cardpath)
AddNumericWithUnit(tree, cardpath + ':START_T', 'START_DCARD' +
str(DAQnum), 's')
AddNumericWithUnit(tree, cardpath + ':E... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DIOcards(tree, DAQcard):\n diocardpath = '.SETTINGS.NI.NI_6133_DIO'\n tree.addNode(diocardpath + '.DAQ_' + str(DAQcard))",
"def DIOchannels(tree, DAQcard, DIOnum):\n diocardpath = '.SETTINGS.NI.NI_6133_DIO.DAQ_' + str(DAQcard)\n diopath = diocardpath + '.CHANNEL_' + str(DIOnum)\n tree.addNode(... | [
"0.71192527",
"0.5919546",
"0.58032954",
"0.57738405",
"0.55639565",
"0.5560349",
"0.55597764",
"0.55248404",
"0.5518322",
"0.5513368",
"0.5481981",
"0.53573126",
"0.53409165",
"0.5331847",
"0.5283227",
"0.52581215",
"0.52394295",
"0.52316743",
"0.52119964",
"0.52090025",
"0.... | 0.71261823 | 0 |
This function creates the tree structure for a given PXI6133 DAQ channel by reading the variable DAQnum. | def DAQchannels(tree, DAQnum, CHnum):
tree.addNode('.NI_6133.DAQ_' + str(DAQnum) + '.CHANNEL_' + str(CHnum))
chanpath = ('.NI_6133.DAQ_' + str(DAQnum) + '.CHANNEL_' + str(CHnum)
+ '.CHAN_SETTING')
tree.addNode(chanpath)
AddNodeWithTag(tree, chanpath + ':ACTIVE', 'NUMERIC', 'DAQTIVE_DCAR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DIOchannels(tree, DAQcard, DIOnum):\n diocardpath = '.SETTINGS.NI.NI_6133_DIO.DAQ_' + str(DAQcard)\n diopath = diocardpath + '.CHANNEL_' + str(DIOnum)\n tree.addNode(diopath)\n AddNodeWithTag(tree, diopath + ':CHANNEL_NAME', 'TEXT',\n 'USERNAME_DIOCARD' + str(DAQcard) + 'CH' + str... | [
"0.68553644",
"0.6789712",
"0.6493938",
"0.63280606",
"0.5849526",
"0.55885977",
"0.5479602",
"0.5474553",
"0.5338553",
"0.5316705",
"0.5168333",
"0.5039844",
"0.5027912",
"0.49974814",
"0.4955698",
"0.4944726",
"0.49163145",
"0.4891642",
"0.48317364",
"0.48271474",
"0.477208... | 0.7257309 | 0 |
This function creates the tree structure for all NI PXIe7962R FPGA RIO cards with NI 5752 digitizer adapter. | def RIOcards(tree, RIOnum):
cardpath = ('.NI_FPGA.RIO_' + str(RIOnum) + '.RCARD_GLOBAL')
tree.addNode('.NI_FPGA.RIO_' + str(RIOnum))
tree.addNode(cardpath)
AddNumericWithUnit(tree, cardpath + ':START_T', 'START_RCARD' +
str(RIOnum), 's')
AddNumericWithUnit(tree, cardpath + ':END_T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DIOcards(tree, DAQcard):\n diocardpath = '.SETTINGS.NI.NI_6133_DIO'\n tree.addNode(diocardpath + '.DAQ_' + str(DAQcard))",
"def DAQcards(tree, DAQnum):\n cardpath = ('.NI_6133.DAQ_' + str(DAQnum) + '.DCARD_GLOBAL')\n tree.addNode('.NI_6133.DAQ_' + str(DAQnum))\n tree.addNode(cardpath)\n Add... | [
"0.5947757",
"0.5873329",
"0.5795543",
"0.5628073",
"0.5614374",
"0.5578806",
"0.55061513",
"0.539918",
"0.5356151",
"0.5328047",
"0.5324649",
"0.5312456",
"0.5311537",
"0.5300892",
"0.52779937",
"0.52663827",
"0.52431136",
"0.5221406",
"0.5219581",
"0.5204605",
"0.5197559",
... | 0.62322 | 0 |
This function creates the tree structure for a given RIO channel by reading the variable RIOnum. | def RIOchannels(tree, RIOnum, CHnum):
tree.addNode('.NI_FPGA.RIO_' + str(RIOnum) + '.CHANNEL_' + str(CHnum))
chanpath = ('.NI_FPGA.RIO_' + str(RIOnum) + '.CHANNEL_' + str(CHnum)
+ '.CHAN_SETTING')
tree.addNode(chanpath)
AddNodeWithTag(tree, chanpath + ':ACTIVE', 'NUMERIC', 'RIAQTIVE_RCA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def DATAchannels_R(tree, RIOnum, CHnum):\n datapath = ('.NI_FPGA.RIO_' + str(RIOnum) + '.CHANNEL_' + str(CHnum))\n AddNodeWithTag(tree, datapath + ':VOLTAGE', 'SIGNAL', 'NIRAWDATA_RCARD' \n + str(RIOnum) + 'CH' + str(CHnum))\n AddNodeWithTag(tree, datapath + ':COUNTS', 'SIGNAL', 'NIRAWCO... | [
"0.6976687",
"0.6684082",
"0.5860063",
"0.5668086",
"0.56018776",
"0.55926317",
"0.53140104",
"0.5252317",
"0.52303934",
"0.52213657",
"0.51571435",
"0.512227",
"0.51056355",
"0.5053629",
"0.504619",
"0.50279355",
"0.50154555",
"0.50050694",
"0.50020903",
"0.49955115",
"0.496... | 0.7793475 | 0 |
This function builds the general settings for the PIMAX3 camera. | def camsettings(tree):
settingspath = '.PIMAX3.CAM_SETTING'
AddNodeWithTag(tree, '.PIMAX3.RAW:HEADER', 'TEXT',
'PIMAX_RAWHEADER')
AddNodeWithTag(tree, '.PIMAX3.RAW:FOOTER', 'TEXT',
'PIMAX_RAWFOOTER')
AddNodeWithTag(tree, settingspath + ':NUMERFRAMES', 'NUMERIC',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createCameraOptions(self):\n\t\tcamera = mc.optionMenuGrp(\"cameraPresets\", query=True, value=True)\n\t\trig = mc.checkBox(\"createRig\", query=True, value=True)\n\t\tphysical = mc.checkBox(\"physicalCam\", query=True, value=True)\n\n\t\t#print camera, rig, physical\n\t\tself.createCamera(camera, rig, physica... | [
"0.65740067",
"0.64491534",
"0.6397232",
"0.6268779",
"0.62566304",
"0.62068146",
"0.6007629",
"0.593394",
"0.589879",
"0.5833066",
"0.58150697",
"0.5789289",
"0.57274455",
"0.57177186",
"0.56755215",
"0.5673748",
"0.5662495",
"0.564375",
"0.5621268",
"0.56205434",
"0.5613931... | 0.76374453 | 0 |
This function builds the storage nodes for the global experimental settings. | def globalsettings(tree):
globepath = '.SETTINGS.EXPERIMENT.GLOBAL'
backpath = globepath + '.BACKGROUND'
puffpath = globepath + '.GAS_PUFF'
PSUpath = globepath + '.PSU_VOLTS'
tree.addNode(globepath)
tree.addNode(backpath)
AddNodeWithTag(tree, backpath + ':REF_SHOTNUM', 'NUMERIC',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def installStorage():\n for name,data in Online.SetupParams.detectors.items():\n s = data['System']\n c = Online.PVSSSystems.controlsMgr(s)\n inst = Installer(c)\n nf = data['SubFarms']\n streams = data['StorageStreams']\n inst.createStorage(name,streams,nf)\n return c",
"def node_storage(sel... | [
"0.6099824",
"0.58241117",
"0.56635416",
"0.55096596",
"0.54715955",
"0.5319876",
"0.5286273",
"0.5261687",
"0.5193375",
"0.51824534",
"0.5152154",
"0.5149715",
"0.5146604",
"0.51361907",
"0.51166236",
"0.5114605",
"0.5113918",
"0.50899243",
"0.5088444",
"0.5077658",
"0.50564... | 0.6000283 | 1 |
``scipy.optimize.minimize`` compatible implementation of ADAM | def adam(
fun,
jac,
x0,
args=(),
learning_rate=0.001,
beta1=0.9,
beta2=0.999,
eps=1e-8,
startiter=0,
maxiter=1000,
callback=None,
**kwargs
):
x = x0
m = np.zeros_like(x)
v = np.zeros_like(x)
best_energy = fun... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def minimize(A, t, y0, function):\n return y0 - function(A, t)",
"def minimize(A):\n return determinize(reverse(determinize(reverse(A))))",
"def minimize(self, fun, x_0, bounds=None):\n x = np.copy(x_0).reshape(-1)\n opt = climin.Adadelta(wrt=x, fprime=fun, step_rate=self.step_rate, momentu... | [
"0.636945",
"0.6079807",
"0.597317",
"0.58873415",
"0.58073026",
"0.580379",
"0.5782658",
"0.5770722",
"0.57679063",
"0.5752192",
"0.57015294",
"0.5696423",
"0.56645566",
"0.5646255",
"0.56429344",
"0.56254464",
"0.5616206",
"0.5580845",
"0.55763245",
"0.55730236",
"0.5563484... | 0.6663761 | 0 |
Handle partner assignation during a lead conversion. if action is 'create', create new partner with contact and assign lead to new partner_id. otherwise assign lead to the specified partner_id | def handle_partner_assignation(self, action='create', partner_id=False):
partner_ids = {}
for lead in self:
if lead.partner_id:
partner_ids[lead.id] = lead.partner_id.id
continue
if action in ('create', 'nothing'):
partner = lead._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_partner_assignation(self, action='create', partner_id=False):\n partner_ids = {}\n for lead in self:\n if lead.partner_id:\n partner_ids[lead.id] = lead.partner_id.id\n continue\n if action == 'create':\n partner = lead._c... | [
"0.7834948",
"0.71536636",
"0.7007727",
"0.6529146",
"0.6267386",
"0.6180731",
"0.60434467",
"0.60434467",
"0.56764877",
"0.56633",
"0.5397563",
"0.5381632",
"0.53453547",
"0.53453434",
"0.52963567",
"0.5259907",
"0.5219743",
"0.51943946",
"0.51261926",
"0.5004807",
"0.499306... | 0.7857573 | 0 |
Handle partner assignation during a lead conversion. if action is 'create', create new partner with contact and assign lead to new partner_id. otherwise assign lead to the specified partner_id | def handle_partner_assignation(self, action='create', partner_id=False):
partner_ids = {}
for lead in self:
if lead.partner_id:
partner_ids[lead.id] = lead.partner_id.id
continue
if action == 'create':
partner = lead._create_lead_p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_partner_assignation(self, action='create', partner_id=False):\n partner_ids = {}\n for lead in self:\n if lead.partner_id:\n partner_ids[lead.id] = lead.partner_id.id\n continue\n if action in ('create', 'nothing'):\n part... | [
"0.7858009",
"0.7153905",
"0.700918",
"0.65277624",
"0.62665325",
"0.61809754",
"0.6041029",
"0.6041029",
"0.56755596",
"0.5663098",
"0.53965086",
"0.5380003",
"0.53451055",
"0.53449315",
"0.5294607",
"0.52589893",
"0.5219041",
"0.5192853",
"0.5125537",
"0.5004031",
"0.499168... | 0.7835354 | 1 |
Sell all of a stock | def sell_stock(self, symbol):
amount_to_sell = self.get_equity(symbol)
chirp.order_sell_fractional_by_price(symbol, amount_to_sell)
self.L.add_line('', symbol, 'SOLD', amount_to_sell) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sell_all(self):\n\n from_symbol = self.symbol\n to_symbol = self.currency\n price = self.data[0].close\n amount = self.portfolio['buy_sell_amount'][self.currency]\n date = self.date\n\n if self.slippage:\n slip_factor = (self.data[-1].high - self.data[-1].cl... | [
"0.80758953",
"0.7081876",
"0.6978759",
"0.6884453",
"0.6852426",
"0.6782819",
"0.67323405",
"0.6668666",
"0.6661381",
"0.6649067",
"0.65729076",
"0.6541096",
"0.65021694",
"0.6496479",
"0.6421273",
"0.6410854",
"0.64063126",
"0.6401245",
"0.6344086",
"0.6338569",
"0.6319794"... | 0.73174804 | 1 |
Parse git log output. | def parse_git_log(cls, repo_path, commit=None, pkgs=False, verbosity=-1):
cmd = shlex.split(cls._git_cmd)
# custom git log format, see the "PRETTY FORMATS" section of the git
# log man page for details
format_lines = [
'# BEGIN COMMIT',
'%h', # abbreviated commit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _parse_commit_log(base_commit, tip_commit):\n\n class LogState(object):\n SEPARATOR_LINE = 0\n COMMIT_SHA1_LINE = 1\n MERGE_LINE = 2\n AUTHOR_LINE = 3\n COMMITTER_LINE = 4\n MIDDLE_SEPARATOR_LINE = 5\n TITLE_LINE = 6\n BLANK_LINE = 7\n BODY_LINE... | [
"0.7206427",
"0.7193171",
"0.68756026",
"0.67344743",
"0.6552737",
"0.64511865",
"0.64287007",
"0.64057523",
"0.63300204",
"0.63262427",
"0.631632",
"0.62489337",
"0.6236464",
"0.61734873",
"0.61565423",
"0.60980016",
"0.6034522",
"0.601556",
"0.6008357",
"0.59906316",
"0.597... | 0.7205721 | 1 |
Parse package changes from git log output. | def _pkg_changes(self, local=False, **kwargs):
seen = set()
for pkg in self.parse_git_log(self.location, pkgs=True, **kwargs):
atom = pkg.atom
key = (atom, pkg.status)
if key not in seen:
seen.add(key)
self.data.setdefault(atom.category... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_git_log(cls, repo_path, commit=None, pkgs=False, verbosity=-1):\n cmd = shlex.split(cls._git_cmd)\n # custom git log format, see the \"PRETTY FORMATS\" section of the git\n # log man page for details\n format_lines = [\n '# BEGIN COMMIT',\n '%h', # abbrev... | [
"0.6314454",
"0.62517124",
"0.6138244",
"0.6123645",
"0.61143327",
"0.60015136",
"0.5936875",
"0.5919519",
"0.59081864",
"0.5845898",
"0.5829762",
"0.5731764",
"0.5714883",
"0.56854004",
"0.5671369",
"0.56621295",
"0.5654946",
"0.56443906",
"0.56337553",
"0.56179357",
"0.5592... | 0.6503082 | 0 |
Stub method for matching eclasses against commits. | def _committed_eclass(committed, eclass):
return eclass in committed | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_class_ended(self, cls):",
"def test_git_commits(self):\n event_id = dog.Event.create(title=\"Testing git commits\", text=\"\"\"$$$\n eac54655 * Merge pull request #2 from DataDog/alq-add-arg-validation (alq@datadoghq.com)\n |\\\n 760735ef | * origin/alq-add-arg-... | [
"0.55264115",
"0.5490887",
"0.52549887",
"0.52544",
"0.5116345",
"0.50836957",
"0.50357133",
"0.50337803",
"0.50225776",
"0.49937692",
"0.4946607",
"0.49347556",
"0.49097857",
"0.48844475",
"0.48717982",
"0.48595667",
"0.48523936",
"0.4823",
"0.48155016",
"0.4813981",
"0.4809... | 0.61829054 | 0 |
Load a repo's .gitignore and .git/info/exclude files for path matching. | def gitignore(self):
patterns = []
for path in ('.gitignore', '.git/info/exclude'):
try:
with open(pjoin(self.options.target_repo.location, path)) as f:
patterns.extend(f)
except FileNotFoundError:
pass
except IOErro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gitignored(self, path):\n if path.startswith(self.options.target_repo.location):\n repo_prefix_len = len(self.options.target_repo.location) + 1\n path = path[repo_prefix_len:]\n return self.gitignore.match_file(path)",
"def read_gitignore():\n excludes = []\n gitigno... | [
"0.6879036",
"0.6628683",
"0.6492809",
"0.63889205",
"0.634545",
"0.62992334",
"0.61711836",
"0.608084",
"0.58592796",
"0.572035",
"0.57054436",
"0.5647694",
"0.56371015",
"0.5610596",
"0.5551651",
"0.5473216",
"0.54715616",
"0.5459211",
"0.5455009",
"0.5449749",
"0.5439363",... | 0.73499036 | 0 |
Determine if a given path in a repository is matched by .gitignore settings. | def gitignored(self, path):
if path.startswith(self.options.target_repo.location):
repo_prefix_len = len(self.options.target_repo.location) + 1
path = path[repo_prefix_len:]
return self.gitignore.match_file(path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def should_ignore_path(path):\n for p in config.compiled_ignore_patterns:\n if p.match(path):\n return True\n return False",
"def gitignore(self):\n patterns = []\n for path in ('.gitignore', '.git/info/exclude'):\n try:\n with open(pjoin(self.optio... | [
"0.6958648",
"0.6881131",
"0.6757538",
"0.6719417",
"0.6706559",
"0.660011",
"0.6573252",
"0.6476697",
"0.64476603",
"0.6446768",
"0.6443724",
"0.640878",
"0.6395901",
"0.6386467",
"0.6337892",
"0.6199399",
"0.61787766",
"0.61610645",
"0.6127308",
"0.6094345",
"0.6045951",
... | 0.8094266 | 0 |
Retrieve a git repo's commit hash for a specific commit object. | def get_commit_hash(repo_location, commit='origin/HEAD'):
if not os.path.exists(pjoin(repo_location, '.git')):
raise ValueError
ret, out = spawn_get_output(
['git', 'rev-parse', commit], cwd=repo_location)
if ret != 0:
raise ValueError(
f'faile... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_commit_hash():\n git_dir = get_git_root()\n args = [\"git\", \"-C\", git_dir, \"rev-parse\", \"--short\", \"--verify\", \"HEAD\"]\n return subprocess.check_output(args).strip().decode()",
"def _get_git_hash(self):\n try:\n with open(os.path.join(self._base_dir, '.git', 'HEAD'),... | [
"0.76705337",
"0.74592024",
"0.7341322",
"0.72765917",
"0.71075326",
"0.7017635",
"0.6956348",
"0.69457567",
"0.69301647",
"0.68955094",
"0.6797547",
"0.6789367",
"0.67771494",
"0.67634493",
"0.6752397",
"0.6752005",
"0.6731274",
"0.6642779",
"0.663993",
"0.66005427",
"0.6582... | 0.79971015 | 0 |
Calculate reward for a single step transition | def _calculate_single_step_reward(
self,
state: EnvState,
action: int,
transition_function_reward_output: chex.Array,
params: EnvParams,
) -> int:
cost = jnp.dot(transition_function_reward_output, params.cost_components)
reward = -1 * cost
return rewar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_reward(self):\n if self.status():\n return self.current_step/self.ep_length # the reward is proportional to the duration \n else:\n return 0",
"def _compute_reward(self): \n reward = -1\n return reward",
"def reward(input):\n state = np.array([input[0], input[1... | [
"0.8068978",
"0.76587135",
"0.7587889",
"0.7578856",
"0.7549204",
"0.7503443",
"0.7481505",
"0.74812055",
"0.7467154",
"0.73962283",
"0.7393348",
"0.7391761",
"0.73647404",
"0.73616785",
"0.7330723",
"0.72702837",
"0.7244375",
"0.7224694",
"0.72191805",
"0.718389",
"0.7179192... | 0.78513455 | 1 |
Issue stock using OUFO policy | def _issue_oufo(self, opening_stock: chex.Array, demand: int) -> chex.Array:
# Oldest stock on RHS of vector, so reverse
_, remaining_stock = jax.lax.scan(
self._issue_one_step, demand, opening_stock, reverse=True
)
return remaining_stock | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adosc(portfolio_item,transaction_volume, buy_threshold_difference=2, sell_threshold_difference=2, period='5d',\n fastperiod=3, slowperiod=10):\n from yahooquery import Ticker\n from time import sleep\n from math import floor\n import talib\n from .TradeHistoryItem import log_trade\n ... | [
"0.59350795",
"0.58191836",
"0.5801692",
"0.58012795",
"0.5765441",
"0.5752485",
"0.5742967",
"0.57145315",
"0.56767726",
"0.5592",
"0.5575715",
"0.5531077",
"0.5527267",
"0.5501706",
"0.5475134",
"0.5472274",
"0.5438976",
"0.539367",
"0.53895575",
"0.5370208",
"0.53666687",
... | 0.63215005 | 0 |
Get logits for multinomial distribution for units received, which may depend on action | def _get_multinomial_logits(self, action, params):
c_0 = params.shelf_life_at_arrival_distribution_c_0
c_1 = params.shelf_life_at_arrival_distribution_c_1
# Assume logit for useful_life=1 is 0, concatenate with logits
# for other ages using provided coefficients and order size action
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_log_p_multinomial(self, n_counts, nbins, batch_size):\n\n n_counts = tf.cast(n_counts, tf.float32)\n nbins = tf.cast(nbins, tf.float32)\n batch_size = tf.cast(batch_size, tf.float32)\n\n term_a = tf.lgamma(batch_size + 1)\n term_b = tf.reduce_sum(tf.lgamma(n_counts ... | [
"0.68257177",
"0.6538125",
"0.64939874",
"0.64903486",
"0.6482317",
"0.6321152",
"0.6089787",
"0.6014353",
"0.58765537",
"0.586044",
"0.58248866",
"0.5822549",
"0.58028674",
"0.5800193",
"0.57891846",
"0.57330257",
"0.5729014",
"0.5709534",
"0.57063144",
"0.56780946",
"0.5648... | 0.7795639 | 0 |
Calculate KPIs for each rollout, using the output of a rollout from RolloutWrapper | def calculate_kpis(cls, rollout_results: Dict) -> Dict[str, float]:
service_level = (
rollout_results["info"]["demand"] - rollout_results["info"]["shortage"]
).sum(axis=-1) / rollout_results["info"]["demand"].sum(axis=-1)
wastage = rollout_results["info"]["expiries"].sum(axis=-1) / ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kubelkaMunkReflectanceToKS(reflList):\n # NOTE: Here, divisions by 0 are avoided\n return [((1.0-refl)**2)/(2.0*max(0.00001,refl)) for refl in reflList]",
"def callback(self, rollout):\n assert len(self._t_switch)==len(self._scale)==len(self._k_star)\n # Log rollout statistics\n if sel... | [
"0.5259234",
"0.5208672",
"0.5152064",
"0.50551164",
"0.50142246",
"0.50015604",
"0.4963275",
"0.49427444",
"0.49364752",
"0.4932645",
"0.4921663",
"0.49054953",
"0.48024893",
"0.47893646",
"0.47838637",
"0.47509313",
"0.4747837",
"0.47476923",
"0.47350302",
"0.4716762",
"0.4... | 0.65874535 | 0 |
Validate query `s` by looking for forgotten semicolon. The implication could be the keyword CREATE appearing twice | def validate_semicolon(s):
positions = identify_create_table_view(s)
validation = {
"exit_code": 0,
"total_lines": count_lines(s)
}
if len(positions) > 1:
validation["exit_code"] = 1
validation["val_lines"] = positions
return validation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_extra_semicolon(sql_str):\r\n try:\r\n if len(sql_str.split(';')) > 2:\r\n raise sqlErr(\"Extra Semi-Colon Detected!\")\r\n except Exception as e:\r\n raise e",
"def test_sql_injection(self):\n\n self.create_job('Tejas', 'tejas.s1996@gmail.c... | [
"0.70108575",
"0.6074252",
"0.576631",
"0.56857127",
"0.5684582",
"0.5666593",
"0.5652216",
"0.5588579",
"0.55201554",
"0.55088115",
"0.54181755",
"0.54119617",
"0.5400707",
"0.5371861",
"0.533825",
"0.53381395",
"0.533363",
"0.5283078",
"0.52770054",
"0.5274601",
"0.5258131"... | 0.7080496 | 0 |
Encode the output result from y training and y testing set deep learning neural network model is a model that only accept numeric type on both input and output parameter. In order to put the output in model,We need to transfrom data to encoded lable. | def encode(y):
le = LabelEncoder()
le.fit(y)
print(list(le.classes_))
y = le.transform(y)
return y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_labels(y_train, y_test):\n le = LabelEncoder()\n le.fit(y_train)\n y_train = le.transform(y_train)\n y_test = le.transform(y_test)\n return y_train, y_test",
"def fit(self, X, y):\n \n # brings the variables from the BaseEncoder\n super().fit(X, y)\n\n if y i... | [
"0.6605991",
"0.6357394",
"0.63549024",
"0.62887555",
"0.61798644",
"0.6131163",
"0.6074112",
"0.59940577",
"0.5932825",
"0.5918288",
"0.5917792",
"0.5900649",
"0.5871724",
"0.5871724",
"0.5844559",
"0.58443993",
"0.5840909",
"0.5836682",
"0.5824687",
"0.581382",
"0.58090675"... | 0.66761804 | 0 |
It takes the wkn/isin information out of the table "boersenbwertung" and update the data in "all_wkn_entries". | def update_all_wkn(new_data):
if not 'boersenbewertung' in new_data: return 0
shareinfolist = []
for block in new_data['boersenbewertung']:
shareinfo = {}
blockkeys = new_data['boersenbewertung'][block].keys()&['wkns','isins']
for entries in blockkeys:
for entry in new_da... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Kennzahlentable(conn, new_data, table):\n print(table.columns.keys())\n if 'boersenbewertung' not in new_data: return 0\n for boerse in new_data['boersenbewertung']:\n if 'kennzahlen' not in new_data['boersenbewertung'][boerse]: continue\n featkeys = list(new_data['boersenbewertung'][boe... | [
"0.63259184",
"0.55756223",
"0.5497471",
"0.54563946",
"0.5426237",
"0.54128546",
"0.5389669",
"0.53772753",
"0.5328818",
"0.52700716",
"0.5254682",
"0.51455504",
"0.51224226",
"0.5121691",
"0.51158345",
"0.5097364",
"0.50734955",
"0.5052391",
"0.50405145",
"0.5030488",
"0.49... | 0.73984337 | 0 |
Extracts the share, share_pc (percentage) and the currency of the entrystring. | def get_share(entry):
share, share_pc, currency = "", "", ""
if entry != "":
if ":" in entry:
clean_entry = entry.split(":")[1].strip()
if "(" in clean_entry:
share_list = clean_entry.replace(")", "").split("(")
share_pc = share_list[1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def seperate_shareinfo(entry_split,entries,shareinfo):\n # Test if Stückelung wasn't recognized\n shareinfo['currency'] = entry_split\n shareinfo['amount'] = \"\"\n for idx, entry in enumerate(entries.split(\" \")[1:]):\n if entry == \"\":\n continue\n if entry[0].isdigit():\n ... | [
"0.6878257",
"0.5775377",
"0.56379956",
"0.52574784",
"0.5171768",
"0.50689054",
"0.5063933",
"0.50392544",
"0.49766636",
"0.49719173",
"0.49680567",
"0.49242723",
"0.49199694",
"0.48593205",
"0.48358423",
"0.48181435",
"0.48180252",
"0.4812144",
"0.48014098",
"0.47992522",
"... | 0.771785 | 0 |
Generates a list of cuinfo (Currency & Unit INFO) dictonaries. And converts units from words to numbers (e.g. "Mio">"1000000") | def get_currencyinfo(table):
cuinfo = []
for item in table:
if "Beschäft" in item:
continue
currency = ""
unit = "1"
if "TEUR" in item:
currency = "EUR"
unit = "1000"
elif "TDM" in item:
currency = "DM"
unit = "1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_units(data, units):\n # Build the dictionary of units conversions\n convert = {'m' : [1.0, 0., 'm'], \n 'meter' : [1.0, 0., 'm'], \n 'deg C' : [1.0, 273.15, 'K'], \n 'Celsius' : [1.0, 273.15, 'K'], \n 'K' : [1.0, 0., 'K'],\n 'd... | [
"0.630281",
"0.61332965",
"0.6072566",
"0.6010609",
"0.5955414",
"0.58728546",
"0.5755223",
"0.57190734",
"0.56057626",
"0.55950314",
"0.5533894",
"0.5528036",
"0.54907805",
"0.5469204",
"0.540708",
"0.5407067",
"0.5403886",
"0.5344846",
"0.5310675",
"0.53051037",
"0.5250631"... | 0.7246062 | 0 |
Extracts the currency and the unit of the entrystring. | def get_currency_unit(table):
currency = ""
unit = "1"
if 'waehrung' in table.keys():
if "TEUR" in table['waehrung']:
currency = "EUR"
unit = "1000"
elif "TDM" in table['waehrung']:
currency = "DM"
unit = "1000"
elif len(table['waehrung... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_price_and_unit(self, price_str: str) -> tuple:\n\n # fetch the digits from the price string\n price = float(extract_required_data(data_str=price_str, req_type=r'[+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)')[0])\n\n # fetch the unit\n unit = price_str[price_str.index('/') + 1:]\n\n ... | [
"0.6466058",
"0.6191532",
"0.6029872",
"0.578515",
"0.56832075",
"0.56776136",
"0.5671568",
"0.5666925",
"0.566051",
"0.55563223",
"0.5534594",
"0.55284965",
"0.5522819",
"0.5506253",
"0.54777926",
"0.547571",
"0.54691905",
"0.5447424",
"0.5397326",
"0.53863865",
"0.53790575"... | 0.64968723 | 0 |
Creates a new directory | def create_dir(newdir):
if not os.path.isdir(newdir):
try:
os.mkdir(newdir)
print(newdir)
except IOError:
print("cannot create %s directoy" % newdir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dir(newdir):\n try:\n os.makedirs(newdir)\n except OSError as exc:\n if exc.errno == errno.EEXIST and os.path.isdir(newdir):\n pass\n else:\n raise",
"def create_directory(path, name):\n new_path = os.path.join(path, name)\n if not os.path.isdir(n... | [
"0.82040167",
"0.8098473",
"0.80732435",
"0.80479",
"0.8045547",
"0.8011422",
"0.8002602",
"0.8002602",
"0.80019146",
"0.7993634",
"0.797482",
"0.79358506",
"0.79238635",
"0.7911859",
"0.78886724",
"0.7881794",
"0.7872197",
"0.7860215",
"0.7856015",
"0.78468466",
"0.7840974",... | 0.8114512 | 1 |
Load remote S3 DB | def load_remote_db(self):
signature_version = self.settings_dict.get("SIGNATURE_VERSION", "s3v4")
s3 = boto3.resource(
's3',
config=botocore.client.Config(signature_version=signature_version),
)
if '/tmp/' not in self.settings_dict['NAME']:
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def s3_load(self, bucket_name, file_name, region):\n cursor = self.conn.cursor()\n\n table_name = file_name.split(\".\")[0]\n\n cursor.execute(\"\"\"SELECT aws_s3.table_import_from_s3(\\\n %s, '', '(format csv)', \n %s, %s, %s\n );\n \"\"\", (table_name,... | [
"0.67710966",
"0.6761338",
"0.621084",
"0.6101175",
"0.6023489",
"0.5982162",
"0.58745855",
"0.5809348",
"0.5797521",
"0.5745436",
"0.57287925",
"0.5708187",
"0.5689548",
"0.56768733",
"0.5634888",
"0.559284",
"0.5580341",
"0.5534077",
"0.55335045",
"0.5520093",
"0.5512935",
... | 0.7557822 | 0 |
Removes the translations with the indices in removeList from the multitransformation | def removeTransition(self, removeList = []):
assert isinstance(removeList, (list, tuple, np.ndarray, np.int64, np.int32, int))
try:
removeList = list(removeList)
except:
try:
removeList = [int(removeList)]
except:
asser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _remove_from_index_operations(self, which, transforms):\n if len(transforms) == 0:\n transforms = which.properties()\n removed = np.empty((0,), dtype=int)\n for t in list(transforms):\n unconstrained = which.remove(t, self._raveled_index())\n removed = np.u... | [
"0.6234954",
"0.6234954",
"0.58833855",
"0.5875795",
"0.5642232",
"0.559314",
"0.54940677",
"0.545653",
"0.5428662",
"0.5422384",
"0.5417958",
"0.53918344",
"0.53835464",
"0.53778404",
"0.53631103",
"0.5321622",
"0.5315119",
"0.5288479",
"0.5274028",
"0.5272367",
"0.52703303"... | 0.68391186 | 0 |
Computes the intermediate jacobians for the transformations from X_cart > X_Rot > X_polar > X_scaled (direction = True) or X_scaled > X_polar > X_rot > X_cart (direction = False) So the jacobians are J_polar2scaled.J_rot2polar.J_cart2rot (direction = True) and (J_polar2scaled.J_rot2polar.J_cart2rot)^1 (direction = Fals... | def intermediateJac(self, x, isRot=False):
if not isRot:
x = dot(self._rotation,x)
#Due to how it is constructed,
#J_rot2polar is its own inverse (and symmetric)
Jac = self.intermediateJacRot2Polar(x)
#Jac = S.J.R
s=self._scaled.res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def intermediateJacRot2Polar(self,x):\n r = cNorm(x[:2,:],kd=False)\n x0overr = x[0,:]/r\n x1overr = x[1,:]/r\n\n Jac = Idn(x.shape[1],x.shape[0])\n Jac[:,0,0] = -x1overr\n Jac[:,0,1] = x0overr\n Jac[:,1,0] = x0overr\n Jac[:,1,1] = x1overr\n \n ... | [
"0.7081942",
"0.69370437",
"0.6367097",
"0.62326556",
"0.61751866",
"0.60751736",
"0.5926308",
"0.58700335",
"0.5608925",
"0.5585623",
"0.55706793",
"0.55591404",
"0.55477065",
"0.55353373",
"0.5518831",
"0.54839927",
"0.53879833",
"0.53830355",
"0.5318986",
"0.529636",
"0.52... | 0.76233786 | 0 |
Emit a record. Output the record to the file, catering for rollover as described in doRollover(). | def emit(self, record):
FileHandler.emit(self, record)
self.doRollover() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def emit(self, record):\r\n FileHandler.emit(self, record)\r\n self.doRollover()",
"def emit(self, record):\n try:\n if self.shouldRollover(record):\n self.doRollover()\n if self.header_msg is not None:\n for msg in self.header_msg:... | [
"0.7927401",
"0.78582025",
"0.78582025",
"0.7324074",
"0.727338",
"0.7155671",
"0.70980895",
"0.69586146",
"0.69495517",
"0.6924322",
"0.69128066",
"0.6901734",
"0.6901734",
"0.688906",
"0.6861842",
"0.68529326",
"0.67618215",
"0.6720927",
"0.67097735",
"0.6654566",
"0.661578... | 0.7992042 | 0 |
Creates a (hardcoded) PyTree out of flat 1D array for testing purposes. | def _do_pytree(array, split_indices, reshape_shape):
pytree = jnp.split(array, split_indices)
pytree[0] = pytree[0].reshape(reshape_shape)
pytree[-1] = {'-1': pytree[-1]}
return pytree | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeTTree():\n \n tree = TTree(\"tree\",\"tree\")\n px = array('d',[0])\n py = array('d',[0])\n pz = array('d',[0])\n pi = array('i',[0])\n tree.Branch(\"x\",px,\"x/D\")\n tree.Branch(\"y\",py,\"y/D\")\n tree.Branch(\"z\",pz,\"y/D\")\n tree.Branch(\"i\",pi,\"y/I\")\n fo... | [
"0.6703232",
"0.64735085",
"0.63102984",
"0.60695755",
"0.59999394",
"0.59909546",
"0.59761584",
"0.59739226",
"0.59236884",
"0.5901962",
"0.5840487",
"0.58278966",
"0.5786626",
"0.57555383",
"0.5732222",
"0.5677074",
"0.56690866",
"0.5663703",
"0.56592137",
"0.5657288",
"0.5... | 0.74564993 | 0 |
Recovers flat 1D array from (hardcoded) PyTree for testing purposes. | def _undo_pytree(pytree):
pytree = pytree.copy()
pytree[0] = pytree[0].reshape([-1])
pytree[-1] = pytree[-1]['-1']
return jnp.concatenate(pytree) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _do_pytree(array, split_indices, reshape_shape):\n pytree = jnp.split(array, split_indices)\n pytree[0] = pytree[0].reshape(reshape_shape)\n pytree[-1] = {'-1': pytree[-1]}\n return pytree",
"def gather_tree_py(values, parents):\n beam_length = values.shape[0]\n num_beams = values.shape[1]\n r... | [
"0.6703734",
"0.5986659",
"0.5916958",
"0.58138466",
"0.56845146",
"0.5671683",
"0.5597876",
"0.559468",
"0.5556959",
"0.55409724",
"0.5448669",
"0.5357855",
"0.5357855",
"0.53274417",
"0.53008646",
"0.52885514",
"0.527811",
"0.5252576",
"0.5229968",
"0.5227887",
"0.52275324"... | 0.6350076 | 1 |
Wraps fun_flat with (hardcoded) yTree input / output. | def fun(x_pytree):
x = self._undo_pytree(x_pytree)
y = fun_flat(x)
return self._do_pytree(y, self.y_split_indices, self.y_reshape_shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten_and_unflatten(input_tree) -> Tuple[Callable, Callable]:\n\n tree_structure = tree_util.tree_structure(input_tree)\n\n leaf_shapes = [get_shape(leaf) for leaf in tree_util.tree_leaves(input_tree)]\n\n def flatten(tree):\n leaves = tree_util.tree_leaves(tree)\n flattened_leaves = [... | [
"0.60819143",
"0.56993383",
"0.5558518",
"0.55345696",
"0.5532351",
"0.54948175",
"0.5492494",
"0.5470431",
"0.5436179",
"0.53726214",
"0.5306351",
"0.5285248",
"0.52021044",
"0.5162746",
"0.51133025",
"0.5067578",
"0.50417256",
"0.50383896",
"0.49873123",
"0.49503982",
"0.49... | 0.6749448 | 0 |
Implements a toy nonlinear curve fitting problem on 2D. The model is defined as `f(theta; x) = offset + slope sigmoid(w1 x1 + w2 x2 t0)` where, for the purposes of testing, `theta = (w1, w2, t0, offset)` are treated as the parameters to be fit via leastsquares and `slope` as a hyperparameter used to test implicit diffe... | def model_fun(params, slope, x):
w = params['w']
t0 = params['t0']
offset = params['offset']
return offset + slope * jax.nn.sigmoid(jnp.dot(x, w) - t0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def linear_slope_fit(wf, mean_y, sigma_y, slope, intercept):\n\n sum_x = sum_x2 = sum_xy = sum_y = mean_y[0] = sigma_y[0] = 0\n isum = len(wf)\n\n for i,value in enumerate(wf):\n sum_x += i \n sum_x2 += i**2\n sum_xy += (value * i)\n sum_y += value\n mean_y += (value-mea... | [
"0.6770082",
"0.6627492",
"0.6452892",
"0.643027",
"0.6337879",
"0.6317758",
"0.63114625",
"0.6302614",
"0.62836415",
"0.62761945",
"0.622019",
"0.61996865",
"0.6177114",
"0.61601955",
"0.6158581",
"0.61354756",
"0.6099748",
"0.6085855",
"0.60824215",
"0.6079606",
"0.6075272"... | 0.69133735 | 0 |
Sets the value of the given socket option. The needed symbolic constants are defined in the ``socket`` module (``SO_`` etc.). The value can be an integer or a byteslike object representing a buffer. | def setsockopt(self, level: int, optname: int,
value: Union[int, bytes]) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setsockopt(self, level, optname, value, *args) -> None:\n self.raw_socket.setsockopt(level, optname, value, *args)",
"def setsockopt(self, level, optname, value):\r\n return self.sock.setsockopt(level, optname, value)",
"def setsockopt(self, level, optname, value):\n return self.sock.s... | [
"0.7081325",
"0.6849514",
"0.68158185",
"0.67233723",
"0.6645665",
"0.65632904",
"0.6260947",
"0.62118304",
"0.5881193",
"0.5813204",
"0.57955575",
"0.57152766",
"0.57105964",
"0.5708083",
"0.55964726",
"0.55392206",
"0.5480424",
"0.54712677",
"0.5448369",
"0.54214793",
"0.54... | 0.7213821 | 0 |
Sets a timeout on blocking socket operations. The value argument can be a nonnegative floating point number expressing seconds, or ``None``. | def settimeout(self, value: int) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def settimeout(self, value):\r\n return self.sock.settimeout(value)",
"def timeout(self, value):\n if isinstance(value, timedelta):\n value = value.days * 3600 * 24 + value.seconds\n self._timeout = value # noqa",
"def set_timeout_millis(self, value):\n self.dp.set_timeo... | [
"0.79684216",
"0.70650953",
"0.7051572",
"0.6886931",
"0.67018974",
"0.6680086",
"0.6631004",
"0.65857637",
"0.65128756",
"0.6480641",
"0.64751804",
"0.64647174",
"0.6457587",
"0.6432594",
"0.64272845",
"0.6366115",
"0.629458",
"0.6238201",
"0.6234436",
"0.61907434",
"0.61831... | 0.76870126 | 1 |
This method will allow up to 30 seconds for discovery (communicating with) an Arduino board and then will determine a pin configuration table for the board. | def auto_discover_board(self, verbose):
# get current time
start_time = time.time()
# wait for up to 30 seconds for a successful capability query to occur
while len(self.analog_mapping_query_results) == 0:
if time.time() - start_time > 30:
return False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def relay_board_setup(port_id_to_detect, ss_pid):\n ss_jumper_usb_s = 2\n # For specific ports, we want to use the Sain Smart Relay Library\n # that's because these ports require jumpers and power cycles to\n # detect.\n if port_id_to_detect == 'PORT_ID_TREERUNNER':\n # Initialize the relay b... | [
"0.57722586",
"0.56640464",
"0.5595978",
"0.55761725",
"0.553386",
"0.5527801",
"0.5442053",
"0.54390985",
"0.5428271",
"0.54277045",
"0.5313601",
"0.52541065",
"0.5204199",
"0.5204005",
"0.5198648",
"0.51974994",
"0.5190636",
"0.5171001",
"0.51617837",
"0.51561743",
"0.51475... | 0.7738055 | 0 |
This method "arms" a pin to allow data latching for the pin. | def set_analog_latch(self, pin, threshold_type, threshold_value, cb):
with self.pymata.data_lock:
self.analog_latch_table[pin] = [self.LATCH_ARMED, threshold_type, threshold_value, 0, 0, cb] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_pin(self):\n GPIO.setwarnings(False)\n GPIO.setmode(GPIO.BOARD)\n GPIO.setup(self.pin, GPIO.OUT)\n GPIO.output(self.pin, GPIO.LOW)\n time.sleep(3)\n GPIO.output(self.pin, GPIO.HIGH)",
"async def set_analog_latch(self, pin, threshold_type, threshold_value,\n ... | [
"0.65796274",
"0.63799745",
"0.6361733",
"0.6284265",
"0.62752664",
"0.62104493",
"0.6159042",
"0.6091673",
"0.60040885",
"0.5995735",
"0.59672",
"0.5949061",
"0.5945401",
"0.59234715",
"0.59191954",
"0.5906057",
"0.5906057",
"0.5905058",
"0.58869725",
"0.5881773",
"0.5857249... | 0.6599514 | 0 |
This method handles the incoming analog data message. It stores the data value for the pin in the analog response table. If a callback function was associated with this pin, the callback function is invoked. This method also checks to see if latching was requested for the pin. If the latch criteria was met, the latchin... | def analog_message(self, data):
with self.pymata.data_lock:
# hold on to the previous value
previous_value = \
self.analog_response_table[data[self.RESPONSE_TABLE_MODE]][self.RESPONSE_TABLE_PIN_DATA_VALUE]
self.analog_response_table[data[self.RESPONSE_TABLE_MO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _analog_message(self, data):\n pin = data[0]\n value = (data[PrivateConstants.MSB] << 7) + data[PrivateConstants.LSB]\n # if self.analog_pins[pin].current_value != value:\n self.analog_pins[pin].current_value = value\n\n # append pin number, pin value, and pin type to r... | [
"0.76063585",
"0.7583257",
"0.65122956",
"0.6266641",
"0.6230448",
"0.6173268",
"0.6063904",
"0.5983611",
"0.5905073",
"0.58214813",
"0.5784091",
"0.5784091",
"0.576922",
"0.5763034",
"0.56965995",
"0.5653001",
"0.56306094",
"0.5618487",
"0.5595102",
"0.5593153",
"0.5590795",... | 0.82850856 | 0 |
This method handles the incoming encoder data message and stores the data in the digital response table. | def encoder_data(self, data):
prev_val = self.digital_response_table[data[self.RESPONSE_TABLE_MODE]][self.RESPONSE_TABLE_PIN_DATA_VALUE]
val = int((data[self.MSB] << 7) + data[self.LSB])
# set value so that it shows positive and negative values
if val > 8192:
val -= 16384
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_data(self, line):\n\n # AorM - 0: M / 1: A\n feedback_AorM = ord(line[4])\n\n # Gear - 0: B / 1: N / 2: D\n feedback_gear = ord(line[5])\n\n # Speed\n feedback_KPH = (ord(line[6]) + ord(line[7]) * 256) / 10\n feedback_speed = self.kph2mps(value=feedback_K... | [
"0.646714",
"0.62977713",
"0.62212765",
"0.5981519",
"0.5845614",
"0.5807489",
"0.5759383",
"0.5739204",
"0.5672401",
"0.5664096",
"0.5662159",
"0.56180274",
"0.5616401",
"0.5602831",
"0.5602831",
"0.5602831",
"0.5602831",
"0.5602831",
"0.5602831",
"0.5591733",
"0.555795",
... | 0.6868791 | 0 |
This method returns the entire analog response table to the caller | def get_analog_response_table(self):
with self.pymata.data_lock:
data = self.analog_response_table
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_digital_response_table(self):\n with self.pymata.data_lock:\n data = self.digital_response_table\n return data",
"def sql_response(self):\n return self.axl_data",
"def get(self):\n return TableDetails.query.all(), 200",
"def rawtable(self):\n return self.... | [
"0.71142936",
"0.62490803",
"0.6163312",
"0.60580313",
"0.5937055",
"0.5896267",
"0.58015335",
"0.57838464",
"0.5743673",
"0.57340896",
"0.57025415",
"0.5697201",
"0.5680298",
"0.5656654",
"0.5621708",
"0.56066406",
"0.56038684",
"0.55768615",
"0.55768615",
"0.55681247",
"0.5... | 0.8271087 | 0 |
This method returns the entire digital response table to the caller | def get_digital_response_table(self):
with self.pymata.data_lock:
data = self.digital_response_table
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_analog_response_table(self):\n with self.pymata.data_lock:\n data = self.analog_response_table\n return data",
"def get(self):\n return TableDetails.query.all(), 200",
"def extract_table(self):\n\n doc = html.document_fromstring(self.req.text)\n numbers_div... | [
"0.7166792",
"0.6412879",
"0.63826436",
"0.6360638",
"0.6317879",
"0.6304024",
"0.60252136",
"0.6013355",
"0.5948698",
"0.5928255",
"0.5926096",
"0.5916677",
"0.59111106",
"0.59060526",
"0.5844231",
"0.58412516",
"0.5839267",
"0.5835036",
"0.58318233",
"0.58307767",
"0.579708... | 0.82324076 | 0 |
This method receives replies to i2c_read requests. It stores the data for each i2c device address in a dictionary called i2c_map. The data is retrieved via a call to i2c_get_read_data() in pymata.py It a callback was specified in pymata.i2c_read, the raw data is sent through the callback | def i2c_reply(self, data):
reply_data = []
address = (data[0] & 0x7f) + (data[1] << 7)
register = data[2] & 0x7f + data[3] << 7
reply_data.append(register)
for i in range(4, len(data), 2):
data_item = (data[i] & 0x7f) + (data[i + 1] << 7)
reply_data.appen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _i2c_reply(self, data):\n # remove the start and end sysex commands from the data\n data = data[1:-1]\n reply_data = []\n # reassemble the data from the firmata 2 byte format\n address = (data[0] & 0x7f) + (data[1] << 7)\n\n # if we have an entry in the i2c_map, ... | [
"0.7106457",
"0.70831144",
"0.62038636",
"0.5990229",
"0.5990229",
"0.5971022",
"0.5918641",
"0.5904158",
"0.56850857",
"0.5648382",
"0.5511592",
"0.54429305",
"0.5388487",
"0.5291939",
"0.5286525",
"0.52773994",
"0.5262555",
"0.52104264",
"0.5204577",
"0.5179082",
"0.5133663... | 0.7482828 | 0 |
This method handles a capability response message and stores the results to be retrieved via get_capability_query_results() in pymata.py | def capability_response(self, data):
self.capability_query_results = data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _capability_response(self, data):\n self.query_reply_data[PrivateConstants.CAPABILITY_RESPONSE] = data[1:-1]",
"async def _capability_response(self, data):\n self.query_reply_data[PrivateConstants.CAPABILITY_RESPONSE] = data[1:-1]",
"async def get_capability_report(self):\n if se... | [
"0.81238896",
"0.81238896",
"0.6730226",
"0.6730226",
"0.5934268",
"0.58812743",
"0.58509034",
"0.5822898",
"0.57149833",
"0.57071143",
"0.55727774",
"0.5566569",
"0.5410685",
"0.54099864",
"0.5398561",
"0.53971225",
"0.53698057",
"0.53614074",
"0.5343167",
"0.534099",
"0.533... | 0.8184472 | 0 |
This method handles an analog mapping query response message and stores the results to be retrieved via get_analog_mapping_request_results() in pymata.py | def analog_mapping_response(self, data):
self.analog_mapping_query_results = data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def _analog_mapping_response(self, data):\n self.query_reply_data[PrivateConstants.ANALOG_MAPPING_RESPONSE] = \\\n data[1:-1]",
"async def _analog_mapping_response(self, data):\n self.query_reply_data[PrivateConstants.ANALOG_MAPPING_RESPONSE] = \\\n data[1:-1]",
"async... | [
"0.80211776",
"0.80211776",
"0.67953515",
"0.65851074",
"0.5993131",
"0.5841161",
"0.570164",
"0.56129295",
"0.5612231",
"0.5511611",
"0.54918134",
"0.54480267",
"0.54464275",
"0.5439594",
"0.5407685",
"0.52985716",
"0.5269495",
"0.52636206",
"0.52636206",
"0.5245216",
"0.518... | 0.8399111 | 0 |
This method handles a stepper library version message sent from the Arduino | def stepper_version_response(self, data):
self.stepper_library_version = (data[0] & 0x7f) + (data[1] << 7) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_version(self, message_header, message):\n\t\tself.remote_height = message.start_height\n\t\tself.send_message(VerAck())\n\t\tself.connected()",
"def handle_request_version(self, msg):\n\t\tres = Response(msg)\n\t\tres.body['version'] = VERSION\n\t\tself.finished(msg.id, res)",
"async def handle_vers... | [
"0.6739485",
"0.65551937",
"0.6399664",
"0.626589",
"0.61662644",
"0.6118785",
"0.6118785",
"0.6113714",
"0.5942543",
"0.5857521",
"0.58118445",
"0.57812196",
"0.5774167",
"0.57262385",
"0.5725863",
"0.57091475",
"0.5696192",
"0.5656188",
"0.56506443",
"0.56031924",
"0.560319... | 0.76419914 | 0 |
Construct a vocabulary from tokenized lines. | def construct_vocab(lines, vocab_size):
vocab = {}
for line in lines:
for word in line:
if word not in vocab:
vocab[word] = 1
else:
vocab[word] += 1
word2id = {}
id2word = {}
word2id['<pad>'] = 0
word2id['<unk>'] = 1
id2wor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_vocabulary(sentences, path):\n print('creating vocab..')\n\n word_dict = dict(); vocabulary = dict()\n for sentence in sentences:\n for word in nltk.word_tokenize(sentence):\n if word not in word_dict:\n word_dict[word] = ''\n word_dict['<s>'] = ''\n word_... | [
"0.6886147",
"0.67650145",
"0.6671887",
"0.6412148",
"0.6310041",
"0.6281287",
"0.62189853",
"0.6184756",
"0.61354417",
"0.61252844",
"0.60972285",
"0.6096611",
"0.60783905",
"0.6047903",
"0.6047043",
"0.60348874",
"0.6030517",
"0.6022313",
"0.60200393",
"0.6007116",
"0.59863... | 0.7205435 | 0 |
Reads a GMT psvelo file | def read(cls, file_name=None, lexclude=[], lonly=[], verbose=False):
###################################################################
# import
import numpy as np
# init
vf = Velocity_Field()
# fake 4-letters code generation using hexadecimal
def __g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_velo_timestamps(velo_path):\n ts_start_file = os.path.join(velo_path, 'timestamps_start.txt')\n ts_end_file = os.path.join(velo_path, 'timestamps_end.txt')\n\n ts_start = load_timestamps(ts_start_file)\n ts_end = load_timestamps(ts_end_file)\n\n return ts_start, ts_end",
"def read(self):\... | [
"0.617878",
"0.5880933",
"0.5834995",
"0.5830158",
"0.5822301",
"0.5813585",
"0.5707645",
"0.5707645",
"0.5687243",
"0.5597998",
"0.55933875",
"0.55784416",
"0.55457",
"0.5537852",
"0.55077535",
"0.5467256",
"0.53825134",
"0.5364913",
"0.5338459",
"0.5323941",
"0.5315872",
... | 0.6230697 | 0 |
delete all files inside a given folder | def delete_all_files_in_folder(folder_path: str) -> None:
if os.path.isdir(folder_path):
[FileHandler.delete_file(path=path) for path in glob(os.path.join(folder_path, "*"))]
else:
raise Exception("Not a valid path for a folder") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rm(folder):\n import os\n import shutil\n for the_file in os.listdir(folder):\n file_path = os.path.join(folder, the_file)\n try:\n if os.path.isfile(file_path):\n os.unlink(file_path)\n elif os.path.isdir(file_path):\... | [
"0.80162996",
"0.7990656",
"0.7837827",
"0.7828477",
"0.7707431",
"0.75918984",
"0.7508437",
"0.73966825",
"0.73634017",
"0.73543835",
"0.73361015",
"0.73142534",
"0.73118734",
"0.73112303",
"0.72664857",
"0.7203846",
"0.71997255",
"0.71780586",
"0.71335286",
"0.71274835",
"0... | 0.82466924 | 0 |
Return all parent reference nodes of reference node | def get_reference_node_parents(ref):
parents = []
return parents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parents(self, node):\n pass",
"def referencing_nodes(self):\n\n return self._referencing_nodes",
"def get_parents(self):\n return NodeList(self._my_map['parentNodes'])",
"def parents(self):\n p = self\n result = []\n while p:\n result.append(p)... | [
"0.77438605",
"0.74003035",
"0.7348796",
"0.71603286",
"0.71409374",
"0.7095996",
"0.70957136",
"0.7073448",
"0.7040106",
"0.70062804",
"0.6988936",
"0.68935776",
"0.68149966",
"0.68003714",
"0.6789328",
"0.6788129",
"0.6774331",
"0.6774331",
"0.6751735",
"0.6745037",
"0.6729... | 0.8662787 | 0 |
Remove an existing `container` | def remove(self, container):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_container(self, container: Container):",
"def delete_container(self, account, container):\n \n pass",
"def delete_container(ContainerName=None):\n pass",
"def remove(self, **kwargs):\n return self.client.api.remove_container(self.id, **kwargs)",
"def destroyContainer(tag)... | [
"0.850604",
"0.7618259",
"0.7586366",
"0.757009",
"0.7165779",
"0.7080091",
"0.7041301",
"0.7017105",
"0.6953132",
"0.6731134",
"0.6729838",
"0.6649547",
"0.65714514",
"0.65401983",
"0.65296966",
"0.6493233",
"0.6362888",
"0.63270676",
"0.63161176",
"0.6314182",
"0.62674767",... | 0.84029305 | 1 |
Get PredefinedMessage from datastore that matches the fields. | def GetPredefinedMessage(message_type, lab_name, content):
predefined_message_entities = (
datastore_entities.PredefinedMessage.query()
.filter(datastore_entities.PredefinedMessage.type == message_type).filter(
datastore_entities.PredefinedMessage.lab_name == lab_name).filter(
data... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetOrCreatePredefinedMessage(message_type, lab_name, content):\n exisiting_predefined_message_entity = GetPredefinedMessage(\n message_type=message_type, lab_name=lab_name, content=content)\n if exisiting_predefined_message_entity:\n return exisiting_predefined_message_entity\n else:\n return dat... | [
"0.6937927",
"0.60146546",
"0.5713352",
"0.5668567",
"0.55950904",
"0.5518032",
"0.54971987",
"0.5439495",
"0.5398678",
"0.539755",
"0.5344279",
"0.53377557",
"0.53225976",
"0.5265966",
"0.52655786",
"0.5230329",
"0.52144694",
"0.5182683",
"0.5177246",
"0.5166756",
"0.5148238... | 0.7225359 | 0 |
Get PredefinedMessage datastore entity or create it if not existing. | def GetOrCreatePredefinedMessage(message_type, lab_name, content):
exisiting_predefined_message_entity = GetPredefinedMessage(
message_type=message_type, lab_name=lab_name, content=content)
if exisiting_predefined_message_entity:
return exisiting_predefined_message_entity
else:
return datastore_enti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetPredefinedMessage(message_type, lab_name, content):\n predefined_message_entities = (\n datastore_entities.PredefinedMessage.query()\n .filter(datastore_entities.PredefinedMessage.type == message_type).filter(\n datastore_entities.PredefinedMessage.lab_name == lab_name).filter(\n ... | [
"0.68195426",
"0.65582556",
"0.57011265",
"0.5647662",
"0.5533371",
"0.54775923",
"0.5372559",
"0.534231",
"0.5339693",
"0.5339149",
"0.5256763",
"0.5224388",
"0.51546174",
"0.5071481",
"0.50631547",
"0.5060428",
"0.50558394",
"0.5046496",
"0.5036136",
"0.5033243",
"0.5029295... | 0.7676765 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.