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 |
|---|---|---|---|---|---|---|
Gets a ``CommentList`` corresponding to the given comment genus ``Type`` and include any additional comments with genus types derived from the specified ``Type``. | def get_comments_by_parent_genus_type(self, comment_genus_type):
# Implemented from template for
# osid.resource.ResourceLookupSession.get_resources_by_parent_genus_type
# STILL NEED TO IMPLEMENT!!!
return objects.CommentList([]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_by_genus_type(self, comment_genus_type):\n # Implemented from template for\n # osid.resource.ResourceLookupSession.get_resources_by_genus_type\n # NOTE: This implementation currently ignores plenary view\n collection = JSONClientValidated('commenting',\n ... | [
"0.77354604",
"0.710349",
"0.6945482",
"0.68799645",
"0.6520769",
"0.62607336",
"0.62215036",
"0.61736494",
"0.61298835",
"0.57949764",
"0.5617653",
"0.5569759",
"0.55401784",
"0.55231917",
"0.54597247",
"0.54250884",
"0.5357421",
"0.52820945",
"0.52820945",
"0.52820945",
"0.... | 0.7559935 | 1 |
Gets a ``CommentList`` containing the given comment record ``Type``. | def get_comments_by_record_type(self, comment_record_type):
# Implemented from template for
# osid.resource.ResourceLookupSession.get_resources_by_record_type
# STILL NEED TO IMPLEMENT!!!
return objects.CommentList([]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_by_genus_type(self, comment_genus_type):\n # Implemented from template for\n # osid.resource.ResourceLookupSession.get_resources_by_genus_type\n # NOTE: This implementation currently ignores plenary view\n collection = JSONClientValidated('commenting',\n ... | [
"0.7270703",
"0.68646073",
"0.676033",
"0.64582574",
"0.634903",
"0.614865",
"0.61244595",
"0.6021373",
"0.58704853",
"0.5869703",
"0.5833812",
"0.57910854",
"0.56667525",
"0.565118",
"0.56449765",
"0.55936635",
"0.5426422",
"0.5373219",
"0.53415656",
"0.53154033",
"0.5276660... | 0.8408125 | 0 |
Gets a list of all comments corresponding to a resource ``Id`` and effective during the entire given date range inclusive but not confined to the date range. | def get_comments_for_commentor_on_date(self, resource_id, from_, to):
# Implemented from template for
# osid.relationship.RelationshipLookupSession.get_relationships_for_destination_on_date
comment_list = []
for comment in self.get_comments_for_commentor():
if overlap(from_, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_between(self, start_date, end_date):\n ret = []\n ids = self.get_post_ids(start_date, end_date)\n\n for id in ids:\n comments = self.reddit.submission(id).comments\n ret.append(self.get_nested_comments(comments))\n return ret",
"def get_comments_... | [
"0.7158561",
"0.69310486",
"0.67755306",
"0.6633708",
"0.6268268",
"0.6017398",
"0.5765618",
"0.56689966",
"0.5598511",
"0.55958277",
"0.5593436",
"0.55545807",
"0.5499906",
"0.54898906",
"0.5473202",
"0.54611444",
"0.54546434",
"0.5454203",
"0.5373503",
"0.53721774",
"0.5352... | 0.75241077 | 0 |
Gets a list of all comments of the given genus type corresponding to a resource ``Id`` and effective during the entire given date range inclusive but not confined to the date range. | def get_comments_by_genus_type_for_commentor_on_date(self, resource_id, comment_genus_type, from_, to):
raise errors.Unimplemented() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_by_genus_type_for_reference_on_date(self, reference_id, comment_genus_type, from_, to):\n # Implemented from template for\n # osid.relationship.RelationshipLookupSession.get_relationships_by_genus_type_for_source_on_date\n comment_list = []\n for comment in self.get_com... | [
"0.6809972",
"0.64708966",
"0.64239943",
"0.6186121",
"0.609781",
"0.6064781",
"0.6030827",
"0.6014355",
"0.6002978",
"0.58541834",
"0.5788782",
"0.5763983",
"0.5589301",
"0.55681354",
"0.55553627",
"0.53404146",
"0.53301966",
"0.52368593",
"0.51902926",
"0.51415366",
"0.5123... | 0.6662174 | 1 |
Gets a list of all comments corresponding to a reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range. | def get_comments_for_reference_on_date(self, reference_id, from_, to):
# Implemented from template for
# osid.relationship.RelationshipLookupSession.get_relationships_for_source_on_date
comment_list = []
for comment in self.get_comments_for_reference(reference_id):
if overlap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_between(self, start_date, end_date):\n ret = []\n ids = self.get_post_ids(start_date, end_date)\n\n for id in ids:\n comments = self.reddit.submission(id).comments\n ret.append(self.get_nested_comments(comments))\n return ret",
"def get_comments_... | [
"0.7234657",
"0.70719373",
"0.6991571",
"0.68628234",
"0.6430302",
"0.6250021",
"0.58757615",
"0.58235896",
"0.58179855",
"0.5685607",
"0.560133",
"0.56004786",
"0.5592098",
"0.5574015",
"0.5557389",
"0.5522056",
"0.5504479",
"0.5312983",
"0.5290305",
"0.52881515",
"0.5273492... | 0.764671 | 0 |
Gets a list of all comments corresponding to a resource and reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range. | def get_comments_for_commentor_and_reference_on_date(self, resource_id, reference_id, from_, to):
raise errors.Unimplemented() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_for_commentor_on_date(self, resource_id, from_, to):\n # Implemented from template for\n # osid.relationship.RelationshipLookupSession.get_relationships_for_destination_on_date\n comment_list = []\n for comment in self.get_comments_for_commentor():\n if overl... | [
"0.74694806",
"0.72792614",
"0.71093345",
"0.6903956",
"0.6266337",
"0.6180936",
"0.607888",
"0.59575754",
"0.5885219",
"0.56007606",
"0.55652887",
"0.55269015",
"0.5421804",
"0.5407062",
"0.5383751",
"0.5369716",
"0.5335828",
"0.53321344",
"0.53236073",
"0.53147197",
"0.5305... | 0.7255787 | 2 |
Gets a list of all comments corresponding to a resource and reference ``Id`` and effective during the entire given date range inclusive but not confined to the date range. | def get_comments_by_genus_type_for_commentor_and_reference_on_date(self, resource_id, reference_id, comment_genus_type, from_, to):
raise errors.Unimplemented() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comments_for_commentor_on_date(self, resource_id, from_, to):\n # Implemented from template for\n # osid.relationship.RelationshipLookupSession.get_relationships_for_destination_on_date\n comment_list = []\n for comment in self.get_comments_for_commentor():\n if overl... | [
"0.7469022",
"0.72780234",
"0.72545433",
"0.71086013",
"0.6903032",
"0.62671906",
"0.6181736",
"0.60775185",
"0.59565717",
"0.5884894",
"0.5565529",
"0.55239505",
"0.5419757",
"0.5406539",
"0.53827953",
"0.5369887",
"0.53349763",
"0.5330268",
"0.5323971",
"0.5314115",
"0.5306... | 0.55996025 | 10 |
Gets the ``Book`` ``Id`` associated with this session. | def get_book_id(self):
# Implemented from template for osid.resource.ResourceLookupSession.get_bin_id
return self._catalog_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getId(self):\n return self.session.request('id/')",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_i... | [
"0.6768813",
"0.6590069",
"0.6590069",
"0.6590069",
"0.6590069",
"0.6590069",
"0.6590069",
"0.64731216",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.64559823",
"0.... | 0.7994723 | 2 |
Gets a comment query. | def get_comment_query(self):
# Implemented from template for
# osid.resource.ResourceQuerySession.get_resource_query_template
return queries.CommentQuery(runtime=self._runtime) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_comment_query_session(self):\n raise Unimplemented()",
"def get_comment_query_session(self, proxy=None):\n if proxy is None:\n raise NullArgument()\n raise Unimplemented()",
"def supports_comment_query(self):\n return False",
"def get_comments_by_query(self, com... | [
"0.7160014",
"0.6551286",
"0.65420234",
"0.64702123",
"0.63903075",
"0.62301564",
"0.61268145",
"0.60809445",
"0.606229",
"0.59921944",
"0.59453064",
"0.5915195",
"0.58783895",
"0.58536386",
"0.5808951",
"0.5767042",
"0.5762327",
"0.57604027",
"0.5737071",
"0.56959414",
"0.56... | 0.83252674 | 0 |
Gets the ``Book`` ``Id`` associated with this session. | def get_book_id(self):
# Implemented from template for osid.resource.ResourceLookupSession.get_bin_id
return self._catalog_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getId(self):\n return self.session.request('id/')",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_id(self):\n return self._id",
"def get_i... | [
"0.67711055",
"0.6592667",
"0.6592667",
"0.6592667",
"0.6592667",
"0.6592667",
"0.6592667",
"0.64721787",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
"0.645847",
... | 0.7994095 | 1 |
Tests if this user can update comments. A return of true does not guarantee successful authorization. A return of false indicates that it is known updating a ``Comment`` will result in a ``PermissionDenied``. This is intended as a hint to an application that may not wish to offer update operations to unauthorized users... | def can_update_comments(self):
# Implemented from template for
# osid.resource.ResourceAdminSession.can_update_resources
# NOTE: It is expected that real authentication hints will be
# handled in a service adapter above the pay grade of this impl.
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_user_can_update_comment(self):\n token = self.create_user(VALID_USER_DATA)\n response = self.create_article(VALID_ARTICLE, token)\n\n response = self.create_comment(\n token=token,\n parentId=0,\n slug=response.data['article']['slug']\n ... | [
"0.6664955",
"0.6631961",
"0.6614367",
"0.6436579",
"0.6378953",
"0.63283336",
"0.63095975",
"0.62722355",
"0.6244667",
"0.6226579",
"0.6162568",
"0.6133568",
"0.6123118",
"0.6099221",
"0.60988504",
"0.60869426",
"0.6049858",
"0.6040769",
"0.586258",
"0.5847504",
"0.5833176",... | 0.7890379 | 0 |
Tests if this user can delete comments. A return of true does not guarantee successful authorization. A return of false indicates that it is known deleting an ``Comment`` will result in a ``PermissionDenied``. This is intended as a hint to an application that may not wish to offer delete operations to unauthorized user... | def can_delete_comments(self):
# Implemented from template for
# osid.resource.ResourceAdminSession.can_delete_resources
# NOTE: It is expected that real authentication hints will be
# handled in a service adapter above the pay grade of this impl.
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_delete_comment(comment, user):\r\n if user.is_staff or user.is_superuser:\r\n return True\r\n if hasattr(comment, 'user') and comment.user == user:\r\n return True\r\n return False",
"def can_delete(self, user):\n raise Return(False)",
"def check_can_delete_comments(member... | [
"0.7813405",
"0.7048792",
"0.6845166",
"0.6832752",
"0.6738561",
"0.6678822",
"0.66078484",
"0.6585122",
"0.6521498",
"0.6507688",
"0.6507688",
"0.64436454",
"0.64268845",
"0.63643116",
"0.631254",
"0.6292842",
"0.6282365",
"0.6259496",
"0.62067854",
"0.6161284",
"0.61329174"... | 0.78848416 | 0 |
Adds an ``Id`` to a ``Comment`` for the purpose of creating compatibility. The primary ``Id`` of the ``Comment`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another comment, it is reassigned to the given comment ``Id``. | def alias_comment(self, comment_id, alias_id):
# Implemented from template for
# osid.resource.ResourceAdminSession.alias_resources_template
self._alias_id(primary_id=comment_id, equivalent_id=alias_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_comment_id(comment_id):\n\t\n\twith _conn.cursor() as cur:\n\t\tcur.execute('INSERT INTO comment_ids (comment_id, timestamp) VALUES (%s, NOW())', [comment_id])\n\t_conn.commit()",
"def comment(self, comment_id):\r\n return c.Comment(self, comment_id)",
"def SetId(self, new_id):\r\n\r\n se... | [
"0.6189758",
"0.56712806",
"0.5639575",
"0.5545899",
"0.55393416",
"0.553618",
"0.55260956",
"0.5363888",
"0.5274192",
"0.5274192",
"0.5274192",
"0.5274192",
"0.5274192",
"0.5274177",
"0.52640754",
"0.52533126",
"0.52533126",
"0.52533126",
"0.52533126",
"0.52533126",
"0.52533... | 0.67881006 | 0 |
Tests if this user can alter comment/book mappings. A return of true does not guarantee successful authorization. A return of false indicates that it is known mapping methods in this session will result in a ``PermissionDenied``. This is intended as a hint to an application that may opt not to offer assignment operatio... | def can_assign_comments(self):
# Implemented from template for
# osid.resource.ResourceBinAssignmentSession.can_assign_resources
# NOTE: It is expected that real authentication hints will be
# handled in a service adapter above the pay grade of this impl.
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CAN_CHANGE_PERMISSIONS(article, user): # pylint: disable=invalid-name\r\n return _is_staff_for_article(article, user)",
"def edit_allowed(self):\n account = Account.current_user_account\n if account is None:\n return False\n return self.user_can_edit(account.user)",
"def can_modify(articl... | [
"0.6132092",
"0.61024094",
"0.5983884",
"0.59715986",
"0.5958646",
"0.5949641",
"0.594484",
"0.5912866",
"0.59046435",
"0.58918923",
"0.58815473",
"0.58730465",
"0.5865155",
"0.5858243",
"0.58538693",
"0.5853447",
"0.5786703",
"0.5762909",
"0.575044",
"0.5719194",
"0.5709206"... | 0.60442424 | 2 |
Tests if this user can alter comment/book mappings. A return of true does not guarantee successful authorization. A return of false indicates that it is known mapping methods in this session will result in a ``PermissionDenied``. This is intended as a hint to an application that may opt not to offer assignment operatio... | def can_assign_comments_to_book(self, book_id):
# Implemented from template for
# osid.resource.ResourceBinAssignmentSession.can_assign_resources_to_bin
# NOTE: It is expected that real authentication hints will be
# handled in a service adapter above the pay grade of this impl.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CAN_CHANGE_PERMISSIONS(article, user): # pylint: disable=invalid-name\r\n return _is_staff_for_article(article, user)",
"def edit_allowed(self):\n account = Account.current_user_account\n if account is None:\n return False\n return self.user_can_edit(account.user)",
"def can_assign_commen... | [
"0.6133551",
"0.6102446",
"0.60465133",
"0.59847903",
"0.59713924",
"0.59584904",
"0.59494656",
"0.5945789",
"0.59141344",
"0.59060436",
"0.58932984",
"0.5883722",
"0.58732396",
"0.58652955",
"0.5859786",
"0.58557105",
"0.58542717",
"0.5787939",
"0.57653177",
"0.5751438",
"0.... | 0.0 | -1 |
Adds an existing ``Comment`` to a ``Book``. | def assign_comment_to_book(self, comment_id, book_id):
# Implemented from template for
# osid.resource.ResourceBinAssignmentSession.assign_resource_to_bin
mgr = self._get_provider_manager('COMMENTING', local=True)
lookup_session = mgr.get_book_lookup_session(proxy=self._proxy)
lo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_comment(self, comment):\n assert isinstance(comment, Comment)\n self._comments.append(comment)\n return None",
"def addBook(self, book):\n self._books[book.getTitle()] = book",
"def add_book(self, book):\n\n try:\n with self._db as db:\n ... | [
"0.68614775",
"0.67351884",
"0.6727313",
"0.6692883",
"0.66474736",
"0.65948236",
"0.6580817",
"0.6559012",
"0.6434129",
"0.6432361",
"0.6322771",
"0.6242738",
"0.6084988",
"0.59747404",
"0.5932399",
"0.58911943",
"0.58363765",
"0.5828485",
"0.58213407",
"0.5772805",
"0.57456... | 0.70033133 | 0 |
Removes a ``Comment`` from a ``Book``. | def unassign_comment_from_book(self, comment_id, book_id):
# Implemented from template for
# osid.resource.ResourceBinAssignmentSession.unassign_resource_from_bin
mgr = self._get_provider_manager('COMMENTING', local=True)
lookup_session = mgr.get_book_lookup_session(proxy=self._proxy)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_book(self, book):\n if self.has_book(book):\n self.books.remove(book)\n return self",
"def remove_book(self, book):\n if self.has_book(book):\n self.books.remove(book)\n if self.owner.lists_with_book_count(book) <= 1:\n self.owne... | [
"0.6437799",
"0.6337031",
"0.63252395",
"0.6280252",
"0.6115586",
"0.61083245",
"0.5793936",
"0.5739752",
"0.56746423",
"0.5647318",
"0.5642754",
"0.5625013",
"0.5609605",
"0.5605535",
"0.5604428",
"0.5573557",
"0.5513995",
"0.5508508",
"0.54973406",
"0.5466595",
"0.54174936"... | 0.76365703 | 0 |
Gets the book form for updating an existing book. A new book form should be requested for each update transaction. | def get_book_form_for_update(self, book_id):
# Implemented from template for
# osid.resource.BinAdminSession.get_bin_form_for_update_template
if self._catalog_session is not None:
return self._catalog_session.get_catalog_form_for_update(catalog_id=book_id)
collection = JSONCl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_book(self, book_form):\n # Implemented from template for\n # osid.resource.BinAdminSession.update_bin_template\n if self._catalog_session is not None:\n return self._catalog_session.update_catalog(catalog_form=book_form)\n collection = JSONClientValidated('commenti... | [
"0.70686907",
"0.64310193",
"0.6417475",
"0.6145621",
"0.6092993",
"0.600895",
"0.56368786",
"0.5463859",
"0.54370743",
"0.54370743",
"0.5416827",
"0.5415673",
"0.5397017",
"0.537442",
"0.5367763",
"0.53390986",
"0.53280944",
"0.5295473",
"0.5242788",
"0.52189684",
"0.5211637... | 0.8189402 | 0 |
Updates an existing book. | def update_book(self, book_form):
# Implemented from template for
# osid.resource.BinAdminSession.update_bin_template
if self._catalog_session is not None:
return self._catalog_session.update_catalog(catalog_form=book_form)
collection = JSONClientValidated('commenting',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, book_id):\n a_book = query_book_by_id(book_id)\n if a_book is None:\n return 'Book does not exit', 404\n body = request.get_json()\n a_book.parse_body(body)\n db.session.add(a_book)\n db.session.commit()\n return a_book.serialize(), 200",
... | [
"0.7676922",
"0.7666895",
"0.7168757",
"0.7109669",
"0.69657815",
"0.677769",
"0.6690522",
"0.6674828",
"0.6565922",
"0.647722",
"0.6394583",
"0.63716525",
"0.6367317",
"0.6144331",
"0.5958954",
"0.59474444",
"0.5938662",
"0.5936048",
"0.59093595",
"0.59084946",
"0.5903671",
... | 0.73040056 | 2 |
Adds an ``Id`` to a ``Book`` for the purpose of creating compatibility. The primary ``Id`` of the ``Book`` is determined by the provider. The new ``Id`` performs as an alias to the primary ``Id``. If the alias is a pointer to another book, it is reassigned to the given book ``Id``. | def alias_book(self, book_id, alias_id):
# Implemented from template for
# osid.resource.BinLookupSession.alias_bin_template
if self._catalog_session is not None:
return self._catalog_session.alias_catalog(catalog_id=book_id, alias_id=alias_id)
self._alias_id(primary_id=book_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_new(cls, name, author_id):\n\t\tbook = Book(name, author_id)\n\t\tdb.session.add(book)\n\t\tdb.session.commit()\n\t\treturn book.id",
"def add_book(book):\n\n global book_list\n book.id = generate_id()\n book_list.append(book)",
"def set_book_id(self, bookid):\n self.bookid = str(bookid... | [
"0.6363523",
"0.63182074",
"0.5935182",
"0.59338576",
"0.5911424",
"0.5827504",
"0.57561815",
"0.5713796",
"0.56904376",
"0.55907154",
"0.5526623",
"0.54667044",
"0.53656644",
"0.5339497",
"0.533185",
"0.53043044",
"0.52461565",
"0.5227103",
"0.52260983",
"0.5223143",
"0.5208... | 0.64784527 | 0 |
Gets the hierarchy ``Id`` associated with this session. | def get_book_hierarchy_id(self):
# Implemented from template for
# osid.resource.BinHierarchySession.get_bin_hierarchy_id
if self._catalog_session is not None:
return self._catalog_session.get_catalog_hierarchy_id()
return self._hierarchy_session.get_hierarchy_id() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_catalog_hierarchy_id(self):\n # Implemented from kitosid template for -\n # osid.resource.BinHierarchySession.get_bin_hierarchy_id\n return self._get_provider_session('catalog_hierarchy_session').get_catalog_hierarchy_id()",
"def getid(self):\n if self.Id is None:\n ... | [
"0.7125257",
"0.6883268",
"0.6883268",
"0.6883268",
"0.6883268",
"0.6883268",
"0.6883268",
"0.682322",
"0.682322",
"0.6821485",
"0.67925215",
"0.67925215",
"0.67925215",
"0.67925215",
"0.67925215",
"0.67925215",
"0.67796063",
"0.67679566",
"0.67633337",
"0.6754055",
"0.675405... | 0.6621401 | 46 |
Tests if an ``Id`` is a direct parent of book. | def is_parent_of_book(self, id_, book_id):
# Implemented from template for
# osid.resource.BinHierarchySession.is_parent_of_bin
if self._catalog_session is not None:
return self._catalog_session.is_parent_of_catalog(id_=id_, catalog_id=book_id)
return self._hierarchy_session.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains_parent(self, pid):\n return pid in self._parent_ids",
"def has_parent_books(self, book_id):\n # Implemented from template for\n # osid.resource.BinHierarchySession.has_parent_bins\n if self._catalog_session is not None:\n return self._catalog_session.has_parent... | [
"0.7025028",
"0.6787635",
"0.6672986",
"0.6672096",
"0.654681",
"0.63782734",
"0.6361868",
"0.62793577",
"0.62684816",
"0.6258171",
"0.6227756",
"0.62173504",
"0.62032753",
"0.62020123",
"0.6027175",
"0.5965511",
"0.59467286",
"0.5937843",
"0.5936601",
"0.5886084",
"0.5882627... | 0.7772851 | 0 |
Gets the hierarchy ``Id`` associated with this session. | def get_book_hierarchy_id(self):
# Implemented from template for
# osid.resource.BinHierarchySession.get_bin_hierarchy_id
if self._catalog_session is not None:
return self._catalog_session.get_catalog_hierarchy_id()
return self._hierarchy_session.get_hierarchy_id() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_catalog_hierarchy_id(self):\n # Implemented from kitosid template for -\n # osid.resource.BinHierarchySession.get_bin_hierarchy_id\n return self._get_provider_session('catalog_hierarchy_session').get_catalog_hierarchy_id()",
"def getid(self):\n if self.Id is None:\n ... | [
"0.71252793",
"0.6884418",
"0.6884418",
"0.6884418",
"0.6884418",
"0.6884418",
"0.6884418",
"0.68236876",
"0.68236876",
"0.6821127",
"0.6793428",
"0.6793428",
"0.6793428",
"0.6793428",
"0.6793428",
"0.6793428",
"0.67802054",
"0.6768881",
"0.67642903",
"0.67549986",
"0.6754998... | 0.66201097 | 47 |
takes a graph and returns a list of the nodes in the graph in some random order. | def random_order(graph):
return random.sample(graph, len(graph)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_order(ugraph):\n nodes = ugraph.keys()\n ro_nodes = []\n while len(nodes) > 0:\n choices = range(0, len(nodes))\n random_node = nodes.pop(random.choice(choices))\n ro_nodes.append(random_node)\n\n return ro_nodes",
"def extract_nodes(graph):\n return graph.get_nodes... | [
"0.7912667",
"0.74318504",
"0.68449664",
"0.6703933",
"0.665076",
"0.6630743",
"0.65739506",
"0.6539121",
"0.64809346",
"0.6460677",
"0.6445434",
"0.6405424",
"0.6390778",
"0.633043",
"0.6284734",
"0.6243805",
"0.6232531",
"0.6229891",
"0.6227312",
"0.62241834",
"0.6212664",
... | 0.7667206 | 1 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in xrange(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.80373776",
"0.7923372",
"0.7921526",
"0.78832066",
"0.78758025",
"0.78139895",
"0.77639675",
"0.7753964",
"0.7742553",
"0.7730092",
"0.7727218",
"0.7723365",
"0.7701169",
"0.76873696",
"0.76873696",
"0.7662493",
"0.765539",
"0.7654256",
"0.7654256",
"0.76442516",
"0.764425... | 0.0 | -1 |
Return the GeoJSON representation of this Geometry. | def json(self):
return capi.to_json(self.ptr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_geojson(self):\n return _property_op(arctern.ST_AsGeoJSON, self)",
"def geojson(self):\n return {\n \"type\": \"FeatureCollection\",\n \"features\": [f.geojson(i) for i, f in self._features.items()]\n }",
"def data_geojson(self):\n coordinates = self.val... | [
"0.80208063",
"0.7876602",
"0.7625194",
"0.74960536",
"0.72676927",
"0.7120832",
"0.69572836",
"0.6746896",
"0.67437017",
"0.6736589",
"0.6736589",
"0.6697058",
"0.6697058",
"0.66877997",
"0.6661496",
"0.66306347",
"0.6581941",
"0.6572714",
"0.6551489",
"0.6548034",
"0.652402... | 0.0 | -1 |
returns set of all zones contained by this space's children does not include zones contained by this space | def get_child_zones( self ):
zones = set()
if self.children is not None:
for space in self.children:
zones |= space.zones | space.get_child_zones()
return zones | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contained(self):\n seen = set()\n return [l.to_segment for l in self.edges_to_contained \\\n if id(l) not in seen and not seen.add(id(l))]",
"def children(self):\n length = len(self.name)\n s = \".%s\" % self.name\n return [\n z for z in DNSZone.objects.filte... | [
"0.65747565",
"0.6551856",
"0.64756376",
"0.63153553",
"0.63094854",
"0.6125579",
"0.61235416",
"0.6110253",
"0.6086279",
"0.60236365",
"0.60236365",
"0.5994792",
"0.59797794",
"0.5890198",
"0.58322483",
"0.58093905",
"0.5795083",
"0.5791707",
"0.5785798",
"0.57633424",
"0.57... | 0.8188812 | 0 |
Join endpoint at the end of url. Take care of considering the slashes at the end of ``url`` and at the beginning of ``endpoint``, each one with the proper semantics. | def _join(url, endpoint):
if not endpoint:
return url
parsed_url = urlparse.urlsplit(url)
new_path = os.path.join(parsed_url.path, endpoint)
parts = list(parsed_url)
parts[2] = new_path
return urlparse.urlunsplit(parts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_url(endpoint, url):\n u = \"%s/%s\" % (endpoint.rstrip(\"/\"), url.strip(\"/\"))\n return u.rstrip('/')",
"def _join_url(saas_url, endpoint):\n\n saas_url = f\"{saas_url}/\"\n endpoint = endpoint.lstrip(\"/\")\n return urljoin(saas_url, endpoint)",
"def get_endpoint_url(endpoi... | [
"0.8435927",
"0.789015",
"0.72727895",
"0.72349405",
"0.722366",
"0.6932529",
"0.6927155",
"0.6922635",
"0.6849334",
"0.67697203",
"0.6740127",
"0.6685301",
"0.6685256",
"0.66599375",
"0.6640584",
"0.66405165",
"0.66367733",
"0.6627729",
"0.6620346",
"0.6598339",
"0.65968704"... | 0.83496267 | 1 |
Compute the lowest common multiple of a and b | def lcm2(a, b):
return a * b / gcd(a, b) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lowest_common_multiple(a, b):\n # 两个数字相乘后除以最大公约数 = 两个数字的最小公倍数\n return a * b // gcd(a, b)",
"def least_common_multiple(number1, number2):\n return number1 * number2 // math.gcd(number1, number2)",
"def lcm(a, b):\n\treturn a * b // gcm(a, b)",
"def lcm(a, b):\r\n return a * b // gcd(a, b)",
... | [
"0.8658008",
"0.77002734",
"0.7509026",
"0.7464487",
"0.74473906",
"0.7433182",
"0.7433182",
"0.7405216",
"0.73895484",
"0.7384071",
"0.7384071",
"0.7384071",
"0.7384071",
"0.7384071",
"0.7384071",
"0.7384071",
"0.7384071",
"0.7384071",
"0.73705244",
"0.7366396",
"0.73513204"... | 0.7100332 | 33 |
Allows the team to set a team name. | def team_name(self):
return 'Team Name' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def team_set_name(self, team_type: TeamType, team_name):\r\n\t\tself._teams[team_type].team_name = team_name\r\n\t\t_logger.info(\"Set the name of team {0} to \\\"{1}\\\".\" \\\r\n\t\t\t.format(team_type, team_name))",
"def team_name(self, team_name):\n\n self._team_name = team_name",
"def team_name(sel... | [
"0.82993644",
"0.8232561",
"0.7640673",
"0.76396996",
"0.7634439",
"0.76320326",
"0.75327253",
"0.750379",
"0.750379",
"0.750379",
"0.750379",
"0.7486884",
"0.7486884",
"0.7382823",
"0.73561835",
"0.7350724",
"0.7350724",
"0.7350724",
"0.7350724",
"0.7350724",
"0.7331584",
... | 0.6981331 | 37 |
wrap compute_features into a tensorflow function. | def compute_features_tf(sample, features_config="{}", identifier_key="sng_id", entity_type="song", seg_start_key="seg_start", seg_duration_key="seg_duration", features_key="features", device="/cpu:0"):
with tf.device(device):
input_args = [
sample[identifier_key],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serve_function(self):\n # Set name attribute of the input TensorSpec.\n input_signature = {\n name: tf.TensorSpec.from_spec(spec, name=name)\n for name, spec in self.features_inputter.input_signature().items()\n }\n\n @tf.function(input_signature=(input_signatu... | [
"0.7315969",
"0.67771196",
"0.67448467",
"0.6593886",
"0.6494422",
"0.6493531",
"0.64284575",
"0.63258106",
"0.6306615",
"0.62988156",
"0.62900025",
"0.628656",
"0.62825507",
"0.6244222",
"0.6217006",
"0.62039167",
"0.6192268",
"0.61838126",
"0.61792636",
"0.6168855",
"0.6168... | 0.6618527 | 3 |
entry2str(entry[, wrap_at[, endline]]) > a string. entry is a dict. Given an entry dict with string values for 'name' and 'sequence', will return a string in noninterleaved NEXUS format. 'endline's (default \\n) will be inserted into the sequence every 'wrap_at' characters (default 80). | def entry2str(entry, wrap_at, endline):
s = []
namelen = len(entry['name'])
remaining = wrap_at - namelen - 2
s.append('%s %s%s' % (entry['name'], entry['sequence'][0:remaining], endline))
if len(entry['sequence']) >= remaining:
# for the wrapping, DON'T use 'textwrap.wrap'. It is very slo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_fasta_entry(otu_name, isolate_name, sequence_id, sequence):\n return f\">{otu_name}|{isolate_name}|{sequence_id}|{len(sequence)}\\n{sequence}\"",
"def entry_string(key, value, entry_char=\">\", attribution_char=\"=\",\n end_char=\"\\n\"):\n result_str = entry_char + \" \"\n re... | [
"0.63064456",
"0.6200705",
"0.614405",
"0.5769507",
"0.5652572",
"0.56045365",
"0.55243444",
"0.5392846",
"0.5382213",
"0.5361466",
"0.5187714",
"0.5175741",
"0.5164723",
"0.51061785",
"0.50813454",
"0.50515944",
"0.5011364",
"0.49644625",
"0.49469957",
"0.4935943",
"0.491931... | 0.8547553 | 0 |
Get a tf.function for training step. | def get_model_train_step_function(model, optimizer, vars_to_fine_tune):
# Use tf.function for a bit of speed.
# Comment out the tf.function decorator if you want the inside of the
# function to run eagerly.
@tf.function
def train_step_fn(image_tensors,
groundtruth_boxes_list,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_step_fn(self) -> Callable:\n\n def loss_fn(\n params: frozen_dict.FrozenDict,\n apply_fn: Callable,\n batch: Dict[str, jnp.ndarray],\n ) -> Tuple[float, Dict[str, float]]:\n \"\"\"Loss function.\"\"\"\n # map samples with the fitted map\n mapped_samples = apply_fn... | [
"0.6815308",
"0.672745",
"0.66933054",
"0.66277367",
"0.66277367",
"0.6619573",
"0.66120225",
"0.6545176",
"0.6469862",
"0.64594257",
"0.6383388",
"0.6319864",
"0.62912625",
"0.62912416",
"0.61952096",
"0.6148935",
"0.61407393",
"0.6134921",
"0.6120006",
"0.60841286",
"0.6057... | 0.6037665 | 22 |
Get a tf.function for detection. | def get_model_detection_function(model):
@tf.function
def detect_fn(image):
"""Detect objects in image."""
image, shapes = model.preprocess(image)
prediction_dict = model.predict(image, shapes)
detections = model.postprocess(prediction_dict, shapes)
return detections, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model_detection_function(model):\n\n @tf.function\n def detect_fn(image):\n \"\"\"Detect objects in image.\"\"\"\n\n # image= tf.convert_to_tensor(image, dtype=tf.float32)\n\n image, shapes = model.preprocess(image)\n prediction_dict = model.predict(image, shapes)\n detections = model.post... | [
"0.7112774",
"0.7107963",
"0.71027005",
"0.6684678",
"0.65463984",
"0.65268725",
"0.6505286",
"0.63129324",
"0.61612254",
"0.6149816",
"0.6118471",
"0.60945255",
"0.6056584",
"0.6024163",
"0.5923366",
"0.5874666",
"0.57565945",
"0.57503176",
"0.5718735",
"0.5704753",
"0.56934... | 0.71129197 | 0 |
Courses should not be listed on the index as they are page extensions. | def test_admin_course_index(self):
user = UserFactory(is_staff=True, is_superuser=True)
self.client.login(username=user.username, password="password")
# Get the admin index view
url = reverse("admin:index")
response = self.client.get(url, follow=True)
self.assertEqual(re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_pages(self):\n return None",
"def course_pages(self):\n return None",
"def test_course_index_view_with_no_courses(self):\r\n # Create a course so there is something to view\r\n resp = self.client.get_html('/course/')\r\n self.assertContains(\r\n resp,\r\... | [
"0.72362167",
"0.72362167",
"0.7036918",
"0.6788231",
"0.64986944",
"0.6484739",
"0.64390963",
"0.6414259",
"0.62774307",
"0.62668973",
"0.6215031",
"0.6189906",
"0.61536765",
"0.6153099",
"0.61501616",
"0.6101253",
"0.6074351",
"0.6070899",
"0.60614705",
"0.6060615",
"0.6030... | 0.6414241 | 8 |
The admin list view of courses should display the title of the related page. | def test_admin_course_list_view(self):
user = UserFactory(is_staff=True, is_superuser=True)
self.client.login(username=user.username, password="password")
# Create a course linked to a page
course = CourseFactory()
# Get the admin list view
url = reverse("admin:courses_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_courses_and_profs(request):\r\n\tcourses = course_views.all_courses(request)\r\n\treturn render(request, 'templates/browse.html', {'courses': courses})",
"def courses(request):\r\n courses = get_courses(request.user, request.META.get('HTTP_HOST'))\r\n courses = sort_by_announcement(courses)\r\n\r\... | [
"0.6409403",
"0.6300677",
"0.6075833",
"0.58664715",
"0.5829079",
"0.5826556",
"0.5807848",
"0.576743",
"0.5746946",
"0.5687991",
"0.5687991",
"0.5682303",
"0.5662944",
"0.56115544",
"0.558111",
"0.5562135",
"0.5520698",
"0.55202514",
"0.54310596",
"0.54298484",
"0.54099524",... | 0.7112943 | 0 |
Render the homepage template on the / route | def homepage():
print(__name__ + " invoked") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template(\"home/index.html\")",
"def home():\n return render_template('homepage.html')",
"def homepage():\n return render_template('homepage.html')",
"def homepage():\n return render_template(\"home/index.html\", title=\"Welcome\")",
"def render_home():\r\n\treturn... | [
"0.85974133",
"0.8569391",
"0.85273063",
"0.8474367",
"0.84740186",
"0.8452618",
"0.84243995",
"0.84243995",
"0.84209305",
"0.8390326",
"0.83126235",
"0.82671976",
"0.82671976",
"0.82671976",
"0.82671976",
"0.82671976",
"0.82671976",
"0.8264297",
"0.82602227",
"0.82514256",
"... | 0.0 | -1 |
Create dictionary of articles mapped to articles they reference, return dictionary Returns a dictionary representing the mappings of article to the citations it references. | def get_citations_ids_map(id_list):
create_unverified_context()
logging.debug('============== IN get_citations_ids_map: ================')
logging.debug('============== ID LIST: ================')
logging.debug(id_list)
linked = {}
for i in range(0, len(id_list)):
handle = Entrez.elink(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_articles_map(query_result):\n logging.debug('============== IN create_articles_map: ================')\n articles_map = {}\n logging.debug(query_result)\n for paper in query_result['PubmedArticle']:\n attributes_map = {}\n attributes_map['pub_year'] = paper['PubmedData']['Histo... | [
"0.6525979",
"0.65174156",
"0.6425909",
"0.6093133",
"0.6089156",
"0.600995",
"0.5984705",
"0.5902765",
"0.5871173",
"0.58456105",
"0.5763512",
"0.56984776",
"0.5633719",
"0.56330174",
"0.5602053",
"0.5593481",
"0.5584784",
"0.55710715",
"0.5555471",
"0.5548207",
"0.5538598",... | 0.645926 | 2 |
Create articles dictionary, return dictionary Returns a dictionary containing detailed data about query_result Entrez Parser object parsed to a regular Python dictionary. | def create_articles_map(query_result):
logging.debug('============== IN create_articles_map: ================')
articles_map = {}
logging.debug(query_result)
for paper in query_result['PubmedArticle']:
attributes_map = {}
attributes_map['pub_year'] = paper['PubmedData']['History'][0]['Ye... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def results(self):\n out = []\n fields = 'eid doi pii pubmed_id title subtype creator afid affilname '\\\n 'affiliation_city affiliation_country author_count '\\\n 'author_names author_ids author_afids coverDate '\\\n 'coverDisplayDate publicationName i... | [
"0.6377724",
"0.6325229",
"0.6153114",
"0.61009747",
"0.6092185",
"0.5985947",
"0.5911246",
"0.5896268",
"0.5801798",
"0.5784512",
"0.57692313",
"0.5765684",
"0.57631975",
"0.5657191",
"0.5612762",
"0.55811036",
"0.5571128",
"0.5559934",
"0.55520344",
"0.55434465",
"0.5529153... | 0.7246906 | 0 |
The calculation of total charge wighted negative surface area It is the partial negative solventaccessible surface area multiplied by the total negative charge. >PNSA2 | def getPNSA2(ChargeSA):
temp1=temp2=0.0
for i in ChargeSA:
if float(i[1])<0:
temp1=temp1+float(i[1])
temp2=temp2+i[2]
res=temp1*temp2
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def surfaceArea(self):\n surfaceArea = self.sideLength**2 * 6\n return surfaceArea",
"def surface_area(self) -> float:\n return 4 * np.pi * self.radius**2",
"def ext_surface_area(self, rho_p, d_p):\n ac = 6./(d_p*rho_p)\n return ac",
"def getSurfaceArea(self) -> flo... | [
"0.6572207",
"0.6483994",
"0.64113265",
"0.6304656",
"0.6274987",
"0.6197511",
"0.6170694",
"0.61496115",
"0.60861194",
"0.60384613",
"0.5866865",
"0.58417004",
"0.5827651",
"0.5820602",
"0.5819946",
"0.58133954",
"0.578421",
"0.57838255",
"0.57838255",
"0.57829434",
"0.57806... | 0.0 | -1 |
The calculation of relative negative charge surface area >RNCS | def getRNCS(ChargeSA):
charge=[]
for i in ChargeSA:
charge.append(float(i[1]))
temp=[]
for i in ChargeSA:
temp.append(i[2])
try:
RNCG = min(charge)/sum([i for i in charge if i < 0.0])
return temp[charge.index(min(charge))]/RNCG
except:
return 0.0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ext_surface_area(self, rho_p, d_p):\n ac = 6./(d_p*rho_p)\n return ac",
"def Z_rms(self) -> np.float64:\n return np.sqrt(np.sum(self.ionic_fractions * self.charge_numbers**2))",
"def _get_R(self, net_r_amp):\n return np.abs(net_r_amp)**2",
"def _vce(self):\n sum... | [
"0.62063116",
"0.59913546",
"0.59450954",
"0.5937972",
"0.58566266",
"0.5768656",
"0.57380325",
"0.57130086",
"0.56735563",
"0.566369",
"0.56544626",
"0.5648585",
"0.56446475",
"0.56446475",
"0.56421643",
"0.5639743",
"0.5635388",
"0.5630033",
"0.56272554",
"0.56222653",
"0.5... | 0.5410769 | 45 |
Create a new limit sell order with the amount we current have. The amount is total amount and price is determined according to our strategy (either fixed increase or increase depending on the signal). | async def new_limit_order(side):
symbol = App.config["symbol"]
now_ts = now_timestamp()
#
# Find limit price (from signal, last kline and adjustment parameters)
#
last_kline = App.analyzer.get_last_kline(symbol)
last_close_price = to_decimal(last_kline[4]) # Close price of kline has index ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sell_limit_order(self, price=0, volume=0):\n auth = CoinbaseExchangeAuth(self.api_key, self.secret_key, self.passphrase)\n data = {\n \"size\": volume,\n \"price\": price,\n \"side\": \"sell\",\n \"product_id\": self.rate,\n \"type\": \"limit... | [
"0.7394044",
"0.71938515",
"0.7143917",
"0.70112383",
"0.6917509",
"0.6835225",
"0.6710877",
"0.66911244",
"0.66626763",
"0.6604514",
"0.6568868",
"0.6497517",
"0.64885277",
"0.64592344",
"0.64136094",
"0.63963795",
"0.6372615",
"0.63533545",
"0.635211",
"0.6337911",
"0.63336... | 0.73623097 | 1 |
Sets the desired settings for the logger | def initLogger(level=logging.DEBUG, logdir='logfiles'):
#Check if logdir exists. Make if not.
################################################################
if not isdir(logdir): makedirs(logdir)
#Init Logger
################################################################
logging.basicConfi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logger_settings(self):\n LOG_CONFIG['root']['handlers'].append(self.logmode)\n flask_log = logging.getLogger(DEFAULT_NAME_FLASK_LOGGER)\n flask_log.setLevel(logging.ERROR)\n dictConfig(LOG_CONFIG)\n self.logger = logging.getLogger()",
"def set_logger(self, logger): \n ... | [
"0.74176",
"0.7095895",
"0.69282144",
"0.6826923",
"0.6799484",
"0.67717457",
"0.67717457",
"0.6756394",
"0.6730018",
"0.667176",
"0.6654869",
"0.66297776",
"0.66291296",
"0.66231596",
"0.66037333",
"0.65955824",
"0.6588919",
"0.65835416",
"0.6581818",
"0.6550928",
"0.6518791... | 0.0 | -1 |
Returns the ask price | def getAsk(self):
return self.data['ask'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_and_pay(self):\n return self.price",
"def get_price(self):\n\n if self.price: return self.price\n # retrieve from args and return if exists\n price = Settings.get_price() or None\n if price: \n self.price = price\n return price\n if not Sett... | [
"0.7236827",
"0.71251833",
"0.71034354",
"0.70678836",
"0.7003833",
"0.7003833",
"0.7003833",
"0.6989772",
"0.69891036",
"0.68701035",
"0.68092954",
"0.68092954",
"0.6794345",
"0.6791103",
"0.6783598",
"0.6697683",
"0.6693055",
"0.6669402",
"0.6547017",
"0.6547017",
"0.652292... | 0.59735787 | 78 |
Returns the bid price | def getBid(self):
return self.data['bid'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_bid_price(market_data):\n print(\"Consultando BID\")\n if market_data[\"marketData\"][\"BI\"]:\n bid_price = market_data[\"marketData\"][\"BI\"][0][\"price\"]\n print(f\"Precio de BID: ${bid_price:,.2f}\".replace('.', ','))\n return bid_price\n print(... | [
"0.7482973",
"0.7412234",
"0.736694",
"0.736694",
"0.736694",
"0.7346365",
"0.73199034",
"0.7270354",
"0.7214473",
"0.72128344",
"0.7117554",
"0.7093904",
"0.7093904",
"0.7022616",
"0.70101255",
"0.70031893",
"0.6951215",
"0.6925883",
"0.6907203",
"0.68987703",
"0.6895927",
... | 0.75416416 | 0 |
Returns the ask price | def getAsk(self):
data = self.pair.data
if data['bid'] == None:
return None
return 1. / data['bid'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def buy_and_pay(self):\n return self.price",
"def get_price(self):\n\n if self.price: return self.price\n # retrieve from args and return if exists\n price = Settings.get_price() or None\n if price: \n self.price = price\n return price\n if not Sett... | [
"0.7236827",
"0.71251833",
"0.71034354",
"0.70678836",
"0.7003833",
"0.7003833",
"0.7003833",
"0.6989772",
"0.68701035",
"0.68092954",
"0.68092954",
"0.6794345",
"0.6791103",
"0.6783598",
"0.6697683",
"0.6693055",
"0.6669402",
"0.6547017",
"0.6547017",
"0.6522927",
"0.6505204... | 0.69891036 | 8 |
Returns the bid price | def getBid(self):
data = self.pair.data
if data['ask'] == None:
return None
return 1. / data['ask'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getBid(self):\r\n\t\treturn self.data['bid']",
"def query_bid_price(market_data):\n print(\"Consultando BID\")\n if market_data[\"marketData\"][\"BI\"]:\n bid_price = market_data[\"marketData\"][\"BI\"][0][\"price\"]\n print(f\"Precio de BID: ${bid_price:,.2f}\".replace('.... | [
"0.75416416",
"0.7482973",
"0.7412234",
"0.736694",
"0.736694",
"0.736694",
"0.7346365",
"0.73199034",
"0.7270354",
"0.7214473",
"0.72128344",
"0.7117554",
"0.7093904",
"0.7093904",
"0.70101255",
"0.70031893",
"0.6951215",
"0.6925883",
"0.6907203",
"0.68987703",
"0.6895927",
... | 0.7022616 | 14 |
Add a set of lines (xys) to an existing image_array | def add_lines(image_array, xys, width=1, weights=None):
for i, xy in enumerate(xys): # loop over lines
# create a new gray scale image
image = Image.new("L", (image_array.shape[1], image_array.shape[0]))
# draw the line
ImageDraw.Draw(image).line(xy, 200, width=width)
# c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_lines(img, lines):\n for l in lines:\n rr, cc, val = line_aa(l[0][1], l[0][0], l[1][1], l[1][0])\n img[rr, cc] = 1\n\n return img",
"def draw_lines(image, lines, delta_x, imagename, epoch='last', color=(0,0,255), thickness = 3, IMG_FOLDER='output'):\n \n image_copy = image.copy... | [
"0.690091",
"0.6317346",
"0.62450397",
"0.62330747",
"0.6124536",
"0.6010603",
"0.59763986",
"0.58471185",
"0.5751895",
"0.5740052",
"0.5686163",
"0.566128",
"0.5639682",
"0.56229615",
"0.562011",
"0.5598085",
"0.55848616",
"0.55842066",
"0.5582656",
"0.556634",
"0.55624914",... | 0.7832095 | 0 |
Get attribute of a class. It's a closure. | def _property(attr):
name = '_' + attr
@property
def prop(self):
"""Get the specific attribute."""
return getattr(self, name)
@prop.setter
def prop(self, value):
"""Set the attribute."""
setattr(self, name, value)
if isa(self, Pair):
self.update_st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getattr__(self, attr):\n return getattr(self.get_function(), attr)",
"def get(self, att):\n return getattr(self, att)",
"def get( self, function ):\n return getattr( function, self.attribute, '' )",
"def __getattr__(self, attr):\n return self.get(attr)",
"def get_attr(self... | [
"0.6921349",
"0.6904278",
"0.6864582",
"0.6826837",
"0.68178976",
"0.66380966",
"0.6585605",
"0.6490513",
"0.6490513",
"0.6485459",
"0.64374954",
"0.6427771",
"0.63992226",
"0.6391466",
"0.6388201",
"0.6388201",
"0.63720715",
"0.6357894",
"0.6343627",
"0.6327898",
"0.6327873"... | 0.0 | -1 |
Append val to a list, not modifying the list. | def append(*values):
require(values, len(values)>=2)
values = list(values)
s_list = values[0]
appended = values[1:]
require_type(isa(s_list,List), 'the first parameter of append must be a list')
last = appended.pop()
members = s_list.members + appended
result = Pair(members[-1], last)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def append(self, val):\n self.val.append(val)",
"def append(self, val):\n self._values.push(val)",
"def append(self, value):\n self.__list += [value]\n return self.__list",
"def append(self, value):\n self.list.append(value)",
"def addAtTail(self, val):\n self.nums... | [
"0.8263389",
"0.815401",
"0.77408445",
"0.7565862",
"0.7408043",
"0.7393479",
"0.7327365",
"0.72849405",
"0.7255646",
"0.71798116",
"0.71175873",
"0.71148044",
"0.7043663",
"0.70054513",
"0.69894385",
"0.69432247",
"0.69418615",
"0.6933613",
"0.68866295",
"0.68703604",
"0.682... | 0.0 | -1 |
Return the ith element of the list. | def list_ref(s_list, i):
require_type(isa(s_list,List), 'parameters of list-ref must be a list')
return s_list[i] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(a_list, i):\n try:\n return a_list[int(i)]\n except IndexError:\n return None",
"def __getitem__(self, i):\n return self.get(i, i + 1)",
"def get_value(_list, _index):\n # print(_list, len(_list))\n if _index >= len(_list):\n return None\n return _list[_inde... | [
"0.719207",
"0.70659333",
"0.6908586",
"0.6724936",
"0.6658127",
"0.6657087",
"0.66506124",
"0.6627558",
"0.6602421",
"0.66007227",
"0.6563245",
"0.65589917",
"0.655312",
"0.6492846",
"0.6445221",
"0.643634",
"0.6431621",
"0.64178056",
"0.6400806",
"0.63927436",
"0.6387883",
... | 0.580982 | 89 |
Implementation of operator not. | def not_op(target):
if not isa(target, bool):
return False
return not target | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bitwise_not(self) -> ColumnOperators:\n\n return self.operate(bitwise_not_op)",
"def is_not(self, other: Any) -> ColumnOperators:\n return self.operate(is_not, other)",
"def logical_not(data):\n return _make.logical_not(data)",
"def bitwise_not(data):\n return _make.bitwise_not(data)"... | [
"0.8070129",
"0.80260915",
"0.78748524",
"0.76537645",
"0.76185334",
"0.75478834",
"0.738145",
"0.7371726",
"0.7267891",
"0.72283626",
"0.722463",
"0.7192302",
"0.7190629",
"0.7161215",
"0.7161215",
"0.7161215",
"0.7161215",
"0.7145311",
"0.7145311",
"0.7145311",
"0.7145311",... | 0.0 | -1 |
Judge whether the symbol is a number. | def is_number(symbol):
return isa(symbol, complex) or is_rational(symbol) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_number(self, symbol):\n if symbol.type == self.scanner.NUMBER:\n return True\n else:\n return False",
"def is_numeral(self, symbol: str) -> bool:\n return symbol in self.numerals",
"def _is_number(s) -> bool:\n try:\n float(s)\n except ValueError:... | [
"0.88926446",
"0.819002",
"0.7540927",
"0.74805933",
"0.7447623",
"0.7417299",
"0.7417299",
"0.7417299",
"0.7403666",
"0.7385745",
"0.7363715",
"0.73635525",
"0.7360654",
"0.7335066",
"0.7332535",
"0.7319016",
"0.73090607",
"0.73057145",
"0.7302445",
"0.72752583",
"0.72616774... | 0.820734 | 1 |
Compute the least common multiple for two numbers. | def lcm(num1, num2):
return num1 * num2 // fractions.gcd(num1,num2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def least_common_multiple(number1, number2):\n return number1 * number2 // math.gcd(number1, number2)",
"def lowest_common_multiple(a, b):\n # 两个数字相乘后除以最大公约数 = 两个数字的最小公倍数\n return a * b // gcd(a, b)",
"def least_common_multiple2(number1, number2, number3, number4):\n return least_common_multiple((n... | [
"0.87592685",
"0.8410335",
"0.79616493",
"0.7719885",
"0.7687137",
"0.7654425",
"0.7617038",
"0.7617038",
"0.75916165",
"0.75916165",
"0.75916165",
"0.75916165",
"0.75916165",
"0.75916165",
"0.75916165",
"0.75916165",
"0.75916165",
"0.7587978",
"0.7565455",
"0.754108",
"0.754... | 0.7318181 | 35 |
Return forced value in promise else raise exception. | def promise_value(promise):
require_type(isa(promise,Promise),
'the parameter of promise_forced must be a Promise')
if promise_forced(promise):
return promise.exprs.env.find(Symbol('result'))['result']
raise RuntimeError('the promise has not been forced') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self):\n self.wait(0)\n try:\n value = self._value\n except AttributeError:\n raise AttributeError('Deferred value not available')\n if isinstance(value, TaskFailure):\n raise value\n return value",
"def value(self):\n self.even... | [
"0.66377974",
"0.6448812",
"0.6353991",
"0.6314438",
"0.59620595",
"0.5945501",
"0.59249043",
"0.58996284",
"0.57959",
"0.5744193",
"0.5641146",
"0.5623533",
"0.5600036",
"0.5599646",
"0.55961686",
"0.55679035",
"0.5533431",
"0.5526598",
"0.55179805",
"0.55179805",
"0.5493913... | 0.71281993 | 0 |
Takes a labeled array as returned by scipy.ndimage.label and returns an intrafeature distance matrix. The functions calculates the distance between every two nonzero element of the input matrix. In order to accelerate the calculation type and avoid unnecessary calculation, the inner pixels within the coherent regions s... | def feature_dist(input_labels, struct=np.ones((3, 3))):
# remove the pixels inside the coherent
input_errosion = binary_erosion(input_labels, structure=struct)
input_labels[input_errosion] = 0
I, J = np.nonzero(input_labels)
labels = input_labels[I, J]
coords = np.column_stack((I, J))
sorter... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot2dist(seg):\n\n C = seg.shape[0]\n res = np.zeros_like(seg)\n for c in range(1, C): # background is excluded (C=0)\n posmask = seg[c].astype(np.bool)\n if posmask.any():\n negmask = ~posmask\n res[c] = distance(negmask) * negmask - (distance(posmask) - 1) * ... | [
"0.6343657",
"0.5941088",
"0.5838073",
"0.5836737",
"0.56563336",
"0.5553434",
"0.55051297",
"0.54339606",
"0.5366263",
"0.5346288",
"0.5342138",
"0.5333087",
"0.5304407",
"0.5301612",
"0.529603",
"0.526296",
"0.52069753",
"0.5197093",
"0.51921463",
"0.5187018",
"0.51837975",... | 0.6820051 | 0 |
quick unban command with reasons | async def unban(self, ctx, *, member): # don't convert to discord.Member as it isn't a server member, just a string
banned_users = await ctx.guild.bans() # pulls ban list
member_name, member_discriminator = member.split('#') # split the member name from the numerical discriminator
for ban_entry... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def unban(self, ctx, name: str):\n try:\n bans = await self.bot.get_bans(ctx.message.server)\n user = discord.utils.get(bans, name=name)\n if user is not None:\n await self.bot.unban(ctx.message.server, user)\n except discord.Forbidden:\n ... | [
"0.77299154",
"0.7625046",
"0.72241914",
"0.72019064",
"0.67524964",
"0.6746936",
"0.6704349",
"0.66777074",
"0.6664596",
"0.65164787",
"0.6427737",
"0.63570565",
"0.63322943",
"0.62869537",
"0.62857884",
"0.62845266",
"0.62773",
"0.62171733",
"0.6209478",
"0.61875534",
"0.61... | 0.6767483 | 4 |
Assert that URLs are dropped from the text. | def test_drop_url():
cleaner = TextCleaner()
assert cleaner.transform([["www.test.com"]])["corpus"][0] == ""
assert not cleaner.drops["url"].dropna().empty | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_urls(text):\n pass",
"def test_url_text(self):\n self.assertEqual(self.content.url_text(), \"\")\n self.content.url = \"https://www.foobar.com/cool\"\n self.assertEqual(self.content.url_text(), \"foobar.com/...\")\n self.content.url = \"www.foobar.com/cool\"\n sel... | [
"0.7155198",
"0.7083242",
"0.66406363",
"0.6571516",
"0.6547821",
"0.654525",
"0.64671475",
"0.6452325",
"0.6420016",
"0.6394082",
"0.6347634",
"0.6253198",
"0.6226735",
"0.62151295",
"0.6129695",
"0.61156976",
"0.6103276",
"0.6096395",
"0.6095377",
"0.6092619",
"0.6086321",
... | 0.7633811 | 0 |
Assert that the gpu implementation calls the get method of matrix. | def test_gpu():
vectorizer = Vectorizer(device="gpu", engine="cuml")
pytest.raises(ValueError, vectorizer.fit_transform, X_text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_matrix(self):\n test_matrix = investment_growth.create_matrix(5, 2)\n self.assertEqual(0, test_matrix[1][4])\n with self.assertRaises(Exception):\n test_matrix[2][5]",
"def test_matrix_a_and_b(self):\n a = matrix([[1., 2.], [2., 1.]])\n self.do(a, Non... | [
"0.61742353",
"0.5900925",
"0.5863344",
"0.5842674",
"0.5817142",
"0.57902217",
"0.57811975",
"0.57633656",
"0.5718977",
"0.56884605",
"0.5688235",
"0.5679555",
"0.5651649",
"0.5637121",
"0.5635859",
"0.5624651",
"0.5623014",
"0.56209016",
"0.556423",
"0.5537308",
"0.5520254"... | 0.0 | -1 |
Compute the index of the min/max value and its distance from the sample mean. | def _target(self, data):
index = self._get_index(data)
value = data[index]
return index, abs(value - data.mean()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _target(self, data):\n relative_values = abs(data - data.mean())\n index = relative_values.idxmax()\n value = relative_values[index]\n return index, value",
"def getNearestSampleIndex(test, trainX):\n dist_matrix = test - trainX\n dist_square = dist_matrix ** 2\n dist_sum... | [
"0.6794804",
"0.60125315",
"0.59731704",
"0.5933289",
"0.5896697",
"0.58446246",
"0.5835186",
"0.5784116",
"0.5783468",
"0.5758512",
"0.57264084",
"0.5714464",
"0.5694405",
"0.5683164",
"0.56745577",
"0.5672318",
"0.5651434",
"0.5631669",
"0.5614416",
"0.5609488",
"0.5609264"... | 0.6365683 | 1 |
Returns a humanreadable string representation of this object. | def __str__(self):
return u"{} - {}".format(self.label, self.message) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return \"<%s: %s>\" % (self.__class__, self.describe())",
"def __str__(self):\n if self.__description:\n return self.__description\n return repr(self)",
"def describe(self):\n return str(self)",
"def __repr__(self):\n\n return str(self)",
"... | [
"0.8249965",
"0.8129905",
"0.8112355",
"0.80885434",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.8074016",
"0.80593",
"0.80593",
"0.80593",
"0.80593",
"0.80561... | 0.0 | -1 |
Create CSV file for each dataframe. | def each_to_csv(data, key, value):
data.to_csv("camelot/clean/nrld_{}_{}.csv".format(key, value), index=False)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_csv(self):\n try:\n # Convert List of Lists to DataFrame and write it to a CSV\n pd.DataFrame(self.data, columns=self.header) \\\n .to_csv(os.path.join(self.file_path, self.file_name), index=False)\n self.successful_run = True\n except:\n ... | [
"0.752253",
"0.73731476",
"0.73102915",
"0.7309827",
"0.7158301",
"0.7083257",
"0.7064362",
"0.70062345",
"0.6988307",
"0.6953233",
"0.6895461",
"0.6886018",
"0.6857747",
"0.68426746",
"0.6804895",
"0.6783859",
"0.6770421",
"0.67435",
"0.6706146",
"0.6694713",
"0.6682821",
... | 0.0 | -1 |
Strip '\x00' from a buffer of bytes | def bytes_strip(buf: bytes) -> bytes:
if b'\x00' in buf:
return buf[:buf.find(b'\x00')]
else:
return buf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _strip_nul(text):\n return text.replace('\\x00', '<NUL>')",
"def _cleanup_string(self, bytes):\n try:\n b = bytes.index(b'\\x00')\n except ValueError:\n return bytes.decode('latin-1').strip()\n else:\n return bytes[:b].decode('latin-1').strip()",
"de... | [
"0.70020413",
"0.6938823",
"0.67705655",
"0.6426264",
"0.6408555",
"0.62753904",
"0.6154169",
"0.6065841",
"0.60506994",
"0.6011202",
"0.6009207",
"0.5808783",
"0.5782977",
"0.57821727",
"0.5753728",
"0.56938696",
"0.5680717",
"0.56625795",
"0.56604236",
"0.5659381",
"0.56028... | 0.8715432 | 0 |
Constructor for Abstract Message Takes in all args that were given to the concrete message and stores them to later be packed | def __init__(self, *args: Any):
self.__args: List[Any] = [x.to_bytes() if isinstance(x, Encodable) else x for x in args] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, message: str = None, **kwargs):\n self.message = message\n self.kwargs = kwargs\n self.args = {}\n self.args['message'] = self.message\n self.args['args'] = self.kwargs",
"def __init__(self, message, *args, **kwargs):\n self.message = message\n ... | [
"0.7705489",
"0.73976827",
"0.7141936",
"0.7140957",
"0.71113956",
"0.7014315",
"0.6975174",
"0.6939228",
"0.6907928",
"0.69034564",
"0.6871111",
"0.6842526",
"0.6842526",
"0.6842526",
"0.6833721",
"0.6833721",
"0.68244433",
"0.6805947",
"0.68031967",
"0.6799859",
"0.6799859"... | 0.0 | -1 |
Initializes self.chitchat_bot with some conversational model. | def create_chitchat_bot(self):
# Hint: you might want to create and train chatterbot.ChatBot here.
# It could be done by creating ChatBot with the *trainer* parameter equals
# "chatterbot.trainers.ChatterBotCorpusTrainer"
# and then calling *train* function with "chatterbot.corpus.engl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, bot):\n self.bot = bot",
"def __init__(self, bot):\n self.bot = bot",
"def initialise_conversation_model(self):\n self.conversation = model.conversation.ConversationSystem()\n #\n # Set all as alive\n for name in 'abcde':\n self.conversati... | [
"0.67929095",
"0.67929095",
"0.67672825",
"0.67607635",
"0.6641166",
"0.6511156",
"0.6511156",
"0.6435355",
"0.6302653",
"0.62517583",
"0.60971355",
"0.60947114",
"0.60165435",
"0.5970731",
"0.5947144",
"0.5945499",
"0.5942612",
"0.5897279",
"0.5893073",
"0.5875649",
"0.58617... | 0.69043535 | 0 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def adjust_learning_rate(optimizer, epoch):
lr = args.lr * (0.95 ** epoch)
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.79138637",
"0.7907123",
"0.78501725",
"0.77759194",
"0.77345806",
"0.77311844",
"0.7723001",
"0.77227825",
"0.772003",
"0.7709925",
"0.76942194",
"0.7674993",
"0.7666409",
"0.7666409",
"0.7666409",
"0.7654975",
"0.7642442",
"0.764",
"0.7638515",
"0.7626761",
"0.7625353",
... | 0.73053 | 92 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.7642779",
"0.74189687",
"0.74181074",
"0.727035",
"0.72464293",
"0.724466",
"0.72376424",
"0.72212404",
"0.72101134",
"0.70590943",
"0.6852469",
"0.67868036",
"0.67830473",
"0.6767807",
"0.67266494",
"0.6717419",
"0.6717419",
"0.6717419",
"0.6717419",
"0.6717419",
"0.67174... | 0.0 | -1 |
Returns a dictionary containing the current environment variables augmented with the part specific overrides. The dictionary is an independent copy of ``os.environ`` and modifications will not be reflected in back in ``os.environ``. | def augmented_environment(self):
env = os.environ.copy()
env.update(self.environ)
return env | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_environ_dict():\n return {\n 'os.environ': _get_os_environ_dict((\n 'AUTH_DOMAIN',\n 'CURRENT_CONFIGURATION_VERSION',\n 'CURRENT_MODULE_ID',\n 'CURRENT_VERSION_ID',\n 'DEFAULT_VERSION_HOSTNAME',\n 'FEDERATED_IDENTITY',\n 'FEDERATED_PROVID... | [
"0.7463404",
"0.74135685",
"0.73664194",
"0.7339993",
"0.7311293",
"0.7131835",
"0.71075463",
"0.7003702",
"0.6960859",
"0.69417185",
"0.69417185",
"0.69417185",
"0.6935614",
"0.6922657",
"0.6906943",
"0.6906943",
"0.68895435",
"0.68584484",
"0.6835128",
"0.6827596",
"0.68150... | 0.7820573 | 0 |
sx + ty = gcd(x, y) = 1 x = p y = a in GF(p) t = a1 in GF(p) | def calculate(a: int) -> int:
if a == 0:
raise ZeroDivisionError("Cannot compute the multiplicative inverse of 0 in a Galois field.")
r2, r1 = CHARACTERISTIC, a
t2, t1 = 0, 1
while r1 != 0:
q = r2 // r1
r2, r1 = r1, r2 - q * r1
t2, t1 = t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extendedGcd(a, b):\n x0 = 1\n x1 = 0\n y0 = 0\n y1 = 1\n\n while b != 0:\n p = a // b\n z = a % b\n a = b\n b = z\n\n w = x1\n x1 = x0 - p * x1\n x0 = w\n \n v = y1\n y1 = y0 - p * y1\n y0 = v\n print(\"returns: gcd,... | [
"0.69932866",
"0.6588971",
"0.6588971",
"0.6588971",
"0.6477707",
"0.6461463",
"0.6458131",
"0.64495254",
"0.64480007",
"0.64464974",
"0.6400425",
"0.64003545",
"0.6364798",
"0.63362604",
"0.6327832",
"0.63026994",
"0.62844914",
"0.62665075",
"0.62529624",
"0.62496233",
"0.62... | 0.0 | -1 |
This generator yields a sequence of 0/255 values for the 1bit pixels of the image. We extend the row to stride 8 pixels. | def generate_pixels_1bit(image, stride):
w, h = image.size
for y in range(h):
for x in range(w):
value = image.getpixel((x, y))
yield value
for x in range(w, stride * 8):
# Pad out the row with zeroes.
yield 0
raise StopIteration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_pixels_8bit(image):\n\n w, h = image.size\n for y in range(h):\n for x in range(w):\n value = pack_argb8(image.getpixel((x, y)))\n yield value\n\n raise StopIteration",
"def generate_rle_1bit(source):\n\n current = 0\n count = 0\n # We start with an imp... | [
"0.70036536",
"0.66047704",
"0.6190772",
"0.6107249",
"0.6094838",
"0.59324247",
"0.5775729",
"0.57321316",
"0.5658611",
"0.55954134",
"0.55954134",
"0.55538034",
"0.55362445",
"0.5535247",
"0.5517691",
"0.55102646",
"0.5497774",
"0.54790884",
"0.5427604",
"0.540152",
"0.5393... | 0.7854041 | 0 |
Returns the next value in the sequence. Returns 1 at the end of the sequence. | def getNextValue(self):
if self.si >= len(self.str):
return -1
# First, count the number of zero chunks until we come to a nonzero chunk.
zeroCount = 0
b = ord(self.str[self.si])
if self.zero_expands:
bmask = (1 << self.n) - 1
bv = b & (bmask... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next(self) -> int:\n value = self.inorder[self.index]\n self.index = self.index + 1\n return value",
"def _get_next_sequence_number(self):\n cur = self._next_sequence_number\n self._next_sequence_number += 1\n return cur",
"def next(self) -> int:\n self.idx ... | [
"0.74392724",
"0.7390471",
"0.7351171",
"0.7351171",
"0.71733165",
"0.7155285",
"0.7135788",
"0.71176004",
"0.70082283",
"0.6929608",
"0.6906658",
"0.6890229",
"0.6880099",
"0.68420315",
"0.68154716",
"0.67666364",
"0.665304",
"0.66502506",
"0.66109776",
"0.65784675",
"0.6569... | 0.58909136 | 94 |
This function checks if there are any operators within quotation marks. | def operators_within_exact_phrase(input_string):
# incomplete
op_re1 = r'\&|\||AND|OR|BUT\sNOT|NOT|\~|\,|NEAR\d{1,3}|WITHIN\d{1,3}'
qcount = 0
strcount = 0
opqu = 0
clqu = 0
for char in input_string:
if char == '"':
if qcount == 1:
clqu = strcount
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def operators_with_no_words_in_between(input_string):\n op_re1 = r'\\&|\\||AND|OR|BUT\\sNOT|NOT|\\~|\\,|NEAR\\d{1,3}|WITHIN\\d{1,3}'\n regex = re.compile('(%s)\\s*(%s)' % (op_re1, op_re1))\n if re.search(regex, input_string) is None:\n return True\n else:\n return False",
"def is_operat... | [
"0.6988757",
"0.69684064",
"0.6846374",
"0.6846187",
"0.68413997",
"0.67898184",
"0.6681477",
"0.6637795",
"0.6577902",
"0.6570639",
"0.6473884",
"0.6448235",
"0.6448054",
"0.6439564",
"0.6432807",
"0.6394247",
"0.63609624",
"0.6310275",
"0.6297373",
"0.628184",
"0.62500435",... | 0.74937034 | 0 |
Captures the transitions in episodes and writes them to disk. Uses a random agent. | def main():
parser = argparse.ArgumentParser(description=main.__doc__)
parser.add_argument('--maxsteps', type=int, default=100000)
parser.add_argument('--seed', type=int, default=0)
parser.add_argument('--savefile', type=str, required=True)
nproc = max(cpu_count() - 1, 1)
parser.add_argument('--... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RecordAgent(env, agent, num_episodes, save_path, render=False):\n\n out = cv2.VideoWriter(save_path, cv2.VideoWriter_fourcc('M','J','P','G'), 15, (500,500))\n\n for i in range(num_episodes):\n totalReward = 0\n\n obs = env.reset()\n r = 0\n done = False\n\n while True:\... | [
"0.68245167",
"0.65842485",
"0.62148046",
"0.6206847",
"0.6179304",
"0.6106893",
"0.60734475",
"0.6056479",
"0.60546553",
"0.5975989",
"0.59425837",
"0.5942023",
"0.592897",
"0.5901999",
"0.5887114",
"0.5873243",
"0.58605814",
"0.5856597",
"0.5855516",
"0.58402133",
"0.581937... | 0.0 | -1 |
returns whether an edge should be there according to the graph topology | def rand_flip_graph(graph, edge):
return rand_zero_or_one(0.5)
# return rand_zero_or_one(edge_prob(graph, edge)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_edge(self, otherNode):\n\t\t\treturn otherNode in self.edges",
"def isEdge(self,x,y):\n\t\treturn y in self._dictOut[x]",
"def isEdge(self,x,y):\n\t\treturn y in self._dict[x]",
"def isEdge(self,x,y):\n\t\treturn self._matr[x][y]",
"def isEdge(self,x,y):\r\n return self.matr[x][y]",
"def i... | [
"0.7691869",
"0.7482167",
"0.73988265",
"0.73176223",
"0.73046106",
"0.728305",
"0.7260127",
"0.7187203",
"0.7179318",
"0.70303434",
"0.7025172",
"0.70143557",
"0.70051324",
"0.6994433",
"0.69447577",
"0.6932793",
"0.69206667",
"0.68799204",
"0.6814416",
"0.6758651",
"0.67447... | 0.0 | -1 |
Convert a NCEI CDO JSON to a pandas dataframe. | def ncei_cdo_json_to_df(datasetid, stationid, start_date=None, end_date=None):
# Read in API key
token = utils.read_api_key("ncei_cdo")
my_client = Client(token, default_units="metric", default_limit=1000)
my_client.verbose = False
df = my_client.get_data_by_station(
datasetid=datasetid,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_pandas(data: str) -> pandas.DataFrame:\n src = json.loads(data)\n if isinstance(src, list): # list of row dicts\n return pandas.DataFrame.from_records(src)\n if 'instances' in src: # TF serving's \"instances\" format\n return pandas.DataFrame.from_records(src['in... | [
"0.62360793",
"0.6071436",
"0.59299934",
"0.58233607",
"0.5821907",
"0.57932353",
"0.57882094",
"0.5759153",
"0.5726504",
"0.571789",
"0.5648804",
"0.56148946",
"0.5606621",
"0.559922",
"0.55247587",
"0.5447501",
"0.5441097",
"0.5416532",
"0.5362113",
"0.5341404",
"0.5329207"... | 0.6060098 | 2 |
Test making a Square from a dict | def testdicttosq(self):
dicty = {"id": 5, "size": 3, "x": 2, "y": 1}
a = Square(3, 2, 1, 5)
b = Square.create(**dicty)
self.assertEqual(a.id, b.id)
self.assertEqual(a.width, b.width)
self.assertEqual(a.height, b.height)
self.assertEqual(a.x, b.x)
self.asse... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_square(self):\n d = self.s1.to_dictionary()\n s3 = Square.create(**d)\n self.assertEqual(str(s3), str(self.s1))",
"def test_create_square(self):\n sq1 = Square(5, 5, 5, 4)\n sq1_dict = sq1.to_dictionary()\n sq2 = Square.create(**sq1_dict)\n self.as... | [
"0.77072847",
"0.766049",
"0.69994026",
"0.6979771",
"0.6875616",
"0.6786906",
"0.6580285",
"0.64699626",
"0.6411378",
"0.63095945",
"0.628247",
"0.6267928",
"0.6200148",
"0.6134323",
"0.6117696",
"0.60865325",
"0.60275936",
"0.60250145",
"0.601296",
"0.59937614",
"0.59326184... | 0.8085536 | 0 |
r"""__eq__(Connection self, Connection rhs) > bool | def __eq__(self, rhs):
return _table.Connection___eq__(self, rhs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if not isinstance(other, Connections):\n return False\n\n return self.__dict__ == other.__dict__",
"def __eq__(self, other):\n return self.conn == other.conn and self.p1 == other.p1 and self.p2 == other.p2",
"def __eq__(self, other):\n if not is... | [
"0.8288482",
"0.8121828",
"0.7857973",
"0.78404593",
"0.7710206",
"0.76408386",
"0.7586854",
"0.75410694",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"0.75184166",
"... | 0.87663716 | 0 |
r"""__lt__(Connection self, Connection rhs) > bool | def __lt__(self, rhs):
return _table.Connection___lt__(self, rhs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __lt__(self, other):\n return True",
"def __lt__(self, other):\n return True",
"def __lt__(self, other):\n return self <= other and self != other",
"def __lt__(self, other):\n return self <= other and self != other",
"def __lt__(self, other):\n return self.__le__(othe... | [
"0.7596476",
"0.7596476",
"0.7458926",
"0.7458926",
"0.7458918",
"0.7432387",
"0.7299423",
"0.7283935",
"0.7282821",
"0.7220784",
"0.71652895",
"0.715412",
"0.7144389",
"0.71166253",
"0.71166253",
"0.7110336",
"0.70951635",
"0.7084888",
"0.7063386",
"0.7063372",
"0.70587766",... | 0.8458936 | 0 |
r"""__init__(STable self, int dim, int connections_per_row=3) > STable | def __init__(self, dim, connections_per_row=3):
_table.STable_swiginit(self, _table.new_STable(dim, connections_per_row)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n _table.Table_swiginit(self, _table.new_Table(*args))",
"def __init__(self, rows=[]):\n self._rows, self._columns = Rows(self), Columns(self)\n self._m = 0 # Number of columns per row, see Table.insert().\n self.extend(rows)",
"def __init__(self, rows, co... | [
"0.69283414",
"0.69271743",
"0.6822354",
"0.681418",
"0.66978014",
"0.6686127",
"0.6616789",
"0.6599677",
"0.65682334",
"0.65662944",
"0.6416784",
"0.63747585",
"0.63651276",
"0.62946993",
"0.6288352",
"0.6272444",
"0.622977",
"0.62290984",
"0.6190136",
"0.61735165",
"0.61441... | 0.91892374 | 0 |
r"""NumberOfRows(DSTable self) > int | def NumberOfRows(self):
return _table.DSTable_NumberOfRows(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumRows(self) -> int:\n ...",
"def num_rows(self):\n return (len(self.rows))",
"def __len__(self):\n return len(self.rows)",
"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 ... | [
"0.73181444",
"0.70509183",
"0.70400465",
"0.69242114",
"0.6891161",
"0.6891161",
"0.6872741",
"0.6805292",
"0.6727057",
"0.6682585",
"0.6661005",
"0.66498756",
"0.6619065",
"0.65826124",
"0.6544138",
"0.6476911",
"0.64691174",
"0.644389",
"0.64086026",
"0.6392717",
"0.639241... | 0.79213095 | 0 |
Fetches unique elements in a list. | def unique(list1):
# intilize a null list
unique_list = []
# traverse for all elements
for x in list1:
# check if exists in unique_list or not
if x not in unique_list:
unique_list.append(x)
return unique_list | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _unique(li):\n return list(set(li))",
"def unique_list(inlist):\n return set(inlist)",
"def unique(input_list): \n try:\n # intilize a null list \n unique_list = [] \n # traverse for all elements \n for x in input_list: \n # check if exists in unique_list or... | [
"0.75204873",
"0.7417192",
"0.7240101",
"0.7172696",
"0.71503067",
"0.70646673",
"0.70432264",
"0.69681555",
"0.6956914",
"0.69495887",
"0.6917237",
"0.6915752",
"0.6903149",
"0.6890926",
"0.6772238",
"0.67101705",
"0.6703569",
"0.66854006",
"0.66686225",
"0.6667973",
"0.6638... | 0.6930155 | 10 |
Returns the count of variables for a line that has variable(s) in a Python script. | def variable_count(file):
var_count=[]
with open(file,encoding="utf-8",errors='ignore') as f:
for cnt, line in enumerate(f):
#Get lines that have = but not ==, +=, -=,*=,etc.
fn_match = re.search('^(?=.*=)(?!.*==)(?!.*-=)(?!.*\+=)(?!.*\*=)(?!.*import)(?!.*def)(?!.*;).*', line)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def number_of_variables(dataset, name_of_variable):\r\n first_row = dataset[0].keys()\r\n num = 0\r\n for variable in first_row:\r\n if name_of_variable in variable:\r\n num += 1 \r\n return num",
"def countVars(self):\n return len(self.initializedVars[\"GF\"]) + len(self.i... | [
"0.674192",
"0.6577156",
"0.6502371",
"0.6275816",
"0.625485",
"0.61881924",
"0.6179578",
"0.61794853",
"0.6167017",
"0.6153191",
"0.6119793",
"0.6095014",
"0.60789293",
"0.60200053",
"0.5940954",
"0.58748287",
"0.58090055",
"0.58047014",
"0.57693493",
"0.57683784",
"0.575009... | 0.787804 | 0 |
creates a TensorVariable of the given shape and type | def FreeVariable( name, shape, dtype):
shape = np.atleast_1d(shape)
var = TensorType(str(dtype), shape == 1)(name)
var.dshape = tuple(shape)
var.dsize = int(np.prod(shape))
return var | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def var(tensor_type, last_dim=0, test_shape=None):\n # Create tensor\n from deepy.core.neural_var import NeuralVariable\n from deepy.core.env import env\n from theano.tensor.var import TensorVariable\n if isinstance(tensor_type, NeuralVariable):\n var = tensor_type\n if last_dim != 0:\... | [
"0.729683",
"0.70468736",
"0.69661313",
"0.6814048",
"0.66985804",
"0.6653034",
"0.66455615",
"0.66404825",
"0.6635486",
"0.66089976",
"0.657259",
"0.65465534",
"0.65037984",
"0.64901954",
"0.64866406",
"0.6344335",
"0.6308054",
"0.6295618",
"0.6288674",
"0.6288674",
"0.62886... | 0.7838223 | 0 |
export the specified motif to a pandas dataframe | def get_motif_pssm(self, cluster_num, motif_num):
#conn = sql3.connect(self.dbfile)
#cursor = conn.cursor()
#cursor.execute('select max(iteration) from motif_infos')
#iteration = cursor.fetchone()[0]
#query = 'select rowid from motif_infos where iteration=? and cluster=? and mot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_output(pris):\n pris.to_csv('reactors_pris_2016.csv',\n index=False,\n sep=',',\n )",
"def extract_ipo_data_to_dataframe(output_path: str):\n ipo_guiden_url = \"https://www.affarsvarlden.se/ipo-guiden/screener\"\n driver = web_scraper.get_chrome_driv... | [
"0.5933712",
"0.5891572",
"0.57654464",
"0.57008946",
"0.56977654",
"0.5687174",
"0.56842023",
"0.5602609",
"0.5511893",
"0.5511893",
"0.5500696",
"0.5449493",
"0.5439807",
"0.5419989",
"0.5388766",
"0.53855205",
"0.5381732",
"0.5373441",
"0.53679895",
"0.53585464",
"0.534643... | 0.0 | -1 |
Predicate on whether number has an even number of set bits. Variant of kernighan's algorithm. | def has_even_set_bits(num: int) -> int:
isEven = True
while num != 0:
num &= num - 1 # clear the least significant bit set
isEven != isEven
return isEven | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_even(n):\n return not n & 1",
"def is_even(bin_num):\n if list(bin_num).count('1') % 2 == 0:\n return True\n else:\n return False",
"def is_even(x):\n\n return (x & 1) == 0",
"def is_even_faster(number: int) -> bool:\n return number & 1 == 0",
"def even(n):\n return n... | [
"0.778172",
"0.76012075",
"0.75431395",
"0.72146493",
"0.703786",
"0.70363736",
"0.6982985",
"0.69545233",
"0.6952043",
"0.69456315",
"0.6904122",
"0.68976945",
"0.68932724",
"0.68591934",
"0.68445736",
"0.68411094",
"0.68221337",
"0.68099296",
"0.67939466",
"0.6790237",
"0.6... | 0.8118144 | 0 |
fill in dictionary with key walues from a txt file | def fill_in_dict():
# assign a 'data' list from the txt file
data = open('words.txt')
# assign an empty 'my_dict' dictionary
my_dict = dict()
for word in data:
# fill in dictionarys wit a keys and empty values
my_dict[word] = ''
return(my_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_from_file():\n\n plik=open('data.txt')\n for line in plik:\n (key, temp, weat, pres)=line.split()\n dict_from_file[key]=[temp, weat.replace('_',' '), pres]",
"def insert_file_to_dictionary():\r\n file = open(sys.argv[1], \"r\")\r\n #movies is my the dictionary\r\n movies = {... | [
"0.7469321",
"0.7359511",
"0.7322702",
"0.7100944",
"0.70464045",
"0.6970614",
"0.6964565",
"0.6949787",
"0.6908787",
"0.69036305",
"0.68311906",
"0.67684865",
"0.67383885",
"0.671733",
"0.6706961",
"0.6673144",
"0.6663256",
"0.6659219",
"0.6658733",
"0.6637288",
"0.66335726"... | 0.73288995 | 2 |
Test that unloading an entry works. | async def test_unload_entry(hass: HomeAssistant) -> None:
entry = MockConfigEntry(
domain=DOMAIN,
unique_id="0123456789",
data=DEFAULT_CONFIG,
options=DEFAULT_OPTIONS,
)
entry.add_to_hass(hass)
await hass.config_entries.async_setup(entry.entry_id)
await hass.async_bl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unload(self):\n self.instance.load()\n self.assertIsNotNone(self.instance._author)\n self.instance.unload()\n self.assertIsNone(self.instance._author)",
"async def test_unload_entry(hass):\n entry = await init_integration(hass)\n\n assert len(hass.config_entries.async_e... | [
"0.745756",
"0.72451824",
"0.7212864",
"0.71059227",
"0.69350874",
"0.68380535",
"0.67400676",
"0.6651979",
"0.66275996",
"0.66198164",
"0.65616053",
"0.64519477",
"0.63797134",
"0.6342953",
"0.6335653",
"0.6236239",
"0.62268424",
"0.62224346",
"0.6191956",
"0.6167702",
"0.61... | 0.6662962 | 7 |
Creates QueueSimulator object. Arguments | def __init__(self, numQueues, rate, start_hour, end_hour, appt_low, appt_high):
self.rate = rate
self.numQueues = numQueues
self.start = datetime.datetime.combine(datetime.date.today(), datetime.time(start_hour,0,0))
self.end = datetime.datetime.combine(datetime.date.today(), datetime.t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_queue(self):\n # Instantiate\n queue = pbs.queue(verbose=not self.quiet)\n\n if self.q == 'ember':\n # Submitting to Utah ember cluster\n ppn = 12\n cpus = ppn if self.cpus is None else min(self.cpus, ppn)\n walltime = self.walltime if in... | [
"0.66447055",
"0.64939517",
"0.6092597",
"0.6043892",
"0.5924383",
"0.5910528",
"0.5907221",
"0.5831699",
"0.5823763",
"0.5812082",
"0.58109456",
"0.58082455",
"0.5735584",
"0.57232714",
"0.5722301",
"0.572144",
"0.5713813",
"0.5700075",
"0.5688309",
"0.56702524",
"0.56540143... | 0.0 | -1 |
Making onehot encoding and padding (optional) for a sequence of indices | def one_hot(list_of_index, vocab_size=None, pad=False, max_len=None):
if vocab_size is None:
raise Exception('\'vocab_size\' arg is required.')
if pad:
if max_len is None:
raise Exception('If padding, \'max_len\' arg is required.')
matrix = np.zeros([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(index, dims, dtype=np.uint8):\n\n seq_len = len(index)\n ret = np.zeros((seq_len, dims), dtype)\n for i in range(seq_len):\n ret[i][index[i]]=1\n\n return ret",
"def one_hot_encoding(sequence):\n\n mydict = {\n \"A\": np.asarray([1, 0, 0, 0]),\n \"a\": np.asarray([... | [
"0.77902925",
"0.7588166",
"0.7505535",
"0.74692816",
"0.74303466",
"0.74011946",
"0.73511684",
"0.7343085",
"0.7343085",
"0.7343085",
"0.7343085",
"0.7323562",
"0.73203534",
"0.72895473",
"0.7286472",
"0.7283403",
"0.72781134",
"0.72719824",
"0.7267994",
"0.7258156",
"0.7257... | 0.7521659 | 2 |
DCM from given quaternion | def from_quaternion(self, q: np.ndarray) -> np.ndarray:
if q is None:
return np.identity(3)
if q.shape[-1]!=4 or q.ndim>2:
raise ValueError("Quaternion must be of the form (4,) or (N, 4)")
if q.ndim>1:
q /= np.linalg.norm(q, axis=1)[:, None] # Normalize
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quat2DCM(q):\n\tDCM = quatLeftMat(q) @ quatRightMat(q).T\n\tDCM = DCM[1:, 1:]\n\treturn DCM",
"def quat2dcm(q):\n q0q0 = q[0] * q[0]\n q0q1 = q[0] * q[1]\n q0q2 = q[0] * q[2]\n q0q3 = q[0] * q[3]\n q1q1 = q[1] * q[1]\n q1q2 = q[1] * q[2]\n q1q3 = q[1] * q[3]\n q2q2 = q[2] * q[2]\n ... | [
"0.8108216",
"0.7622309",
"0.761226",
"0.69390064",
"0.6903899",
"0.6840777",
"0.674344",
"0.6624096",
"0.65572655",
"0.6093272",
"0.6022374",
"0.59967595",
"0.5948338",
"0.5892284",
"0.58826536",
"0.5831265",
"0.57716954",
"0.57505953",
"0.571294",
"0.571266",
"0.5697808",
... | 0.58295435 | 16 |
Synonym of method ``from_quaternion`` | def from_q(self, q: np.ndarray) -> np.ndarray:
return self.from_quaternion(self, q) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_quaternion(self, q: np.ndarray) -> np.ndarray:\n if q is None:\n return np.identity(3)\n if q.shape[-1]!=4 or q.ndim>2:\n raise ValueError(\"Quaternion must be of the form (4,) or (N, 4)\")\n if q.ndim>1:\n q /= np.linalg.norm(q, axis=1)[:, None] #... | [
"0.7389958",
"0.7127332",
"0.70689607",
"0.7061809",
"0.6956991",
"0.6898827",
"0.6897811",
"0.6848875",
"0.6773726",
"0.67537975",
"0.66988176",
"0.6695084",
"0.66732496",
"0.66456074",
"0.66350013",
"0.6581842",
"0.6566178",
"0.6557515",
"0.65510404",
"0.65235966",
"0.65183... | 0.67563546 | 9 |
Quaternion from Direction Cosine Matrix. There are five methods available to obtain a quaternion from a | def to_quaternion(self, method: str = 'chiaverini', **kw) -> np.ndarray:
q = np.array([1., 0., 0., 0.])
if method.lower()=='hughes':
q = hughes(self.A)
if method.lower()=='chiaverini':
q = chiaverini(self.A)
if method.lower()=='shepperd':
q = shepperd(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _rotate_quaternion(self, q):\n self._normalise()\n return self * q * self.conjugate",
"def _quaternions(self, R):\n # Simple Wikipedia version\n # en.wikipedia.org/wiki/Rotation_matrix#Quaternion\n # For other options see math.stackexchange.com/questions/2074316/calculating... | [
"0.72543365",
"0.7028105",
"0.7016137",
"0.6891996",
"0.6867333",
"0.68475723",
"0.6827582",
"0.68257916",
"0.6825129",
"0.6823862",
"0.6822986",
"0.68202215",
"0.6804415",
"0.6747819",
"0.6721418",
"0.6716098",
"0.66858435",
"0.6677061",
"0.66632396",
"0.66587996",
"0.665434... | 0.6668296 | 18 |
Synonym of method ``to_quaternion`` | def to_q(self, method: str = 'chiaverini', **kw) -> np.ndarray:
return self.to_quaternion(method=method, **kw) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def angle_to_quaternion(angle):\n\treturn Quaternion(*tf.transformations.quaternion_from_euler(0, 0, angle))",
"def _rotate_quaternion(self, q):\n self._normalise()\n return self * q * self.conjugate",
"def angle_to_quaternion(angle):\n return Quaternion(*tf.transformations.quaternion_from_eul... | [
"0.7773435",
"0.7668176",
"0.76124066",
"0.75109637",
"0.7509201",
"0.74345905",
"0.7248149",
"0.72238505",
"0.7182596",
"0.7151042",
"0.7130376",
"0.71106046",
"0.70890665",
"0.70747155",
"0.7050184",
"0.7020826",
"0.70203286",
"0.7018202",
"0.6969565",
"0.69627476",
"0.6947... | 0.7214946 | 8 |
Ordinary Differential Equation of the DCM. | def ode(self, w: np.ndarray) -> np.ndarray:
return self.A@skew(w) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_derivative_Omega_M(self):\n\n Omega_M = self.theta_fid[0] # Fiducial param\n domega = 0.001\n # Calculate the noiseless Cl just above the fidicual param\n Cls_t, _ = euclid_ccl(Omega_M = Omega_M+domega)\n # Numerical derivative, give Cl noiseless its redundant axis back\... | [
"0.705143",
"0.6744259",
"0.65665555",
"0.6540257",
"0.6452997",
"0.6349583",
"0.61580443",
"0.60617137",
"0.59988195",
"0.59753686",
"0.5969434",
"0.59147024",
"0.59014565",
"0.5901123",
"0.58775634",
"0.58582616",
"0.5850622",
"0.5843531",
"0.5837406",
"0.5821323",
"0.58066... | 0.0 | -1 |
Set whether the input socket is enable or not. | def set_input_socket_by(self, socket_name_dict):
default_enable_socket_list = []
for socket_name, c in self.__taskobject.inputs.items():
if not c['optional']:
default_enable_socket_list.append( socket_name )
sdesl = set(default_enable_socket_list)
ssndk = set... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setLoopback(self, enable): \n if enable == True:\n DPxEnableDoutDinLoopback()\n else:\n DPxDisableDoutDinLoopback()",
"def enable(self):\n # Netmiko reports enable and config mode as being enabled\n if not self.native.check_enable_mode():\n self.na... | [
"0.6328038",
"0.6141934",
"0.6140854",
"0.6127846",
"0.59765595",
"0.5906767",
"0.58990806",
"0.58877736",
"0.5856475",
"0.5813778",
"0.57914263",
"0.5781425",
"0.5776666",
"0.572038",
"0.5691975",
"0.5688704",
"0.56743896",
"0.5673722",
"0.56590647",
"0.564134",
"0.564134",
... | 0.7006334 | 0 |
Takes a datetime.time() object and a string representing a timezone, and uses this information and the pytz library to convert time to UTC. | def get_utc(local_tm, tz):
utc_tz = pytz.utc
utc_now = datetime.utcnow().replace(tzinfo=utc_tz)
local_tz = pytz.timezone(tz)
local_now = local_tz.normalize(utc_now)
local_alarm = local_now.replace(hour=local_tm.hour, minute=local_tm.minute)
utc_alarm = utc_tz.normalize(local_alarm)
return ut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resolved_at_to_utc(user_time, user_tz):\n if isinstance(user_tz, str):\n user_tz = dateutil.tz.gettz(user_tz)\n\n localized_time = user_time.replace(tzinfo=user_tz)\n return localized_time.to(\"UTC\").datetime",
"def localize_datetime_utc(date_time):\n return pytz.utc.localize(date_time)",... | [
"0.7613901",
"0.7082771",
"0.7082771",
"0.7082771",
"0.7075718",
"0.7075718",
"0.6980046",
"0.6870693",
"0.68344724",
"0.67982554",
"0.6707277",
"0.66131246",
"0.65021455",
"0.64751524",
"0.6459743",
"0.64281934",
"0.63901955",
"0.6372665",
"0.6360399",
"0.6345804",
"0.631377... | 0.60448915 | 37 |
Takes a datetime.time() object and a string representing a timezone, and uses this information and the pytz library to convert this UTC time to a local time in the given timezone. | def get_local(utc_time, tz):
utc_tz = pytz.utc
utc_now = datetime.utcnow().replace(tzinfo=utc_tz)
utc_alarm = utc_now.replace(hour=utc_time.hour, minute=utc_time.minute)
local_tz = pytz.timezone(tz)
local_alarm = local_tz.normalize(utc_alarm)
return local_alarm.time() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_timezone_datetime(_local_tz: str, _time: datetime.time):\n return pytz.timezone(_local_tz).localize(\n datetime.datetime.combine(datetime.datetime.now().date(), _time)\n )",
"def convert_timezone(time):\n if time is None:\n return None\n from_zone = tz.tzutc()\n to_zone = t... | [
"0.7402427",
"0.71077245",
"0.7042963",
"0.6925428",
"0.6857159",
"0.6776689",
"0.67206216",
"0.67206216",
"0.66327685",
"0.6607059",
"0.6570549",
"0.65419537",
"0.64860797",
"0.6458145",
"0.6458145",
"0.6458145",
"0.6457394",
"0.6417082",
"0.63996595",
"0.63705176",
"0.63482... | 0.70351917 | 3 |
Returns the location of the first blank in board | def find_blank(bd):
count = 0
for num in bd:
if num == " ":
return count
else:
count += 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def firstEmptyCell(board):\r\n for i in range(9):\r\n for j in range(9):\r\n if board[i][j] == 0:\r\n return (i, j) # row, col\r\n return None",
"def get_next_empty_cell(self):\n for row in range(len(self.grid)):\n for col in range(len(self.grid[0])):\n ... | [
"0.81882685",
"0.7924884",
"0.7682579",
"0.75888264",
"0.75666875",
"0.7518079",
"0.7350819",
"0.71132505",
"0.7102861",
"0.7099499",
"0.7046433",
"0.69972974",
"0.6964082",
"0.6951179",
"0.69497305",
"0.679662",
"0.67868096",
"0.6778067",
"0.6776477",
"0.67696226",
"0.675762... | 0.0 | -1 |
Returns True if all rows, cols, and squares of Board are valid | def is_board_valid(bd):
return is_rows_valid(bd) and is_cols_valid(bd) and is_sqrs_valid(bd) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_board_valid(board, rows, cols):\n return all(all(is_cell_valid(board, r, c) for c in xrange(cols)) for r in xrange(rows))",
"def is_valid_board(self):\n for (row, col), value in np.ndenumerate(self.final_values): # Iterate through each position\n if not self.__is_valid_value(row, col... | [
"0.821935",
"0.78617334",
"0.78427565",
"0.7805896",
"0.77616715",
"0.7633204",
"0.75650537",
"0.7557985",
"0.754972",
"0.74979675",
"0.7491603",
"0.74663806",
"0.74360687",
"0.740403",
"0.7403735",
"0.7394343",
"0.73941535",
"0.7345891",
"0.7337375",
"0.7316177",
"0.73031795... | 0.84711677 | 0 |
Produce True if all the rows in board are valid | def is_rows_valid(bd):
for row in rows:
seen = []
for num in nums:
if bd[row[num]] == " ":
continue
elif bd[row[num]] not in seen:
seen += [bd[row[num]]]
else:
return False
else:
continue
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check(self) -> bool:\n\n\t\treturn all([all(row) for row in self.board])",
"def is_board_valid(board, rows, cols):\n return all(all(is_cell_valid(board, r, c) for c in xrange(cols)) for r in xrange(rows))",
"def is_valid_board(board):\n valid = len(board) == 9\n valid &= -1 <= sum(board) <= 1\n ... | [
"0.8179805",
"0.80350727",
"0.7978894",
"0.7978362",
"0.78597134",
"0.7831764",
"0.78134537",
"0.7753488",
"0.75918406",
"0.7590312",
"0.75240564",
"0.75107545",
"0.745614",
"0.7417445",
"0.74046415",
"0.73841214",
"0.7380437",
"0.7360972",
"0.73237234",
"0.73237234",
"0.7322... | 0.7173518 | 35 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.