query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Check if the given user has permissions delete comments in the blog Nomembers (membership==None) considered to have no rights. | def check_can_delete_comments(membership):
if membership is not None and not membership.is_left():
return membership.can_delete_comments()
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_can_delete_posts(membership):\n if membership is not None and not membership.is_left():\n return membership.can_delete_posts()\n else:\n return False",
"def can_delete_comment(comment, user):\r\n if user.is_staff or user.is_superuser:\r\n return True\r\n ... | [
"0.723269",
"0.6997169",
"0.651881",
"0.6411024",
"0.6285288",
"0.62087744",
"0.62018156",
"0.61553687",
"0.6151497",
"0.6150228",
"0.61200863",
"0.6069862",
"0.6069862",
"0.60664016",
"0.6063829",
"0.6015258",
"0.6014622",
"0.601289",
"0.5997717",
"0.59741014",
"0.5951961",
... | 0.784091 | 0 |
Check if the given user has permissions to add posts to this blog | def check_can_post(self, user):
if not user.is_active or user.is_anonymous():
return False
membership = self.check_membership(user)
if ((self.type != 'O' or self.post_membership_required or self.post_admin_required) and
(membership is None or
member... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_add_permission(self, request):\n return request.user.is_superuser or super().has_add_permission(request)",
"def check_permission(self, action, username, resource, perm):\n if not resource:\n return\n if resource.realm == 'blog' and resource.id:\n the_post = Blog... | [
"0.7474568",
"0.74464935",
"0.7315883",
"0.7249627",
"0.7249627",
"0.7216329",
"0.7216329",
"0.7198394",
"0.7198394",
"0.713924",
"0.70996654",
"0.708064",
"0.70770514",
"0.7046714",
"0.6993291",
"0.6969549",
"0.6857705",
"0.6837688",
"0.6837688",
"0.6837688",
"0.68241686",
... | 0.7027354 | 14 |
Check if the given user has permissions to add comments to this blog | def check_can_comment(self, user):
if not user.is_active or user.is_anonymous():
return False
membership = self.check_membership(user)
if ((self.type != 'O' or self.comment_membership_required) and
(membership is None or
membership.is_banned() or
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_object_permission(self, request, view, obj):\n\n # Users can always see and edit their own comments\n if obj.create_user == request.user:\n return True\n\n # And see but not edit those from their others in their own\n # organization\n if obj.create_user.organiz... | [
"0.7184772",
"0.71361125",
"0.71345925",
"0.7096219",
"0.6988791",
"0.6936903",
"0.69043106",
"0.68605214",
"0.6824901",
"0.6814687",
"0.6782642",
"0.6615401",
"0.6608074",
"0.65894634",
"0.65786886",
"0.65604955",
"0.65604955",
"0.6537028",
"0.6537028",
"0.6537028",
"0.65358... | 0.71554816 | 1 |
Checks if the user can join the blog Note that joining process should go through the special method. Note also that this method returns `True` for blogs with manual approval required. | def check_can_join(self, user):
if not user.is_active or user.is_anonymous():
return False
membership = self.check_membership(user)
if membership is not None and not membership.is_left():
return False # Already joined
if self.join_condition == 'A':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join(self, user, role=None):\n if self.check_can_join(user) or role is not None:\n membership, c = Membership.objects.get_or_create(user=user, blog=self)\n if c:\n post_rating = PostVote.objects.filter(object__author=user, object__blog=self).score()\n ... | [
"0.67377913",
"0.66194767",
"0.6566953",
"0.6566953",
"0.6566953",
"0.653689",
"0.65266365",
"0.6427925",
"0.64022386",
"0.6291846",
"0.62525475",
"0.6250671",
"0.6250671",
"0.6250671",
"0.6243101",
"0.6219995",
"0.619222",
"0.6188215",
"0.6186493",
"0.6175812",
"0.61413354",... | 0.73284477 | 0 |
String for representing the Model object. | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
String for representing the Model object (in Admin site etc.) | def __str__(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return '%s%s' % (self.name, ' - %s' % self.model if self.model else '')",
"def __str__(self):\n model = self._meta.verbose_name.title()\n return f\"{model:s}: {self.name:s}\"",
"def __str_... | [
"0.7802202",
"0.7711799",
"0.7674433",
"0.7674433",
"0.752465",
"0.7403027",
"0.7398214",
"0.7378213",
"0.7327721",
"0.7271377",
"0.72439706",
"0.7235207",
"0.72073966",
"0.71746266",
"0.71665883",
"0.7110483",
"0.70384824",
"0.70384824",
"0.7012211",
"0.69870925",
"0.6968247... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return self.title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.8236402",
"0.79899704",
"0.7847493",
"0.7846091",
"0.7750677",
"0.762421",
"0.762421",
"0.7623445",
"0.7623445",
"0.7547878",
"0.75219196",
"0.7469617",
"0.7468823",
"0.7445783",
"0.7445783",
"0.7429821",
"0.7426174",
"0.7389077",
"0.73497665",
"0.7340129",
"0.73219186",
... | 0.0 | -1 |
Returns the url to access a detail record for this injury. | def get_absolute_url(self):
return reverse('bleedinfo-detail', args=[str(self.id)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return reverse('injury-detail', args=[str(self.id)])",
"def get_absolute_url(self):\n return reverse(\"jewelry_detail\", args = [str(self.id)])",
"def details_url(self):\n if self._data.get('details_url'):\n path = self._data.get('details_url')\n ... | [
"0.7073692",
"0.6999588",
"0.69653976",
"0.6759536",
"0.6619313",
"0.6589582",
"0.65138644",
"0.6467399",
"0.6467399",
"0.6399804",
"0.638207",
"0.63716835",
"0.6354455",
"0.63493323",
"0.62990445",
"0.6286036",
"0.6284344",
"0.62812483",
"0.62595403",
"0.6231972",
"0.6220524... | 0.64515024 | 9 |
String for representing the Model object. | def __str__(self):
return self.title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Returns the url to access a detail record for this injury. | def get_absolute_url(self):
return reverse('injury-detail', args=[str(self.id)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return reverse(\"jewelry_detail\", args = [str(self.id)])",
"def details_url(self):\n if self._data.get('details_url'):\n path = self._data.get('details_url')\n try:\n path, hash_ = path.split('#')\n hash_ = '#' + has... | [
"0.69980395",
"0.69633394",
"0.6758284",
"0.66189903",
"0.6588964",
"0.6512662",
"0.64651656",
"0.64651656",
"0.6450233",
"0.6397388",
"0.6382602",
"0.637055",
"0.6354602",
"0.6346269",
"0.62967193",
"0.62843674",
"0.62832063",
"0.62775266",
"0.62584555",
"0.62308043",
"0.621... | 0.7072419 | 0 |
Create a string for the Genre. This is required to display genre in Admin. | def display_injury_type(self):
return ', '.join(type_of_injury.name for genre in self.type_of_injury.all()[:3]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_genre(self):\n \n # Get first 3 genres and join to a string.\n return ', '.join([ genre.name for genre in self.genre.all()[:3] ])",
"def display_genre(self):\n\n\t\treturn ', '.join(genre.name for genre in self.genre.all()[:3])",
"def add_genre(request):\n\tif request.method =... | [
"0.7103225",
"0.68971926",
"0.68660194",
"0.6831769",
"0.67917305",
"0.6764569",
"0.6721592",
"0.67126375",
"0.6579803",
"0.65513444",
"0.65331054",
"0.6464626",
"0.6461136",
"0.6457999",
"0.6445",
"0.6142628",
"0.6134151",
"0.60860276",
"0.6040892",
"0.6019959",
"0.60043347"... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return self.title | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Returns the url to access a detail record for this book. | def get_absolute_url(self):
return reverse('book-detail', args=[str(self.id)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_absolute_url(self):\n return reverse('book-detail', args=[str(self.id)]) \n # Returns an URL that can be used to access a detail record for this model \n # (for this to work we will have to \n # -- Define a URL mapping that has the name 'book-detail' (name='book-detail')\n ... | [
"0.77006745",
"0.76134276",
"0.71197015",
"0.69947064",
"0.69518226",
"0.6938773",
"0.6845785",
"0.6590401",
"0.654268",
"0.65400743",
"0.6464381",
"0.6443594",
"0.6431019",
"0.6430846",
"0.64146614",
"0.6406946",
"0.63889843",
"0.6365317",
"0.6365317",
"0.6357425",
"0.635742... | 0.7260556 | 2 |
Create a string for the Genre. This is required to display genre in Admin. | def display_genre(self):
return ', '.join(genre.name for genre in self.genre.all()[:3]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_genre(self):\n \n # Get first 3 genres and join to a string.\n return ', '.join([ genre.name for genre in self.genre.all()[:3] ])",
"def display_genre(self):\n\n\t\treturn ', '.join(genre.name for genre in self.genre.all()[:3])",
"def add_genre(request):\n\tif request.method =... | [
"0.7101087",
"0.6894888",
"0.68674725",
"0.68306917",
"0.67894596",
"0.6722814",
"0.671151",
"0.65781707",
"0.655101",
"0.65311456",
"0.64684707",
"0.6463993",
"0.645929",
"0.6447288",
"0.6143433",
"0.61355335",
"0.60892785",
"0.604131",
"0.60220075",
"0.6002638",
"0.5959059"... | 0.6762231 | 5 |
String for representing the Model object. | def __str__(self):
return f'{self.id} ({self.book.title})' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.8236402",
"0.79899704",
"0.7847493",
"0.7846091",
"0.7750677",
"0.762421",
"0.762421",
"0.7623445",
"0.7623445",
"0.7547878",
"0.75219196",
"0.7469617",
"0.7468823",
"0.7445783",
"0.7445783",
"0.7429821",
"0.7426174",
"0.7389077",
"0.73497665",
"0.7340129",
"0.73219186",
... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return f'{self.id} ({self.book.title})' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return f'{self.last_name}, {self.first_name}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.8237102",
"0.79895926",
"0.78485906",
"0.7846189",
"0.77511",
"0.76247364",
"0.76247364",
"0.7622933",
"0.7622933",
"0.7547188",
"0.75233495",
"0.74708194",
"0.7470042",
"0.74472684",
"0.74472684",
"0.7431884",
"0.74270374",
"0.73904866",
"0.7351086",
"0.7342717",
"0.73235... | 0.0 | -1 |
String for representing the Model object. | def __str__(self):
return f'{self.last_name}, {self.first_name}' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return super().__str__() + self.model.__str__()",
"def __str__(self):\n return \"DataModel(name={},attributes={},description={})\".format(\n self.name, {a.name: str(a) for a in self.attributes}, self.description\n )",
"def __str__(self):\n \n res =... | [
"0.82368803",
"0.79901737",
"0.7849152",
"0.78468513",
"0.77520275",
"0.7625378",
"0.7625378",
"0.76225406",
"0.76225406",
"0.75483394",
"0.7522958",
"0.7470355",
"0.7469358",
"0.7447144",
"0.7447144",
"0.74314755",
"0.7427648",
"0.7389925",
"0.7351721",
"0.73424315",
"0.7322... | 0.0 | -1 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in range(0, len(l), n):
yield l[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038813",
"0.79248375",
"0.7923423",
"0.7885103",
"0.78773195",
"0.7815877",
"0.77655786",
"0.77556044",
"0.77441615",
"0.7731815",
"0.77288336",
"0.772473",
"0.77028215",
"0.76889825",
"0.76889825",
"0.7664208",
"0.76570904",
"0.7655856",
"0.7655856",
"0.76458347",
"0.764... | 0.7448925 | 71 |
The role management policy name. | def name(self) -> pulumi.Output[str]:
return pulumi.get(self, "name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def role_management_policy_assignment_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"role_management_policy_assignment_name\")",
"def policy_name(self):\n return self._policy_name",
"def policy_name(self) -> Optional[str]:\n return pulumi.get(self, \"policy_name\")"... | [
"0.7809514",
"0.7721111",
"0.7585177",
"0.7585177",
"0.747349",
"0.7451607",
"0.7450519",
"0.7427982",
"0.73612803",
"0.73612803",
"0.73612803",
"0.73612803",
"0.73612803",
"0.73612803",
"0.73612803",
"0.6951396",
"0.6808217",
"0.680751",
"0.673182",
"0.66732365",
"0.6552239"... | 0.0 | -1 |
The role management policy type. | def type(self) -> pulumi.Output[str]:
return pulumi.get(self, "type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"policy_type\")",
"def policy_type(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"policy_type\")",
"def policy_type(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"policy_type\")",
"def pol... | [
"0.73519444",
"0.7210269",
"0.7164856",
"0.68844867",
"0.67646295",
"0.6189584",
"0.60447127",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",
"0.6035742",... | 0.0 | -1 |
trim words number to num | def trim_words(word_set, data_sets, num):
word_dict = {}
for data in data_sets:
for word_list, _ in data:
for word in word_list:
if word not in word_set:
continue
if word in word_dict:
word_dict[word] += 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeNumbers(self, words):\n\t\treturn re.sub(r'\\d', '', words)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
... | [
"0.75503",
"0.6658466",
"0.6658466",
"0.6658466",
"0.66522586",
"0.65976715",
"0.65976715",
"0.659086",
"0.6578496",
"0.6530361",
"0.6519293",
"0.64790225",
"0.6470576",
"0.6437201",
"0.6435292",
"0.6399585",
"0.6395522",
"0.63547343",
"0.63115805",
"0.63107866",
"0.6303208",... | 0.0 | -1 |
Builds a single dockercompose entry for a given serverless function. Includes the volumes mapping as well as the basic info of the function. Also, if the function has a given requirements file definition, the file will be included as part of the volumes mapping. | def _build_compose_section(ctx, template, name, sls_function):
def get_vol(include):
name = include[include.rindex('/') + 1:]
return f' - {include}:/var/task/common/{name}'
output_dir = ctx.get('package', {}).get('output', DEFAULT_OUT_DIR)
volumes = [
f' - {output_dir}:/v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_compose(logger, ctx):\n\n compose = '\\n'.join([_get_compose_header(ctx), _get_compose_sections(ctx)])\n\n # Returns the name of the temp file that has the docker-compose definition.\n return write_tmp_file(compose)",
"def build(project_name, compose_file, container, container_dir_to_copy, env... | [
"0.5717083",
"0.5686376",
"0.52104664",
"0.5145279",
"0.5071374",
"0.506673",
"0.50457203",
"0.50289404",
"0.49996883",
"0.49955153",
"0.49622178",
"0.4958057",
"0.49479413",
"0.4904515",
"0.48939568",
"0.48725942",
"0.48200387",
"0.48108912",
"0.47941154",
"0.47872984",
"0.4... | 0.69342184 | 0 |
Creates DF with pairs for firecloud metadata export. | def create_pairs_list(all_samples):
dfs = []
# Find match normals for tumor samples only
tumor_samples = all_samples[all_samples.sample_type=="Tumor"]
i = 0
for index, row in tumor_samples.iterrows():
# Find all samples from same individual (same individual_id, different sample_id)
p... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_metadata(data_dir):\n pool = multiprocessing.Pool()\n raw_feature_paths = [os.path.join(data_dir, \"features.jsonl\")]\n records = list(pool.imap(read_metadata_record, raw_feature_iterator(raw_feature_paths)))\n records = [dict(record, **{\"subset\": \"train\"}) for record in records]\n\n ... | [
"0.6295725",
"0.60453296",
"0.602557",
"0.596953",
"0.59174734",
"0.5897661",
"0.58661073",
"0.58466095",
"0.5818278",
"0.577028",
"0.57485986",
"0.5725341",
"0.5710208",
"0.56612116",
"0.56213826",
"0.5597888",
"0.55692804",
"0.5566143",
"0.5562297",
"0.5555632",
"0.5530969"... | 0.0 | -1 |
Return the topologically ordered strongly connected components of a bipartite graph, projected with respect to a perfect matching The provided undirected bipartite graph is projected into a directed graph on the set of "top nodes" by treating "matched edges" as outedges and "unmatched edges" as inedges. Then the strong... | def get_scc_of_projection(graph, top_nodes, matching=None):
nxb = nx.algorithms.bipartite
nxd = nx.algorithms.dag
if not nxb.is_bipartite(graph):
raise RuntimeError("Provided graph is not bipartite.")
M = len(top_nodes)
N = len(graph.nodes) - M
if M != N:
raise RuntimeError(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connected_components(graph):\n all_nodes = list(graph.keys())\n\n counter = 0\n explored = set()\n components = []\n for node in all_nodes:\n if node not in explored:\n counter += 1\n visited = bfs(graph, node)\n components.append(visited)\n exp... | [
"0.6458638",
"0.6376185",
"0.6351065",
"0.62924886",
"0.62744546",
"0.6272589",
"0.6262599",
"0.6245195",
"0.6230444",
"0.62255967",
"0.62090117",
"0.6189237",
"0.6171968",
"0.6171414",
"0.6112079",
"0.61025673",
"0.6000404",
"0.5992308",
"0.5974356",
"0.5890957",
"0.58811086... | 0.72458696 | 0 |
Initialize calculator with new operator objects. | def setUp(self):
self.adder = Adder()
self.subtracter = Subtracter()
self.multiplier = Multiplier()
self.divider = Divider()
self.calculator = Calculator(self.adder, self.subtracter,
self.multiplier, self.divider) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_operators(self):\n self.relationship_operator = Operators.RelationshipOperator(self)\n self.infection_operator = Operators.InfectionOperator(self)\n self.time_operator = Operators.TimeOperator(self)",
"def __init__(self, op, expression1, expression2):\n LinearExpression.__ini... | [
"0.72311604",
"0.69520086",
"0.6888747",
"0.6862367",
"0.6711085",
"0.669835",
"0.6601064",
"0.6592495",
"0.65747756",
"0.64952916",
"0.6475526",
"0.6421875",
"0.63757235",
"0.63662446",
"0.6242853",
"0.61571527",
"0.6146633",
"0.6125059",
"0.60797065",
"0.6077201",
"0.606856... | 0.583876 | 32 |
Load the appropriate parts of ResNet101 for feature extraction. | def load_resnet_image_encoder(model_stage=2):
print('Load pretrained ResNet 101.')
model = resnet101(pretrained=True)
layers = [model.conv1, model.bn1, model.relu, model.maxpool]
layers += [getattr(model, 'layer{}'.format(i+1)) for i in range(model_stage)]
model = torch.nn.Sequential(*layers)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadParts(self):\n for i in range(15):\n self.model_parts[i] = loadModel(\"ato_{}.pkl\".format(str(i)))",
"def load_features(self, features):\n pass\n # self.features = features",
"def but_load_net(self):\n a = tk.filedialog.askopenfilename(filetypes = [('NN file',['*... | [
"0.6283858",
"0.6103937",
"0.5989564",
"0.5937212",
"0.5907433",
"0.5898195",
"0.588028",
"0.5807268",
"0.57853377",
"0.57571113",
"0.5699515",
"0.5661323",
"0.5653031",
"0.56494755",
"0.564361",
"0.56382096",
"0.5637875",
"0.5631392",
"0.56306785",
"0.5628265",
"0.5621026",
... | 0.55134845 | 42 |
Testing user_profile form is valid | def test_user_profile_form_valid(self):
form = UserProfileForm(data={
'default_phone_number': 'test_phone_number',
'default_town_or_city': 'test_town_or_city',
'default_street_address1': 'test_street1',
'default_street_address2': 'test_street2',
'defau... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_user_profile_form(self):\n data = {\n 'username': 'teddybear',\n 'first_name': 'Fred',\n 'last_name': 'Bob',\n 'email': 'fredbob@fakezzzz.com',\n 'password': 'foobar',\n 'confirm_password': 'foobar',\n 'gender': 'Mal... | [
"0.8134164",
"0.7984866",
"0.715179",
"0.7088237",
"0.7011673",
"0.687972",
"0.6792277",
"0.67701125",
"0.67521083",
"0.67514396",
"0.6718309",
"0.66983557",
"0.6668615",
"0.66507673",
"0.66400594",
"0.66192955",
"0.6617528",
"0.6614049",
"0.65940064",
"0.6587965",
"0.6585391... | 0.8250587 | 0 |
Testing user_profile form is invalid | def test_user_profile_form_invalid(self):
form = UserProfileForm(data={
'default_phone_number': 'test_phone_number',
'default_town_or_city': 'test_town_or_city',
'default_street_address1': 'test_street1',
'default_street_address2': 'test_street2',
'def... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_form(self):\n data = {\n 'username': self.user.username,\n 'first_name': 'Fred',\n 'last_name': 'Bob',\n 'email': 'fredbob@fakezzzz.com',\n 'password': 'foobar',\n 'confirm_password': 'foobar2',\n 'gender': 'male',... | [
"0.75965583",
"0.7504635",
"0.74048626",
"0.72886235",
"0.72659504",
"0.7044586",
"0.6929317",
"0.68275625",
"0.68018526",
"0.6756879",
"0.66951865",
"0.6694815",
"0.6661989",
"0.6638998",
"0.6632332",
"0.66262245",
"0.6587524",
"0.6579431",
"0.65324366",
"0.6504147",
"0.6466... | 0.8414518 | 0 |
Test that the `last_files` property is being correctly maintained. | def test_last_files(self):
glob_manager = GlobManager(['*'])
self.assertCountEqual(glob_manager.last_files, set())
glob_manager.get_files()
self.assertCountEqual(
glob_manager.last_files,
{
'bob.py', 'dave.txt', 'fred.txt.py', 'geoff.py', 'jim.py.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_files(self):\r\n\r\n for path in self.get_files():\r\n self.assertTrue(datetime.fromtimestamp(os.path.getmtime(path)) > self.start_time,\r\n msg='File not recently modified: %s' % os.path.basename(path))",
"def test_pick_latest_file(self):\n max = FILE... | [
"0.7187674",
"0.7085664",
"0.68289006",
"0.64649796",
"0.6360217",
"0.61476624",
"0.611897",
"0.6109586",
"0.6081821",
"0.60529536",
"0.60360855",
"0.6031956",
"0.6021634",
"0.60172206",
"0.6013424",
"0.59967005",
"0.5968303",
"0.59663445",
"0.59538215",
"0.5895803",
"0.58443... | 0.79992676 | 0 |
calibrate the bboxes after the image was resized. | def resize_bboxes(ratios, bboxes):
ymin = bboxes[..., 0] * ratios[0]
xmin = bboxes[..., 1] * ratios[1]
ymax = bboxes[..., 2] * ratios[0]
xmax = bboxes[..., 3] * ratios[1]
bboxes = np.stack([ymin, xmin, ymax, xmax], axis=-1)
return bboxes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _resize_bboxes(self, results):\n for key in results.get('bbox_fields', []):\n bboxes = results[key] * results['scale_factor']\n if self.bbox_clip_border:\n img_shape = results['img_shape']\n bboxes[:, 0::2] = np.clip(bboxes[:, 0::2], 0, img_shape[1])\n... | [
"0.6571369",
"0.6571369",
"0.6553141",
"0.6424841",
"0.64126426",
"0.64126426",
"0.6396581",
"0.63616234",
"0.6172856",
"0.60588104",
"0.588354",
"0.5812369",
"0.57934606",
"0.57847166",
"0.5774379",
"0.5730808",
"0.5705069",
"0.5687453",
"0.56384534",
"0.5609351",
"0.5570448... | 0.6034716 | 10 |
Populate model with probability of word. | def pop_model(self):
dict_words = set([line.strip().lower() for line in open(self.dict_file, "r").readlines()])
word_counts = self.process_file(self.model_file)
N = sum(word_counts.values())
for word in word_counts:
if word in dict_words:
self.model[word] = w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def probability(self, words):\n prob = 1\n for w in words: # Loop through words\n if w not in self.mdl.index: # Not in tokens\n return 0\n else: # Get prob\n prob *= self.mdl.loc[w] \n return prob",
"def probability(self, words):\n p... | [
"0.67770225",
"0.67770225",
"0.66033477",
"0.6528961",
"0.63492835",
"0.63388",
"0.63128126",
"0.6312456",
"0.6309804",
"0.6246543",
"0.61738235",
"0.6160451",
"0.6141089",
"0.61305416",
"0.601105",
"0.59853184",
"0.5963927",
"0.59491026",
"0.59182745",
"0.59128785",
"0.59039... | 0.7060669 | 0 |
Populate self.bigrams with probs of next words using Norvig | def pop_bigrams(self):
bigram_counts = self.process_file(self.bigram_file)
N = sum(bigram_counts.values())
for bigram in bigram_counts:
self.bigrams[bigram.lower()] = bigram_counts[bigram] / N | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generateBigrams(self,text):\n self.bigrams=self._generateNgrams(text,2)",
"def add_bigrams(text):\n\n\tbigram = Phrases(text, min_count=20) # min freq of 20\n\tbi_phraser = Phraser(bigram)\n\tfor idx in range(len(text)):\n\t\tfor token in bi_phraser[text[idx]]:\n\t\t\tif '_' in token:\n\t\t\t\ttext[... | [
"0.7058819",
"0.6902035",
"0.6849263",
"0.6701952",
"0.633981",
"0.6335367",
"0.6331697",
"0.6321548",
"0.6265385",
"0.6234569",
"0.6096577",
"0.6023397",
"0.60061955",
"0.5971684",
"0.5955851",
"0.5950986",
"0.5936531",
"0.59019685",
"0.5865454",
"0.5825319",
"0.5823965",
... | 0.6745485 | 3 |
Predict the next words given the sentence. | def predict(self, sentence):
prev_two_words = sentence.split()[-2:]
options = dict(self.trigrams[tuple(prev_two_words)])
return options | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def predict_next_word(self, features, params, precomputed):\n raise NotImplementedError(\"Model does not implement word prediction.\")",
"def predict_next(self, words):\n prefix = \"%s \" % ' '.join(self.history)\n order = len(self.history) + 1\n scaling_factor = math.log(10) if self.conv... | [
"0.7397201",
"0.7314176",
"0.6993498",
"0.6991378",
"0.6950248",
"0.68496877",
"0.673331",
"0.6689913",
"0.6668884",
"0.65930575",
"0.6572024",
"0.6563852",
"0.65422404",
"0.65367365",
"0.65303856",
"0.65058595",
"0.6505619",
"0.64866084",
"0.647444",
"0.6444354",
"0.6422909"... | 0.66285807 | 9 |
Reset the values of health_meter dict to the original ones | def reset_health_meter(health_meter):
health_meter['player'] = 40
health_meter['enemy'] = 30 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_metric_stats(self):\n\n self.__stats_table = {}",
"def reset_metric_stats(self):\n self.__stats_table = {}",
"def _reset(self):\n self._values = {}",
"def reset(self):\n self.stats = {}",
"def reset(self):\n reset_system_health_series()",
"def reset(self) -> N... | [
"0.69027525",
"0.68950874",
"0.6761559",
"0.6746385",
"0.6540609",
"0.6508202",
"0.64174014",
"0.63314915",
"0.62363005",
"0.6225187",
"0.6201655",
"0.61971945",
"0.6192975",
"0.6130893",
"0.6122586",
"0.6089264",
"0.6040436",
"0.6040436",
"0.59639764",
"0.592196",
"0.5900264... | 0.8173619 | 0 |
Print a string in 'bold' font | def print_bold(msg, end='\n'):
print("\033[1m" + msg + "\033[0m", end=end) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bold(string):\n return BOLD + string + RESETFORMAT",
"def bold(self, s):\n return '\\x02%s\\x02' % s",
"def bold(msg):\n return '\\033[1m%s\\033[0m' % msg",
"def bold(string):\n return BOLD + string + END",
"def asBold(self):\n\t\treturn TextFont( self.name[0:2]+'B', self.size)",
"def... | [
"0.81249005",
"0.8013307",
"0.7843382",
"0.7741452",
"0.7614055",
"0.7524295",
"0.74767923",
"0.7322054",
"0.7261777",
"0.7229781",
"0.7215142",
"0.71516895",
"0.70972615",
"0.6931748",
"0.6903624",
"0.6889189",
"0.6834426",
"0.68165",
"0.6789199",
"0.67810476",
"0.6760514",
... | 0.7515065 | 7 |
Validate that all API users are unique. | def has_all_unique_users(value):
api_users = [user[CONF_API_USER] for user in value]
has_unique_values(api_users)
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_unique(self):\n pass",
"def validate_unique(self, exclude=None, **kwargs):\n return super().validate_unique(exclude=exclude, user=self.user)",
"def validate_unique(self, exclude=None):\n MyUser.objects.filter(email=self.email, is_active=False).delete()\n super(MyUser, self... | [
"0.72889185",
"0.6924524",
"0.6590948",
"0.65030235",
"0.6494532",
"0.64772284",
"0.6338684",
"0.6324511",
"0.6323914",
"0.6300938",
"0.624186",
"0.6238004",
"0.62260777",
"0.6219345",
"0.6188961",
"0.6166548",
"0.6039054",
"0.6035771",
"0.603131",
"0.60006136",
"0.5998029",
... | 0.70905703 | 1 |
Unload a config entry. | async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
unload_ok = await hass.config_entries.async_unload_platforms(entry, PLATFORMS)
if unload_ok:
hass.data[DOMAIN].pop(entry.entry_id)
if len(hass.config_entries.async_entries(DOMAIN)) == 1:
hass.services.async_remov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_unload_entry(hass, config_entry):\n unload_ok = await hass.config_entries.async_forward_entry_unload(\n config_entry, \"climate\"\n )\n return unload_ok",
"async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:\n hass.data.pop(DOMAIN)\n return True",
... | [
"0.697284",
"0.6888074",
"0.6779855",
"0.6747459",
"0.6689002",
"0.6657831",
"0.66162205",
"0.6603433",
"0.65925974",
"0.65595686",
"0.65411645",
"0.6507643",
"0.6507643",
"0.6507643",
"0.6507643",
"0.64977276",
"0.64931643",
"0.6486601",
"0.6486601",
"0.6486601",
"0.6486601"... | 0.639899 | 40 |
Initializes estimated locations for test images. | def process_test_data(test_data, loc_by_img, mean_loc_by_tag, locality):
test_imgs_by_tag = {}
for test_img in test_data:
img_id = test_img['watchlink']
img_tags = test_img['tags']
remove_low_locality_tags(locality, img_tags)
# Initialize lat, lon, and var
min_var_loc =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self):\n self.testInst = pysat.Instrument('pysat', 'testing2D_xarray',\n clean_level='clean')\n self.testInst.bounds = (dt.datetime(2008, 1, 1),\n dt.datetime(2008, 2, 1))\n self.dname = 'images'\n self.tes... | [
"0.64599884",
"0.64464694",
"0.6376553",
"0.6365806",
"0.6350205",
"0.6350205",
"0.6350205",
"0.6350205",
"0.6350205",
"0.6294783",
"0.62515885",
"0.6190728",
"0.61594284",
"0.61594284",
"0.61594284",
"0.6149689",
"0.61191446",
"0.61115605",
"0.6098518",
"0.60936797",
"0.6041... | 0.0 | -1 |
Create an EtlSettings instance from a yaml_file path. | def from_yaml(cls, path: str) -> "EtlSettings":
with fsspec.open(path) as f:
yaml_file = yaml.safe_load(f)
return cls.parse_obj(yaml_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_yaml_file(cls, file_path: str) -> Config:\n return cls(**read_yaml_file(file_path))",
"def create_from_config_file(cls, filename: str):\n return cls(load_yaml_config(filename))",
"def from_yaml(cls, yaml_filename):\n # TODO: Implement YAML validation routine?\n # Note - a t... | [
"0.7468101",
"0.7028307",
"0.6657288",
"0.65396357",
"0.653905",
"0.65167445",
"0.64637667",
"0.6410285",
"0.6388075",
"0.6367077",
"0.6350551",
"0.6346436",
"0.6342432",
"0.6325121",
"0.63148767",
"0.6299536",
"0.62603164",
"0.6258264",
"0.6211542",
"0.6195223",
"0.6176193",... | 0.86948407 | 0 |
Add a new experience to memory. | def add(self, state, action, reward, next_state, done):
e = self.transition(state, action, reward, next_state, done)
self.buffer.append(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new_experience(self, state, action, reward, next_state, done):\n e = self.experience(state, action, reward, next_state, done, self.max_priority)\n self.memory.append(e)",
"def add(self, state, action, reward, next_state, done):\n experience = Experience(state, action, reward, next_st... | [
"0.79575163",
"0.7904917",
"0.7880746",
"0.7578514",
"0.75727165",
"0.7448136",
"0.7361892",
"0.72705156",
"0.7218082",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0.71984065",
"0... | 0.0 | -1 |
A model h = f(xW_xh + b_h) y = softmax(hW_hy + b_y) with a crossentropy loss and f determined by `hidden_activation`. | def __init__(self,
hidden_dim=50,
hidden_activation=nn.Tanh(),
**base_kwargs):
self.hidden_dim = hidden_dim
self.hidden_activation = hidden_activation
super().__init__(**base_kwargs)
self.loss = nn.CrossEntropyLoss(reduction="mean")
self.params... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(X,W,b,V,d):\n H = sigmoid(X, W, b)\n Y = softmax(H, V, d)\n return H, Y",
"def feed_forward(self):\n self.hidden_activation = self._sigmoid(np.dot(self.input_activation, self.w1))\n self.output_activation = self._sigmoid(np.dot(self.hidden_activation, self.w2))",
"def gradien... | [
"0.6736975",
"0.66512716",
"0.6578134",
"0.656106",
"0.65413475",
"0.65183884",
"0.64480805",
"0.64358914",
"0.64319956",
"0.6401262",
"0.63672036",
"0.6337394",
"0.6337394",
"0.63331324",
"0.6295061",
"0.6287183",
"0.6274046",
"0.6211675",
"0.6211675",
"0.6178863",
"0.616836... | 0.6100298 | 27 |
Define datasets for the model. | def build_dataset(self, X, y=None):
X = np.array(X)
self.input_dim = X.shape[1]
X = torch.FloatTensor(X)
if y is None:
dataset = torch.utils.data.TensorDataset(X)
else:
self.classes_ = sorted(set(y))
self.n_classes_ = len(self.classes_)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datasets(self):\n pass",
"def _create_fit_datasets(self):\n raise NotImplementedError('Please override the _create_fit_datasets '\n 'specific to your model')",
"def _build_datasets(self):\n self._build_datasets_sis3302()\n self._build_datasets_si... | [
"0.79139",
"0.76534194",
"0.7653322",
"0.75640124",
"0.739144",
"0.7252905",
"0.7252905",
"0.71449137",
"0.7088018",
"0.70489633",
"0.6979025",
"0.6965545",
"0.69528145",
"0.6937317",
"0.6936586",
"0.6927799",
"0.6916024",
"0.69039524",
"0.68938863",
"0.6882746",
"0.6873239",... | 0.0 | -1 |
Generate a random string of fixed length >>> type(randomString(15)) >>> len(randomString(15)) 15 | def randomString(stringLength: int = 10) -> str:
letters = string.ascii_lowercase
return ''.join(choice(letters) for i in range(stringLength)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length):\r\n return ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(length))",
"def random_string(le... | [
"0.827571",
"0.82510406",
"0.8175678",
"0.8155405",
"0.81370866",
"0.81216455",
"0.8109603",
"0.8092551",
"0.808361",
"0.80765086",
"0.80759907",
"0.8043304",
"0.8042056",
"0.8020516",
"0.80184984",
"0.8011952",
"0.80061466",
"0.7992085",
"0.7990866",
"0.79806095",
"0.7979666... | 0.7804635 | 42 |
Return a dict of paths useful to train/test/inference. | def paths(self):
paths = {
'json_path': self._json_path,
'models_path': osp.join(self.prerequisites_path,
'models', self.commit, ''),
'results_path': osp.join(self.prerequisites_path,
'results', self.com... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_train_paths(self):\n\n assert self.dataset_type_first_step == \"sequential\" or self.dataset_type_first_step == \"overlapped\", \\\n \"Error! dataset_type_first_step should be set to 'sequential' or to 'overlapped'\"\n\n assert self.dataset_type_incremental == \"sequential\" or sel... | [
"0.6784329",
"0.6678999",
"0.6652604",
"0.66462713",
"0.6531913",
"0.64789593",
"0.6475372",
"0.6447398",
"0.6334969",
"0.6328861",
"0.6315132",
"0.6244046",
"0.6233547",
"0.61621165",
"0.61582315",
"0.6118774",
"0.6104572",
"0.60984224",
"0.609288",
"0.60646755",
"0.6061784"... | 0.61559886 | 15 |
Test that post request fails for unauthenticated user | def test_unauthenticated_user_post_request_failure(self):
res = self.client.post(PROCEDURE_URL, self.payload, format='json')
self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testPostAccessDenied(self):\n self.runPost(None, data=self.post_data)\n self.response_401()\n for user in (self.guest, self.norole, self.unrelated_owner):\n self.runPost(user, data=self.post_data)\n self.response_403()",
"def test_post_answer_if_not_autheticated(sel... | [
"0.799031",
"0.7951984",
"0.79412085",
"0.79231215",
"0.7921281",
"0.7893837",
"0.77860355",
"0.7761405",
"0.77237594",
"0.7629064",
"0.75960255",
"0.7558854",
"0.7557759",
"0.7533041",
"0.7531583",
"0.7438604",
"0.74260056",
"0.74215215",
"0.74191",
"0.74179745",
"0.74122816... | 0.79904485 | 0 |
Test that post request fails for authenticated user | def test_authenticated_user_post_request_failure(self):
res = self.client.post(PROCEDURE_URL, self.payload, format='json')
self.assertEqual(res.status_code, status.HTTP_403_FORBIDDEN) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_post_authenticated(self):\n with self.assertRaises(HTTPError):\n self.client.post(STATUS_PATH)",
"def test_unauthenticated_user_post_request_failure(self):\n\n res = self.client.post(PROCEDURE_URL, self.payload, format='json')\n\n self.assertEqual(res.status_code, status.... | [
"0.79692465",
"0.78765947",
"0.7763321",
"0.77249014",
"0.770779",
"0.76275957",
"0.76105696",
"0.7559219",
"0.7554408",
"0.7505445",
"0.7443584",
"0.7441674",
"0.74384916",
"0.74189544",
"0.73988605",
"0.73935205",
"0.7332848",
"0.7326073",
"0.731104",
"0.73015606",
"0.72726... | 0.79425603 | 1 |
Test that invalid image upload fails | def test_user_profile_picture_invalid_image_fails(self):
image_upload_url = PROCEDURE_URL
payload = {
'name': 'temp',
'speciality': [self.speciality.pk],
'image': 'invalid image',
'overview': 'bla bla bla'
}
res = self.client.post(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_bad_file(self):\n url = image_upload_url(self.reteta.id)\n res = self.client.post(url, {'image': 'notimage'}, format='multipart')\n self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)",
"def test_invalid_image_upload(self):\n res = self.client.post(\n ... | [
"0.85134715",
"0.84968907",
"0.8386776",
"0.83654094",
"0.8285552",
"0.8231662",
"0.8231263",
"0.81843096",
"0.8179493",
"0.8175242",
"0.8109983",
"0.7748736",
"0.7542681",
"0.7390996",
"0.73096645",
"0.7282337",
"0.7245721",
"0.7220622",
"0.71950585",
"0.7180803",
"0.7173191... | 0.7777658 | 11 |
Transforms column to a numarray If possible, the column data is transformed to a numarray object and returned. Type specific numarrays are created to shorten the effort in the numarray module. | def tonumarray(self):
import numarray
# initialize the return
narray = None
if None in self._data:
raise Exception('There are "None" elements in the column. They can not be\ntransformed to numarrays!')
# check for string column
if self._type == str:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_data_to_numeric(data, columns_to_convert):\n numpy_data = data.values\n\n for i in range(len(numpy_data[0])):\n temp = numpy_data[:, i]\n if i in columns_to_convert:\n dict = numpy.unique(numpy_data[:, i])\n for j in range(len(dict)):\n temp[nump... | [
"0.65685624",
"0.6434618",
"0.6322535",
"0.6267725",
"0.61796737",
"0.61433953",
"0.6130777",
"0.61105615",
"0.61046374",
"0.6089691",
"0.6081266",
"0.6053793",
"0.595011",
"0.5927565",
"0.58897823",
"0.5880332",
"0.58650005",
"0.5804213",
"0.5795171",
"0.57753026",
"0.575590... | 0.80192024 | 0 |
Returns the number of rows. | def get_nrows(self):
return self._nrows | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumRows(self) -> int:\n ...",
"def num_rows(self):\n return (len(self.rows))",
"def row_count(self) -> int:\n return len(self.rows)",
"def row_count(self) -> int:\n return len(self.rows)",
"def get_num_rows(self):\n return self._num_rows",
"def num_rows(self):\n ... | [
"0.91806567",
"0.8805216",
"0.8805118",
"0.8805118",
"0.87695277",
"0.87469846",
"0.8744087",
"0.8658158",
"0.8596907",
"0.85554296",
"0.84842277",
"0.84817845",
"0.8478153",
"0.84271914",
"0.8415132",
"0.838368",
"0.82402307",
"0.8194073",
"0.8157834",
"0.8156398",
"0.813746... | 0.7550955 | 49 |
Create wide resnet. Instantiate the Wide Residual Network architecture, optionally loading weights pretrained on CIFAR10. Note that when using TensorFlow, for best performance you should set `image_dim_ordering="tf"` in your Keras config at ~/.keras/keras.json. The model and the weights are compatible with both TensorF... | def create_model(classes=10, input_shape=None, config=None,
depth=28, width=8, dropout_rate=0.0,
include_top=True, weights=None,
input_tensor=None):
if weights not in {'cifar10', None}:
raise ValueError('The `weights` argument should be either '
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wide_resnet101_2(pretrained=False, progress=True, **kwargs):\n kwargs['width_per_group'] = 64 * 2\n model = ResNetFeatures(BottleneckFeatures, [3, 4, 23, 3], **kwargs)\n\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['wide_resnet101_2']))\n\n return model",
"def wid... | [
"0.717131",
"0.7114835",
"0.7114835",
"0.71007246",
"0.7070409",
"0.699773",
"0.69080895",
"0.690456",
"0.68711394",
"0.68711394",
"0.6645957",
"0.6559593",
"0.6535796",
"0.6469119",
"0.6405253",
"0.6405253",
"0.6398017",
"0.6372417",
"0.63405097",
"0.63236827",
"0.6311548",
... | 0.74515617 | 0 |
Computes a reward for a given time step. The reward is negative if the current time step is past the expected time. The reward is positive if the current time step is before the expected time. | def ComputeTimeReward(self, currentTime, expectedTime):
return (expectedTime - currentTime) * 1 if currentTime < expectedTime else (expectedTime - currentTime) * 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_reward(self):\n if self.status():\n return self.current_step/self.ep_length # the reward is proportional to the duration \n else:\n return 0",
"def reward(self):\n if self.num_steps >= self.timeout:\n return self.fail_penalty\n\n return self.default_reward",
"... | [
"0.7420469",
"0.7330587",
"0.69760716",
"0.69477975",
"0.6932424",
"0.68891233",
"0.6752446",
"0.66772145",
"0.66419643",
"0.6641573",
"0.6636242",
"0.6627881",
"0.66208917",
"0.66121435",
"0.66034883",
"0.6601455",
"0.6580316",
"0.6555096",
"0.6545993",
"0.65189654",
"0.6512... | 0.71755356 | 2 |
Parse a limit query param into something usable. | def _get_limit(self, req):
try:
limit = int(req.str_params.get('limit', MAX_ITEM_LIMIT))
except ValueError:
raise exc.HTTPBadRequest("limit param must be an integer")
if limit < 0:
raise exc.HTTPBadRequest("limit param must be positive")
return min(M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_limit(val):\n if val is None:\n return None\n\n num, unit = val[:-1], val[-1]\n val = float(num) * {\n 'K': 1024,\n 'M': 1024 * 1024,\n 'G': 1024 * 1024 * 1024,\n 'T': 1024 * 1024 * 1024 * 1024,\n 'P': 1024 * 1024 * 1024 * 1024 * 1024,\n }[unit.upper(... | [
"0.6798631",
"0.6766065",
"0.6446185",
"0.62429684",
"0.6140869",
"0.6084813",
"0.6010515",
"0.5937067",
"0.5885832",
"0.5853818",
"0.5834893",
"0.58115035",
"0.5797141",
"0.57959366",
"0.5778241",
"0.572617",
"0.5723264",
"0.5709878",
"0.5664017",
"0.5662866",
"0.5650458",
... | 0.67161006 | 2 |
Returns the template for this job's run page. | def get_job_run_template(self, job_name, preview=True, request=None, object_id=None, view_name=None,
extra_context=None):
return 'django_admin_rq/job_run.html' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def template(self):\n with open(self.compute.submission_template, \"r\") as f:\n return f.read()",
"def template(self) -> 'outputs.GoogleCloudRunV2ExecutionTemplateResponse':\n return pulumi.get(self, \"template\")",
"def get_job_complete_template(self, job_name, request=None, object_i... | [
"0.7089868",
"0.6806625",
"0.67453974",
"0.6711976",
"0.6629198",
"0.66239643",
"0.65290415",
"0.65290415",
"0.65290415",
"0.64320403",
"0.6273244",
"0.6213097",
"0.61545193",
"0.61364007",
"0.6109733",
"0.60996443",
"0.6059894",
"0.60518116",
"0.60358465",
"0.6005911",
"0.59... | 0.7868778 | 0 |
Returns the template for this job's complete page | def get_job_complete_template(self, job_name, request=None, object_id=None, view_name=None,
extra_context=None):
return 'django_admin_rq/job_complete.html' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_updated_jobtemplate(self):\n return self.response_json",
"def GetTemplate(self, _page_data):\n return self.template",
"def template(self):\n with open(self.compute.submission_template, \"r\") as f:\n return f.read()",
"def get_template(self):\n return self.template"... | [
"0.6432075",
"0.64038116",
"0.6393848",
"0.63553125",
"0.62987775",
"0.62938505",
"0.6111249",
"0.6111249",
"0.6111249",
"0.600747",
"0.59600925",
"0.59257907",
"0.5920801",
"0.5889606",
"0.587359",
"0.58716726",
"0.584402",
"0.5817675",
"0.58119",
"0.5786086",
"0.5781747",
... | 0.75463974 | 0 |
Returns a random filename in ./data/htmlfiles/ | def random_html_file():
nb_of_files = len([name for name in listdir(DATA_PATH)])
list_of_files = [f for f in listdir(
DATA_PATH) if isfile(join(DATA_PATH, f))]
random_nb = random.randint(0, nb_of_files - 1)
return random.choice(list_of_files) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_filename():\n\n return ''.join(random.choices(string.ascii_uppercase + string.digits, k=5))",
"def get_random_file():\n\n return random.choice(File.get_files())",
"def create_random_file_name():\n\n def random_file_name_factory():\n length = random.randint(10, 15)\n chars ... | [
"0.76826423",
"0.7305651",
"0.71329266",
"0.7124584",
"0.7022251",
"0.6854005",
"0.68276423",
"0.6791338",
"0.67560524",
"0.6672447",
"0.66611874",
"0.66594833",
"0.66464025",
"0.6629262",
"0.6596564",
"0.6594027",
"0.6558593",
"0.650907",
"0.64750427",
"0.64622366",
"0.64419... | 0.82083184 | 0 |
The prox operator for the L2 norm. assuming last entry is constant offset. x_i = (1 / (1 + tau)) x_i | def prox(self, x):
if self.regularize:
x[:self.offset(x)] /= (1 + 2 * self.tau * self.lambda_)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proximal(self):\n return proximal_l2_squared(space=self.domain)",
"def _l2_normalize(x, axis=None, eps=1e-12):\n return x * jax.lax.rsqrt((x * x).sum(axis=axis, keepdims=True) + eps)",
"def l2_norm(self):\n return (self.x**2 + self.y**2 + self.z**2)**0.5",
"def prox_l1_norm(w, lamb):\n\tre... | [
"0.648691",
"0.63592386",
"0.635098",
"0.63241583",
"0.62074876",
"0.61817247",
"0.5981379",
"0.5836194",
"0.58205754",
"0.57820505",
"0.574818",
"0.57402045",
"0.5730516",
"0.57257706",
"0.5697328",
"0.56836027",
"0.56820333",
"0.56811196",
"0.56804514",
"0.5668138",
"0.5657... | 0.6859232 | 1 |
The prox operator for the L2 norm. assuming last entry is constant offset. x_i = (1 / (1 + tau)) x_i | def prox(self, x):
if self.regularize:
x[:self.offset(x)] /= (1 + 2 * self.tau * self.lambda_)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proximal(self):\n return proximal_l2_squared(space=self.domain)",
"def _l2_normalize(x, axis=None, eps=1e-12):\n return x * jax.lax.rsqrt((x * x).sum(axis=axis, keepdims=True) + eps)",
"def l2_norm(self):\n return (self.x**2 + self.y**2 + self.z**2)**0.5",
"def prox_l1_norm(w, lamb):\n\tre... | [
"0.64847034",
"0.6361705",
"0.6352037",
"0.6324219",
"0.62085927",
"0.61829656",
"0.59829134",
"0.58381677",
"0.5818935",
"0.57838076",
"0.5749598",
"0.574227",
"0.5732611",
"0.57270837",
"0.569762",
"0.568555",
"0.56818897",
"0.5681673",
"0.5678328",
"0.56693876",
"0.5656393... | 0.68571967 | 2 |
The prox operator for the L2 norm. assuming last entry is constant offset. x_i = (1 / (1 + tau)) x_i | def prox(self, x):
if self.regularize:
x[:self.offset(x)] /= (1 + 2 * self.tau * self.lambda_)
return x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def proximal(self):\n return proximal_l2_squared(space=self.domain)",
"def _l2_normalize(x, axis=None, eps=1e-12):\n return x * jax.lax.rsqrt((x * x).sum(axis=axis, keepdims=True) + eps)",
"def l2_norm(self):\n return (self.x**2 + self.y**2 + self.z**2)**0.5",
"def prox_l1_norm(w, lamb):\n\tre... | [
"0.648691",
"0.63592386",
"0.635098",
"0.63241583",
"0.62074876",
"0.61817247",
"0.5981379",
"0.5836194",
"0.58205754",
"0.57820505",
"0.574818",
"0.57402045",
"0.5730516",
"0.57257706",
"0.5697328",
"0.56836027",
"0.56820333",
"0.56811196",
"0.56804514",
"0.5668138",
"0.5657... | 0.6859232 | 0 |
Assign default values to all parameters and replace parameter values found in yaml. | def read_params(self):
detector_params = namedtuple('params', ['image_path', 'circle_region',
'vis_circle_det',
'template_path', 'score_thres',
'vis_det'])
with... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _apply_defaults(self):\n # Applies normal parameter defaults\n for scalar_parameter, value in self._DEFAULT_PARAMETER_SCALARS.items():\n if scalar_parameter not in self.parameters:\n self.parameters[scalar_parameter] = copy.copy(value)\n\n # Applies defaults to al... | [
"0.72887856",
"0.7058455",
"0.7009436",
"0.7009436",
"0.672338",
"0.6717612",
"0.6662756",
"0.65840924",
"0.6543925",
"0.65097827",
"0.6458374",
"0.64069897",
"0.6398941",
"0.63963264",
"0.638621",
"0.63592935",
"0.63489354",
"0.63174784",
"0.6296886",
"0.62886745",
"0.626280... | 0.0 | -1 |
Yield successive nsized chunks from th elements list. | def divide_list_in_chunks(self, elements, chunk_size):
if len(elements) == 0:
yield []
for i in range(0, len(elements), chunk_size):
yield elements[i:i + chunk_size] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(self, lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"def _chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def _chunks(l, n):\n\tfor i in range(0, len(l), n):\n\t\tyield l[i:i + n]",
"def __chunks(l, n):\n fo... | [
"0.73911494",
"0.73642135",
"0.7334106",
"0.73329824",
"0.72729516",
"0.72647786",
"0.7241541",
"0.72351474",
"0.72351474",
"0.7211492",
"0.7211492",
"0.7188259",
"0.7181491",
"0.7156445",
"0.715278",
"0.7150895",
"0.71223587",
"0.7120117",
"0.7120117",
"0.7120117",
"0.712011... | 0.0 | -1 |
Return the name of the device if any. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_name(self) -> Optional[str]:\n return pulumi.get(self, \"device_name\")",
"def device_name(self) -> Optional[str]:\n return pulumi.get(self, \"device_name\")",
"def name(self):\n return self._device.name",
"def name(self):\n return self._device.name",
"def name(self):... | [
"0.89726496",
"0.89726496",
"0.8584672",
"0.8584672",
"0.8584672",
"0.850212",
"0.84946066",
"0.84203684",
"0.8395054",
"0.8395054",
"0.8378909",
"0.8316349",
"0.8307453",
"0.8161342",
"0.81572443",
"0.8089769",
"0.80879545",
"0.8074055",
"0.8007309",
"0.7998442",
"0.79543054... | 0.0 | -1 |
Return the device state attributes. | def device_state_attributes(self):
return {
ATTR_ATTRIBUTION: DEFAULT_ATTRIBUTION,
ATTR_CAMERA_TYPE: self._device_type,
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\r\n return self._attributes",
"def device_state_attributes(self):\n return self._attrs",
"def device_state_attributes(self):\n return self.attr",
"def device_state_attributes(self... | [
"0.93173087",
"0.9245708",
"0.92207897",
"0.92147964",
"0.92147964",
"0.9210798",
"0.9210798",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
"0.91909975",
... | 0.8315584 | 52 |
Used by deciders to tell the service that the DecisionTask identified by the task_token has successfully completed. The decisions argument specifies the list of decisions made while processing the task. A DecisionTaskCompleted event is added to the workflow history. The executionContext specified is attached to the eve... | def respond_decision_task_completed(token, decisions, execution_context=None):
kwargs = {}
if execution_context:
kwargs['executionContext'] = execution_context
result = make_request(
SWF.respond_decision_task_completed,
taskToken=token,
decisions=decisions,
**kwargs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_task_token(decision):\n try:\n return decision[\"taskToken\"]\n except KeyError:\n # No taskToken returned\n return None",
"def complete_workflow_execution(self, result=None):\n o = {}\n o['decisionType'] = 'CompleteWorkflowExecution'\n attrs = o['completeW... | [
"0.48493338",
"0.4519796",
"0.4419872",
"0.43289265",
"0.43281686",
"0.43234178",
"0.43211606",
"0.42849508",
"0.4282278",
"0.42385006",
"0.4235821",
"0.4234635",
"0.42257264",
"0.417039",
"0.41447863",
"0.41223934",
"0.4111084",
"0.40998745",
"0.4064446",
"0.40632963",
"0.40... | 0.77125955 | 0 |
Initialize bounds and fitness function. | def __init__(self, limits, resolution):
self.limits = limits
self.resolution = resolution
self.X, self.Y = self._create_meshgrid()
self.coords, self.tree = self._generate_coords()
self.fitness_function = self._calculate_fitness().reshape(self.resolution, self.resolution)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, bounds=None, feasible=None):\n if bounds is None:\n bounds = {}\n\n self.bounds = bounds\n self.feasible = feasible\n self.update()",
"def __init__(self, fitness_function=None):\n Function.initialize(self, fitness_function)",
"def setup(self):\n ... | [
"0.7116127",
"0.70670277",
"0.6936971",
"0.6889328",
"0.6771898",
"0.66038585",
"0.65823597",
"0.6580138",
"0.65597576",
"0.6503792",
"0.63147134",
"0.6313142",
"0.62874895",
"0.62807155",
"0.6247785",
"0.6215972",
"0.6205945",
"0.61574996",
"0.6136636",
"0.6130352",
"0.61049... | 0.6700057 | 5 |
Extract the Python code from \pyenv{ } | def _CleanChunk(self, chunk):
mystr = '\n'.join(chunk)
#find periods with only one space after them
p = re.compile(r'\. ([A-Z])')
mystr = p.sub(r'. \1',mystr)
p2 = re.compile(self.pat+'(.*)}', re.DOTALL)
q2 = p2.search(mystr)
code = q2.group(2)
code = Ba... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getpythonenv(options,buildout):\n crypt=''\n if os.uname()[0] != 'Darwin':\n crypt=' -lcrypt '\n myfile = open(\n os.path.join(\n options['compile-directory'],\n 'Modules',\n 'Setup.local'),\n 'w'\n )\n myfile.write(\"\"\"\nzlib zlibmodule.c ... | [
"0.5959309",
"0.59064233",
"0.58676636",
"0.576979",
"0.57147706",
"0.56861675",
"0.562594",
"0.55938965",
"0.55911446",
"0.5588094",
"0.5578456",
"0.5537176",
"0.5339738",
"0.53235006",
"0.5305718",
"0.53047585",
"0.53047585",
"0.52816725",
"0.52765083",
"0.52529955",
"0.522... | 0.0 | -1 |
Sets the colorscale and only has an effect if `line.color` is set to a numerical array. The colorscale must be an array containing arrays mapping a normalized value to an rgb, rgba, hex, hsl, hsv, or named color string. At minimum, a mapping for the lowest (0) and highest (1) values are required. For example, `[[0, 'rg... | def colorscale(self):
return self['colorscale'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_colorscale(colors, scale=None):\n colorscale = []\n\n # validate minimum colors length of 2\n if len(colors) < 2:\n raise exceptions.PlotlyError(\"You must input a list of colors that \"\n \"has at least two colors.\")\n\n if not scale:\n scale... | [
"0.59164155",
"0.58387566",
"0.5589771",
"0.5558366",
"0.5547074",
"0.5520202",
"0.5501048",
"0.5385823",
"0.5308171",
"0.52657485",
"0.5141189",
"0.5133696",
"0.5132214",
"0.5129681",
"0.50887406",
"0.5079019",
"0.50697035",
"0.5053363",
"0.50502884",
"0.50369406",
"0.500926... | 0.5575357 | 3 |
Has an effect only if `line.color` is set to a numerical array. Determines whether or not a colorbar is displayed. The 'showscale' property must be specified as a bool (either True, or False) Returns bool | def showscale(self):
return self['showscale'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_scale_enabled(self) -> bool:\r\n ...",
"def ColorBarEnabled(self):\n sliceAnnotations = DataProbeLib.SliceAnnotations()\n sliceAnnotations.scalarBarEnabled = 1\n sliceAnnotations.updateSliceViewFromGUI()",
"def _colorBar(self):\n self.gc.show_colorscale(cmap=self.colormap, vmin=se... | [
"0.62203336",
"0.61939436",
"0.54686",
"0.53048074",
"0.53019017",
"0.52542675",
"0.5232585",
"0.5195412",
"0.5143616",
"0.5143616",
"0.5119842",
"0.511108",
"0.5075574",
"0.50669014",
"0.50430465",
"0.5039227",
"0.50161064",
"0.49981353",
"0.49517438",
"0.49367988",
"0.49340... | 0.5364469 | 3 |
Construct a new Line object | def __init__(
self,
arg=None,
autocolorscale=None,
cauto=None,
cmax=None,
cmin=None,
color=None,
colorscale=None,
colorsrc=None,
dash=None,
reversescale=None,
showscale=None,
width=None,
**kwargs
):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createFromLine(cls, line, **kwargs):\n angle = line.angle\n x, y = cls.cartesian([1, angle])\n return cls(x, y, **kwargs)",
"def getLine(self, **kwargs):\n return Line(self.p1, self.angle, **kwargs)",
"def __init__(self, vertices, **kwargs):\n super(Line, self).__init__(v... | [
"0.7590642",
"0.75330955",
"0.74995667",
"0.74495375",
"0.7341352",
"0.7289103",
"0.72728866",
"0.7157574",
"0.7139277",
"0.70514715",
"0.70317733",
"0.68535954",
"0.6828772",
"0.6773587",
"0.6772886",
"0.676653",
"0.6745451",
"0.6744249",
"0.67418313",
"0.6704445",
"0.663992... | 0.59547305 | 87 |
Creates a user entity for the specified email. | def createOtherUser(self, email):
from soc.models.user import User
from soc.modules.seeder.logic.providers.user import FixedUserProvider
properties = {'account': FixedUserProvider(value=email), 'status': 'valid'}
self.user = seeder_logic.seed(User, properties=properties)
return self.user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, **extra_fields):\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.save(using=self._db)\n return user",
"def create_user(self, email):\n if not email:\n raise ValueError('Users must have an ema... | [
"0.8237654",
"0.8141455",
"0.809875",
"0.7761052",
"0.7755779",
"0.7721071",
"0.7719008",
"0.7715745",
"0.76870686",
"0.76684797",
"0.766674",
"0.7665888",
"0.7665888",
"0.7665888",
"0.7665661",
"0.764867",
"0.7646023",
"0.7646023",
"0.7646023",
"0.7646023",
"0.7646023",
"0... | 0.7500395 | 60 |
Sets the current suer to be a student for the current program. | def createStudent(self):
self.createProfile()
from soc.modules.gsoc.models.profile import GSoCStudentInfo
properties = {'key_name': self.profile.key().name(), 'parent': self.profile}
self.profile.student_info = seeder_logic.seed(GSoCStudentInfo, properties)
self.profile.put() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_student(self, student_id):\n self._student = student_id",
"def student(self):\n if \"student\" in self._prop_dict:\n if isinstance(self._prop_dict[\"student\"], OneDriveObjectBase):\n return self._prop_dict[\"student\"]\n else :\n self._pr... | [
"0.65010715",
"0.6156979",
"0.5807452",
"0.56787235",
"0.56195354",
"0.55794626",
"0.554375",
"0.5515274",
"0.5502809",
"0.54869014",
"0.5482215",
"0.5474328",
"0.5457622",
"0.5441015",
"0.54320383",
"0.53813326",
"0.5361281",
"0.53332615",
"0.5317914",
"0.5278555",
"0.526869... | 0.5515564 | 7 |
Test templatetag for great than char. | def test_unescape__great_than(self) -> None:
escaped: str = ">"
unescaped: str = ">"
self.assertEqual(first=unescape(value=escaped), second=unescaped) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_condenses_whitespace(self):\n t = Template('{% load djblets_utils %}'\n '<span{% attr \"data-foo\" %}\\n'\n 'some \\n\\n'\n 'value\\n'\n '{% endattr %}>')\n\n self.assertEqual(\n t.render(Context())... | [
"0.5884731",
"0.5762217",
"0.57148033",
"0.56171125",
"0.5563623",
"0.54967445",
"0.54916173",
"0.5479862",
"0.5438337",
"0.539884",
"0.5388552",
"0.53837955",
"0.5371001",
"0.5355524",
"0.53122044",
"0.52624255",
"0.5228112",
"0.5216889",
"0.51993394",
"0.519482",
"0.5194264... | 0.0 | -1 |
Test templatetag for superuser. | def test_readonly_submit_row__for_superuser(self) -> None:
user = User.objects.first()
user.is_superuser = True # type: ignore
user.save(update_fields=["is_superuser"]) # type: ignore
request: HttpRequest = HttpRequest()
request.user = user # type: ignore
context: Requ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tag_is_in_the_template(self):\n\n template = Template(\n '{% load profile_admin_editing %}{% edit_link profile %}')\n\n context = Context({'profile': self.profile})\n\n self.assertEqual(self.super_link, template.render(context))",
"def test_func(self):\n return self.... | [
"0.6745062",
"0.65424937",
"0.6349382",
"0.6349382",
"0.63221526",
"0.62654877",
"0.6231164",
"0.6146131",
"0.6069223",
"0.60357785",
"0.6017497",
"0.599969",
"0.5995684",
"0.5984835",
"0.59490186",
"0.59236753",
"0.59115094",
"0.59053296",
"0.59046525",
"0.5877041",
"0.58501... | 0.0 | -1 |
Test templatetag without read only permissions. | def test_readonly_submit_row__without__read_only_permissions(self) -> None:
Permission.objects.filter(
codename__startswith=settings.READ_ONLY_ADMIN_PERMISSION_PREFIX
).delete()
user = User.objects.first()
request: HttpRequest = HttpRequest()
request.user = user # t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_treant_read_only(self, treant):\n c = dtr.treants.Treant(treant.filepath)\n\n assert '72' in c.tags\n\n with pytest.raises(OSError):\n c.tags.add('yet another')",
"def test_tag_is_in_the_template(self):\n\n template = Template(\n '{% load profile_admin_edi... | [
"0.61190975",
"0.6086904",
"0.6052937",
"0.5827966",
"0.581275",
"0.57271177",
"0.5710848",
"0.57108027",
"0.5704276",
"0.5665072",
"0.5631103",
"0.5597773",
"0.5547841",
"0.55258054",
"0.550138",
"0.54962355",
"0.54947996",
"0.5480777",
"0.54641604",
"0.5458246",
"0.54438907... | 0.0 | -1 |
XML with no network and no filesystem. | def test_domain_xml(self):
config = """<domain></domain>"""
expected = """<domain><name>foo</name><uuid>foo</uuid><devices /></domain>"""
results = lxc.domain_xml('foo', config, [])
self.assertEqual(results, expected, compare(results, expected)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xml(self):\n raise NotImplementedError('This api does not return xml')",
"def xml(self):\n raise NotImplementedError('must be implemented by all subclasses')",
"def get_xml(self):\n with io.StringIO() as string:\n string.write(ET.tostring(self.root, encoding=\"unicode\"))\n ... | [
"0.67211664",
"0.6709897",
"0.6594518",
"0.6356559",
"0.6220376",
"0.6173464",
"0.6173464",
"0.61177075",
"0.61158663",
"0.61071706",
"0.6065701",
"0.60616076",
"0.60153663",
"0.60100573",
"0.59988874",
"0.5965165",
"0.59403014",
"0.59362495",
"0.591197",
"0.585255",
"0.58465... | 0.0 | -1 |
Resources initializer with no extra value. | def test_initialize_default(self, create_mock, libvirt_mock):
resources = lxc.LXCResources('foo', {'domain': 'bar'})
libvirt_mock.open.assert_called_with('lxc:///')
create_mock.assert_called_with(resources.hypervisor, 'foo', 'bar', network_name=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: BundleArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def __init__(__self__,\n resource_name: str,\n args: RuntimeArgs,\n opts: Optional[pul... | [
"0.69835156",
"0.6968175",
"0.6919319",
"0.6858264",
"0.6858264",
"0.6858264",
"0.68213904",
"0.67804784",
"0.6768846",
"0.6751683",
"0.6732026",
"0.6678428",
"0.66677177",
"0.66382426",
"0.66382426",
"0.6621855",
"0.6600339",
"0.65958875",
"0.65857095",
"0.65857095",
"0.6585... | 0.0 | -1 |
Resources initializer with hypervisor. | def test_initialize_hypervisor(self, create_mock, libvirt_mock):
resources = lxc.LXCResources('foo', {'domain': 'bar', 'hypervisor': 'baz'})
libvirt_mock.open.assert_called_with('baz')
create_mock.assert_called_with(resources.hypervisor, 'foo', 'bar', network_name=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: RuntimeArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def __init__(__self__,\n resource_name: str,\n args: Optional[AgentArgs] = None,\n op... | [
"0.70111245",
"0.69389325",
"0.6907474",
"0.67549026",
"0.67546374",
"0.6732985",
"0.67153203",
"0.66878206",
"0.66878206",
"0.66878206",
"0.66878206",
"0.66878206",
"0.66878206",
"0.6632734",
"0.65965056",
"0.65924555",
"0.6588648",
"0.6577639",
"0.65654016",
"0.65654016",
"... | 0.63862586 | 36 |
return unique elements with original order | def uniq(elements):
us = set()
ret = []
for e in elements:
if e not in us:
ret.append(e)
us.add(e)
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def uniq_stable(elems):\r\n unique = []\r\n unique_set = set()\r\n for nn in elems:\r\n if nn not in unique_set:\r\n unique.append(nn)\r\n unique_set.add(nn)\r\n return unique",
"def _unique(li):\n return list(set(li))",
"def _naive_unique(li):\n tmp = []\n for... | [
"0.7550287",
"0.7497579",
"0.7439703",
"0.74223703",
"0.73448586",
"0.7324739",
"0.73042953",
"0.7301965",
"0.7275987",
"0.72683775",
"0.7239039",
"0.7217278",
"0.71151435",
"0.7104646",
"0.7085114",
"0.7069256",
"0.70334715",
"0.6945896",
"0.6941064",
"0.69389355",
"0.689732... | 0.7472282 | 2 |
Build a Pyspark session Returns A Pyspark object | def create_spark_session():
try:
spark = (
SparkSession.builder
# .config("spark.hadoop.fs.s3a.awsAccessKeyId", os.environ['AWS_ACCESS_KEY_ID'])
# .config("spark.hadoop.fs.s3a.awsSecretAccessKey", os.environ['AWS_SECRET_ACCE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_sparksession():\n return SparkSession.builder.\\\n appName(\"Transforming the historical parking occupancy and blockface datasets\").\\\n getOrCreate()",
"def get_pyspark_session():\n session_object = SparkSession \\\n .builder \\\n .appName(\"PySpark ... | [
"0.83327085",
"0.8046334",
"0.79543847",
"0.7754394",
"0.7748665",
"0.7748665",
"0.7748665",
"0.7748665",
"0.7748665",
"0.7748665",
"0.7748665",
"0.7748665",
"0.7748665",
"0.77421665",
"0.7740549",
"0.7740549",
"0.7740549",
"0.7740549",
"0.77382874",
"0.7731292",
"0.7698544",... | 0.7432718 | 27 |
Write a caDNAno JSON file. | def write_cadnano_file(self, file_name):
cadnano_writer = CadnanoWriter(self.dna_structure)
cadnano_writer.write(file_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_json(self):\n with open(self._file_path, 'w') as f:\n json.dump(self._content, f, indent=4, separators=None,\n encoding='utf-8', sort_keys=False)",
"def write_json_file(self, file, content):\n with open(file, \"w\", encoding=\"utf-8\") as f:\n j... | [
"0.6951074",
"0.677341",
"0.6629737",
"0.6629737",
"0.66059667",
"0.65767187",
"0.65417486",
"0.6537758",
"0.6508778",
"0.6502386",
"0.64639634",
"0.64595634",
"0.6426804",
"0.6416569",
"0.6396158",
"0.63837844",
"0.63826203",
"0.63814265",
"0.63765866",
"0.63731694",
"0.6372... | 0.60426 | 69 |
Creates a context with an open SQLAlchemy session. | def get_db_session():
engine = create_engine(get_connection_string(), convert_unicode=True)
connection = engine.connect()
db_session = Session(
autocommit=False,
autoflush=True,
bind=engine
)
yield db_session
db_session.close()
connection.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _session_maker(self) -> ContextManager[Session]:\r\n session = self._Session()\r\n try:\r\n yield session\r\n session.commit()\r\n except DBAPIError:\r\n session.rollback()\r\n raise\r\n finally:\r\n session.close()",
"def ses... | [
"0.709479",
"0.7078785",
"0.70605564",
"0.700395",
"0.6848739",
"0.6826667",
"0.6761636",
"0.67514133",
"0.67454827",
"0.6744146",
"0.6734932",
"0.6719413",
"0.6709968",
"0.66998",
"0.6686789",
"0.66775167",
"0.66750073",
"0.6670862",
"0.6666354",
"0.6579564",
"0.657379",
"... | 0.64129317 | 32 |
Softmax over groups. All groups share the same group size. | def sog(x, groups_size):
# Sanity check
assert isinstance(x, tf.Tensor)
x_shape = x.shape.as_list()
assert len(x_shape) == 2
num_neurons = x_shape[-1]
S = checker.check_positive_integer(groups_size)
assert num_neurons % S == 0
# Reshape neurons
x_reshaped = tf.reshape(x, shape=[-1, S])
# Apply soft... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(x):\n # (n_samples, n_classes)\n if len(x.shape) == 2:\n row_max = np.max(x, axis=1)\n x -= row_max.reshape((x.shape[0], 1))\n x = np.exp(x)\n row_sum = np.sum(x, axis=1)\n x /= row_sum.reshape((x.shape[0], 1))\n # (n_samples, n_tasks, n_classes)\n elif len(x.shape) == 3:\n row_ma... | [
"0.6568198",
"0.631294",
"0.6010785",
"0.59596485",
"0.5951292",
"0.5859833",
"0.5859649",
"0.5839281",
"0.5810791",
"0.5785066",
"0.5770015",
"0.5770015",
"0.5770015",
"0.5770015",
"0.5727089",
"0.5721308",
"0.57204163",
"0.57156783",
"0.569816",
"0.5689935",
"0.5677133",
... | 0.63796103 | 1 |
Returns capital letters within the input string. | def abbreviate(x: str) -> str:
i = 0
abbreviation: str = ""
while i < len(x):
if x[i].isupper():
abbreviation += x[i]
i += 1
return abbreviation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def capitalcase(string):\n\n string = str(string)\n if not string:\n return string\n return uppercase(string[0]) + string[1:]",
"def upper(string):\n new_string = '' # Empty string to append to\n for char in string: # Itterate over each character in user's string\n if char.isalpha() ... | [
"0.7921962",
"0.7850552",
"0.7691541",
"0.7644469",
"0.76217824",
"0.7605055",
"0.75617313",
"0.75459915",
"0.75251865",
"0.7404995",
"0.7378243",
"0.73501873",
"0.7344418",
"0.72820425",
"0.7280072",
"0.7279875",
"0.7255222",
"0.71737206",
"0.71700895",
"0.7123255",
"0.71054... | 0.71397704 | 19 |
check if the start_row_id has map in end_knowledge_table | def exist_import_record(session, kg_table_id, kg_table_primary_key):
try:
team = session.query(DocumentSourceRecord).filter_by(kg_table_id=kg_table_id,
kg_table_primary_key=kg_table_primary_key).first()
if team:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66128033",
"0.649678",
"0.59735113",
"0.59398353",
"0.58602375",
"0.56573",
"0.55274904",
"0.55151254",
"0.5495567",
"0.54856944",
"0.54851085",
"0.54788804",
"0.54737073",
"0.5415907",
"0.53599536",
"0.5304519",
"0.5286059",
"0.5279504",
"0.5275848",
"0.5267347",
"0.52338... | 0.0 | -1 |
check if the start_row_id has map in end_knowledge_table | def exist_import_record(session, doc_id, sentence_index):
try:
team = session.query(DocumentSentenceText).filter_by(doc_id=doc_id,
sentence_index=sentence_index).first()
if team:
return True
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66129446",
"0.6497109",
"0.597367",
"0.5940399",
"0.5860753",
"0.56569415",
"0.55275184",
"0.55145544",
"0.5494718",
"0.54860157",
"0.54846746",
"0.5479943",
"0.5473402",
"0.54169065",
"0.535991",
"0.5303709",
"0.52869266",
"0.5280877",
"0.5277315",
"0.52677774",
"0.523415... | 0.0 | -1 |
check if the start_row_id has map in end_knowledge_table | def exist_import_record(session, doc_id):
try:
team = session.query(DocumentSentenceText).filter_by(doc_id=doc_id).first()
if team:
return True
else:
return False
except Exception:
traceback.print_exc()
return Fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66114324",
"0.6495087",
"0.5973403",
"0.59395033",
"0.5859096",
"0.5656392",
"0.55260056",
"0.5516347",
"0.54967105",
"0.5484372",
"0.54840684",
"0.5477858",
"0.5475501",
"0.5414925",
"0.5359367",
"0.53071344",
"0.52858347",
"0.5280636",
"0.5273883",
"0.5267743",
"0.523310... | 0.0 | -1 |
check if the start_row_id has map in end_knowledge_table | def exist_import_record(session, doc_id, sentence_index):
try:
team = session.query(DocumentSentenceText).filter_by(doc_id=doc_id,
sentence_index=sentence_index).first()
if team:
return True
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66114324",
"0.6495087",
"0.5973403",
"0.59395033",
"0.5859096",
"0.5656392",
"0.55260056",
"0.5516347",
"0.54967105",
"0.5484372",
"0.54840684",
"0.5477858",
"0.5475501",
"0.5414925",
"0.5359367",
"0.53071344",
"0.52858347",
"0.5280636",
"0.5273883",
"0.5267743",
"0.523310... | 0.0 | -1 |
check if the start_row_id has map in end_knowledge_table | def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):
try:
team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,
end_table_id=end_knowledge_tabl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id, start_row_name):\n\n try:\n team = session.query(KnowledgeTableColumnMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n ... | [
"0.649678",
"0.59735113",
"0.59398353",
"0.58602375",
"0.56573",
"0.55274904",
"0.55151254",
"0.5495567",
"0.54856944",
"0.54851085",
"0.54788804",
"0.54737073",
"0.5415907",
"0.53599536",
"0.5304519",
"0.5286059",
"0.5279504",
"0.5275848",
"0.5267347",
"0.523386",
"0.5226956... | 0.66128033 | 0 |
check if the start_row_id has map in end_knowledge_table | def get_end_row_id(session, start_knowledge_table, end_knowledge_table, start_row_id):
try:
end_row_id = session.query(KnowledgeTableRowMapRecord.end_row_id).filter_by(
start_table_id=start_knowledge_table.id,
end_table_id=end_knowledge_table.id,
star... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66129446",
"0.6497109",
"0.5940399",
"0.5860753",
"0.56569415",
"0.55275184",
"0.55145544",
"0.5494718",
"0.54860157",
"0.54846746",
"0.5479943",
"0.5473402",
"0.54169065",
"0.535991",
"0.5303709",
"0.52869266",
"0.5280877",
"0.5277315",
"0.52677774",
"0.52341586",
"0.5227... | 0.597367 | 2 |
check if the start_row_id has map in end_knowledge_table | def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id, start_row_name):
try:
team = session.query(KnowledgeTableColumnMapRecord).filter_by(start_table_id=start_knowledge_table.id,
end_table... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66114324",
"0.5973403",
"0.59395033",
"0.5859096",
"0.5656392",
"0.55260056",
"0.5516347",
"0.54967105",
"0.5484372",
"0.54840684",
"0.5477858",
"0.5475501",
"0.5414925",
"0.5359367",
"0.53071344",
"0.52858347",
"0.5280636",
"0.5273883",
"0.5267743",
"0.5233106",
"0.522652... | 0.6495087 | 1 |
check if the start_row_id has map in end_knowledge_table | def get_end_row_id(session, start_knowledge_table, end_knowledge_table, start_row_id, start_row_name):
try:
end_row_id = session.query(KnowledgeTableColumnMapRecord.end_row_id).filter_by(
start_table_id=start_knowledge_table.id,
end_table_id=end_knowledge_table.id,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exist_import_record(session, start_knowledge_table, end_knowledge_table, start_row_id):\n\n try:\n team = session.query(KnowledgeTableRowMapRecord).filter_by(start_table_id=start_knowledge_table.id,\n end_table_id=end_knowl... | [
"0.66114324",
"0.6495087",
"0.5973403",
"0.5859096",
"0.5656392",
"0.55260056",
"0.5516347",
"0.54967105",
"0.5484372",
"0.54840684",
"0.5477858",
"0.5475501",
"0.5414925",
"0.5359367",
"0.53071344",
"0.52858347",
"0.5280636",
"0.5273883",
"0.5267743",
"0.5233106",
"0.5226524... | 0.59395033 | 3 |
make a temp folder with two files, set all assert expectations | def setUp(self):
if not os.path.exists(TEMPDIR):
os.makedirs(TEMPDIR)
self.file1 = os.path.join(TEMPDIR, 'list1')
tempfile = open(self.file1, 'w')
tempfile.write('123\r\n'
'ggg\n'
'456\n'
'789\n'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create1(self):\n fname = TempfileManager.create_tempfile()\n OUTPUT = open(fname, 'w')\n OUTPUT.write('tempfile\\n')\n OUTPUT.close()\n self.assertEqual(len(list(glob.glob(tempdir + '*'))), 1)\n fname = os.path.basename(fname)\n self.assertTrue(fname.starts... | [
"0.6826671",
"0.6748019",
"0.67260873",
"0.671061",
"0.66951644",
"0.6670541",
"0.6655966",
"0.65996593",
"0.65901643",
"0.65636027",
"0.655527",
"0.6543404",
"0.6538157",
"0.6524749",
"0.65193",
"0.6510551",
"0.64770895",
"0.6474521",
"0.64591104",
"0.6421846",
"0.63996977",... | 0.0 | -1 |
This function takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. | def vowel_check(char) :
try :
if len(char) > 1 :
print("Plase enter a string of length 1.")
return "None"
if char in 'aeiou' :
return 'TRUE'
else :
return 'FALSE'
except :
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vowel(self, letter):\n\n if letter in (\"a\", \"e\", \"i\", \"o\", \"u\", \"A\", \"E\", \"I\", \"O\", \"U\"):\n return True\n return False",
"def is_english_vowel(c):\n # y was included in the vowel set guided by the tests.\n return c in 'aeiouyAEIOUY'",
"def is_vowel(x):\... | [
"0.84264004",
"0.8105966",
"0.80350935",
"0.8011603",
"0.7709178",
"0.76001656",
"0.75937635",
"0.72694975",
"0.7150572",
"0.7058797",
"0.70575094",
"0.7041131",
"0.6919922",
"0.6821393",
"0.6727686",
"0.66585976",
"0.66014874",
"0.6589503",
"0.658432",
"0.6567346",
"0.654478... | 0.81157774 | 1 |
Initialize anything that is necessary for the driver to function, including catching up with currently running VM's on the given host. | def init_host(self, host):
LOG.debug("init_host") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_host(self, host):\n if self._drv_nodes is None:\n self.set_nodes([nova_conf.host])\n args = (drv_conf.tenant_id, drv_conf.client_id, drv_conf.client_secret,\n drv_conf.subscription_id)\n\n self.compute_client = utils.get_compute_client(*args)\n self.re... | [
"0.73931396",
"0.699368",
"0.6976518",
"0.6920141",
"0.6685205",
"0.6634639",
"0.661946",
"0.63049614",
"0.62223625",
"0.6211909",
"0.6137838",
"0.613504",
"0.6130874",
"0.61211365",
"0.6111591",
"0.6081075",
"0.60656035",
"0.6050122",
"0.6029312",
"0.60287863",
"0.59993434",... | 0.78632885 | 0 |
Sets all pixels of the mask with any of the `void_labels` to `ignore_index` (250 by default). It also sets all of the valid pixels to the appropriate value between 0 and `len(valid_labels)` (the number of valid classes), so it can be used properly by the loss function when comparing with the output. | def encode_segmap(self, mask):
for voidc in self.void_labels:
mask[mask == voidc] = self.ignore_index
for validc in self.valid_labels:
mask[mask == validc] = self.class_map[validc]
# remove extra idxs from updated dataset
mask[mask > 33] = self.ignore_index
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mask_for_valid_labels(y_true, num_classes, ignore_value=255):\n mask_for_class_elements = y_true < num_classes\n mask_for_not_ignored = y_true != ignore_value\n mask = mask_for_class_elements & mask_for_not_ignored\n return mask",
"def mask_labels(labels):\n def do_one_row(row):\n e... | [
"0.59062743",
"0.5682668",
"0.5658332",
"0.5476246",
"0.5444317",
"0.54396766",
"0.5410731",
"0.54062945",
"0.53907627",
"0.5373888",
"0.5351935",
"0.5350788",
"0.53493685",
"0.5337512",
"0.5311257",
"0.53056294",
"0.53038055",
"0.5296964",
"0.5291443",
"0.52890015",
"0.52799... | 0.5542859 | 3 |
This function is aimed to perform global cepstral mean and variance normalization (CMVN) on input feature vector "vec". The code assumes that there is one observation per row. | def cmvn(vec, variance_normalization=False):
eps = 2**-30
rows, cols = vec.shape
# Mean calculation
#norm = numpy.mean(vec, axis=0)
norm=[13.81728912,13.54220955,14.5613793,15.45506153,16.28197078,16.77583828,16.90248914,16.51130705,16.87707883,17.03003926,16.79243714,16.4319049,16.15078832,15.9641... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_comp(cvec):\n return cvec / cvec.norm()",
"def cmvn2(vec,in_norm=None, variance_normalization=False,dim=80):\n rows,cols = vec.shape\n if in_norm is None:\n norm = [[-3.42167211,-3.19438577,-3.38188171,-3.70518327,-3.95481634,-4.08967972,\n-4.12971735,-4.0177989,-4.05439854,-4.11131... | [
"0.67202294",
"0.6673946",
"0.61875623",
"0.61011565",
"0.59893864",
"0.5933701",
"0.5918822",
"0.5900189",
"0.58628786",
"0.58394897",
"0.5838135",
"0.58169335",
"0.5767543",
"0.57610124",
"0.56862885",
"0.5676205",
"0.5675418",
"0.56637156",
"0.5636937",
"0.563527",
"0.5626... | 0.72533476 | 0 |
This function is aimed to perform global cepstral mean and variance normalization (CMVN) on input feature vector "vec". The code assumes that there is one observation per row. | def cmvn2(vec,in_norm=None, variance_normalization=False,dim=80):
rows,cols = vec.shape
if in_norm is None:
norm = [[-3.42167211,-3.19438577,-3.38188171,-3.70518327,-3.95481634,-4.08967972,
-4.12971735,-4.0177989,-4.05439854,-4.11131907,-4.2040782,-4.20991182,
-4.25162649,-4.25907564,-4.2473011,-4.28639... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cmvn(vec, variance_normalization=False):\n eps = 2**-30\n rows, cols = vec.shape\n\n # Mean calculation\n #norm = numpy.mean(vec, axis=0)\n norm=[13.81728912,13.54220955,14.5613793,15.45506153,16.28197078,16.77583828,16.90248914,16.51130705,16.87707883,17.03003926,16.79243714,16.4319049,16.15078... | [
"0.7252343",
"0.67199934",
"0.61868334",
"0.61004674",
"0.5988228",
"0.5934621",
"0.59169245",
"0.5900855",
"0.58614826",
"0.5838757",
"0.5837043",
"0.58157766",
"0.57666147",
"0.57600486",
"0.56847477",
"0.5673683",
"0.5672899",
"0.566184",
"0.5634466",
"0.5634102",
"0.56252... | 0.6672436 | 2 |
Convert a value in Hertz to Mels | def hz2mel(hz):
return 1127 * numpy.log(1+hz/700.0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mel_to_hertz(self, mel):\n # return 700.0 * (10**(mel / 2595.0)) - 700.0\n return 250.0 * (9**(mel / 3340.0)) - 250.0",
"def hertz_to_mel(self, freq):\n return 3340.0 * log(1 + (freq / 250.0), 9)",
"def hertz_to_mel(freq: float, mel_scale: str = \"htk\") -> float:\n\n if mel_scale n... | [
"0.65619797",
"0.6403715",
"0.6179361",
"0.614567",
"0.6110985",
"0.6022982",
"0.60077816",
"0.6001723",
"0.5920106",
"0.58806825",
"0.5839047",
"0.57391065",
"0.5721858",
"0.5710986",
"0.57069176",
"0.5697958",
"0.5669627",
"0.5623773",
"0.5597605",
"0.5586246",
"0.5542022",... | 0.5577878 | 20 |
Convert a value in Mels to Hertz | def mel2hz(mel):
return 700 * (numpy.exp(mel/1127.0)-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mel_to_hertz(self, mel):\n # return 700.0 * (10**(mel / 2595.0)) - 700.0\n return 250.0 * (9**(mel / 3340.0)) - 250.0",
"def torch_mel_to_hertz(frequencies_mel):\r\n # return _MEL_BREAK_FREQUENCY_HERTZ * (\r\n # tf.math.exp(frequencies_mel / _MEL_HIGH_FREQUENCY_Q) - 1.)\r\n ret... | [
"0.7050474",
"0.62311673",
"0.6166904",
"0.6111613",
"0.6007273",
"0.5893435",
"0.58479744",
"0.5803646",
"0.57042795",
"0.57033795",
"0.56962776",
"0.5662375",
"0.5657948",
"0.56506306",
"0.5649922",
"0.56447536",
"0.56268424",
"0.5604601",
"0.5570622",
"0.55185694",
"0.5517... | 0.51501805 | 51 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.