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 |
|---|---|---|---|---|---|---|
Overrides Publisher method, because there may be some descendants, which are waiting for parent to publish, so publish them if possible. | def publish(self, fields=None, exclude=None):
# clean moderation log
self.pagemoderatorstate_set.all().delete()
# can be this page published?
if self.mptt_can_publish():
self.moderator_state = Page.MODERATOR_APPROVED
else:
self.moderator_state = P... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _notify_parent_change(self):\n pass",
"def on_parent_changed(self):\n pass",
"def _update_parent_attachments(self):\n try:\n self._parent.has_attachments = bool(len(self.__attachments))\n except AttributeError:\n pass",
"def publish(self):\n return... | [
"0.605876",
"0.5671696",
"0.56162834",
"0.5568196",
"0.55627656",
"0.55452615",
"0.55029297",
"0.54026634",
"0.54004335",
"0.54004335",
"0.537827",
"0.5354135",
"0.53013587",
"0.52420294",
"0.5166492",
"0.5158825",
"0.51457006",
"0.5101871",
"0.50980556",
"0.5087998",
"0.5087... | 0.6279266 | 0 |
Returns true if public model is published. | def is_public_published(self):
if hasattr(self, 'public_published_cache'):
# if it was cached in change list, return cached value
return self.public_published_cache
# othervise make db lookup
if self.public:
return self.public.published
#return is_publ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_published(self) -> bool:\n return self.published and self.published <= timezone.now()",
"def is_published(self):\n now = timezone.now()\n return now >= self.pub_date",
"def is_public(self):\n return self.document.is_public",
"def public(self) -> bool:\n return self._... | [
"0.7853329",
"0.77930677",
"0.7677848",
"0.73914605",
"0.73765314",
"0.71067935",
"0.7081282",
"0.7081282",
"0.7081282",
"0.7081282",
"0.7045333",
"0.6970942",
"0.68620694",
"0.6652326",
"0.6652326",
"0.6616775",
"0.65929407",
"0.6519627",
"0.64643705",
"0.6459555",
"0.642842... | 0.84666336 | 0 |
Return overrwriten url, or None | def overwrite_url(self):
if self.has_url_overwrite:
return self.path
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_url(self, absolute):",
"def get_url(self):\r\n if self.mod.filename:\r\n return self.mod.service.get_mirror() + self.mod.filename",
"def __get_url_addr(self):\n request = urlopen(self.url)\n version = request.readline()\n request.close()\n request = urlparse.urlparse(self... | [
"0.6445694",
"0.6432429",
"0.63952386",
"0.6263736",
"0.6187996",
"0.61590326",
"0.60932136",
"0.6037233",
"0.5998153",
"0.5960509",
"0.5957526",
"0.5915956",
"0.59118295",
"0.58678854",
"0.5845085",
"0.5812721",
"0.57971686",
"0.57644355",
"0.5757884",
"0.57559407",
"0.57541... | 0.81936914 | 0 |
Get src URL for instance's icon | def get_instance_icon_src(self):
instance, plugin = self.get_plugin_instance()
if instance:
return plugin.icon_src(instance)
else:
return u'' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def icon(self):\r\n try:\r\n return self.data['icon_url_base']+self.data['icon_url_name']\r\n except KeyError:\r\n return ''",
"def icon_url(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"icon_url\")",
"def icon(self):\n return self.__icon",
... | [
"0.7681349",
"0.7591989",
"0.7404013",
"0.73230845",
"0.7276072",
"0.7258099",
"0.7258099",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0.72561705",
"0... | 0.85926807 | 0 |
Get alt text for instance's icon | def get_instance_icon_alt(self):
instance, plugin = self.get_plugin_instance()
if instance:
return unicode(plugin.icon_alt(instance))
else:
return u'' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_icon_title(self): # real signature unknown; restored from __doc__\n return \"\"",
"def get_alt(self):\n p = self._get_sub_text('alt')\n if not p:\n return None\n else:\n try:\n return int(p)\n except ValueError:\n ... | [
"0.7206248",
"0.68852603",
"0.6804482",
"0.6772271",
"0.67636156",
"0.67636156",
"0.672871",
"0.67071545",
"0.67071545",
"0.67071545",
"0.66867185",
"0.6654262",
"0.6637052",
"0.6633226",
"0.6626289",
"0.6614716",
"0.6602623",
"0.6600994",
"0.6589052",
"0.6566196",
"0.6564646... | 0.8435488 | 0 |
Just some logical stuff if user haves moderate_descendants then moderate_children | def save(self, force_insert=False, force_update=False):
if self.moderate_descendants:
self.moderate_children = True
else:
self.moderate_children = False
super(PageModerator, self).save(force_insert, force_update) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_grandchildren():\n\n # note c.upto(\"status\").desired.grandchildren\n # this is the same as *c.upto(\"status\").desired in python3.5+\n res = conf.status.conditions.choose(lambda c: (c.type, c.reason, c.upto(\"status\").desired.grandchildren))\n assert \"type\" in res\n assert \"reason\" i... | [
"0.60822916",
"0.5971886",
"0.5689409",
"0.5348866",
"0.5331274",
"0.53272384",
"0.5250134",
"0.5239354",
"0.5235983",
"0.52199626",
"0.5202542",
"0.517231",
"0.517231",
"0.5168321",
"0.5156678",
"0.51472634",
"0.51328313",
"0.5096494",
"0.50384384",
"0.5033463",
"0.5027114",... | 0.6343787 | 0 |
Search for the value target in the array A using binary search. | def BinarySearch(A, target):
return _BinarySearchAux(A, target, 0, len(A) - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binary_search_whole_array(arr, target):\n return binary_search(arr, target, 0, len(arr))",
"def binary_search(alist, target):\n index = binary_search_iterative(alist, target)\n return index",
"def binary_search(array: list[int], target: int) -> int:\n left = 0\n right = len(array) - 1\n\n ... | [
"0.7775253",
"0.74781513",
"0.7369633",
"0.7230093",
"0.71581167",
"0.71295196",
"0.7120497",
"0.70985",
"0.7073721",
"0.7009145",
"0.6975184",
"0.6966726",
"0.69441426",
"0.6911794",
"0.6841253",
"0.6775388",
"0.6751996",
"0.6710357",
"0.66489124",
"0.6639372",
"0.66381973",... | 0.8287194 | 0 |
r"""Hyperbole function Implements $$ f(x_0, x_1) = 8 (x_0 2)^2 (x_1 2)^2 $$ | def f(x0: float, x1: float) -> float:
return 8 - (x0 - 2) ** 2 - (x1 - 2) ** 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f1(x, a, b):\n #return x**43 - b*x**42 + x**7 - x**6 * a + 84*x - 42 * b - 42 * a\n return (x**42 + 42)/(x-a) + (x**6 + 42)/(x-b)",
"def f1(x):\n return x**3 - 2*x + 2",
"def bdq1(f, x, h=1e-5):\n return (f(x)-f(x-h))/h\n raise NotImplementedError(\"Problem 2 Incomplete\")",
"def bdq2(f, x... | [
"0.7119387",
"0.6948508",
"0.6846777",
"0.67713606",
"0.67150784",
"0.6619665",
"0.65248656",
"0.65127057",
"0.65080285",
"0.646941",
"0.6453863",
"0.6434166",
"0.6391845",
"0.637635",
"0.63548464",
"0.6348041",
"0.6331476",
"0.6295169",
"0.62527907",
"0.6240218",
"0.62143505... | 0.7577568 | 0 |
Computes `omega_0 p constraint2` in the bit basis with slack variables. Calls `qlp.eqn_converter.constraints_to_matrix` to compute the constrained matrix. | def get_omega(
inequalities: List[Relational], n_bits: int, p: int = 10, as_numeric: bool = False
) -> Matrix:
n_vars = len(DEPENDENTS) + len(inequalities)
q = qe.get_bit_map(n_vars=n_vars, n_bits=n_bits)
a, b = qe.constraints_to_matrix(
inequalities, dependents=DEPENDENTS, as_numeric=as_numeric... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_omega_0(n_bits: int, as_numeric: bool = False) -> Matrix:\n q = qe.get_bit_map(len(DEPENDENTS), n_bits)\n mat = -q.T @ q + 4 * np.diag(np.sum(q, axis=0))\n return np.array(mat) if as_numeric else mat",
"def constraints(self) -> Tuple[NDArray, NDArray]:\n symm = not self._asym\n k =... | [
"0.5836039",
"0.52766746",
"0.52113706",
"0.5034138",
"0.49834907",
"0.49747926",
"0.4951916",
"0.49246576",
"0.49246576",
"0.49243265",
"0.49236357",
"0.49225742",
"0.4921374",
"0.49076325",
"0.48932192",
"0.4883221",
"0.4836027",
"0.48178357",
"0.47918007",
"0.47856057",
"0... | 0.5731313 | 1 |
Calculates the area of a circle | def circle_area(circle):
return pi * circle.radius * circle.radius | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area_of_circle(radius):\n return radius",
"def circle_area(radius):\n area = radius ** 2 * math.pi\n return area",
"def area(self):\n\t\t#print (self.radius*self.radius*math.pi)\n\t\tcircle_area = (self.radius*self.radius*math.pi)\n\t\treturn circle_area",
"def circle_area(radius):\n return m... | [
"0.8745869",
"0.85839",
"0.8566856",
"0.85599434",
"0.85569406",
"0.8524091",
"0.85074466",
"0.83901566",
"0.83901566",
"0.82570344",
"0.82275945",
"0.8139902",
"0.8088065",
"0.8049198",
"0.8049198",
"0.80170983",
"0.800644",
"0.80042857",
"0.7991567",
"0.7976803",
"0.7958631... | 0.8968238 | 0 |
Calculate volume of a cuboid. | def volume_of_a_cuboid(length, width, height):
return length * width * height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cube_volume(edge : number) -> number:\n volume = edge*edge*edge\n\n return volume",
"def volume (self):\n volume = self.sideLength**3\n return volume",
"def volume(self):\n _alpha = np.radians(self.alpha)\n _beta = np.radians(self.beta)\n _gamma = np.radians(self.g... | [
"0.7463701",
"0.7420508",
"0.7405192",
"0.7366741",
"0.72924733",
"0.7245695",
"0.7229531",
"0.72160167",
"0.714981",
"0.7031789",
"0.7000545",
"0.6992655",
"0.6952574",
"0.6806591",
"0.6764553",
"0.66988105",
"0.666664",
"0.6657859",
"0.6654271",
"0.66385776",
"0.66198796",
... | 0.8282409 | 0 |
Finds the number of cows and chickens by being given the amount of heads and legs on the farm. | def heads_legs(heads, legs):
for i in range(0, heads + 1):
cows = heads - i
if 4 * cows + 2 * i == legs:
chickens = i
return chickens, cows
return "No solutions." | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_number_of_cows(self):\n bulls = self.get_number_of_bulls()\n list_of_cows = set(self.puzzle) & set(self.guess)\n cows = (len(list_of_cows) - bulls)\n return cows",
"def get_number_of_cheeses(self):\n number = 0\n for i in range(len(self._stools)):\n nu... | [
"0.66352767",
"0.6518265",
"0.63447565",
"0.6115597",
"0.6059045",
"0.59676576",
"0.58928794",
"0.5813358",
"0.5791248",
"0.57536227",
"0.5720542",
"0.570668",
"0.56826264",
"0.56752414",
"0.5674353",
"0.56580544",
"0.56282103",
"0.56080395",
"0.5601535",
"0.557459",
"0.55704... | 0.68843335 | 0 |
Concatenates strings in a specific order (short + long + short). | def short_long_short(first, second):
if len(first) > len(second):
return ''.join(second + first + second)
return ''.join(first + second + first) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_strings(l_strings):\n if l_strings == []:\n return \"\"\n else: \n return l_strings[0] + \" \" + concat_strings(l_strings[1:])",
"def laceStrings(s1, s2):\n # Your Code Here\n minLen = min(len(s1), len(s2))\n s3 = \"\".join(y for x in zip(s1, s2) for y in x) + s1[minLen:]... | [
"0.6632312",
"0.6397937",
"0.60567135",
"0.60250455",
"0.5989258",
"0.59715545",
"0.595117",
"0.58524996",
"0.5837099",
"0.5823456",
"0.57466316",
"0.574089",
"0.5736465",
"0.5709352",
"0.5689944",
"0.5689944",
"0.5689944",
"0.5687452",
"0.5655868",
"0.56552184",
"0.561772",
... | 0.69274545 | 0 |
Calculates how many bottles of duty free whiskey you would have to buy bottle_cost, duty_free_discont and cost_of_the_holiday. | def duty_free(price: int, discount: int, holiday_cost: int) -> int:
if holiday_cost == 500:
return holiday_cost
discount /= 100
price = holiday_cost / (price * discount)
price = int(price)
return price | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateCosts(self):\n self.costs = 0\n for house in self.houses:\n if not house.distance == 1000:\n self.costs += house.distance * 9\n for battery in self.batteries:\n self.costs += battery.costs\n return self.costs",
"def calculate_cost(self... | [
"0.67098325",
"0.66555476",
"0.65634406",
"0.6384225",
"0.63169754",
"0.62693393",
"0.6262279",
"0.61780584",
"0.6173227",
"0.6133311",
"0.6071943",
"0.60596",
"0.6055912",
"0.60195255",
"0.60087186",
"0.59921587",
"0.5984442",
"0.5981656",
"0.5976567",
"0.59566116",
"0.58903... | 0.6847768 | 0 |
Convert miles per imperial gallon into kilometers per liter. | def miles_per_gallon_to_kilometers_per_liter(miles_per_gallon):
converted_value = miles_per_gallon * ONE_MILE_IN_KILOMETERS / ONE_IMP_GALLON_IN_LITERS
return round(converted_value, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def miles_to_kilometers(miles):\n #convert miles to km:\n return miles*1.60934",
"def miles_to_kilometers(miles: float) -> float:\n mile = float(miles)\n kilometers = float(float(mile) * 1.60934)\n return round(kilometers, 2)",
"def kilometers_to_miles(km):\n #convert km to miles:\n return... | [
"0.810501",
"0.77146244",
"0.7660003",
"0.7547199",
"0.7521227",
"0.7105088",
"0.7034444",
"0.6854184",
"0.6576829",
"0.6553181",
"0.6421252",
"0.6299841",
"0.62697154",
"0.6260179",
"0.6246678",
"0.62450707",
"0.6243071",
"0.6237388",
"0.6223361",
"0.6187523",
"0.6170195",
... | 0.81636584 | 0 |
Returns a list of numbers which are divisible by given number | def divisible_by(array, divisor):
return_list = list()
for i in array:
if i % divisor == 0:
return_list.append(i)
return return_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_divisores(num):\n divisores = [] #uso una lista para guardar los divisores\n for i in range(1, num):\n if num%i == 0:\n divisores.append(i)\n return divisores",
"def simple_get_divisors(num: int) -> list:\n all_divisors = []\n for possible_divisor in range(1, math.floor(n... | [
"0.7834503",
"0.76458055",
"0.76339",
"0.7617275",
"0.752643",
"0.745404",
"0.7447987",
"0.7377548",
"0.7367242",
"0.73452306",
"0.7332288",
"0.7256012",
"0.721771",
"0.7188026",
"0.7091371",
"0.7077676",
"0.70762545",
"0.70386696",
"0.698966",
"0.6971757",
"0.6922879",
"0.... | 0.7736536 | 1 |
Round number to two decimal places. | def two_decimal_places(number):
return round(number, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def two_decimal_places(n):\n return float('{:.2f}'.format(n))",
"def round2(number, ndigits=None):\n if ndigits is None:\n ndigits = 0\n\n if ndigits < 0:\n exponent = 10 ** (-ndigits)\n quotient, remainder = divmod(number, exponent)\n if remainder >= exponent // 2 and number... | [
"0.7912119",
"0.7121332",
"0.70237994",
"0.69846284",
"0.67931926",
"0.66351336",
"0.65924495",
"0.65116143",
"0.64275634",
"0.6412318",
"0.62899566",
"0.6285706",
"0.6269954",
"0.6259456",
"0.6230161",
"0.6226126",
"0.6186584",
"0.6106894",
"0.59868294",
"0.5954083",
"0.5928... | 0.8178348 | 0 |
Build tiles from definition | def buildTiles(self, items, attributes):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tiles(cls):\n\n LOGGER.debug(\"Building tiles\")\n\n for tile_id in tiledata.TILE_DATA:\n if not Tile.tile_factory(tile_id):\n LOGGER.error(\"Could not construct tile with ID %d\", tile_id)\n sys.exit(1)",
"def populate_tiles(self):\n\n # gr... | [
"0.68891084",
"0.64572304",
"0.6323403",
"0.6250683",
"0.6089269",
"0.6088719",
"0.5969581",
"0.5969581",
"0.59590614",
"0.5950307",
"0.5935144",
"0.59060156",
"0.5876645",
"0.5876645",
"0.58567715",
"0.5856534",
"0.5855962",
"0.58338034",
"0.5832484",
"0.582266",
"0.5780481"... | 0.6888281 | 1 |
ExpansionUsers that can get are correctly first name last name | def test_expansionusers_name(self):
user1 = ExpansionUsers.objects.get(username="test@test.ru")
user2 = ExpansionUsers.objects.get(username="test2@test.ru")
print user1.first_name, user1.last_name
print user2.first_name, user2.last_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ldap_get_fullname(self, user):\n result = super(Auth42, self)._search_not_empty(user)\n if result is not None:\n fullname = (result.get(\"first-name\")[0], result.get(\"last-name\")[0])\n return ' '.join(str(name) for name in fullname)\n\n return None",
"def get_ful... | [
"0.67720646",
"0.6671337",
"0.6629962",
"0.64379114",
"0.64336544",
"0.64033014",
"0.6378841",
"0.6376377",
"0.6368268",
"0.6365409",
"0.6353563",
"0.6345074",
"0.63399214",
"0.63134235",
"0.63052213",
"0.6296006",
"0.6286999",
"0.6285708",
"0.6285708",
"0.6280305",
"0.626952... | 0.7815781 | 0 |
Returns a new Wall mirrored over the middle of the lanes. | def mirror(self):
newRot = [x for x in self.rot]
newRot[1] = -newRot[1]
newLRot = [x for x in self.lrot]
newLRot[1] = -newLRot[1]
newLRot[2] = -newLRot[2]
return Wall(self.beat, self.dur, -self.r, -self.l, self.d, self.u, newRot, newLRot) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def north_wall(self, x, y, z, width=10, length=10, height=10, details=None, name=\"wall\", mergeshape=None):\r\n global wallnum\r\n n = z + width / 2\r\n s = z - width / 2\r\n e = x + length / 2\r\n w = x - length / 2\r\n\r\n nwall = SolidObject(name+str(wallnum), Size(length, height, 1), Positio... | [
"0.63168657",
"0.63059783",
"0.6195468",
"0.6179768",
"0.6068646",
"0.60602653",
"0.60175794",
"0.5983031",
"0.59415644",
"0.59131116",
"0.5791608",
"0.5791608",
"0.5719669",
"0.569298",
"0.568444",
"0.566718",
"0.5666786",
"0.56274647",
"0.5609347",
"0.55890185",
"0.5540185"... | 0.7466312 | 0 |
Returns an identical Wall at the given beat. | def clone(self, beat):
return Wall(beat, self.dur, self.l, self.r, self.d, self.u, self.rot, self.lrot, self.animation) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_duplicate_walls(self):\n wall_map = {}\n duplicates = []\n for cnt, thing in enumerate(self.things):\n if isinstance(thing, Wall):\n if not wall_map.has_key(thing.location):\n wall_map[thing.location] = True\n else:\n ... | [
"0.5049386",
"0.4911792",
"0.48737365",
"0.48634148",
"0.47977442",
"0.4789481",
"0.47650355",
"0.47466433",
"0.4713171",
"0.470344",
"0.46669558",
"0.46617383",
"0.4601232",
"0.45878884",
"0.45483723",
"0.45483723",
"0.4531489",
"0.45207295",
"0.45195243",
"0.45181847",
"0.4... | 0.76180756 | 0 |
Get the wall as a json object. | def json(self):
beat = self.beat + 1.4 # replace with hjd
w, h = self.getWidth(), self.getHeight()
return {
"_time": beat,
"_duration": self.dur,
#"_lineIndex": 0,
#"_type": 0,
#"_width": 0,
"_customData": {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_feed():\n return jsonify(dict({\n \"result\": mongo.get_hpfeed(),\n \"code\": 200\n }))",
"def walls(self):\n return self.container['walls']",
"def currentWall(request):\n if request.method == 'GET':\n current = WallConfiguration.objects.... | [
"0.61182976",
"0.6091173",
"0.60240865",
"0.60231704",
"0.58529484",
"0.58529484",
"0.5777419",
"0.57769907",
"0.5729566",
"0.5647898",
"0.56427675",
"0.5582847",
"0.54869914",
"0.54786336",
"0.54461646",
"0.5436713",
"0.5424193",
"0.54131466",
"0.540085",
"0.53960735",
"0.53... | 0.65477777 | 0 |
Lookup municipality codes and names. By default, it looks for all municipalities. You can also use 'all' to in `name_muni` or `code_muni` to get all municipalities. Input a municipality NAME or CODE and get the names and codes of the municipality's corresponding state, meso, micro, intermediate, and immediate regions. ... | def lookup_muni(name_muni=None, code_muni=None, verbose=False):
# Get metadata with data url addresses
temp_meta = utils.select_metadata(geo="lookup_muni", year=2010)
# Read DataFrame available at provided url
lookup_table = utils.download_metadata(
temp_meta.loc[:, "download_path"].to_list()[0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def municipality(self, municipality):\n\n self._municipality = municipality",
"def doMunicipalityExtraction(self, inputDataFile, col, row, lim):\n\n # print \"Harvesting data from input file {}...\".format(inputDataFile)\n\n # Open workbook for input data\n self.inputDataFile = inputD... | [
"0.5410167",
"0.53954566",
"0.52363294",
"0.5100454",
"0.4966442",
"0.4919593",
"0.4915527",
"0.48639882",
"0.48639882",
"0.47431022",
"0.47338513",
"0.46779698",
"0.46355852",
"0.46141896",
"0.45225304",
"0.4520622",
"0.45026007",
"0.44715694",
"0.44459715",
"0.44454393",
"0... | 0.7943366 | 0 |
Test that the julian date function matches | def test_julian_date_matches_vallado():
dt = vallado_3_4_dt
jd_ut = special_datetime.datetime2jd(dt)
expected_jd = vallado_3_4_jd
assert abs(jd_ut-expected_jd) < .000001 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_julian_dates_10_1000_1582_2000():\n\tyears = [10,1000,1582,1582,2000]\n\tmonths = [5,12,10,10,1]\n\tdays = [30,20,4,5,1]\n\tjulians = date_functions.is_julian( years, months, days )\n\tassert julians[0] # 10-05-30 was a Julian date\n\tassert julians[1] # 1000-12-20 was a Julian date\n\tassert julians[2] #... | [
"0.83279824",
"0.73964554",
"0.7202944",
"0.7032448",
"0.6926785",
"0.67389816",
"0.6726091",
"0.67065644",
"0.6703583",
"0.6670712",
"0.66419154",
"0.65830725",
"0.6574549",
"0.65594155",
"0.6481684",
"0.64698035",
"0.64698035",
"0.6467114",
"0.6465527",
"0.63816047",
"0.634... | 0.81889576 | 1 |
Test that the gregorianjulian date function in astrodyanmics matches | def test_gregorian_date_matches_vallado():
#Test using example in vallado pp. 209
given_jd = vallado_3_13_jd
dt = special_datetime.jd2datetime(given_jd)
expected_dt = vallado_3_13_dt
delta_t = (dt-expected_dt).total_seconds()
#Better than millisecond accuracy, at least for this date!
assert ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_gregorian_dates_10_1000_1582_2000():\n\tyears = [10,1000,1582,1582,2000]\n\tmonths = [5,12,10,10,1]\n\tdays = [30,20,4,5,1]\n\tgregorians = date_functions.is_gregorian( years, months, days )\n\tassert not gregorians[0] # 10-05-30 was not a Gegorian date\n\tassert not gregorians[1] # 1000-12-20 was not a G... | [
"0.8227319",
"0.75000685",
"0.7434814",
"0.7066292",
"0.70325553",
"0.6335981",
"0.6271381",
"0.62363726",
"0.6232766",
"0.6228892",
"0.6224275",
"0.6214344",
"0.61677647",
"0.61564004",
"0.61313844",
"0.6129193",
"0.6077165",
"0.6062438",
"0.6061544",
"0.60608673",
"0.604004... | 0.76632327 | 1 |
Test the vectorization function factory works to create datetimearr2jd, and that this function works with scalars, 1D lists and 1D numpy arrays | def test_vectorized_datetime_to_julian_date(example_dt,example_jd,shape):
dts = ex_as_arr(example_dt,shape)
expected_jds = ex_as_arr(example_jd,shape)
jds = special_datetime.datetimearr2jd(dts)
#Comparison is in units of days (use tolerance of a milisecond)
atol = .001/86400.
nptest.assert_allcl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_vectorized_julian_date_to_datetime(example_jd,example_dt,shape):\n jds = ex_as_arr(example_jd,shape)\n expected_dts = ex_as_arr(example_dt,shape)\n dts = special_datetime.jdarr2datetime(jds)\n timedeltas = (expected_dts-dts).flatten()\n delta_ts = np.array([abs(tdelta.total_seconds()) for t... | [
"0.70639384",
"0.64770925",
"0.64389896",
"0.6249208",
"0.60850185",
"0.60801625",
"0.6063983",
"0.5967729",
"0.59255487",
"0.59204966",
"0.58881587",
"0.58787084",
"0.58785045",
"0.58393157",
"0.58264935",
"0.582606",
"0.58191967",
"0.5795057",
"0.5772121",
"0.57522243",
"0.... | 0.7364402 | 0 |
Test the vectorization function factory works to create datetimearr2jd, and that this function works with scalars, 1D lists and 1D numpy arrays | def test_vectorized_julian_date_to_datetime(example_jd,example_dt,shape):
jds = ex_as_arr(example_jd,shape)
expected_dts = ex_as_arr(example_dt,shape)
dts = special_datetime.jdarr2datetime(jds)
timedeltas = (expected_dts-dts).flatten()
delta_ts = np.array([abs(tdelta.total_seconds()) for tdelta in t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_vectorized_datetime_to_julian_date(example_dt,example_jd,shape):\n dts = ex_as_arr(example_dt,shape)\n expected_jds = ex_as_arr(example_jd,shape)\n jds = special_datetime.datetimearr2jd(dts)\n #Comparison is in units of days (use tolerance of a milisecond)\n atol = .001/86400.\n nptest.a... | [
"0.7364292",
"0.6476464",
"0.64374894",
"0.62481827",
"0.6085785",
"0.6078412",
"0.60643107",
"0.59681135",
"0.5924805",
"0.59210545",
"0.5886178",
"0.58777344",
"0.58772993",
"0.5839404",
"0.5826778",
"0.5825607",
"0.5819688",
"0.57958835",
"0.5772121",
"0.57524043",
"0.5752... | 0.70635253 | 1 |
Test that vectorization works correctly in the presence of additional input arguments (the year, for the day of year to datetime conversion) | def test_vectorized_day_of_year_to_datetime(example_doy,example_dt,example_year,
shape):
doy = ex_as_arr(example_doy,shape)
year = ex_as_arr(example_year,shape)
expected_dts = ex_as_arr(example_dt,shape)
dts = special_datetime.doyarr2datetime(doy,year)
tim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_convert_date_to_year(self):\n # TODO there might be a more robust way to write this with try except statements.",
"def test_evaluate_year_expression(self):\n for f, r in (\n (\"year\", 2013),\n (\"month\", 9),\n (\"day\", 1),\n (\... | [
"0.6325704",
"0.63071436",
"0.6047931",
"0.60215926",
"0.5969062",
"0.5864323",
"0.5816081",
"0.580706",
"0.57386917",
"0.5731787",
"0.5725655",
"0.5712398",
"0.57113844",
"0.5696993",
"0.5690391",
"0.5672519",
"0.5661212",
"0.5645891",
"0.5628325",
"0.56209546",
"0.5569543",... | 0.73709923 | 0 |
Recursive utility function to get a (possibly nested) attribute of a gym Space | def get_space_attr(space, attr='shape'):
assert isinstance(space, gym.Space)
if hasattr(space, 'spaces'):
return tuple(get_space_attr(s, attr=attr) for s in space.spaces)
else:
value = getattr(space, attr)
# If this value is seen as nested (i.e. a tuple with shape), make it
# an array so that it i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attribute(root, attribute):\n command_tree = [root]\n while command_tree:\n current_object = command_tree.pop()\n if hasattr(current_object, attribute):\n return getattr(current_object, attribute)\n\n parent = getattr(current_object, \"parent\", None)\n if paren... | [
"0.5793785",
"0.5663005",
"0.55385864",
"0.551476",
"0.5488922",
"0.5479301",
"0.54579216",
"0.5456438",
"0.54298663",
"0.5381794",
"0.5380499",
"0.53704673",
"0.53517205",
"0.5322042",
"0.5284191",
"0.520735",
"0.5195089",
"0.5138233",
"0.5129488",
"0.5119389",
"0.5104115",
... | 0.66327345 | 0 |
Returns a (possibly nested) TensorSpec with space's shape and dtype. | def get_space_spec(space, remove_first_dim=None):
remove_first_dim = -3 if remove_first_dim is None else int(remove_first_dim)
return tf.nest.map_structure(
lambda s,d: tf.TensorSpec(shape=s[remove_first_dim:], dtype=d),
get_space_attr(space, 'shape'),
get_space_attr(space, 'dtype')
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def input_spec_to_jax_shape_dtype_struct(\n spec: Union[Tuple[Tuple[int, ...], jnp.dtype], Tuple[int, ...]],\n batch_size: Optional[int] = None) -> jax.ShapeDtypeStruct:\n spec = tuple(spec)\n if len(spec) == 2 and isinstance(spec[0], collections.abc.Iterable):\n shape = (batch_size,) + tuple(spec[0][1:... | [
"0.5697807",
"0.5612899",
"0.53450495",
"0.5181592",
"0.5137726",
"0.51283",
"0.4993917",
"0.4989812",
"0.49839875",
"0.4942706",
"0.48814404",
"0.48760477",
"0.4757064",
"0.47533423",
"0.47456124",
"0.47387892",
"0.47022027",
"0.4699525",
"0.46986052",
"0.46869597",
"0.46786... | 0.76544815 | 0 |
Sample an action from the environment's action space | def sample(self):
return self._action_out(self._env.action_space.sample()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_random_action(env):\n return env.action_space.sample()",
"def act(self, env: FakeEnv, s: ActorStrategy):\n action = env.action_space.sample()\n print(f\"Sampled action shape : {action.shape}\")\n env.step(action)",
"def get_action(self, state):\n return self.env.action... | [
"0.80715424",
"0.7760127",
"0.7720179",
"0.76235783",
"0.7516814",
"0.7289412",
"0.7254607",
"0.7201601",
"0.7039239",
"0.7027224",
"0.7021836",
"0.6994475",
"0.6859091",
"0.6837737",
"0.68123066",
"0.6800573",
"0.6772669",
"0.6708706",
"0.67032886",
"0.6620695",
"0.65986115"... | 0.7905459 | 1 |
Sends the exit command and joins each process. | def terminate(self):
while self._conns:
conn = self._conns.pop()
try:
conn.send((self.EXIT, ()))
except BrokenPipeError:
pass
conn.close()
while self._processes:
p = self._processes.pop()
p.join(1)
if p.exitcode is None:
# Force termination if ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit(self):\n self.tcp_server_exit_event.set()\n for _, process in self.name_to_process.items():\n process.terminate()",
"def exit(self):\n if self._isSubProcessRunning() and self._exitCommand is not None:\n self.__process.stdin.write(self._exitCommand)\n ... | [
"0.7215597",
"0.7111311",
"0.6823135",
"0.67789716",
"0.66514933",
"0.6586141",
"0.6395664",
"0.6376092",
"0.63705796",
"0.6341093",
"0.63190144",
"0.6283062",
"0.62591743",
"0.6225285",
"0.62007153",
"0.61884004",
"0.61577284",
"0.61331403",
"0.6066164",
"0.6064636",
"0.6053... | 0.7258543 | 0 |
Create a logger for logging the training process. | def make_logger(model_dir: str, log_file: str = "train.log") -> Logger:
logger = logging.getLogger(__name__)
if not logger.handlers:
logger.setLevel(level=logging.DEBUG)
fh = logging.FileHandler("{}/{}".format(model_dir, log_file))
fh.setLevel(level=logging.DEBUG)
logger.addHandl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logging(config: Any) -> Logger:\n green = \"\\033[32m\"\n reset = \"\\033[0m\"\n logger = setup_logger(\n name=f\"{green}[ignite]{reset}\",\n level=logging.DEBUG if config.debug else logging.INFO,\n format=\"%(name)s: %(message)s\",\n filepath=config.output_dir / \"tr... | [
"0.73104",
"0.7274566",
"0.72351295",
"0.7038086",
"0.6970917",
"0.694863",
"0.69329464",
"0.6877087",
"0.67576975",
"0.6727164",
"0.6625625",
"0.6584788",
"0.65420365",
"0.6532559",
"0.6518412",
"0.6513807",
"0.64985186",
"0.64930636",
"0.64551353",
"0.6439497",
"0.6430948",... | 0.7477239 | 0 |
Set the random seed for modules torch, numpy and random. | def set_seed(seed: int):
torch.manual_seed(seed)
np.random.seed(seed)
random.seed(seed) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_seed(seed):\n torch.manual_seed(seed)\n random.seed(seed)\n np.random.seed(seed)",
"def set_seed(seed: int):\n random.seed(seed)\n np.random.seed(seed)\n torch.manual_seed(seed)",
"def set_global_seeds(seed):\n \n torch.manual_seed(seed)\n np.random.seed(seed)\n random.see... | [
"0.83239275",
"0.8218641",
"0.82023215",
"0.81600124",
"0.8130066",
"0.8105975",
"0.8091466",
"0.8070724",
"0.8070274",
"0.8041538",
"0.8000993",
"0.7976506",
"0.7959923",
"0.7942736",
"0.7942736",
"0.7922287",
"0.79220265",
"0.79220265",
"0.78897405",
"0.78857374",
"0.786589... | 0.82849205 | 1 |
Log statistics of data and vocabulary. | def log_data_info(
train_data: Dataset,
valid_data: Dataset,
test_data: Dataset,
gls_vocab: GlossVocabulary,
txt_vocab: TextVocabulary,
logging_function: Callable[[str], None],
):
logging_function(
"Data set sizes: \n\ttrain {:d},\n\tvalid {:d},\n\ttest {:d}".format(
len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _logging(self):\n msgs = []\n # patch to log stdout spawned processes of dataloader\n logger = init_logger()\n for ds_name, ds_count in self._counts.items():\n msgs.append(f\"\\t\\t\\t* {ds_name}: {ds_count}\")\n logger.info(\"Weighted corpora loaded so far:\\n\" +... | [
"0.66488",
"0.6610018",
"0.6240891",
"0.61634624",
"0.6061095",
"0.6054172",
"0.60420674",
"0.598377",
"0.59695536",
"0.5959021",
"0.58413374",
"0.58403563",
"0.5838658",
"0.5812123",
"0.5798962",
"0.57827675",
"0.5781888",
"0.5759608",
"0.5751315",
"0.5745328",
"0.57450753",... | 0.69618124 | 0 |
Returns the latest checkpoint (by time) from the given directory. If there is no checkpoint in this directory, returns None | def get_latest_checkpoint(ckpt_dir: str) -> Optional[str]:
list_of_files = glob.glob("{}/*.ckpt".format(ckpt_dir))
latest_checkpoint = None
if list_of_files:
latest_checkpoint = max(list_of_files, key=os.path.getctime)
return latest_checkpoint | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_latest_checkpoint(cls, experiment_path):\n checkpoints_path = os.path.join(experiment_path, cls.CHECKPOINT_DIR_NAME)\n all_times = sorted(os.listdir(checkpoints_path), reverse=True)\n return os.path.join(checkpoints_path, all_times[0])",
"def get_latest_checkpoint_path(dirpath: str) ... | [
"0.7700107",
"0.74362636",
"0.7350826",
"0.70492095",
"0.70353407",
"0.686673",
"0.6788162",
"0.6776815",
"0.6733546",
"0.67268467",
"0.66239303",
"0.64845854",
"0.64429843",
"0.640534",
"0.62015307",
"0.6133778",
"0.6057183",
"0.6019879",
"0.59937334",
"0.5984722",
"0.595231... | 0.8131056 | 0 |
Enumerates absolute paths of files under `dir` but excluding those the function `filter` returns False. | def list_image_files(dir, filter=None):
for entry in os.listdir(dir):
path = os.path.join(dir, entry)
if os.path.isdir(path):
for p in list_image_files(path, filter):
yield p
elif any((entry.lower().endswith(ext) for ext in image_exts)):
if filter and ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_files_recursively(dir: str, valid_extensions: list = None, filter_fn=None) -> list:\n\n def file_path_generator():\n for dir_name, _, file_names in os.walk(dir):\n for filename in file_names:\n yield os.path.join(dir_name, filename)\n\n return [file_path for file_pat... | [
"0.6643024",
"0.66275597",
"0.6609569",
"0.65067625",
"0.6464404",
"0.64575857",
"0.6438825",
"0.6407994",
"0.6387433",
"0.6345481",
"0.6318649",
"0.6316253",
"0.62388134",
"0.6195835",
"0.6184927",
"0.61324525",
"0.6122803",
"0.6077047",
"0.6065856",
"0.6043274",
"0.60263616... | 0.6766971 | 0 |
Returns whether the file specified with `path` is a sidecar JPEG file or not. | def is_sidecar_jpeg(path):
path_filename, ext = os.path.splitext(path)
ext = ext.lower()
return any((ext == x for x in jpeg_exts)) and \
any((os.path.exists(path_filename + x) for x in raw_exts)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_jpg(filename):\n return '.jpg' in filename",
"def isPicture(file): \n return os.path.splitext(file)[1][1:].lower() in ['jpg', 'jpeg', 'gif', 'png', 'tif', 'tiff', 'bmp']",
"def check_type(filename):\n try:\n im = Image.read(filename)\n except SanperaError:\n return False\n e... | [
"0.61065996",
"0.60510033",
"0.59241307",
"0.59176433",
"0.5875605",
"0.58321977",
"0.5815605",
"0.574858",
"0.56689245",
"0.56637555",
"0.56612223",
"0.5611139",
"0.5608929",
"0.5594044",
"0.5588557",
"0.55783355",
"0.5538523",
"0.5523795",
"0.5503051",
"0.5489112",
"0.54878... | 0.8176112 | 0 |
transform target sense annotated with NOAD (New Oxford American Dictionary) word senses into WordNet senses | def NOAD_to_wordnet(data):
NOAD_to_wordnet = {}
with open(algorithmic_map, 'r') as f:
lines = f.readlines()
for line in lines:
noad, wordnet = line.split()
NOAD_to_wordnet[noad] = wordnet
with open(manual_map, 'r') as f:
lines = f.readlines()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_english_raw_texts():\n # conceptnet triples raw text\n cpnet_en_raw_text = []\n\n # conceptnet entity context\n cpnet_en_entity_context = []\n\n with open(conceptnet_path, encoding=\"utf8\") as f:\n for line in f.readlines():\n ls = line.split('\\t')\n if ls[... | [
"0.61455923",
"0.6104557",
"0.5963491",
"0.58825034",
"0.5802276",
"0.5780971",
"0.57554984",
"0.5746371",
"0.5708776",
"0.56963277",
"0.56147546",
"0.560279",
"0.55962706",
"0.55882293",
"0.5502685",
"0.5463144",
"0.5444419",
"0.5439072",
"0.54318523",
"0.54296017",
"0.54290... | 0.7904227 | 0 |
build sense vector for every target sense using the definition of wordnet and glove embedding return | def build_sense_embedding(target_sense_to_id, word_freq, EMBEDDING_DIM):
res = {}
wordvecs = load_glove(EMBEDDING_DIM)
for target_sense_list in target_sense_to_id:
for key, _ in target_sense_list.items():
sense_vector = np.zeros(EMBEDDING_DIM)
senses = key.split('... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_doc_sense_vec(self):\n\t\twith codecs.open(self.vocab_file, encoding='utf-8', mode='r') as infile:\n\t\t\tline = infile.readline()\n\t\t\ti = 0\n\t\t\twhile line:\n\t\t\t\tword = line.split()[0]\n\t\t\t\tif not self.word2IdVocabulary.has_key(word):\n\t\t\t\t\t# print i, word\n\t\t\t\t\t# else:\n\t\t\t\t\... | [
"0.6847894",
"0.6233457",
"0.6051749",
"0.6051169",
"0.60288686",
"0.5982624",
"0.5979444",
"0.59690243",
"0.5957364",
"0.59261304",
"0.5911474",
"0.58430237",
"0.5838928",
"0.580763",
"0.5762697",
"0.57598484",
"0.57554895",
"0.57523525",
"0.57427406",
"0.5739391",
"0.572869... | 0.73034346 | 0 |
Finalize the encapsulated simulated request. This method causes the request event emitter to begin emitting ``'http.disconnect'`` events and then awaits the completion of the asyncio task that is running the simulated ASGI request. | async def finalize(self):
self._req_event_emitter.disconnect()
await self._task | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _finalize_request(self, request_no):\n now = _now()\n # Find request info in current requests\n request_info = self._current_requests.pop(request_no, None)\n if not request_info:\n logging.error(\"Couldn't finalize request #{} as it wasn't started \"\n \"or it was started lo... | [
"0.599261",
"0.58126885",
"0.57832295",
"0.57138246",
"0.56882215",
"0.5686544",
"0.5677415",
"0.56466365",
"0.5626848",
"0.5616015",
"0.5615296",
"0.55539614",
"0.55263776",
"0.55126804",
"0.5511265",
"0.54770803",
"0.5459623",
"0.5418623",
"0.54156804",
"0.541335",
"0.53688... | 0.77098256 | 0 |
Simulate a request to an ASGI application. | async def _simulate_request_asgi(
app,
method='GET',
path='/',
query_string=None,
headers=None,
content_type=None,
body=None,
json=None,
params=None,
params_csv=True,
protocol='http',
host=helpers.DEFAULT_HOST,
remote_addr=None,
extras=None,
http_version='1.1'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_basic_asgi_call(self):\n app = otel_asgi.OpenTelemetryMiddleware(simple_asgi)\n self.seed_app(app)\n self.send_default_request()\n outputs = self.get_all_output()\n self.validate_outputs(outputs)",
"def test_basic_asgi_call(self):\n app = otel_asgi.OpenTelemetry... | [
"0.6697261",
"0.6697261",
"0.6463477",
"0.64476454",
"0.62754405",
"0.6240101",
"0.6212896",
"0.61975616",
"0.6176701",
"0.6165948",
"0.61617255",
"0.61466104",
"0.6127736",
"0.6127736",
"0.6127736",
"0.6011134",
"0.5981526",
"0.59622854",
"0.5924651",
"0.5876444",
"0.587383"... | 0.696744 | 0 |
Simulate a GET request to a WSGI or ASGI application. | def simulate_get(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'GET', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_GET(self):\r\n self._send_handler_response('GET')",
"def get(self, url, **kwargs):\n logging.info('OUTGOING HTTP GET: %s' % url)\n try:\n return self.wrapped_app.get(url, **kwargs)\n except webtest.AppError as e:\n raise VirtualAppError(msg='HTTP GET faile... | [
"0.7422761",
"0.71843797",
"0.7106445",
"0.70900655",
"0.6984407",
"0.6970873",
"0.6878353",
"0.6760326",
"0.67270213",
"0.6703166",
"0.6636329",
"0.66259116",
"0.6616825",
"0.66046745",
"0.65231144",
"0.6460621",
"0.6452677",
"0.644508",
"0.6409575",
"0.63991606",
"0.6382206... | 0.78489506 | 0 |
Simulate a HEAD request to a WSGI or ASGI application. | def simulate_head(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'HEAD', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_HEAD(self):\n self.do_GET(True)",
"def HEAD(self, req):\r\n resp = req.get_response(self.app)\r\n\r\n return HTTPOk(headers=resp.headers)",
"def do_HEAD(self):\n self.log.debug('do_HEAD called')\n self.HeadGet('HEAD')",
"def head(self, url, *args, **kwargs):\n with LO... | [
"0.78091705",
"0.7650182",
"0.7624783",
"0.7595388",
"0.753932",
"0.75186324",
"0.7429734",
"0.7328362",
"0.73160917",
"0.72809213",
"0.713504",
"0.71180564",
"0.71009296",
"0.7089121",
"0.7067554",
"0.70673203",
"0.70619255",
"0.7036367",
"0.7036367",
"0.7036367",
"0.7036367... | 0.8178949 | 0 |
Simulate a POST request to a WSGI or ASGI application. | def simulate_post(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'POST', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_POST(self):\r\n self._send_handler_response('POST')",
"def post(self, *args, **kwargs):\n self.request(\"post\", *args, **kwargs)",
"def do_POST(self): # pylint: disable=invalid-name\n self.handle_request()",
"def do_POST(self,):\n self.http_method = 'POST'\n ... | [
"0.71617234",
"0.7045804",
"0.6867098",
"0.6853614",
"0.6829674",
"0.6813335",
"0.6783007",
"0.6774898",
"0.6717171",
"0.6653153",
"0.6608424",
"0.66032755",
"0.6583824",
"0.6545123",
"0.65369654",
"0.6514101",
"0.65099627",
"0.6505311",
"0.6446184",
"0.63772756",
"0.63557357... | 0.77779883 | 0 |
Simulate a PUT request to a WSGI or ASGI application. | def simulate_put(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'PUT', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_PUT(self,):\n self.http_method = 'PUT'\n # Nothing to do for now.\n pass",
"def put(self, *args, **kwargs):\n self.request(\"put\", *args, **kwargs)",
"def _put(self, *args, **kwargs):\n return self._request('put', *args, **kwargs)",
"def simulate_put(self, path='/',... | [
"0.7430654",
"0.7420765",
"0.7254375",
"0.72292215",
"0.7130859",
"0.7076189",
"0.70692164",
"0.7004767",
"0.696957",
"0.69484067",
"0.692274",
"0.69176435",
"0.68755746",
"0.683001",
"0.6824943",
"0.68128455",
"0.67805594",
"0.6752393",
"0.6752393",
"0.6752393",
"0.6705847",... | 0.82123727 | 0 |
Simulate an OPTIONS request to a WSGI or ASGI application. | def simulate_options(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'OPTIONS', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OPTIONS(self, req):\r\n resp = req.get_response(self.app)\r\n return resp",
"def handleHttpOptions():\n response = flask.Response(\"\", mimetype=\"application/json\")\n response.headers.add(\"Access-Control-Request-Methods\", \"GET,POST,OPTIONS\")\n return response",
"def do_OPTIONS(... | [
"0.7863422",
"0.73523796",
"0.7177669",
"0.71471834",
"0.70651054",
"0.6973183",
"0.6879857",
"0.6852321",
"0.68058544",
"0.6744779",
"0.6601881",
"0.6532627",
"0.6517702",
"0.6396257",
"0.62983924",
"0.6216214",
"0.61781067",
"0.61551476",
"0.612352",
"0.58386046",
"0.578458... | 0.7776818 | 1 |
Simulate a PATCH request to a WSGI or ASGI application. | def simulate_patch(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'PATCH', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch(self, *args, **kwargs):\n self.request(\"patch\", *args, **kwargs)",
"def simulate_patch(self, path='/', **kwargs):\n return self.simulate_request('PATCH', path, **kwargs)",
"def test_client_can_do_patch_request(self):\n response = self.httpbin_4.test_requests_patch_method()\n ... | [
"0.77237695",
"0.7579202",
"0.74945503",
"0.7375038",
"0.7336147",
"0.71931046",
"0.709597",
"0.7059055",
"0.70421225",
"0.70336956",
"0.6954821",
"0.6954437",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.69469035",
"0.6... | 0.843222 | 0 |
Simulate a DELETE request to a WSGI or ASGI application. | def simulate_delete(app, path, **kwargs) -> _ResultBase:
return simulate_request(app, 'DELETE', path, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_DELETE(self,):\n self.http_method = 'DELETE'\n self.response()",
"def delete(self, url):\n return self.request(url, \"DELETE\")",
"def delete(self, *args, **kwargs):\n self.request(\"delete\", *args, **kwargs)",
"def _delete(self, url):\n return self._request(url, me... | [
"0.7512464",
"0.73937106",
"0.7383249",
"0.7367261",
"0.73230493",
"0.7305496",
"0.72956675",
"0.72301793",
"0.72071403",
"0.7176349",
"0.7168482",
"0.7161482",
"0.7146861",
"0.7128366",
"0.71066153",
"0.7064168",
"0.7042529",
"0.7008366",
"0.6931621",
"0.6908701",
"0.6888692... | 0.81882477 | 0 |
set session for current user | def set_current_user(self, user):
self.session['u'] = user.get().key.urlsafe() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_login(user):\n session[CURRENT_USER_KEY] = user.id",
"def set_su_user(self, su_user):\n self.request.session[AUTH_SESSION_KEY] = su_user.id\n self.request.session[AUTH_HASH_SESSION_KEY] = su_user.get_session_auth_hash()\n if su_user.id != self.auth_user.id:\n self.reques... | [
"0.740831",
"0.71369225",
"0.70445764",
"0.6964448",
"0.6953895",
"0.6869955",
"0.6834737",
"0.68247133",
"0.6789445",
"0.6729116",
"0.6723161",
"0.6709489",
"0.6669265",
"0.6656851",
"0.66272396",
"0.66168904",
"0.66127384",
"0.6612591",
"0.66067016",
"0.6592191",
"0.6569845... | 0.7985505 | 0 |
set session for current school that user choose when login | def set_current_school(self, school_key):
self.session['s'] = school_key | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose_school():\n if current_user.is_administrator():\n schools = School.query.order_by(School.long_name)\n else:\n schools = current_user.schools_coached\n\n # if initial get request, render add_school.html\n return render_template('choose_school.html', schools=schools)",
"def set... | [
"0.6246114",
"0.6165318",
"0.60238373",
"0.59813094",
"0.5963209",
"0.58441776",
"0.58033544",
"0.5755063",
"0.5727515",
"0.5708403",
"0.56811965",
"0.56026447",
"0.5592895",
"0.5572259",
"0.55581385",
"0.54835755",
"0.5440814",
"0.5436401",
"0.54343957",
"0.5427836",
"0.5427... | 0.7416146 | 0 |
set session for current admin | def setup_admin_session(self, user):
self.session['ad'] = user.get().key.urlsafe() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_current_user(self, user):\n self.session['u'] = user.get().key.urlsafe()",
"def login(test_app):\n from flask_monitoringdashboard import config\n\n with test_app.session_transaction() as sess:\n sess[config.link + '_logged_in'] = True\n sess[config.link + '_admin'] = True",
"... | [
"0.64475083",
"0.640205",
"0.63752884",
"0.6369683",
"0.63622195",
"0.62239605",
"0.6216995",
"0.6164825",
"0.61162066",
"0.60842025",
"0.6078582",
"0.60669124",
"0.6065299",
"0.60632056",
"0.60338914",
"0.6033646",
"0.6027066",
"0.6002428",
"0.5977556",
"0.59413683",
"0.5925... | 0.743749 | 0 |
Return business version object associated with a given transaction id for a business. | def get_business_revision_obj(transaction_id, business):
business_version = version_class(Business)
business_revision = db.session.query(business_version) \
.filter(business_version.transaction_id <= transaction_id) \
.filter(business_version.operation_type != 2) \
.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_business_revision(transaction_id, business) -> dict:\n business_version = version_class(Business)\n business_revision = db.session.query(business_version) \\\n .filter(business_version.transaction_id <= transaction_id) \\\n .filter(business_version.operation_type != 2) \... | [
"0.7636616",
"0.6377281",
"0.6335256",
"0.63015807",
"0.6286003",
"0.6253474",
"0.6029115",
"0.5956254",
"0.5956254",
"0.5956254",
"0.593759",
"0.5815979",
"0.5777107",
"0.5764829",
"0.57134163",
"0.55761206",
"0.5534498",
"0.5525413",
"0.55233735",
"0.5461759",
"0.5421985",
... | 0.8101256 | 0 |
Get business info with last value of dissolution_date or restoration_expiry_date. | def find_last_value_from_business_revision(transaction_id, business_id,
is_dissolution_date=False,
is_restoration_expiry_date=False) -> dict:
business_version = version_class(Business)
query = db.session.query(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_adv_acct_business(clean_data, all_slot_coupons, this_advertiser):\n business_id = clean_data['business_id']\n if business_id:\n business = Business.objects.get(id=business_id)\n elif all_slot_coupons:\n # Select the business with the most recently added slot_time_frame.\n busi... | [
"0.63183683",
"0.59914434",
"0.53736246",
"0.5331287",
"0.5306034",
"0.5255722",
"0.51936203",
"0.51891106",
"0.51854855",
"0.51780736",
"0.51550066",
"0.5148936",
"0.5130781",
"0.50994205",
"0.5098762",
"0.5097678",
"0.50936073",
"0.50932556",
"0.50902474",
"0.50853217",
"0.... | 0.6853517 | 0 |
Consolidates all share classes upto the given transaction id. | def get_share_class_revision(transaction_id, business_id) -> dict:
share_class_version = version_class(ShareClass)
share_classes_list = db.session.query(share_class_version) \
.filter(share_class_version.transaction_id <= transaction_id) \
.filter(share_class_version.operation_ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_by_namespace(self):\n package = self.container.config.output.package\n groups = collections.group_by(self.container, key=get_target_namespace)\n for namespace, classes in groups.items():\n self.assign(classes, package, namespace or \"\")",
"def group_by_strong_components... | [
"0.5139013",
"0.50330913",
"0.48715967",
"0.48479706",
"0.48171863",
"0.4742321",
"0.46083876",
"0.45552248",
"0.4535983",
"0.4531581",
"0.45151782",
"0.44682208",
"0.4465922",
"0.44380042",
"0.44106326",
"0.44035476",
"0.44020128",
"0.4396122",
"0.43579513",
"0.43411663",
"0... | 0.5442146 | 0 |
Consolidates all share series under the share class upto the given transaction id. | def get_share_series_revision(transaction_id, share_class_id) -> dict:
share_series_version = version_class(ShareSeries)
share_series_list = db.session.query(share_series_version) \
.filter(share_series_version.transaction_id <= transaction_id) \
.filter(share_series_version.oper... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_share_class_revision(transaction_id, business_id) -> dict:\n share_class_version = version_class(ShareClass)\n share_classes_list = db.session.query(share_class_version) \\\n .filter(share_class_version.transaction_id <= transaction_id) \\\n .filter(share_class_version.o... | [
"0.5190824",
"0.5187994",
"0.5142222",
"0.5073142",
"0.4927391",
"0.49156842",
"0.48170972",
"0.48046333",
"0.47612914",
"0.4756013",
"0.46777904",
"0.46077105",
"0.45642272",
"0.45364735",
"0.45220184",
"0.44816855",
"0.4480779",
"0.44729975",
"0.44729114",
"0.44596547",
"0.... | 0.55091697 | 0 |
Return the party member by type as a json object. | def party_revision_type_json(party_revision, is_ia_or_after) -> dict:
member = {}
if party_revision.party_type == Party.PartyTypes.PERSON.value:
member = {
'officer': {
'firstName': party_revision.first_name,
'lastName': party_revision.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_person_like_json(self):\n return json.dumps(self.get_person())",
"def json(self):\n return {'name': self.neighbourhood_group, 'neighbourhood': self.room_type}",
"def to_json(self):\r\n return {'type': self.type, 'name': self.name}",
"def test_party_json(session):\n party = Mhr... | [
"0.59179246",
"0.5765067",
"0.5714951",
"0.5656859",
"0.5601924",
"0.5516952",
"0.5516952",
"0.55098546",
"0.54318315",
"0.5260781",
"0.52107835",
"0.52107835",
"0.52107835",
"0.52107835",
"0.5145145",
"0.5145117",
"0.5118637",
"0.5068482",
"0.50048494",
"0.4981137",
"0.49722... | 0.65182054 | 0 |
Return the share_class as a json object. | def share_class_revision_json(share_class_revision) -> dict:
share_class = {
'id': share_class_revision.id,
'name': share_class_revision.name,
'priority': share_class_revision.priority,
'hasMaximumShares': share_class_revision.max_share_flag,
'maxNumbe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self):\n obj_dict = self.__dict__\n obj_dict[\"_class_\"] = self.__class__.__name__\n return obj_dict",
"def cls2json(self):\n return json.dumps(self.__dict__)",
"def cls2json(self):\n return json.dumps(self.__dict__)",
"def to_dict(self):\n result = supe... | [
"0.64385223",
"0.64294195",
"0.64294195",
"0.6168101",
"0.599551",
"0.5803228",
"0.57021445",
"0.57014143",
"0.5676124",
"0.5641927",
"0.5622269",
"0.5605307",
"0.55982053",
"0.55899024",
"0.55899024",
"0.55899024",
"0.5582552",
"0.55741054",
"0.5545515",
"0.5539542",
"0.5539... | 0.692662 | 0 |
Return the share series revision as a json object. | def share_series_revision_json(share_series_revision) -> dict:
share_series = {
'id': share_series_revision.id,
'name': share_series_revision.name,
'priority': share_series_revision.priority,
'hasMaximumShares': share_series_revision.max_share_flag,
'm... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_share_series_revision(transaction_id, share_class_id) -> dict:\n share_series_version = version_class(ShareSeries)\n share_series_list = db.session.query(share_series_version) \\\n .filter(share_series_version.transaction_id <= transaction_id) \\\n .filter(share_series_v... | [
"0.708846",
"0.6720135",
"0.6084429",
"0.58188486",
"0.5759813",
"0.5623428",
"0.5623428",
"0.5560211",
"0.55411124",
"0.55097365",
"0.5487668",
"0.54803145",
"0.54494274",
"0.5414318",
"0.539694",
"0.5353764",
"0.52968645",
"0.5291189",
"0.52851427",
"0.5240236",
"0.52177316... | 0.8145801 | 0 |
Return the name translation revision as a json object. | def name_translations_json(name_translation_revision) -> dict:
name_translation = {
'id': str(name_translation_revision.id),
'name': name_translation_revision.alias,
'type': name_translation_revision.type
}
return name_translation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def revision_name(self):\n return self._revision_name",
"def get_name_translations_revision(transaction_id, business_id) -> dict:\n name_translations_version = version_class(Alias)\n name_translations_list = db.session.query(name_translations_version) \\\n .filter(name_translation... | [
"0.63252676",
"0.6090434",
"0.59809774",
"0.59141386",
"0.5811075",
"0.5675912",
"0.5657325",
"0.5536982",
"0.54140645",
"0.5410727",
"0.54099125",
"0.5404105",
"0.53842735",
"0.5366681",
"0.5348114",
"0.53427243",
"0.53400004",
"0.5282428",
"0.5273558",
"0.5273386",
"0.52596... | 0.81740797 | 0 |
Return the resolution revision as a json object. | def resolution_json(resolution_revision) -> dict:
resolution = {
'id': resolution_revision.id,
'date': resolution_revision.resolution_date.strftime('%B %-d, %Y'),
'type': resolution_revision.resolution_type
}
return resolution | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self):\n return {\n 'revision': self.revision,\n 'active': self.active,\n 'archived_at': self.archived_at\n }",
"def revision(self):\n return self._revision",
"def revision(self):\n return self._revision",
"def get_revision(self) -> str... | [
"0.6687245",
"0.6393448",
"0.6393448",
"0.62428397",
"0.62007344",
"0.6174118",
"0.6029406",
"0.6012772",
"0.59804827",
"0.5977369",
"0.59660566",
"0.5938327",
"0.5914053",
"0.58789593",
"0.5854711",
"0.58510196",
"0.58412087",
"0.5827877",
"0.5823848",
"0.57971644",
"0.57879... | 0.7941922 | 0 |
Return the business revision as a json object. | def business_revision_json(business_revision, business_json):
business_json['hasRestrictions'] = business_revision.restriction_ind
business_json['dissolutionDate'] = LegislationDatetime.format_as_legislation_date(
business_revision.dissolution_date) if business_revision.dissolution_date else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self):\n return {\n 'revision': self.revision,\n 'active': self.active,\n 'archived_at': self.archived_at\n }",
"def get_cod_revision(filing, business) -> dict:\n cod_json = {}\n\n cod_json['business'] = \\\n VersionedBusinessDet... | [
"0.73196644",
"0.7150604",
"0.6965336",
"0.69643956",
"0.6898412",
"0.6647638",
"0.6617927",
"0.64494884",
"0.6417139",
"0.6356839",
"0.6356563",
"0.6326582",
"0.618475",
"0.61779064",
"0.6150429",
"0.6115579",
"0.61032957",
"0.6018561",
"0.6018561",
"0.6005441",
"0.59775114"... | 0.76480556 | 0 |
Return incorporation agreement from filing json. | def get_incorporation_agreement_json(filing):
return filing.json['filing']['incorporationApplication'].get('incorporationAgreement', {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_agreement(self):\n pass",
"def agreements():\n pass",
"def reconcile_somef_data(data):\n out = {}\n for key, value in data.items():\n # for now, we are not exporting provenance keys. Ignore all keys like somef_provenance\n if \"somef\" not in key:\n ... | [
"0.56559736",
"0.55618954",
"0.5244109",
"0.5151223",
"0.5143148",
"0.5112683",
"0.5045774",
"0.49902293",
"0.4906993",
"0.48691648",
"0.48342612",
"0.4829858",
"0.48195443",
"0.48008758",
"0.478164",
"0.47634107",
"0.47534582",
"0.47188726",
"0.47175965",
"0.4712452",
"0.465... | 0.7839245 | 0 |
Return name request from filing json. | def get_name_request_revision(filing):
return filing.json['filing']['incorporationApplication'].get('nameRequest', {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\r\n return self.data[\"name\"]",
"def name(self) -> str:\n\t\treturn self._raw_result['name']",
"def name(self):\n return self.raw.get(\"name\")",
"def name(self):\n return self._data.get('name')",
"def name(self):\n return self._data.get('name')",
"def name(se... | [
"0.6360576",
"0.614522",
"0.606821",
"0.60068506",
"0.60068506",
"0.60066885",
"0.6003148",
"0.5909763",
"0.5893203",
"0.5820227",
"0.57792675",
"0.5760327",
"0.5744369",
"0.571816",
"0.56807256",
"0.5665313",
"0.56221956",
"0.5590636",
"0.5578593",
"0.55743855",
"0.5563658",... | 0.64409065 | 0 |
Return contact point from filing json. | def get_contact_point_revision(filing):
return filing.json['filing']['incorporationApplication'].get('contactPoint', {}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contact_point(self) -> object:\n return self._contact_point",
"def get_contact_points(contact_points_path, json_name='contact_points.json',\n dataset_type='ycb', use_clustering=True,\n use_filter_penetration=True,\n inf_penetration_chec... | [
"0.6430361",
"0.63854986",
"0.59952515",
"0.59549403",
"0.5636144",
"0.55968314",
"0.5538288",
"0.544604",
"0.5436567",
"0.5314432",
"0.5294083",
"0.52843034",
"0.5142142",
"0.51301235",
"0.5117246",
"0.51044",
"0.50873756",
"0.5062358",
"0.5023777",
"0.50134194",
"0.5011443"... | 0.6746772 | 0 |
Given a sourceDirectory, returns the registered schema. MUST Register schema here! | def getSchema( sourceDirectory ):
if( sourceDirectory == settings.LEXISNEXIS_FILETAG ): return LexisNexisSchema()
raise Exception( "Filer for source <%s> is not registered in getSchema( source )." % ( sourceDirectory ) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_source_schema(cls) -> dict:\n source_schema = get_base_schema(\n root=True,\n id_=\"source.schema.json\",\n title=\"Source data schema\",\n description=\"Schema for the source data, files and directories\",\n version=\"0.1.0\",\n )\n ... | [
"0.65721476",
"0.6316953",
"0.6152082",
"0.59883946",
"0.59503275",
"0.58201414",
"0.562178",
"0.56007177",
"0.5588063",
"0.55684656",
"0.5486071",
"0.54797757",
"0.54383653",
"0.53457683",
"0.53429353",
"0.5330753",
"0.5323797",
"0.5298691",
"0.5294363",
"0.5268257",
"0.5266... | 0.77906126 | 0 |
This is the model_fn for nizza models. Subclasses should not override this function directly, but rather control its behavior by implementing `precompute()` and `compute_loss()` | def nizza_model_fn(self, features, mode, params):
precomputed = self.precompute(features, mode, params)
loss = self.compute_loss(features, mode, params, precomputed)
train_op = tf.contrib.layers.optimize_loss(
loss=loss,
global_step=tf.train.get_global_step(),
optimizer=tf.train.Adam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_loss(self, features, mode, params, precomputed):\n raise NotImplementedError(\"Model does not implement loss.\")",
"def model_fn(self, features, labels, mode, params, config):\n raise NotImplementedError()",
"def build_model_fn(self):\n # Define the model_fn we want to return\n ... | [
"0.6493121",
"0.64661187",
"0.63006353",
"0.6268264",
"0.6256369",
"0.62445",
"0.6237785",
"0.6226766",
"0.6207205",
"0.6190259",
"0.6169209",
"0.6139843",
"0.61165994",
"0.61126524",
"0.6089907",
"0.60873324",
"0.60776514",
"0.6052805",
"0.60448414",
"0.60442406",
"0.6020787... | 0.7382619 | 0 |
This is a helper function for alignment models for embeddings. This function returns an embedding for features[name] of size params.name_embed_size assuming a vocab size of params.name_vocab_size. features[feature_name] has to be an integer tensor of shape [batch_size, max_sequence_length]. | def embed(self, features, feature_name, params):
with tf.variable_scope("%s_embed" % feature_name):
embed_matrix = tf.get_variable("embedding_matrix",
[getattr(params, "%s_vocab_size" % feature_name),
getattr(params, "%s_embed_size" % feature_name)])
return tf.nn.embedding_look... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_embedding_layer(inputs_, vocab_size, embed_size):\n embedding = tf.Variable(tf.random_uniform((vocab_size, embed_size), -1, 1))\n embed = tf.nn.embedding_lookup(embedding, inputs_)\n \n return embed",
"def embed_features(batch, f_size):\n for f in range(Config.num_feature):\n ... | [
"0.6896678",
"0.66577274",
"0.6655466",
"0.6557072",
"0.6546917",
"0.6513097",
"0.6508412",
"0.6499041",
"0.648341",
"0.6480802",
"0.63810956",
"0.6362331",
"0.6333119",
"0.62890506",
"0.6286926",
"0.62582594",
"0.6158827",
"0.61498016",
"0.61458313",
"0.61418664",
"0.6091481... | 0.7802241 | 0 |
Computes the training loss for the alignment model. For example, you could implement crossentropy loss as loss_num, loss_den = common_utils.padded_cross_entropy( precomputed, features["targets"], params.label_smoothing) loss = loss_num / tf.maximum(1.0, loss_den) return loss assuming that precomputed holds the logits f... | def compute_loss(self, features, mode, params, precomputed):
raise NotImplementedError("Model does not implement loss.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_loss(self):\n self.test_logits = self.compute_logits()\n loss = tf.nn.sparse_softmax_cross_entropy_with_logits(\n labels=self.data.test_labels, logits=self.test_logits)\n cross_entropy_loss = tf.reduce_mean(loss)\n regularization = tf.reduce_sum(\n tf.get_collection(tf.GraphKe... | [
"0.712148",
"0.70395255",
"0.7023037",
"0.6964694",
"0.6878926",
"0.6830145",
"0.6824834",
"0.6801352",
"0.6765133",
"0.67370236",
"0.67324895",
"0.67233557",
"0.67031574",
"0.67031574",
"0.6662697",
"0.6619361",
"0.6566079",
"0.6541267",
"0.6530644",
"0.6516976",
"0.6510028"... | 0.7048177 | 1 |
The combination of penalty='l1' and loss='hinge' is not supported penalty='l2' and loss='hinge' is only supported when dual='true' penalty='l1' is only supported when dual='false'. | def _svm_loss_penalty_dual(name):
return hp.choice(name, [
('hinge', 'l2', True),
('squared_hinge', 'l2', True),
('squared_hinge', 'l1', False),
('squared_hinge', 'l2', False)
]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def l2_training_penalty(batched_out: base.Output):\n if isinstance(batched_out, base.OutputWithPrior):\n return 0.5 * jnp.mean(jnp.square(batched_out.train))\n else:\n logging.warning('L2 weight penalty only works for OutputWithPrior.')\n return 0.",
"def test_hinge_loss_backward():\n from your_cod... | [
"0.6574107",
"0.58923316",
"0.57923156",
"0.57098234",
"0.5634288",
"0.56300277",
"0.55809635",
"0.5567596",
"0.5531175",
"0.55264515",
"0.55053544",
"0.5501286",
"0.54875517",
"0.54657626",
"0.546015",
"0.54392153",
"0.5435707",
"0.5426929",
"0.54195803",
"0.5418796",
"0.538... | 0.75576925 | 0 |
Return a pyll graph with hyperparamters that will construct a sklearn.svm.SVC model with a user specified kernel. See help(hpsklearn.components._svm_hp_space) for info on additional SVM arguments. | def svc_kernel(name, kernel, random_state=None, probability=False, **kwargs):
def _name(msg):
return '%s.%s_%s' % (name, kernel, msg)
hp_space = _svm_hp_space(_name, kernel=kernel, **kwargs)
hp_space.update(_svc_hp_space(_name, random_state, probability))
return scope.sklearn_SVC(**hp_space) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_svm_hyperparams():\n NUM_ITERS = 10\n # coefs = np.arange(-5, 5).astype(np.float)\n coefs = np.linspace(0.25, 1, 10)\n Cs = np.power(2, coefs)\n results = []\n\n for _ in range(NUM_ITERS):\n data = FaceDataset(\"embeddings/dev\", n=50)\n train_data, train_labels = data.trai... | [
"0.73476094",
"0.70958614",
"0.6964052",
"0.67831784",
"0.67662734",
"0.66739416",
"0.65586966",
"0.64921445",
"0.64792943",
"0.63226485",
"0.6296224",
"0.62792623",
"0.610844",
"0.61017793",
"0.61011374",
"0.6083185",
"0.6076828",
"0.6073266",
"0.6069783",
"0.6007494",
"0.59... | 0.71698 | 1 |
Return a pyll graph with hyperparamters that will construct a sklearn.svm.SVR model with a user specified kernel. | def svr_kernel(name, kernel, epsilon=None, **kwargs):
def _name(msg):
return '%s.%s_%s' % (name, kernel, msg)
hp_space = _svm_hp_space(_name, kernel=kernel, **kwargs)
hp_space.update(_svr_hp_space(_name, epsilon))
return scope.sklearn_SVR(**hp_space) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def svm():",
"def __init__(self, kernel='poly', degree=3, verbose=False, gamma='auto', reg=1/1000, random_state=0):\n print(\"Initialize model SVM\")\n # Check if gamma='auto' is useful\n self.kernel = kernel\n self.random_state = random_state\n self.model = SVC(gamma=gamma, ke... | [
"0.69277614",
"0.6893122",
"0.68732125",
"0.6781692",
"0.6691403",
"0.6546042",
"0.64860064",
"0.6480777",
"0.6352892",
"0.632312",
"0.6207076",
"0.61844045",
"0.6074828",
"0.60648793",
"0.60161895",
"0.5979811",
"0.5845912",
"0.580389",
"0.57575077",
"0.5752655",
"0.5745429"... | 0.71148735 | 0 |
Update the remote entity attributes from the local attributes. | def update(self):
self.attributes = self.call('UPDATE', expect=error.OK, body=self.attributes) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self) -> None:\n self._api.update()\n if self.available:\n self._attr_native_value = self._api.data[self.entity_description.key]\n else:\n self._attr_native_value = None",
"def _async_update_attrs(self) -> None:\n self._attr_is_on = self.entity_descrip... | [
"0.62692803",
"0.58587396",
"0.5731269",
"0.5658316",
"0.5653894",
"0.5645511",
"0.56131625",
"0.5568307",
"0.5567129",
"0.55060637",
"0.54385704",
"0.54360443",
"0.5434658",
"0.5410549",
"0.5394486",
"0.5393542",
"0.5386407",
"0.5382385",
"0.5378643",
"0.5375315",
"0.5351614... | 0.6422116 | 0 |
Check a management response message for errors and correlation ID. | def check_response(response, expect=error.OK):
code = response.properties.get('statusCode')
if code != expect:
if 200 <= code <= 299:
raise ValueError("Response was %s(%s) but expected %s(%s): %s" % (
code, error.STATUS_TEXT[code], expect, error.STATUS_TEX... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_response_errors(self, resp):\n return True",
"def validate_reply(request, reply):\n assert isinstance(reply, dict) and 'id' in reply\n assert ('result' in reply) != ('error' in reply)\n assert reply['id'] == request['id'] or \\\n reply['id'] == '00' and 'error... | [
"0.63983744",
"0.6147145",
"0.6012438",
"0.5871563",
"0.5813378",
"0.5793791",
"0.579217",
"0.5788185",
"0.5732082",
"0.5707856",
"0.5679702",
"0.5675938",
"0.5664866",
"0.5634316",
"0.5605626",
"0.56005645",
"0.5583741",
"0.5568571",
"0.55622566",
"0.55569047",
"0.55382013",... | 0.61792576 | 1 |
Results as list of entities. | def get_entities(self, clean=False):
return list(self.iter_entities(clean=clean)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entities(self):\n return list(self._entities.values())",
"def entities(self):\n return self._entities",
"def fetch_all(self):\n return list(iter(self))",
"def _ProcessQueryResult(self, result):\n self.__more_results = result.more_results()\n\n if self.__keys_only:\n re... | [
"0.7450944",
"0.7289201",
"0.71123934",
"0.7064505",
"0.6879179",
"0.68518984",
"0.67838556",
"0.67776567",
"0.67633843",
"0.6654585",
"0.6624513",
"0.65606433",
"0.65234804",
"0.6501614",
"0.64880025",
"0.64698946",
"0.6461406",
"0.64253384",
"0.64148086",
"0.6390837",
"0.63... | 0.74944 | 0 |
Send an AMQP management query message and return the response. At least one of type, attribute_names must be specified. | def query(self, type=None, attribute_names=None, offset=None, count=None):
# There is a bug in proton (PROTON-1846) wherein we cannot ask for
# too many rows. So, as a safety we are going to ask only for
# MAX_ALLOWED_COUNT_PER_REQUEST. Since this is used by both qdstat
# and qdmanage, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exec_worker_query(self, endpoint, args, request):\n\n queue = self.iden\n args['endpoint'] = endpoint\n args['headers'] = dict(request.headers)\n client = Producer(queue_host=Config.get('queue', 'host'),\n queue_port=Config.getint('queue', 'port'),\n ... | [
"0.5666461",
"0.5519574",
"0.54946125",
"0.54469186",
"0.5337671",
"0.52884877",
"0.5221358",
"0.5207394",
"0.5201482",
"0.5199975",
"0.5172254",
"0.5171461",
"0.51697814",
"0.5079349",
"0.50026894",
"0.49766466",
"0.49718434",
"0.49627665",
"0.49605957",
"0.49461535",
"0.492... | 0.5581281 | 1 |
Create an entity. type and name can be specified in the attributes. | def create(self, attributes=None, type=None, name=None):
attributes = attributes or {}
type = type or attributes.get('type')
name = name or attributes.get('name')
request = self.request(operation='CREATE', type=type, name=name, body=attributes)
return Entity(self, self.call(reque... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_ent(self, classname: str, **kargs: ValidKVs) -> 'Entity':\n kargs['classname'] = classname\n ent = Entity(self, keys=kargs)\n self.add_ent(ent)\n return ent",
"def new_entity_type(name, client=default):\n data = {\"name\": name}\n return raw.create(\"entity-types\", d... | [
"0.72611463",
"0.69911486",
"0.68685687",
"0.67663044",
"0.6730212",
"0.6570471",
"0.65568805",
"0.65514016",
"0.64008546",
"0.6378404",
"0.6324603",
"0.6296172",
"0.62146676",
"0.6205613",
"0.6160402",
"0.6128596",
"0.6092469",
"0.6092469",
"0.60874885",
"0.6042646",
"0.5993... | 0.8365472 | 0 |
Read an AMQP entity. If both name and identity are specified, only identity is used. | def read(self, type=None, name=None, identity=None):
if name and identity:
name = None # Only specify one
request = self.request(operation='READ', type=type, name=name, identity=identity)
return Entity(self, self.call(request).body) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entity_by_name(self, entity_name):\n return Artifact.get_by_name(entity_name)",
"def get(entity, name=None, version=None, lineage=None):",
"def read(self, entity, content_type):\n return None",
"def entity(self, rawbase_name, entity_id):\n url = \"%s/record/%s?id=%s\" % (self.api... | [
"0.62228894",
"0.620416",
"0.58133674",
"0.5727325",
"0.5724071",
"0.5682123",
"0.5652508",
"0.5433038",
"0.5282821",
"0.5263503",
"0.51750666",
"0.51130986",
"0.5110109",
"0.50656855",
"0.5023652",
"0.500365",
"0.50004137",
"0.49858084",
"0.49682954",
"0.4962826",
"0.4862536... | 0.7346474 | 0 |
Update an entity with attributes. type, name and identity can be specified in the attributes. If both name and identity are specified, only identity is used. | def update(self, attributes, type=None, name=None, identity=None):
attributes = attributes or {}
type = type or attributes.get('type')
name = name or attributes.get('name')
identity = identity or attributes.get('identity')
if name and identity:
name = None # Only sen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, **values):\r\n if self.__abstract__:\r\n raise ThunderdomeException('cant update abstract elements')\r\n self.pre_update(**values)\r\n for key in values.keys():\r\n if key not in self._columns:\r\n raise TypeError(\"unrecognized attribute n... | [
"0.642415",
"0.6374976",
"0.6271963",
"0.62489027",
"0.6163514",
"0.61539215",
"0.6141256",
"0.606471",
"0.60338706",
"0.59787714",
"0.59568894",
"0.592971",
"0.5914256",
"0.59075946",
"0.5860035",
"0.5827293",
"0.5811051",
"0.5775297",
"0.57727534",
"0.5761102",
"0.57545567"... | 0.85509366 | 0 |
Delete the remote entity. If both name and identity are specified, only identity is used. | def delete(self, type=None, name=None, identity=None):
if name and identity:
name = None # Only specify one
request = self.request(operation='DELETE', type=type, name=name,
identity=identity)
self.call(request, expect=error.NO_CONTENT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_entity(self, owner_username, entity_relative_id):\n\t\treturn self._send_command_to_entity_server(us.SERVER_COMMAND_DELETE_ENTITY, owner_username + '|' + str(entity_relative_id))",
"def delete(self, name):\n err = C.git_remote_delete(self._repo._repo, to_bytes(name))\n check_error(err)",... | [
"0.6528239",
"0.62902176",
"0.62646383",
"0.6199844",
"0.6184214",
"0.60638714",
"0.6012517",
"0.6003652",
"0.59530914",
"0.5951121",
"0.5893608",
"0.5893519",
"0.5859471",
"0.5847694",
"0.5823332",
"0.58162194",
"0.58157164",
"0.5809494",
"0.5784756",
"0.5783919",
"0.5783919... | 0.68937683 | 0 |
The rating_list is already in time order return a 1 seq_len matrix | def rating_coding(self, rating_list, seq_len):
output = np.ones((1, seq_len)) * (-1)
if len(rating_list) > seq_len:
rating_list = rating_list[len(rating_list) - seq_len:]
for i in range(seq_len - len(rating_list), seq_len):
output[0, i] = self.movie2ratingid(rating_list[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left2vector(self, ratings):\n output = np.zeros((1, self.movieDim))\n for rating in ratings:\n output[0, self.movieID2index[rating[0]]] = rating[1]\n return output",
"def get_score_matrix(self) -> int:",
"def listening_count_to_rating(urm):\n for i in range(urm.shape[0]):... | [
"0.5722327",
"0.5500496",
"0.54548484",
"0.5454357",
"0.5429427",
"0.5396892",
"0.5340522",
"0.5305781",
"0.52911794",
"0.52710074",
"0.52710074",
"0.5269098",
"0.523033",
"0.5229637",
"0.52237904",
"0.5157594",
"0.5110092",
"0.510619",
"0.509394",
"0.5069315",
"0.5054868",
... | 0.66449964 | 0 |
Parse proj4 string and create a dictionary out of it | def parse_proj_string(proj_string):
regex_pattern = "(\+(\w+)=([A-Z\d+\w+\.]*))"
regex = re.compile(regex_pattern)
regex_results = regex.findall(proj_string)
proj_dict = {}
for proj_element in regex_results:
proj_dict[proj_element[1]] = proj_element[2]
return proj_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _proj4Proj(proj):\n if isinstance(proj, bytes):\n proj = proj.decode()\n if not isinstance(proj, str):\n return\n if proj.lower().startswith('proj4:'):\n proj = proj.split(':', 1)[1]\n if proj.lower().startswith('epsg:'):\n proj = NeededIn... | [
"0.6873182",
"0.6064661",
"0.6064661",
"0.5855108",
"0.582458",
"0.57799417",
"0.5713942",
"0.5708816",
"0.56618255",
"0.5651791",
"0.5435009",
"0.54001766",
"0.53807443",
"0.5372783",
"0.5320022",
"0.53102314",
"0.53064334",
"0.53042746",
"0.52941704",
"0.5279955",
"0.526814... | 0.7964794 | 0 |
Transform (Rasterio) geotiff meta dictionary to pyresample area definition | def geotiff_meta_to_areadef(meta):
area_id = ""
name = ""
proj_id = "Generated from GeoTIFF"
proj_dict = meta['crs']
proj_dict_with_string_values = dict(zip([str(key) for key in proj_dict.keys()], [str(value) for value in proj_dict.values()]))
x_size = meta['width']
x_res = meta['transform']... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_meta_from_wrf( ds ):\n import pyproj, rasterio\n\n wgs84 = pyproj.Proj( '+units=m +proj=latlong +datum=WGS84' )\n pargs = dict()\n # get some metadata from the RAW WRF file we got from Peter.\n cen_lon = ds.CEN_LON\n cen_lat = ds.CEN_LAT\n dx = ds.DX\n dy = ds.DY\n pargs['lat_1']... | [
"0.56938297",
"0.5444017",
"0.5412894",
"0.5374239",
"0.5367224",
"0.53590244",
"0.5350049",
"0.5344032",
"0.53003776",
"0.526953",
"0.52409095",
"0.5237224",
"0.5235499",
"0.52294",
"0.5228723",
"0.51985055",
"0.51663595",
"0.5160842",
"0.5151635",
"0.5138923",
"0.5138923",
... | 0.76776683 | 0 |
Save the record in a bulkbuffer. Also, flush the buffer by saving its content to Splunk when the buffer size exceeds configured self._buffer_size | def write(self, record):
# Make Splunk ready payload data and append it to self._buffers list.
self._buffer.append({
'index': self._index,
'sourcetype': 'json',
'event': record
})
# If the records count in self._buffer is more than allowed by
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _flush(self):\n buffer_len = len(self._buffer)\n\n if buffer_len == 0:\n _log.info('No pending records to index; URI: %s; index: %s',\n self._uri, self._index)\n return\n\n _log.info('Indexing %d records; URI: %s; index: %s ...',\n ... | [
"0.6441635",
"0.60757685",
"0.6013589",
"0.6002337",
"0.59962714",
"0.5938248",
"0.5889271",
"0.5862441",
"0.58550036",
"0.5659928",
"0.564264",
"0.5625408",
"0.5602134",
"0.5580345",
"0.5546973",
"0.5546801",
"0.5543745",
"0.54664934",
"0.5465568",
"0.5460882",
"0.5445714",
... | 0.6554746 | 0 |
Windows specific version of getch. Special keys like arrows actually post two key events. If you want to use these keys you can create a dictionary and return the result of looking up the appropriate second key within the if block. | def _getch_windows(prompt):
print(prompt, end="")
key = msvcrt.getch()
if ord(key) == 224:
key = msvcrt.getch()
return key
print(key.decode())
return key.decode() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_key_press():\n return ord(getch.getch());",
"def _getch_windows(prompt):\n\tprint(prompt, end=\"\")\n\tkey = msvcrt.getch()\n\tif ord(key) == 224:\n\t\tkey = msvcrt.getch()\n\t\treturn key\n\tprint(key.decode())\n\treturn key.decode()",
"def get_input(self):\n try:\n char = self.sc... | [
"0.7330238",
"0.72014165",
"0.6819026",
"0.6753253",
"0.64544827",
"0.6429468",
"0.634012",
"0.6334296",
"0.6330903",
"0.6315383",
"0.62986517",
"0.62607694",
"0.6247113",
"0.6173776",
"0.61598206",
"0.60886425",
"0.60829335",
"0.60615426",
"0.60125107",
"0.5976557",
"0.59730... | 0.7368495 | 0 |
Linux specific version of getch. | def _getch_linux(prompt):
print(prompt, end="")
sys.stdout.flush()
fd = sys.stdin.fileno()
old = termios.tcgetattr(fd)
new = termios.tcgetattr(fd)
new[3] = new[3] & ~termios.ICANON & ~termios.ECHO
new[6][termios.VMIN] = 1
new[6][termios.VTIME] = 0
termios.tcsetattr(fd, termios.TCSANO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getch_linux(prompt):\n\tprint(prompt, end=\"\")\n\tsys.stdout.flush()\n\tfd = sys.stdin.fileno()\n\told = termios.tcgetattr(fd)\n\tnew = termios.tcgetattr(fd)\n\tnew[3] = new[3] & ~termios.ICANON & ~termios.ECHO\n\tnew[6][termios.VMIN] = 1\n\tnew[6][termios.VTIME] = 0\n\ttermios.tcsetattr(fd, termios.TCSANOW,... | [
"0.6580795",
"0.600784",
"0.5912592",
"0.58335704",
"0.57894963",
"0.5648049",
"0.56449205",
"0.56109875",
"0.55676854",
"0.5544848",
"0.54586834",
"0.53401434",
"0.53044146",
"0.5304004",
"0.5300996",
"0.5259408",
"0.5229581",
"0.5158003",
"0.49587855",
"0.4835934",
"0.47297... | 0.63425136 | 1 |
Return the column from the grid at column_index as a list. | def get_column(grid, column_index):
return [row[column_index] for row in grid] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_column(grid, column_index):\n\treturn [row[column_index] for row in grid]",
"def column(self, index):\n result = []\n for col in self.data:\n result.append(col[index])\n return result",
"def column(self, index: int) -> List[int]:\n return [x[index - 1] for x in se... | [
"0.89470553",
"0.8450442",
"0.81118757",
"0.78952646",
"0.75983846",
"0.7451289",
"0.73715085",
"0.7209294",
"0.71991056",
"0.7171867",
"0.7042811",
"0.69441384",
"0.6866465",
"0.68610626",
"0.6849367",
"0.683718",
"0.6781807",
"0.6746657",
"0.66863",
"0.6637373",
"0.6564681"... | 0.8921025 | 1 |
Replace the values in the grid at column_index with the values in new. The grid is changed inplace. | def set_column(grid, column_index, new):
for i,row in enumerate(grid):
row[column_index] = new[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_column(grid, column_index, new):\n\tfor i,row in enumerate(grid):\n\t\trow[column_index] = new[i]",
"def update_positions(self, grid):\r\n self.grid = grid",
"def map (a_data,a_column,a_old,a_new) :\n loc_new_data = a_data\n a_data[a_column].replace(a_old,a_new,inplace=True)",
"def _swit... | [
"0.76025754",
"0.60900813",
"0.59735054",
"0.59235686",
"0.58712214",
"0.569676",
"0.5643494",
"0.5593835",
"0.55842495",
"0.5554945",
"0.55202717",
"0.54953027",
"0.54953027",
"0.5490993",
"0.54732704",
"0.5437195",
"0.54323137",
"0.54323137",
"0.54323137",
"0.54083097",
"0.... | 0.75669354 | 1 |
Perform a vertical shift on all columns. Pass up=True for up and up=False for down. The grid will be changed inplace. | def push_all_columns(grid, up=True):
r = 0
for i,val in enumerate(grid[0]):
column = get_column(grid, i)
new, r_ = push_row(column, up)
r += r_
set_column(grid, i, new)
return r | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def push_all_columns(grid, up=True):\n\tfor i,val in enumerate(grid[0]):\n\t\tcolumn = get_column(grid, i)\n\t\tnew = push_row(column, up)\n\t\tset_column(grid, i, new)",
"def expand(self, right=0, down=0, left=0, up=0):\n self.min_col -= left\n self.min_row -= up\n self.max_col += right\n ... | [
"0.6787514",
"0.63330275",
"0.62566",
"0.60964894",
"0.59969014",
"0.59673285",
"0.59260863",
"0.5910102",
"0.58406526",
"0.5828836",
"0.578919",
"0.57400197",
"0.57400197",
"0.56714576",
"0.56558293",
"0.56536555",
"0.56502515",
"0.5644719",
"0.5620115",
"0.56125003",
"0.559... | 0.6490686 | 1 |
Return a list of coordinate pairs corresponding to empty cells. | def get_empty_cells(grid):
empty = []
for j,row in enumerate(grid):
for i,val in enumerate(row):
if not val:
empty.append((j,i))
return empty | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_empty_cells(grid):\n\tempty = []\n\tfor j,row in enumerate(grid):\n\t\tfor i,val in enumerate(row):\n\t\t\tif not val:\n\t\t\t\tempty.append((j,i))\n\treturn empty",
"def empty_cells(state):\r\n cells = []\r\n for x, row in enumerate(state):\r\n for y, cell in enumerate(row):\r\n ... | [
"0.82954764",
"0.8106722",
"0.7881721",
"0.78399885",
"0.7816201",
"0.7774224",
"0.76896685",
"0.7566796",
"0.75358933",
"0.7367822",
"0.7362139",
"0.7313527",
"0.72766584",
"0.7221659",
"0.7109574",
"0.7071009",
"0.7039268",
"0.6926364",
"0.6887955",
"0.68496126",
"0.6788944... | 0.82016677 | 1 |
Get the system user id of given `user`. | def _get_uid(self, user):
if not isinstance(user, int):
user = pwd.getpwnam(user).pw_uid
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_id(self, user):\n\n found_user = self.search(user)\n\n if found_user:\n return found_user[\"data\"][0][\"id\"]\n else:\n raise UserNotFound(\"User \" + user + \" not found.\")",
"def get_user_id():\n return os.getuid()",
"def _get_user_id(self, user: O... | [
"0.78394127",
"0.72201926",
"0.7206051",
"0.71757543",
"0.69904256",
"0.69616765",
"0.69289255",
"0.6870075",
"0.6840206",
"0.67820036",
"0.6742118",
"0.6731155",
"0.6718753",
"0.671598",
"0.6700523",
"0.6700523",
"0.6679785",
"0.6679785",
"0.663261",
"0.66112316",
"0.6611231... | 0.72854525 | 1 |
Get the system user name of given `uid`. | def _get_uname(self, uid):
try:
return pwd.getpwuid(uid).pw_name
except KeyError:
return uid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_user_name():\n return pwd.getpwuid(os.getuid())[0]",
"def get_user_name():\r\n if _user_name_override is not None:\r\n return _user_name_override\r\n elif platform.system() == \"Windows\":\r\n return os.getlogin()\r\n elif platform.system() == \"Linux\":\r\n try:\r\n ... | [
"0.77526003",
"0.74957865",
"0.72558403",
"0.72035503",
"0.7141105",
"0.7099099",
"0.7032858",
"0.69628805",
"0.6834799",
"0.67754704",
"0.6650063",
"0.66139495",
"0.66045195",
"0.6583292",
"0.6566232",
"0.65561146",
"0.6542888",
"0.65071654",
"0.6469562",
"0.64543766",
"0.64... | 0.8196208 | 0 |
Check whether `path` is owned by `owner`, and it has the `mode`. | def _require_owner_mod(self, path, owner, mode, must_exist=False):
if not os.path.exists(path):
if must_exist:
self.logger.warning('"%(path)s" is required but not exist.' %
{'path': path})
return
# get uid and file mode
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_same_owner(path):\n try:\n assert find_owner(path) == getuser(), f\"{path} must be owned by {getuser()}\"\n except AssertionError as error:\n raise click.UsageError(str(error))\n except FileNotFoundError:\n pass",
"def check_perms(resource):\r\n stmode = os.stat(resour... | [
"0.665854",
"0.6358101",
"0.6358101",
"0.6148049",
"0.592861",
"0.5894546",
"0.5885529",
"0.58449787",
"0.582066",
"0.5792091",
"0.5770554",
"0.57237005",
"0.57046616",
"0.5663423",
"0.5608839",
"0.5608839",
"0.56082845",
"0.560709",
"0.55715185",
"0.55554926",
"0.5518401",
... | 0.68992776 | 0 |
Sets space 1. Used for the player to take and place chips | def setS1(self, num):
self.space1 = num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def give_space(self):\r\n pen.forward(20)",
"def setS2(self, num):\n self.space2 = num",
"def setS4(self, num):\n self.space4 = num",
"def setupNewGame(self):\r\n self.level = 1\r\n self.num_cows = 2\r\n self.num_farmers = 1\r\n self.levelHeading = Text(self.gameDispl... | [
"0.648908",
"0.6256856",
"0.622479",
"0.59005326",
"0.5855918",
"0.584492",
"0.5798336",
"0.5775155",
"0.5761521",
"0.5757626",
"0.56840444",
"0.567584",
"0.5667802",
"0.5648039",
"0.56433135",
"0.562361",
"0.5606193",
"0.55980283",
"0.559422",
"0.5589287",
"0.5579349",
"0.... | 0.69900984 | 0 |
Sets space 2. Used for the player to take and place chips | def setS2(self, num):
self.space2 = num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPlayerTwo(self, boardSize):\n mid = int(boardSize / 2)\n for i in range(mid, boardSize):\n for j in range(mid, i + 1):\n temp = i - j\n x = i\n y = boardSize - 1 - temp\n self.addPion(Pion.Pion(self.noPlayer, Posisi.Posisi(... | [
"0.609539",
"0.59154177",
"0.5838363",
"0.5738315",
"0.55881906",
"0.5528215",
"0.5527765",
"0.5523904",
"0.54916984",
"0.548473",
"0.54332143",
"0.54312956",
"0.54301214",
"0.5429926",
"0.54089487",
"0.539706",
"0.5370935",
"0.53638",
"0.53439146",
"0.53387654",
"0.5334625",... | 0.6854359 | 0 |
Sets space 3. Used for the player to take and place chips | def setS3(self, num):
self.space3 = num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSpace(*args):",
"def give_space(self):\r\n pen.forward(20)",
"def set_position(self, x, y, z):\n for sec in self.all:\n for i in range(int(nrn.n3d())):\n nrn.pt3dchange(i, \\\n x-self.x+nrn.x3d(i), \\\n y... | [
"0.5924214",
"0.58395326",
"0.574476",
"0.5617801",
"0.5536231",
"0.5511567",
"0.55061364",
"0.5446015",
"0.5417021",
"0.5370311",
"0.53616726",
"0.5321982",
"0.5320206",
"0.53100693",
"0.5288594",
"0.52832794",
"0.5230901",
"0.52031595",
"0.5191511",
"0.5171889",
"0.5143608"... | 0.67878133 | 0 |
Sets space 4. Used for the player to take and place chips | def setS4(self, num):
self.space4 = num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def give_space(self):\r\n pen.forward(20)",
"def resetBoard(self):\n self.space1 = 0\n self.space2 = 0\n self.space3 = 0\n self.space4 = 0\n self.space5 = 0\n self.space6 = 0",
"def setS5(self, num):\n self.space5 = num",
"def setSpace(*args):",
"def spacing(self, spacing):\n\n ... | [
"0.64468443",
"0.6064833",
"0.598866",
"0.59127885",
"0.576141",
"0.57233346",
"0.57063156",
"0.5673211",
"0.56223977",
"0.55711496",
"0.5570859",
"0.5567136",
"0.5544356",
"0.55372965",
"0.5534279",
"0.55292845",
"0.55286235",
"0.54391205",
"0.5392329",
"0.5385134",
"0.53777... | 0.7290923 | 0 |
Sets space 5. Used for the player to take and place chips | def setS5(self, num):
self.space5 = num | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def give_space(self):\r\n pen.forward(20)",
"def setS4(self, num):\n self.space4 = num",
"def addS6(self):\n self.space6 += 1",
"def resetBoard(self):\n self.space1 = 0\n self.space2 = 0\n self.space3 = 0\n self.space4 = 0\n self.space5 = 0\n self.space6 = 0",
"def setS1(self... | [
"0.6360752",
"0.6360656",
"0.60956097",
"0.6004102",
"0.591427",
"0.5885007",
"0.5881092",
"0.58527756",
"0.5836404",
"0.58263266",
"0.57794124",
"0.56868494",
"0.5658177",
"0.56414497",
"0.5613952",
"0.55858064",
"0.55542696",
"0.5495327",
"0.5483208",
"0.54149437",
"0.54116... | 0.7593468 | 0 |
Adds to space 6 since none can be taken from this space. | def addS6(self):
self.space6 += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, num):\n self.__reserved_members = [Virus() for _ in range(num)]",
"def part_6():\n\n raise NotImplementedError",
"def add_objects_to_space(self):\n self.anti_spacecraft.add_to_space(self.space) # Anti-spacecraft Parts (represent the whole vehicle)\n self.space.add(self.sp... | [
"0.53742313",
"0.5356937",
"0.5167358",
"0.515593",
"0.5112406",
"0.5082839",
"0.5044318",
"0.49988443",
"0.49928892",
"0.49881366",
"0.4977138",
"0.49732727",
"0.49399695",
"0.4932652",
"0.4932652",
"0.4932652",
"0.4887998",
"0.48813823",
"0.48692477",
"0.4863233",
"0.485088... | 0.79343045 | 0 |
Adds the players to a list and sorts them by who had the lowest initial dice rolls and if there are people who had the same dice roll it returns a false which gets the main client code to prompt the player class to reroll its initial roll | def addPlayers(self, player):
if len(self.playerList) == 0:
self.playerList.append(player)
else:
i = 0
for item in self.playerList:
if player.compareTo(item) == -1:
self.playerList.insert(i,player)
return(True)
elif player.compareTo(item) == 0:
pla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sixteen_is_dead(players):\n \n number = setup_number_of_dices()\n faces = setup_number_of_faces()\n result_list = []\n for player in range(1, players+1):\n total_points = 0\n while total_points < 16:\n user_input = user_interface(player)\n if user_input == \"\... | [
"0.6164179",
"0.59093684",
"0.58791447",
"0.58399826",
"0.5808645",
"0.5789685",
"0.5758518",
"0.57551587",
"0.574693",
"0.57403266",
"0.57224333",
"0.5636663",
"0.56151736",
"0.5586196",
"0.55676913",
"0.5547949",
"0.55419695",
"0.5520167",
"0.55043435",
"0.5502129",
"0.5489... | 0.6229501 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.