query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Creates a parity plot Input | def parity_plot(y_pred, y_act):
fig = plt.figure(figsize=FIG_SIZE)
plt.scatter(y_act, y_pred)
plt.plot([y_act.min(), y_act.max()], [y_act.min(), y_act.max()],
lw=4, color='r')
plt.xlabel('Actual')
plt.ylabel('Predicted')
return fig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parity_plot(self, X, y, hypes='current', shuffle=True, standardize=True, test_size=0.2,\n ax=None, figsize=(5,5), lim=450, title=''):\n \n ### SPLIT + STANDARDIZE DATA ###\n X_train, X_val, y_train, y_val = \\\n model_selection.train_test_split(X, y, shuffle=s... | [
"0.60325396",
"0.55027705",
"0.5502308",
"0.5413973",
"0.5303545",
"0.5166134",
"0.5129697",
"0.51236194",
"0.51084274",
"0.50956047",
"0.49979413",
"0.49950665",
"0.49406904",
"0.4930244",
"0.4929135",
"0.49003434",
"0.48894036",
"0.4883277",
"0.48773867",
"0.48701388",
"0.4... | 0.64282143 | 0 |
Creates a plot of training vs. test error Input | def train_test_error(e_train, e_test, model_params):
fig = plt.figure(figsize=FIG_SIZE)
plt.plot(model_params, e_train, label='Training Set')
plt.plot(model_params, e_train, label='Test Set')
plt.xlabel('Model Parameter')
plt.ylabel('MSE of model')
plt.legend()
return fig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_train_test_errors(train_errors, test_errors, lambda_str , K , path, rng):\n plt.plot(range(rng), train_errors, marker='o', label='Training Data');\n plt.plot(range(rng), test_errors, marker='v', label='Test Data');\n plt.title('ALS-WR Learning Curve, lambda = %s, K = %d'%(lambda_str, K))\n plt... | [
"0.7718284",
"0.75233483",
"0.7521889",
"0.75182676",
"0.73229706",
"0.72969925",
"0.7259998",
"0.7252103",
"0.7241215",
"0.72121704",
"0.7191472",
"0.7167743",
"0.7133397",
"0.706208",
"0.7051364",
"0.7009513",
"0.6983194",
"0.6949672",
"0.6917633",
"0.6906476",
"0.685914",
... | 0.78787816 | 0 |
Ensure that the sender ID is valid, based on the email's intent. Many emails are only allowed to be sent by a certain user or type of user, e.g. 'admin' or an admin/moderator. This function will raise an exception if the given sender is not allowed to send this type of email. | def _require_sender_id_is_valid(intent, sender_id):
if intent not in SENDER_VALIDATORS:
raise Exception('Invalid email intent string: %s' % intent)
else:
if not SENDER_VALIDATORS[intent](sender_id):
logging.error(
'Invalid sender_id %s for email with intent \'%s\'' %... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __set_sender_id(self, sender_id):\n if not isinstance(sender_id, int):\n raise TypeError('It has to be an integer identifier')\n if sender_id < 0:\n raise ValueError('There are not negative identifiers')\n self.__sender_id = sender_id",
"def is_sender_public_id(self... | [
"0.63011056",
"0.60451776",
"0.5974665",
"0.5636324",
"0.55161345",
"0.54815364",
"0.5412664",
"0.5280462",
"0.5246744",
"0.52253884",
"0.5225088",
"0.5218983",
"0.52032375",
"0.5185404",
"0.5149468",
"0.5148969",
"0.51131505",
"0.5094248",
"0.50170064",
"0.5002656",
"0.49936... | 0.7997367 | 0 |
Sends an email to the given recipient. This function should be used for sending all userfacing emails. Raises an Exception if the sender_id is not appropriate for the given intent. Currently we support only systemgenerated emails and emails initiated by moderator actions. | def _send_email(
recipient_id, sender_id, intent, email_subject, email_html_body,
sender_email, bcc_admin=False, sender_name=None, reply_to_id=None):
if sender_name is None:
sender_name = EMAIL_SENDER_NAME.value
_require_sender_id_is_valid(intent, sender_id)
recipient_email = user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_moderator_action_email(\n sender_id, recipient_id, intent, exploration_title, email_body):\n\n require_moderator_email_prereqs_are_satisfied()\n email_config = feconf.VALID_MODERATOR_ACTIONS[intent]\n\n recipient_user_settings = user_services.get_user_settings(recipient_id)\n sender_use... | [
"0.70404404",
"0.66758424",
"0.6426211",
"0.6346236",
"0.6332512",
"0.62775904",
"0.6215887",
"0.62101585",
"0.619144",
"0.6182269",
"0.6173173",
"0.61452943",
"0.61209476",
"0.6116378",
"0.6083912",
"0.6079683",
"0.60604775",
"0.5991553",
"0.59798497",
"0.5950241",
"0.594205... | 0.7333029 | 0 |
Send an email to the admin email address. The email is sent to the ADMIN_EMAIL_ADDRESS set in feconf.py. | def send_mail_to_admin(email_subject, email_body):
app_id = app_identity_services.get_application_id()
body = '(Sent from %s)\n\n%s' % (app_id, email_body)
system_name_email = '%s <%s>' % (
feconf.SYSTEM_EMAIL_NAME, feconf.SYSTEM_EMAIL_ADDRESS)
email_services.send_mail(
system_name_emai... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_admin_email(message, subject=None):\n send_mail(\n subject=subject if subject else \"Attention Needed\",\n message=message,\n from_email=settings.DEFAULT_FROM_EMAIL,\n recipient_list=[settings.ADMIN_EMAIL],\n fail_silently=True\n )",
"def email_admins(subject, me... | [
"0.7686298",
"0.735426",
"0.7294682",
"0.72052586",
"0.705233",
"0.69091976",
"0.6899131",
"0.6888391",
"0.67242885",
"0.64891297",
"0.64843297",
"0.6481862",
"0.63286996",
"0.6305568",
"0.622519",
"0.617304",
"0.6167632",
"0.6146815",
"0.6135693",
"0.6130531",
"0.6118046",
... | 0.80180204 | 0 |
Sends a postsignup email to the given user. Raises an exception if emails are not allowed to be sent to users (i.e. feconf.CAN_SEND_EMAILS is False). | def send_post_signup_email(user_id):
for key, content in SIGNUP_EMAIL_CONTENT.value.iteritems():
if content == SIGNUP_EMAIL_CONTENT.default_value[key]:
log_new_error(
'Please ensure that the value for the admin config property '
'SIGNUP_EMAIL_CONTENT is set, befo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email_signup_user(email, msg, settings, message_data):\r\n from bookie.lib.message import ActivationMsg\r\n msg = ActivationMsg(email, msg, settings)\r\n status = msg.send(message_data)\r\n if status == 4:\r\n from bookie.lib.applog import SignupLog\r\n trans = transaction.begin()\r\n... | [
"0.7136163",
"0.6299118",
"0.6153206",
"0.6132513",
"0.6083406",
"0.6045676",
"0.5999483",
"0.59717304",
"0.5922723",
"0.58556545",
"0.58483684",
"0.5844414",
"0.5837412",
"0.5828164",
"0.58259803",
"0.58219427",
"0.58205014",
"0.5803705",
"0.580071",
"0.5792874",
"0.5792027"... | 0.8055472 | 0 |
Returns a draft of the text of the body for an email sent immediately when a moderator unpublishes an exploration. An empty body is a signal to the frontend that no email will be sent. | def get_moderator_unpublish_exploration_email():
try:
require_moderator_email_prereqs_are_satisfied()
return config_domain.Registry.get_config_property(
'unpublish_exploration_email_html_body').value
except Exception:
return '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_draft_message(draft):\n return HttpTextResponse(draft.text if draft else '')",
"def draft_message(request):\n query = models.Message.query(\n models.Message.sender == request.user.email(),\n models.Message.draft == True,\n ancestor=request.issue.key)\n if query.count() == 0:\n draft... | [
"0.6826353",
"0.6373287",
"0.6329049",
"0.61740094",
"0.6156092",
"0.6091604",
"0.6048866",
"0.6048866",
"0.6004672",
"0.59915483",
"0.5929247",
"0.59074426",
"0.5902718",
"0.5870653",
"0.57841074",
"0.5735849",
"0.56882584",
"0.56744325",
"0.5673834",
"0.56731755",
"0.565902... | 0.70447296 | 0 |
Raises an exception if, for any reason, moderator emails cannot be sent. | def require_moderator_email_prereqs_are_satisfied():
if not feconf.REQUIRE_EMAIL_ON_MODERATOR_ACTION:
raise Exception(
'For moderator emails to be sent, please ensure that '
'REQUIRE_EMAIL_ON_MODERATOR_ACTION is set to True.')
if not feconf.CAN_SEND_EMAILS:
raise Excepti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_moderator_action_email(\n sender_id, recipient_id, intent, exploration_title, email_body):\n\n require_moderator_email_prereqs_are_satisfied()\n email_config = feconf.VALID_MODERATOR_ACTIONS[intent]\n\n recipient_user_settings = user_services.get_user_settings(recipient_id)\n sender_use... | [
"0.6350764",
"0.61205196",
"0.6099943",
"0.6073155",
"0.6033035",
"0.59109247",
"0.5907083",
"0.59048647",
"0.5878426",
"0.58115745",
"0.57740605",
"0.57735085",
"0.57223177",
"0.5704757",
"0.56990653",
"0.5677356",
"0.56460834",
"0.56319237",
"0.56298757",
"0.55918145",
"0.5... | 0.66376364 | 0 |
Sends a email immediately following a moderator action (unpublish, delete) to the given user. Raises an exception if emails are not allowed to be sent to users (i.e. feconf.CAN_SEND_EMAILS is False). | def send_moderator_action_email(
sender_id, recipient_id, intent, exploration_title, email_body):
require_moderator_email_prereqs_are_satisfied()
email_config = feconf.VALID_MODERATOR_ACTIONS[intent]
recipient_user_settings = user_services.get_user_settings(recipient_id)
sender_user_settings =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_admin_notification_callback(sender, **kwargs):\r\n user = kwargs['user']\r\n\r\n studio_request_email = settings.FEATURES.get('STUDIO_REQUEST_EMAIL', '')\r\n context = {'user_name': user.username, 'user_email': user.email}\r\n\r\n subject = render_to_string('emails/course_creator_admin_subject... | [
"0.64828694",
"0.6278511",
"0.62045395",
"0.6172169",
"0.61680096",
"0.61653394",
"0.61442286",
"0.6036451",
"0.60343355",
"0.6032981",
"0.59950113",
"0.59919906",
"0.5980274",
"0.5976947",
"0.59624887",
"0.595382",
"0.59182537",
"0.5915328",
"0.5914955",
"0.59128886",
"0.590... | 0.7456833 | 0 |
Sends a email when a new user is given activity rights (Manager, Editor, Viewer) to an exploration by creator of exploration. Email will only be sent if recipient wants to receive these emails (i.e. 'can_receive_editor_role_email' is set True in recipent's preferences). | def send_role_notification_email(
inviter_id, recipient_id, recipient_role, exploration_id,
exploration_title):
# Editor role email body and email subject templates.
email_subject_template = (
'%s - invitation to collaborate')
email_body_template = (
'Hi %s,<br>'
'<... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_moderator_action_email(\n sender_id, recipient_id, intent, exploration_title, email_body):\n\n require_moderator_email_prereqs_are_satisfied()\n email_config = feconf.VALID_MODERATOR_ACTIONS[intent]\n\n recipient_user_settings = user_services.get_user_settings(recipient_id)\n sender_use... | [
"0.7290568",
"0.6750215",
"0.6154038",
"0.6101387",
"0.6095636",
"0.5910066",
"0.5909995",
"0.5898312",
"0.58746374",
"0.58726656",
"0.58580977",
"0.58448046",
"0.5832901",
"0.5796564",
"0.57848686",
"0.57595974",
"0.5724443",
"0.5676346",
"0.564586",
"0.5636457",
"0.5582982"... | 0.7351961 | 0 |
Sends an email to all the subscribers of the creators when the creator publishes an exploration. | def send_emails_to_subscribers(creator_id, exploration_id, exploration_title):
creator_name = user_services.get_username(creator_id)
email_subject = ('%s has published a new exploration!' % creator_name)
email_body_template = (
'Hi %s,<br>'
'<br>'
'%s has published a new exploration... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_publishers_authors_email(subject, template_name, context=None):\n\n if context is None:\n context = {}\n\n qry = Q(groups__name='Publishers') | Q(groups__name='Editors')\n\n emails = auth_models.User.objects.filter(qry, is_active=True).distinct().values('email')\n to = [e['email'] for e... | [
"0.6924773",
"0.6706749",
"0.6441707",
"0.64001817",
"0.6382296",
"0.630457",
"0.62586987",
"0.62260795",
"0.6197916",
"0.61378837",
"0.61098725",
"0.60891855",
"0.6049328",
"0.6014133",
"0.60134995",
"0.59922683",
"0.59853923",
"0.5965531",
"0.5957944",
"0.5957566",
"0.59547... | 0.7895617 | 0 |
Send emails to notify the given recipients about new suggestion. Each recipient will only be emailed if their email preferences allow for incoming feedback message emails. | def send_suggestion_email(
exploration_title, exploration_id, author_id, recipient_list):
email_subject = 'New suggestion for "%s"' % exploration_title
email_body_template = (
'Hi %s,<br>'
'%s has submitted a new suggestion for your Oppia exploration, '
'<a href="https://www.op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle(self, *args, **options):\n\n candidates_with_email = [candidate for candidate in Candidate.objects.all()\n if candidate.contact_address and candidate.participating]\n\n\n print 'sending e-mails'\n conn = get_connection()\n for c in candidates_w... | [
"0.65933686",
"0.6401568",
"0.62837064",
"0.61542654",
"0.6150181",
"0.6110756",
"0.60990274",
"0.6087475",
"0.6058593",
"0.60515386",
"0.6035699",
"0.60281765",
"0.6022129",
"0.6002254",
"0.599066",
"0.5976432",
"0.59318906",
"0.5925883",
"0.5912168",
"0.58666724",
"0.584028... | 0.78807247 | 0 |
Send an email to all moderators when an exploration is flagged. | def send_flag_exploration_email(
exploration_title, exploration_id, reporter_id, report_text):
email_subject = 'Exploration flagged by user: "%s"' % exploration_title
email_body_template = (
'Hello Moderator,<br>'
'%s has flagged exploration "%s" on the following '
'grounds: <br... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_activation_notifications(modeladmin, request, queryset):\n for rec in queryset:\n if not rec.is_activated:\n send_activation_notification(rec)\n modeladmin.message_user(request, \"Письма с оповещением отправлены\")\n send_activation_notifications.short_description = 'Отправка пи... | [
"0.63098",
"0.62704873",
"0.6095372",
"0.60124356",
"0.5989169",
"0.5974846",
"0.59564966",
"0.58688504",
"0.5847265",
"0.57325214",
"0.5693095",
"0.567212",
"0.56636727",
"0.5638318",
"0.5626211",
"0.5619218",
"0.56055933",
"0.5587645",
"0.558527",
"0.5584736",
"0.55715865",... | 0.73060805 | 0 |
Sends an email to all the recipients of the query. | def send_user_query_email(
sender_id, recipient_ids, email_subject, email_body, email_intent):
bulk_email_model_id = email_models.BulkEmailModel.get_new_id('')
sender_name = user_services.get_username(sender_id)
sender_email = user_services.get_email_from_user_id(sender_id)
_send_bulk_mail(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_email_users():\n\n # Get users emails\n users_emails = User.objects.exclude(\n Q(email='') |\n Q(email=None)\n ).values_list(\n 'email',\n flat=True\n )\n\n # Send email to each user\n # for email_user in users_emails:\n\n title = 'Se han calculado nuevos H... | [
"0.73025334",
"0.6579745",
"0.6446511",
"0.63694125",
"0.6341413",
"0.6314311",
"0.6313544",
"0.6278935",
"0.62782586",
"0.6242665",
"0.62141085",
"0.6197069",
"0.61943626",
"0.6192925",
"0.6189939",
"0.61847085",
"0.6183954",
"0.6156296",
"0.6138873",
"0.6104926",
"0.6101505... | 0.6887153 | 1 |
Sends an email to users to review suggestions in categories they have agreed to review for. | def send_mail_to_notify_users_to_review(user_id, category):
email_subject = 'Notification to review suggestions'
email_body_template = (
'Hi %s,<br><br>'
'Just a heads-up that there are new suggestions to '
'review in %s, which you are registered as a reviewer for.'
'<br><br>Pl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_mail_to_onboard_new_reviewers(user_id, category):\n\n email_subject = 'Invitation to review suggestions'\n\n email_body_template = (\n 'Hi %s,<br><br>'\n 'Thank you for actively contributing high-quality suggestions for '\n 'Oppia\\'s lessons in %s, and for helping to make these... | [
"0.68983877",
"0.64180887",
"0.57124037",
"0.5420123",
"0.5274859",
"0.5271694",
"0.5123973",
"0.5034608",
"0.50228983",
"0.4986225",
"0.49522626",
"0.49364617",
"0.4912687",
"0.49042255",
"0.48964846",
"0.48510882",
"0.48433986",
"0.48336226",
"0.48301044",
"0.47937506",
"0.... | 0.7463379 | 0 |
want to check if that exact column has other numbers similar to it. | def column_similarity (self, row, col):
my_number = self.board[row][col]
for i in range (9):
if (i,col) == (row,col):
continue
elif self.board[i][col] == my_number:
return [i, col, False]
else:
continue | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_numeric(data, col):\n from pandas.api.types import is_numeric_dtype\n try:\n if is_numeric_dtype(data[col]):\n logging.info(f' {col} is numeric.')\n return data\n else:\n numdata = (data\n .drop([col], axis=1)\n ... | [
"0.6021822",
"0.59742075",
"0.5886473",
"0.5833917",
"0.581885",
"0.58105975",
"0.5785321",
"0.57455134",
"0.5726011",
"0.5720671",
"0.5683801",
"0.5672219",
"0.5668045",
"0.5663133",
"0.5654133",
"0.563048",
"0.5591739",
"0.55355304",
"0.5530956",
"0.5528554",
"0.5494932",
... | 0.6436294 | 0 |
__init__(itkArray2DD self) > itkArray2DD __init__(itkArray2DD self, unsigned int rows, unsigned int cols) > itkArray2DD __init__(itkArray2DD self, itkArray2DD array) > itkArray2DD __init__(itkArray2DD self, vnl_matrixD matrix) > itkArray2DD | def __init__(self, *args):
_itkArray2DPython.itkArray2DD_swiginit(self, _itkArray2DPython.new_itkArray2DD(*args)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DF_swiginit(self, _itkArray2DPython.new_itkArray2DF(*args))",
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DUI_swiginit(self, _itkArray2DPython.new_itkArray2DUI(*args))",
"def __init__(self, *args):\n _itkQuadEdgeCellTrait... | [
"0.78698415",
"0.7478759",
"0.64136213",
"0.6410877",
"0.63646346",
"0.63412094",
"0.63412094",
"0.63412094",
"0.6274328",
"0.62616503",
"0.6219141",
"0.6165293",
"0.6112146",
"0.60364133",
"0.6021272",
"0.60208875",
"0.60110205",
"0.60078305",
"0.5997586",
"0.59894484",
"0.5... | 0.84896344 | 0 |
Fill(itkArray2DD self, double const & v) | def Fill(self, v: 'double const &') -> "void":
return _itkArray2DPython.itkArray2DD_Fill(self, v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Fill(self, v: 'float const &') -> \"void\":\n return _itkArray2DPython.itkArray2DF_Fill(self, v)",
"def Fill(self, v: 'unsigned int const &') -> \"void\":\n return _itkArray2DPython.itkArray2DUI_Fill(self, v)",
"def fill(self, value):\n if self.fragmented:\n (self[self._begi... | [
"0.8544297",
"0.785491",
"0.6256915",
"0.61166364",
"0.5970237",
"0.59047204",
"0.5847172",
"0.58327675",
"0.5689264",
"0.5665186",
"0.56445605",
"0.56017166",
"0.5585389",
"0.554506",
"0.5530757",
"0.54830456",
"0.54423213",
"0.5441942",
"0.5397863",
"0.53732944",
"0.5371750... | 0.8819905 | 0 |
GetElement(itkArray2DD self, unsigned long long row, unsigned long long col) > double const & | def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> "double const &":
return _itkArray2DPython.itkArray2DD_GetElement(self, row, col) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> \"float const &\":\n return _itkArray2DPython.itkArray2DF_GetElement(self, row, col)",
"def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> \"unsigned int const &\":\n return _itkArray2DPython.it... | [
"0.7922373",
"0.7076791",
"0.64822364",
"0.63628876",
"0.62909794",
"0.6235617",
"0.609517",
"0.60182863",
"0.58870274",
"0.5733961",
"0.5595174",
"0.5569219",
"0.55460614",
"0.55460614",
"0.55404353",
"0.5513931",
"0.55024916",
"0.54503983",
"0.54503983",
"0.5434715",
"0.542... | 0.8351469 | 0 |
SetElement(itkArray2DD self, unsigned long long row, unsigned long long col, double const & value) | def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'double const &') -> "void":
return _itkArray2DPython.itkArray2DD_SetElement(self, row, col, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'float const &') -> \"void\":\n return _itkArray2DPython.itkArray2DF_SetElement(self, row, col, value)",
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'unsigned int const &') -> \"void\":... | [
"0.83841926",
"0.7855338",
"0.6741735",
"0.6519097",
"0.6515927",
"0.6506434",
"0.65060234",
"0.64577657",
"0.63357204",
"0.6270508",
"0.61690164",
"0.6160906",
"0.61418504",
"0.6113001",
"0.6109967",
"0.6087935",
"0.6085804",
"0.6001761",
"0.5977456",
"0.5977456",
"0.5901419... | 0.8812194 | 0 |
SetSize(itkArray2DD self, unsigned int m, unsigned int n) | def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> "void":
return _itkArray2DPython.itkArray2DD_SetSize(self, m, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> \"void\":\n return _itkArray2DPython.itkArray2DF_SetSize(self, m, n)",
"def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> \"void\":\n return _itkArray2DPython.itkArray2DUI_SetSize(self, m, n)",
"def set_max_noutput_items(self, m:... | [
"0.8451979",
"0.835548",
"0.658262",
"0.6509408",
"0.6394886",
"0.6241872",
"0.6231723",
"0.62243724",
"0.6178181",
"0.6138018",
"0.6053096",
"0.6031094",
"0.6002116",
"0.59884715",
"0.59771633",
"0.5976593",
"0.59596854",
"0.59272444",
"0.59253377",
"0.59088135",
"0.59065115... | 0.8655469 | 0 |
__init__(itkArray2DF self) > itkArray2DF __init__(itkArray2DF self, unsigned int rows, unsigned int cols) > itkArray2DF __init__(itkArray2DF self, itkArray2DF array) > itkArray2DF __init__(itkArray2DF self, vnl_matrixF matrix) > itkArray2DF | def __init__(self, *args):
_itkArray2DPython.itkArray2DF_swiginit(self, _itkArray2DPython.new_itkArray2DF(*args)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DD_swiginit(self, _itkArray2DPython.new_itkArray2DD(*args))",
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DUI_swiginit(self, _itkArray2DPython.new_itkArray2DUI(*args))",
"def __init__(self, *args):\n _itkQuadEdgeCellTrait... | [
"0.7764629",
"0.7177791",
"0.63070595",
"0.624977",
"0.62463087",
"0.6222416",
"0.61589444",
"0.6103977",
"0.6060324",
"0.6058261",
"0.6057244",
"0.6029068",
"0.59877056",
"0.5977644",
"0.5977644",
"0.5977644",
"0.5973117",
"0.595984",
"0.595467",
"0.59331894",
"0.59264046",
... | 0.86677057 | 0 |
Fill(itkArray2DF self, float const & v) | def Fill(self, v: 'float const &') -> "void":
return _itkArray2DPython.itkArray2DF_Fill(self, v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Fill(self, v: 'double const &') -> \"void\":\n return _itkArray2DPython.itkArray2DD_Fill(self, v)",
"def Fill(self, v: 'unsigned int const &') -> \"void\":\n return _itkArray2DPython.itkArray2DUI_Fill(self, v)",
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value... | [
"0.80922425",
"0.7397962",
"0.6139154",
"0.6133239",
"0.61009586",
"0.5901819",
"0.58754003",
"0.57854307",
"0.5779825",
"0.5766624",
"0.56349725",
"0.56030184",
"0.5570174",
"0.5565274",
"0.553421",
"0.55010086",
"0.5471197",
"0.5467192",
"0.5433345",
"0.5428066",
"0.5417293... | 0.8827043 | 0 |
GetElement(itkArray2DF self, unsigned long long row, unsigned long long col) > float const & | def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> "float const &":
return _itkArray2DPython.itkArray2DF_GetElement(self, row, col) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> \"double const &\":\n return _itkArray2DPython.itkArray2DD_GetElement(self, row, col)",
"def GetElement(self, arg0: 'unsigned long long') -> \"itkQuadEdgeMeshPointF2GQEULLULLBBT\":\n return _itkQuadEdgeCellTraitsInfoPytho... | [
"0.7061847",
"0.62274915",
"0.61730164",
"0.6144366",
"0.61009204",
"0.6037468",
"0.59887797",
"0.5980564",
"0.571045",
"0.5679957",
"0.5569919",
"0.5537453",
"0.55184114",
"0.54868007",
"0.5486629",
"0.5482046",
"0.54703885",
"0.5459366",
"0.5419209",
"0.54164267",
"0.539763... | 0.80808926 | 0 |
SetElement(itkArray2DF self, unsigned long long row, unsigned long long col, float const & value) | def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'float const &') -> "void":
return _itkArray2DPython.itkArray2DF_SetElement(self, row, col, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'double const &') -> \"void\":\n return _itkArray2DPython.itkArray2DD_SetElement(self, row, col, value)",
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'unsigned int const &') -> \"void\"... | [
"0.8119709",
"0.74154353",
"0.6624242",
"0.65521324",
"0.6405638",
"0.63904935",
"0.6346926",
"0.6330578",
"0.62997335",
"0.6197093",
"0.6162876",
"0.61383504",
"0.6048171",
"0.5945354",
"0.5921697",
"0.5916385",
"0.5866174",
"0.58497",
"0.5813784",
"0.5762261",
"0.5751917",
... | 0.8804142 | 0 |
SetSize(itkArray2DF self, unsigned int m, unsigned int n) | def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> "void":
return _itkArray2DPython.itkArray2DF_SetSize(self, m, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> \"void\":\n return _itkArray2DPython.itkArray2DD_SetSize(self, m, n)",
"def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> \"void\":\n return _itkArray2DPython.itkArray2DUI_SetSize(self, m, n)",
"def ndarray_size(self) -> int:\n ... | [
"0.8297612",
"0.80986935",
"0.6593365",
"0.61421",
"0.6090376",
"0.60581696",
"0.6050299",
"0.604565",
"0.6032591",
"0.5971956",
"0.5966166",
"0.59406424",
"0.5928546",
"0.59173846",
"0.58942884",
"0.588672",
"0.5853012",
"0.58337176",
"0.58213764",
"0.57973105",
"0.57750106"... | 0.87428766 | 0 |
__init__(itkArray2DUI self) > itkArray2DUI __init__(itkArray2DUI self, unsigned int rows, unsigned int cols) > itkArray2DUI __init__(itkArray2DUI self, itkArray2DUI array) > itkArray2DUI __init__(itkArray2DUI self, vnl_matrixUI matrix) > itkArray2DUI | def __init__(self, *args):
_itkArray2DPython.itkArray2DUI_swiginit(self, _itkArray2DPython.new_itkArray2DUI(*args)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DD_swiginit(self, _itkArray2DPython.new_itkArray2DD(*args))",
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DF_swiginit(self, _itkArray2DPython.new_itkArray2DF(*args))",
"def __init__(self, *args):\n _itkRGBAPixelPython.itk... | [
"0.80487615",
"0.777564",
"0.69835806",
"0.68892384",
"0.68715703",
"0.67145765",
"0.64858663",
"0.64536214",
"0.6435996",
"0.6420875",
"0.6387748",
"0.6356113",
"0.63242954",
"0.6317986",
"0.6293345",
"0.6236154",
"0.6188177",
"0.61849767",
"0.6184558",
"0.61808354",
"0.6175... | 0.8610839 | 0 |
Fill(itkArray2DUI self, unsigned int const & v) | def Fill(self, v: 'unsigned int const &') -> "void":
return _itkArray2DPython.itkArray2DUI_Fill(self, v) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Fill(self, v: 'double const &') -> \"void\":\n return _itkArray2DPython.itkArray2DD_Fill(self, v)",
"def Fill(self, v: 'float const &') -> \"void\":\n return _itkArray2DPython.itkArray2DF_Fill(self, v)",
"def __init__(self, *args):\n _itkArray2DPython.itkArray2DUI_swiginit(self, _itkAr... | [
"0.7921747",
"0.77203965",
"0.61905295",
"0.60789037",
"0.5938952",
"0.58699584",
"0.5791839",
"0.5729613",
"0.56825614",
"0.56763756",
"0.5667946",
"0.565371",
"0.56478775",
"0.5605819",
"0.5552073",
"0.55115837",
"0.54938257",
"0.54836893",
"0.53783613",
"0.53755033",
"0.53... | 0.8914225 | 0 |
GetElement(itkArray2DUI self, unsigned long long row, unsigned long long col) > unsigned int const & | def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> "unsigned int const &":
return _itkArray2DPython.itkArray2DUI_GetElement(self, row, col) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> \"double const &\":\n return _itkArray2DPython.itkArray2DD_GetElement(self, row, col)",
"def GetElement(self, row: 'unsigned long long', col: 'unsigned long long') -> \"float const &\":\n return _itkArray2DPython.itkArray... | [
"0.7785524",
"0.7625416",
"0.68500215",
"0.6774247",
"0.670162",
"0.644203",
"0.63044876",
"0.62142974",
"0.6013558",
"0.5961701",
"0.5959366",
"0.59231186",
"0.59009427",
"0.5897651",
"0.5849272",
"0.5831127",
"0.5822153",
"0.58043116",
"0.5800766",
"0.57987154",
"0.5794374"... | 0.8432618 | 0 |
SetElement(itkArray2DUI self, unsigned long long row, unsigned long long col, unsigned int const & value) | def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'unsigned int const &') -> "void":
return _itkArray2DPython.itkArray2DUI_SetElement(self, row, col, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'double const &') -> \"void\":\n return _itkArray2DPython.itkArray2DD_SetElement(self, row, col, value)",
"def SetElement(self, row: 'unsigned long long', col: 'unsigned long long', value: 'float const &') -> \"void\":\n ... | [
"0.8413521",
"0.81160265",
"0.6801174",
"0.6781219",
"0.65562356",
"0.6552081",
"0.65435123",
"0.65359664",
"0.6511129",
"0.6507009",
"0.6499812",
"0.6495469",
"0.6465553",
"0.6461614",
"0.6461614",
"0.64564085",
"0.64001876",
"0.6371972",
"0.63610524",
"0.6351999",
"0.634343... | 0.8879996 | 0 |
SetSize(itkArray2DUI self, unsigned int m, unsigned int n) | def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> "void":
return _itkArray2DPython.itkArray2DUI_SetSize(self, m, n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> \"void\":\n return _itkArray2DPython.itkArray2DD_SetSize(self, m, n)",
"def SetSize(self, m: 'unsigned int', n: 'unsigned int') -> \"void\":\n return _itkArray2DPython.itkArray2DF_SetSize(self, m, n)",
"def set_max_noutput_items(self, m: ... | [
"0.85178095",
"0.8374545",
"0.6314273",
"0.6306638",
"0.6238411",
"0.6133936",
"0.6127183",
"0.60872436",
"0.60686094",
"0.6050591",
"0.60306793",
"0.602301",
"0.6011912",
"0.5973902",
"0.5965146",
"0.5953784",
"0.5940959",
"0.5936957",
"0.5917273",
"0.59170175",
"0.59100306"... | 0.87136483 | 0 |
Find the next number in line, starting at position pos. Returns number starting position and length as (start, end) or None. | def find_next_number(line, pos=0):
m = number_re.search(line[pos:])
if m:
span = m.span()
return (span[0]+pos,span[1]+pos) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_linepos(self, pos):\n t = self.input\n if pos < 0 or pos > len(t):\n raise IndexError(\"position %d not in 0..%d\" % (pos, len(t)))\n\n lpc = self.__linepos\n\n # Locate the smallest known line index whose end is at or after p.\n def locate(p):\n se... | [
"0.6902084",
"0.68278724",
"0.6300113",
"0.62892026",
"0.6092027",
"0.5967655",
"0.59053856",
"0.59053856",
"0.59053856",
"0.58831704",
"0.58310235",
"0.5820357",
"0.57687795",
"0.5710002",
"0.5674555",
"0.5665141",
"0.56576127",
"0.56449544",
"0.56415296",
"0.5631679",
"0.56... | 0.85059404 | 0 |
Returns an array with all of the numbers in the line | def numbers_in_line(line):
ret = []
pos = 0
while True:
loc = find_next_number(line, pos)
if not loc:
break
ret.append(loc)
pos = loc[1]
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_line(line):\n return [int(v) for v in line.strip().split()]",
"def read_line_as_numbers(filename):\n # As we expect numbers here and need them in order to do calculations lets map to int\n return list(map(int, read_lines(filename)))",
"def __preprocess_line(line):\n return [int(el... | [
"0.6971801",
"0.69115394",
"0.6783133",
"0.674357",
"0.6740318",
"0.67264277",
"0.66676843",
"0.65289",
"0.6525442",
"0.64807457",
"0.64313036",
"0.63441694",
"0.6276796",
"0.6262876",
"0.62363034",
"0.61972237",
"0.61549926",
"0.6125201",
"0.61193466",
"0.5969897",
"0.596870... | 0.74056095 | 0 |
Takes a number and returns a boolean stating whether or not the number was in scientific form | def in_scientific_form(val):
return (re.search(r"[+\-]?\d+(\.)?\d*[eE][+\-]?\d+", val)) != None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_scientific(number):\n if convert_to_scientific_notation(float(number)) == number:\n return True\n return False",
"def _is_number(s) -> bool:\n try:\n float(s)\n except ValueError:\n return False\n else:\n return True",
"def isnumber(x):\n try:\n float... | [
"0.8920811",
"0.70502317",
"0.6823747",
"0.6822256",
"0.6822256",
"0.6822256",
"0.68053025",
"0.68040735",
"0.68035716",
"0.6800513",
"0.67936176",
"0.67819494",
"0.6738446",
"0.67035544",
"0.6633378",
"0.6615352",
"0.6614249",
"0.6586777",
"0.6566277",
"0.65168226",
"0.65095... | 0.8617736 | 1 |
Takes a cleaned decimal and returns the value's number of trailing zeros | def num_trailing_zeros(val):
val = str(val)
counter = 0
for char in reversed(val):
if char == "." or char != "0" : break
elif char == "0" : counter += 1
return counter | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trailing_zeroes(n):\n str_n = str(n)\n i = len(str_n) - 1\n while str_n[i] == '0':\n i -= 1\n return len(str_n) - 1 - i",
"def strip_trailing_zeros(cls, s):\n # Make sure there's a '.' in the string.\n if s.find('.') < 0:\n return s\n\n # Reverse the string,... | [
"0.6899556",
"0.6781311",
"0.6741457",
"0.6600747",
"0.6523342",
"0.6431094",
"0.6202228",
"0.60454684",
"0.59834653",
"0.5894034",
"0.585169",
"0.5846297",
"0.5807793",
"0.57551146",
"0.5693843",
"0.5690915",
"0.5672005",
"0.5656921",
"0.56408",
"0.5610538",
"0.5585411",
"... | 0.7852471 | 0 |
Odd little function to return the number of significant figures in a number. It kills everything to the right of the e and removes the period | def find_sigfigs(x):
sigfig_re = re.compile("([0-9.]+)")
m = sigfig_re.search("{:e}".format(float(x))) # turn to scientific form
if m:
val = m.group(1).replace(".", "")
while val[-1:] == '0': # remove all trailing zeros
val = val[0:-1]
return len(val)
return 0 # n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def round_sigfigs(num, sig_figs):\n#http://code.activestate.com/recipes/578114-round-number-to-specified-number-of-significant-di/\n if num != 0:\n return round(num, -int(math.floor(math.log10(abs(num))) - (sig_figs - 1)))\n else:\n return 0",
"def significand(x):\n\n assert isinstance(x, ... | [
"0.7250692",
"0.68816465",
"0.6669559",
"0.6556427",
"0.6467628",
"0.6467628",
"0.6347691",
"0.62990284",
"0.62122464",
"0.6182709",
"0.6169792",
"0.6169034",
"0.6145245",
"0.6109955",
"0.6031198",
"0.59817976",
"0.59817976",
"0.59702784",
"0.59157544",
"0.5914876",
"0.589825... | 0.8002274 | 0 |
Like open, but if filename exists and mode is 'w', produce an error | def safe_open(filename, mode, return_none=False, zap=False):
if 'w' in mode and os.path.exists(filename) and not zap:
rounder_logger.error("ABORT: Output file exists '{}'. Please delete "
"or rename the file and restart the program".format(filename))
if return_none:
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_file_exists_and_open(filename):\n if not os.path.exists(filename):\n return open(filename, 'w')\n else:\n return open(filename, 'a')",
"def _try_open(self, location):\n if self._have_permissions(location):\n return open(location, 'w')\n\n raise Exception(\n ... | [
"0.7292264",
"0.6688587",
"0.668574",
"0.65256",
"0.65140605",
"0.6510638",
"0.6510638",
"0.650125",
"0.6474535",
"0.64625996",
"0.6441124",
"0.64294815",
"0.64138067",
"0.63541216",
"0.6323387",
"0.62979037",
"0.6282871",
"0.62748736",
"0.62460715",
"0.624063",
"0.62209237",... | 0.7565609 | 0 |
This function converts the file format of a .xls or .ods (Open Office) spreadsheet to the file format of an xlsx spreadsheet. | def convert_to_xlsx(fname):
import os
# Cannot use win32 API unless on a Windows machine
try:
import win32com.client as win32
except ImportError:
rounder_logger.error("ABORT: Program is failing to convert spreadsheet "
"to xlsx version spreadsheet. Automated ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_sheet(filename, output):\n r2dt.write_converted_sheet(filename, output)",
"def convert_xlsx_to_xls(inp_dict):\n if inp_dict[\".xlsx\"]:\n for fname in inp_dict[\".xlsx\"]:\n fname = os.path.abspath(fname.encode(\"utf-8\"))\n fname = os.path.abspath(fname.decode(\"ut... | [
"0.7192688",
"0.70778984",
"0.69252384",
"0.62354225",
"0.6150759",
"0.60300565",
"0.60074925",
"0.5839166",
"0.58284533",
"0.5773779",
"0.57267624",
"0.5593866",
"0.5559843",
"0.55578685",
"0.5557521",
"0.55502796",
"0.5532979",
"0.55300397",
"0.55246705",
"0.55210763",
"0.5... | 0.75526977 | 0 |
This function converts the file format of a .docx or .odt (Open Office) text document to the file format of a plain .txt file | def convert_word_to_txt(fname):
import os
# Cannot use win32 API unless on a Windows machine
try:
import win32com.client as win32
except ImportError:
rounder_logger.error("ABORT: Program is failing to the document to a "
".txt file. Automated conversion only ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _docx_to_txt(file_path, dst_dir, file_name):\n if not HAS_DOCX:\n raise ImportError(\n \"docx was not importable, therefore _docx_to_txt cannot be used.\")\n\n if file_name is None:\n file_name = os.path.split(file_path)[1]\n file_dst = os.path.join(dst_dir, re.sub(r'\\.docx$'... | [
"0.7295504",
"0.70556235",
"0.66461295",
"0.64506775",
"0.63384914",
"0.61272943",
"0.61052907",
"0.6060944",
"0.6027044",
"0.60045016",
"0.59575623",
"0.5941863",
"0.59138566",
"0.58846676",
"0.58653426",
"0.5843893",
"0.5805275",
"0.58006406",
"0.57917875",
"0.57756037",
"0... | 0.7289672 | 1 |
Scans through excel spreadsheet checks if any cells use formulas. If so, it will create a new spreadsheet with the cells containing formulas colored in. The function will return a boolean to indicate whether or not a formula was found. | def check_for_excel_formulas(fname):
from openpyxl import load_workbook
from openpyxl.styles import PatternFill
FILL_RED = PatternFill(start_color='FF0000', end_color='FF0000', fill_type='solid')
formula_exists = False
wb = load_workbook(fname) # Open the workbook
for sheetname in wb.sheetnam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_noequations(self, sheetname):\n\n self.wb_open = load_workbook(self.name, read_only = True)\n sheet = self.wb_open.get_sheet_by_name(sheetname)\n\n for i in range(1, self.wb.sheet_by_name(sheetname).ncols):\n value = sheet.cell(row = 4, column = i).value\n # equation check logic, might... | [
"0.5479816",
"0.5383185",
"0.5195498",
"0.51454026",
"0.5119979",
"0.5080799",
"0.5054215",
"0.5029955",
"0.50169486",
"0.50169486",
"0.49510047",
"0.49494743",
"0.4936357",
"0.48471498",
"0.4818432",
"0.47928265",
"0.47886422",
"0.47869307",
"0.47683117",
"0.4766622",
"0.476... | 0.7868493 | 0 |
Returns n to the nearest number | def nearest(n, number):
return math.floor((n / number) + 0.5) * number | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nearest_int(num):\n return int(np.round(num))",
"def nearest_square(num):\n\n answer = 0\n while (answer+1)**2 < num:\n answer += 1\n return answer**2",
"def _round_to_nearest_multiple_down(x, n=5):\n return n * math.floor(float(x) / n)",
"def _round_to_nearest_multiple_up(x, n=5):\... | [
"0.79727787",
"0.7289314",
"0.7277677",
"0.7213795",
"0.7167367",
"0.7123137",
"0.7002838",
"0.67128956",
"0.67010766",
"0.6675226",
"0.6635987",
"0.6608803",
"0.6608738",
"0.6587024",
"0.65679616",
"0.6504897",
"0.648127",
"0.64677525",
"0.64274275",
"0.642367",
"0.642367",
... | 0.86348236 | 0 |
Implements the DRB rounding rules for counts. Note that we return a string, so that we can report N < 15 | def round_counts(n):
n = int(n)
assert n == math.floor(n) # make sure it is an integer; shouldn't be needed with above
assert n >= 0
if 0 <= n < 15: return LESS_THAN_15
if 15 <= n <= 99: return str(nearest( n, 10))
if 100 <= n <= 999: return str(nearest( n, 50))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _round_repeats(self, repeats):\n return int(math.ceil(self.depth_coefficient * repeats))",
"def round_repeats(repeats):\n return int(math.ceil(depth_coefficient * repeats))",
"def round_based_alien_limitation(self):\n if self.num_round < 5:\n return 1\n elif self.num_roun... | [
"0.62506104",
"0.60593367",
"0.5905544",
"0.5786499",
"0.57754576",
"0.5763675",
"0.5741162",
"0.5738095",
"0.57288164",
"0.57288164",
"0.57248294",
"0.5710165",
"0.56926984",
"0.56888485",
"0.56773907",
"0.5599772",
"0.55925816",
"0.5579066",
"0.5579066",
"0.5552615",
"0.549... | 0.7190575 | 0 |
Iterate through the contents and gather the counts of words | def count_words(self, contents):
wordCounts = {}
for i in self.ngramCounts:
if i == 0: # want the default to be the size of the corpus
total = 0
for line in contents:
words = line.split(" ")
words = [ w.strip() for w in ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_words(filename):",
"def main ():\n fio = FileIo(\"../input2.txt\")\n text = fio.getInput()\n p = re.compile(r'#?\\d[\\s\\.]?[\\s]?')\n out = filter(None, p.split(text))\n #print out[2]\n #print len(out)\n wc = 0\n\n for s in out:\n text = nltk.word_tokenize(s)\n wc... | [
"0.74756086",
"0.72574675",
"0.7235511",
"0.70567197",
"0.70515025",
"0.70317703",
"0.70185935",
"0.6943421",
"0.6943166",
"0.69408447",
"0.6936458",
"0.6906652",
"0.6867793",
"0.6864529",
"0.6848634",
"0.68415755",
"0.6822305",
"0.6814523",
"0.68125373",
"0.6798606",
"0.6784... | 0.7966412 | 0 |
Generate payprice from normal distribution | def generate_payprice(mu=1., sigma=0.5):
return max(0.1, normal(mu, sigma, 1)[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_price():\n return uniform(1.0, 350.0)",
"def generate_price(base_price, risk_gradient, age, excess=0):\n log = logging.getLogger(__name__)\n\n log.debug(f\"base:{base_price} risk:{risk_gradient} age:{age}\")\n\n age_risk = calculate_age_risk(risk_gradient, age)\n log.debug(f\"age_risk ... | [
"0.76314765",
"0.6760214",
"0.66722476",
"0.6470817",
"0.6466483",
"0.6379267",
"0.62085456",
"0.6105171",
"0.6085694",
"0.6052436",
"0.5878901",
"0.58270425",
"0.58183974",
"0.5791276",
"0.57784235",
"0.57754755",
"0.5744994",
"0.574127",
"0.5736219",
"0.5693803",
"0.5677998... | 0.7830419 | 0 |
Return checkout shipping price. It takes in account all plugins. | def checkout_shipping_price(
*,
manager: "PluginsManager",
checkout_info: "CheckoutInfo",
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
discounts: Optional[Iterable[DiscountInfo]] = None,
) -> "TaxedMoney":
calculated_checkout_shipping = manager.calculate_checkout_shippi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_checkout_delivery_price(\n checkout_info: \"CheckoutInfo\",\n lines: Iterable[\"CheckoutLineInfo\"] = None,\n) -> Money:\n currency = checkout_info.checkout.currency\n\n shipping_price = base_checkout_undiscounted_delivery_price(checkout_info, lines)\n\n is_shipping_voucher = (\n che... | [
"0.7024894",
"0.67271966",
"0.66116214",
"0.6588111",
"0.6499324",
"0.6466315",
"0.6371215",
"0.6371215",
"0.63457894",
"0.6332819",
"0.62777066",
"0.62607366",
"0.61951643",
"0.6179664",
"0.61160535",
"0.61160535",
"0.61160535",
"0.60824025",
"0.6081641",
"0.60458434",
"0.60... | 0.7875183 | 0 |
Return the total cost of the checkout. Total is a cost of all lines and shipping fees, minus checkout discounts, taxes included. It takes in account all plugins. | def checkout_total(
*,
manager: "PluginsManager",
checkout_info: "CheckoutInfo",
lines: Iterable["CheckoutLineInfo"],
address: Optional["Address"],
discounts: Optional[Iterable[DiscountInfo]] = None,
) -> "TaxedMoney":
calculated_checkout_total = manager.calculate_checkout_total(
che... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkout_line_total(\n *,\n manager: \"PluginsManager\",\n checkout_info: \"CheckoutInfo\",\n lines: Iterable[\"CheckoutLineInfo\"],\n checkout_line_info: \"CheckoutLineInfo\",\n discounts: Iterable[DiscountInfo] = [],\n) -> \"TaxedMoney\":\n address = checkout_info.shipping_address or che... | [
"0.699066",
"0.69352424",
"0.67948633",
"0.67613196",
"0.6739813",
"0.67147726",
"0.6710645",
"0.6695521",
"0.6640341",
"0.66280836",
"0.6603674",
"0.6602697",
"0.6597623",
"0.6572456",
"0.65218973",
"0.64966685",
"0.64876944",
"0.6487631",
"0.64736366",
"0.64667153",
"0.6438... | 0.7395403 | 0 |
Return the total price of provided line, taxes included. It takes in account all plugins. | def checkout_line_total(
*,
manager: "PluginsManager",
checkout_info: "CheckoutInfo",
lines: Iterable["CheckoutLineInfo"],
checkout_line_info: "CheckoutLineInfo",
discounts: Iterable[DiscountInfo] = [],
) -> "TaxedMoney":
address = checkout_info.shipping_address or checkout_info.billing_addr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _amount_line(self, cr, uid, ids, prop, unknow_none, unknow_dict):\n res = {}\n tax_obj = self.pool.get('account.tax')\n cur_obj = self.pool.get('res.currency')\n for line in self.browse(cr, uid, ids):\n price = line.price_unit * (1-(line.discount or 0.0)/100.0)\n ... | [
"0.68811136",
"0.68807936",
"0.6563494",
"0.65322506",
"0.6364763",
"0.61911374",
"0.6189038",
"0.6171741",
"0.6161707",
"0.61553276",
"0.61261326",
"0.6070365",
"0.59981155",
"0.5983958",
"0.5981905",
"0.5974914",
"0.59643763",
"0.5950477",
"0.5905625",
"0.5893934",
"0.58819... | 0.733931 | 0 |
Test main() function. Mock argparse and replace with stubs. Verify process_all_files called with expected arguments. | def test_main_function(self, m_process_all_files, m_argparser):
myargs = StubArgs()
m_argparser.return_value = StubArgumentParser(myargs)
retval = main()
m_process_all_files.assert_called_with(workdir='.', simon_sez=False,
mapfile=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n args = parse_args()\n process_args(args)",
"def test_main(self):\n results = main(0.1, files)\n # 1\n self.assertEqual(results, \"All Done Successfully\")\n results = main(0.1, get_files_bad_file_path())\n # 2\n self.assertIn(\"skipping to next\", res... | [
"0.7396876",
"0.73607576",
"0.7000543",
"0.69456595",
"0.69456595",
"0.6754207",
"0.6736761",
"0.67186093",
"0.6644163",
"0.6643511",
"0.6627541",
"0.6619802",
"0.6580328",
"0.6560416",
"0.65508217",
"0.6528448",
"0.6515864",
"0.6509999",
"0.6508808",
"0.65040505",
"0.6504013... | 0.8840999 | 0 |
Execute list of statements | def execute_list(self, stmt: List[loxStmtAST.Stmt]) -> None:
for st in stmt:
st.accept(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute_query_list(cur, conn, query_list):\n try:\n for query in query_list:\n cur.execute(query)\n conn.commit()\n except psycopg2.Error as e:\n print(\"Error executing query list\")\n print(e)",
"def batch_execute(self, sql_list):\n with self.connecti... | [
"0.7514045",
"0.74192536",
"0.7300135",
"0.7220507",
"0.6969305",
"0.69044507",
"0.67884105",
"0.67582345",
"0.6668504",
"0.6647183",
"0.65472674",
"0.65457016",
"0.653904",
"0.65253955",
"0.65042245",
"0.6445236",
"0.6425501",
"0.636002",
"0.6356032",
"0.6351751",
"0.6306997... | 0.75519913 | 0 |
Execute block stateemt called by visit_block_stmt | def execute_block(self, stmt: List[loxStmtAST.Stmt], environment: loxenvironment.Environment) -> None:
previous_env: loxenvironment.Environment = self.environment
try:
self.environment = environment
for statement in stmt:
self.execute(statement)
finally:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_block():\n print_column()\n print_rows()",
"def do_block():\n print_column()\n print_rows()",
"def execute(self, conn, blockStats, transaction = False):\t\n\tif not conn:\n\t dbsExceptionHandler(\"dbsException-failed-connect2host\", \"dbs/dao/Oracle/Block/UpdateStatus expects db connectio... | [
"0.63865596",
"0.63865596",
"0.6373109",
"0.6298282",
"0.61717284",
"0.61332434",
"0.60622966",
"0.60202044",
"0.60053456",
"0.59901047",
"0.5979187",
"0.5931721",
"0.59000915",
"0.59000915",
"0.5831619",
"0.5799989",
"0.5795695",
"0.5765177",
"0.5759118",
"0.5738172",
"0.573... | 0.766471 | 0 |
Get variable (at resolved location) | def lookup_variable(self, name: loxtoken.Token, expr: loxExprAST.Expr) -> object:
distance: int = self.locals.get(expr)
if distance is not None:
return self.environment.get_at(distance, name.lexeme)
else:
return self.globals.get(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lookup_var(self, var):\n if var in self.binding:\n return self.binding[var]\n elif self.parent is not None:\n return self.parent.lookup_var(var)\n else:\n raise Environment.Unbound('unbound variable \"%s\"' % var)",
"def lookup(self, var):\n \n ... | [
"0.695123",
"0.68868434",
"0.6769411",
"0.6697538",
"0.65437466",
"0.6462943",
"0.64409995",
"0.64409196",
"0.64129585",
"0.6396114",
"0.6380359",
"0.63777465",
"0.63389903",
"0.63310117",
"0.6306804",
"0.62852687",
"0.6278986",
"0.6266779",
"0.62318045",
"0.62318045",
"0.621... | 0.72962904 | 0 |
Check if two objects are equal | def is_equal(o1: object, o2: object) -> bool:
if o1 is None and o2 is None:
return True
if o1 is None:
return False
return o1 == o2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def equals(self, obj: object) -> bool:\n ...",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\r\n return self.__dict__ == other.__dict__",
"def test_equal_on_equal(self):\n ... | [
"0.78094596",
"0.7773827",
"0.7773827",
"0.7751994",
"0.7720267",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
"0.77175474",
... | 0.7832948 | 0 |
Check if one or two operands are numeric (float) | def check_number_operands(operator: loxtoken.Token, op1: Any, op2: Any = None) -> bool:
if op2 is None:
if isinstance(op1, float):
return True
raise_error(LoxRuntimeError, operator, "Operand must be a number.")
else:
if isinstance(op1, float) and isins... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_for_float(check):",
"def is_numeric(value):\n return isinstance(value, int) or isinstance(value, float)",
"def check_for_float_and_int(check):",
"def is_float(*args): \n try:\n for i in args:\n float(i)\n return True\n except Exception:\n return False",
... | [
"0.75186485",
"0.74295354",
"0.73775774",
"0.73760265",
"0.71701247",
"0.70824164",
"0.7047912",
"0.69769764",
"0.69203025",
"0.68097115",
"0.6806212",
"0.680336",
"0.6781341",
"0.67649436",
"0.6720998",
"0.67168117",
"0.670655",
"0.6684456",
"0.6679972",
"0.6654104",
"0.6646... | 0.776931 | 0 |
Test the following Keras model | dense| dense | | merge dense | dense| | def test_simple_merge(self):
input_tensor = Input(shape=(3,))
x1 = Dense(4)(input_tensor)
x2 = Dense(5)(x1)
x3 = Dense(6)(x1)
x4 = merge([x2, x3], mode="concat")
x5 = Dense(7)(x4)
model = Model(input=[input_tensor], output=[x5])
input_names = ["data"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_merge_multiply(self):\n input_tensor = Input(shape=(3,))\n x1 = Dense(4)(input_tensor)\n x2 = Dense(5)(x1)\n x3 = Dense(5)(x1)\n x4 = merge([x2, x3], mode=\"mul\")\n x5 = Dense(7)(x4)\n\n model = Model(input=[input_tensor], output=[x5])\n input_names... | [
"0.71359515",
"0.7112506",
"0.6637251",
"0.65542656",
"0.6543468",
"0.6540297",
"0.6473104",
"0.64657444",
"0.64593196",
"0.6375976",
"0.6356236",
"0.6279389",
"0.62673783",
"0.6259179",
"0.6249154",
"0.6245342",
"0.6238475",
"0.6234746",
"0.6231981",
"0.6203151",
"0.6202116"... | 0.7530161 | 0 |
Test the following Keras model | dense| dense | | merge dense | dense| | def test_merge_multiply(self):
input_tensor = Input(shape=(3,))
x1 = Dense(4)(input_tensor)
x2 = Dense(5)(x1)
x3 = Dense(5)(x1)
x4 = merge([x2, x3], mode="mul")
x5 = Dense(7)(x4)
model = Model(input=[input_tensor], output=[x5])
input_names = ["data"]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_simple_merge(self):\n input_tensor = Input(shape=(3,))\n x1 = Dense(4)(input_tensor)\n x2 = Dense(5)(x1)\n x3 = Dense(6)(x1)\n x4 = merge([x2, x3], mode=\"concat\")\n x5 = Dense(7)(x4)\n\n model = Model(input=[input_tensor], output=[x5])\n input_name... | [
"0.7530161",
"0.7112506",
"0.6637251",
"0.65542656",
"0.6543468",
"0.6540297",
"0.6473104",
"0.64657444",
"0.64593196",
"0.6375976",
"0.6356236",
"0.6279389",
"0.62673783",
"0.6259179",
"0.6249154",
"0.6245342",
"0.6238475",
"0.6234746",
"0.6231981",
"0.6203151",
"0.6202116",... | 0.71359515 | 1 |
Assert correctness of field_roles attributed to h_order fields. | def test_set_field_roles(h_order: Hub):
expected_roles = [
{"field": "order_id", "role": FieldRole.BUSINESS_KEY},
{"field": "r_timestamp", "role": FieldRole.METADATA},
{"field": "h_order_hashkey", "role": FieldRole.HASHKEY},
{"field": "r_source", "role": FieldRole.METADATA},
]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_list_roles(self):\n pass",
"def test_roles_widget(self, admin_dashboard):\n admin_roles_tab = admin_dashboard.select_roles()\n expected_dict = self._role_el.ROLE_SCOPES_DICT\n actual_dict = admin_roles_tab.get_role_scopes_text_as_dict()\n assert admin_dashboard.tab_roles.member_count ... | [
"0.632787",
"0.6207065",
"0.6166815",
"0.5946886",
"0.5944814",
"0.59404385",
"0.59319425",
"0.59161973",
"0.5882088",
"0.57969725",
"0.5718565",
"0.5696599",
"0.5639436",
"0.56267047",
"0.561364",
"0.5579006",
"0.5576236",
"0.5561771",
"0.55442077",
"0.5525709",
"0.5495346",... | 0.8025588 | 0 |
Assert correctness of SQL generated in role playing Hub class. | def test_role_playing_hub_load_sql(
test_path: Path, h_customer_role_playing: RolePlayingHub
):
expected_result = (
test_path / "sql" / "expected_result_role_playing_hub.sql"
).read_text()
assert h_customer_role_playing.sql_load_statement == expected_result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_raw_sql(self):\n\n # GIVEN raw SQL command\n sql = 'SELECT id, date_joined from auth_user WHERE id > %s;'\n params = ['0']\n\n # WHEN executing the SQL\n cursor = TestModel.execute_sql(sql, params)\n\n # THEN it should succeed\n results = cursor.fetchall()\... | [
"0.6385458",
"0.62220263",
"0.6053574",
"0.6051311",
"0.6032481",
"0.60017407",
"0.59964406",
"0.59437764",
"0.5937085",
"0.5914016",
"0.58688796",
"0.58450323",
"0.5834013",
"0.5812855",
"0.58080125",
"0.5801019",
"0.57999355",
"0.5778115",
"0.57754666",
"0.5752015",
"0.5746... | 0.6334213 | 1 |
decode the tupple (terme, masque) to make a string readable by 0,1, for example (9, 4) gives 101& | def decode_bin(tup_terme, nbr):
terme, msq = tup_terme
return "".join(['-' if msq & (1 << k) else '1' if terme & (1 << k )
else '0' for k in range(nbr-1, -1, -1)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decode(seq):\n\n # Handle some corner cases\n if (not seq) or (not isinstance(seq, str)):\n return '' # Return empty string on non-strings and all non-true values (empty string, None, 0, ...)\n\n # Use regex to match patterns, t is then a list of tuples (if any patterns found)\n # '2k3b' -... | [
"0.6115483",
"0.6020812",
"0.6020812",
"0.58329725",
"0.57924485",
"0.57465196",
"0.57222986",
"0.5681051",
"0.5680967",
"0.566834",
"0.5645393",
"0.56423813",
"0.5631061",
"0.55987173",
"0.5589958",
"0.55718493",
"0.55592185",
"0.55586416",
"0.55342746",
"0.55218863",
"0.551... | 0.72199124 | 0 |
Discovery of essential terms. From the lists of binary terms table_1 and table_0, returns the essential terms and the list of terms 1 not covered remaining | def __terme_essentiel(table_1, table_0, nbr):
table_essentiel = []
flag = 1 << nbr
msq1 = (1 << nbr)- 1
for tb1 in table_1:
if (tb1 & flag) == 0:
pt_unique = __pt_facteur_unique(tb1, table_0, nbr)
fl = 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __expense_0_1(term_1, term_0, lg):\n erreur = False\n if len(term_0) == 0:\n term1 = __expense(term_1, lg)\n term0 = set(range(0, 1 << lg)) - term1\n elif len(term_1) == 0:\n term0 = __expense(term_0, lg)\n term1 = set... | [
"0.5697593",
"0.5621541",
"0.54984933",
"0.5476297",
"0.5351077",
"0.5286721",
"0.5178162",
"0.51529014",
"0.5145628",
"0.51254004",
"0.51071084",
"0.50902617",
"0.50778633",
"0.50295335",
"0.5015854",
"0.4996024",
"0.49575645",
"0.49336618",
"0.48944142",
"0.4881235",
"0.487... | 0.6200629 | 0 |
Return a context with a sequence database | def fixture_sequence_ctx(sequence_db: Manager) -> Dict[str, Manager]:
return {"db": sequence_db} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_db():\n try:\n db = SessionLocal()\n yield db\n finally:\n db.close()",
"def get_db():\n db = SessionLocal()\n try:\n yield db\n finally:\n db.close()",
"def get_db():\n db = None\n try:\n db = SessionLocal()\n yield db\n finally:... | [
"0.62393457",
"0.62187093",
"0.62112445",
"0.6207755",
"0.6169694",
"0.61378443",
"0.60350645",
"0.60004115",
"0.597488",
"0.59542704",
"0.58730376",
"0.58174145",
"0.5813158",
"0.58043116",
"0.57644117",
"0.5758768",
"0.5727592",
"0.570071",
"0.5700452",
"0.5695101",
"0.5660... | 0.7567604 | 0 |
Return a context with a database only initialized with snps | def fixture_snp_ctx(snp_db: Manager) -> Dict[str, Manager]:
return {"db": snp_db} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_context():\n return {'app': app, 'db': db}",
"def __init__(self, *args, **kwargs):\n self.context = kwargs.get(\"config\")\n if hasattr(self.context, 'database'):\n # XXX this should be replaced with connection_context instead\n self.context.database['database_hos... | [
"0.666298",
"0.63781655",
"0.62423414",
"0.6218642",
"0.6189685",
"0.6134482",
"0.61322135",
"0.6110523",
"0.60033303",
"0.595802",
"0.5953943",
"0.58716375",
"0.57945687",
"0.57843685",
"0.575336",
"0.5739997",
"0.57273644",
"0.5714863",
"0.57026345",
"0.5693663",
"0.5687743... | 0.69841456 | 0 |
Spawn the players Overrides one of the players in CoopScreen with an AI | def spawn_players(self) -> None:
#Create the player
self.player1 = Player(self.sensitivity, self.screen_width, self.screen_height, self.screen_width//(3/2), self.screen_height-50, self.player_lives, self.fps, self.player1_bullet, Direction.UP, self.debug)
#Create the AI
self.player2 = A... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def spawn_players(self) -> None:\n # Initialise the players\n self.player1 = Player(self.sensitivity, self.screen_width, self.screen_height, self.screen_width // 2, 50,\n self.player_lives, self.fps, self.player1_bullet, Direction.DOWN, self.debug)\n self.player2 =... | [
"0.7277874",
"0.63774633",
"0.62822104",
"0.6237607",
"0.615461",
"0.6144451",
"0.6139239",
"0.61377573",
"0.61365795",
"0.613263",
"0.60938674",
"0.60756755",
"0.60370326",
"0.60287136",
"0.59949946",
"0.59532386",
"0.5943082",
"0.5912365",
"0.5901422",
"0.58670527",
"0.5848... | 0.78574896 | 0 |
Adds the given clause to the CNF MazeKnowledgeBase | def tell (self, clause):
self.clauses.add(clause) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_clause(self, clause):\n self.abstract_clauses.append(clause)",
"def add_clause(self, clause):\n self.solver.add_clause(clause)\n if self.dump is not None:\n self.dump.write(\" \".join(map(str, clause)) + \" 0\\n\")",
"def add_clause(self, lits):\n\n self.nclauses ... | [
"0.7903562",
"0.7489257",
"0.6569416",
"0.6402271",
"0.6186902",
"0.5926397",
"0.5857539",
"0.57169896",
"0.5553303",
"0.547115",
"0.5422387",
"0.5407014",
"0.53948516",
"0.5394417",
"0.52712727",
"0.51108617",
"0.50528455",
"0.49922138",
"0.4937099",
"0.49092227",
"0.4905865... | 0.7617311 | 1 |
Given a MazeClause query, returns True if the KB entails the query, False otherwise | def ask (self, query):
temp_kb = copy.deepcopy(self)
for prop in query.props:
# get the clauses
clause = [(prop, False if query.props.get(prop) else True)]
clause = MazeClause(clause)
temp_kb.tell(clause)
while True:
kb = list(temp_kb.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_query(act: Message):\n k = 'is_search_query'\n return k in act and act[k]",
"def hasterm(self, query_term):\n\n if not isinstance(query_term, formula):\n if type(query_term) == type(\"name\"):\n try: query = self[query_term]\n except: return False\n ... | [
"0.59960854",
"0.58377427",
"0.56393766",
"0.56041896",
"0.5601439",
"0.5595883",
"0.5542761",
"0.54888123",
"0.54398024",
"0.54294753",
"0.5383035",
"0.5382331",
"0.534304",
"0.5324607",
"0.52772856",
"0.52404475",
"0.518965",
"0.51685584",
"0.51479656",
"0.5119631",
"0.5113... | 0.75266117 | 0 |
we calculate the waiting time as the time it takes for the previous processes (the burst times), and for the first process we don't have to wait (the time starts at zero.) Note that we don't actually wait for these times (no use of time.sleep) we just calculate them. | def calculate_waiting_times(self):
# let's count time in general units
wait_times = []
current = wait_time = self.processes[0].arrival_time
for p in self.processes:
# We won't actually wait :)
# if the arrival
wait_time = wait_time - p.arrival_time
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _calculate_periodic_loop_sleep_time(self, time_for_process):\n if time_for_process > self.min_time_per_process_loop:\n sleep_time = 0\n else:\n sleep_time = self.min_time_per_process_loop - time_for_process\n\n return sleep_time",
"def calculateWaitingTime(self, inp... | [
"0.67347395",
"0.63521874",
"0.617349",
"0.5951214",
"0.59285337",
"0.58677477",
"0.58376974",
"0.5800605",
"0.5796338",
"0.57944417",
"0.5783189",
"0.5749438",
"0.56967425",
"0.56953186",
"0.56850827",
"0.5674061",
"0.5659167",
"0.5646841",
"0.5601194",
"0.5534767",
"0.55095... | 0.79956114 | 0 |
the turnaround time is how long it takes to wait, start, and finish so we care about the burst time of the process too! | def calculate_turnaround_times(self, wts=None):
trts = []
if wts == None:
wts = self.calculate_waiting_times()
for p in self.processes:
waiting_time = wts.pop(0)
trt = waiting_time + p.burst_time
trts.append(trt)
return trts | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sleeper(self):\n for waittime in (.01, .02, .05, .1, .2, .5):\n yield waittime\n while True:\n waittime = min(waittime + .2, 5)\n yield waittime",
"def deepsleep(time_ms: int = None) -> None:",
"def wait_for_time():\n while rospy.Time().now().to_sec() == 0:\n... | [
"0.5801189",
"0.5729342",
"0.570399",
"0.5686277",
"0.5681719",
"0.5681719",
"0.5681719",
"0.56456846",
"0.56312007",
"0.56146026",
"0.5600773",
"0.5565395",
"0.5562345",
"0.55517167",
"0.5527594",
"0.5518561",
"0.55036926",
"0.54880846",
"0.54752165",
"0.54737365",
"0.545192... | 0.5935178 | 0 |
Method returns a list of names that are results of searching phrase | def get_search_results(self):
return self.get_list_of_names(self.SEARCH_RESULTS) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search(words):\n newlist = [w for w in words if 'son' in w]\n return newlist",
"def name_search(self, search):\n if isinstance(search, str):\n name_re = re.compile(search)\n else:\n name_re = search\n matches = [\n entry\n for entry in se... | [
"0.68255854",
"0.6810953",
"0.6683149",
"0.65864354",
"0.65488327",
"0.6515843",
"0.6513614",
"0.6431293",
"0.6418214",
"0.6405558",
"0.6339954",
"0.63366127",
"0.63287485",
"0.63281167",
"0.6274085",
"0.6268842",
"0.626621",
"0.62524277",
"0.62399864",
"0.62321717",
"0.62121... | 0.76608396 | 0 |
Unfollow profile by mowing mouse to a button then click on it | def unfollow_profile(self):
self.find_clickable_element(self.ISFOLLOWED_BTN).click() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def btn_unfollow_clicked(self, widget, data=None):\n print \"unfollow clicked\"",
"def clickViewProfile(self):\n self.waitForElement(locator=self._viewProfileBtn, locatorType=\"xpath\")\n element = self.getElementList(locator=self._viewProfileBtn, locatorType=\"xpath\")\n self.element... | [
"0.7014275",
"0.65229905",
"0.6288906",
"0.6113619",
"0.6047924",
"0.60308826",
"0.6024783",
"0.5881401",
"0.58788884",
"0.5871091",
"0.5848418",
"0.5776343",
"0.5711946",
"0.5708814",
"0.5702429",
"0.56985444",
"0.56685716",
"0.5660283",
"0.5609581",
"0.5609532",
"0.56092155... | 0.79042375 | 0 |
Method returns list of followed profiles names | def get_followed_profiles(self):
return self.get_list_of_names(self.FOLLOWED_PROFILES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profiles_names(self):\n url = get_url('profiles')\n response = self._get(url)\n raise_on_error(response)\n return response.json()",
"def get_profile_names():\n import botocore.session\n return botocore.session.get_session().full_config.get('profiles', {}).keys()",
"def get... | [
"0.77497405",
"0.7373919",
"0.72452015",
"0.7117073",
"0.7101756",
"0.7061995",
"0.6960764",
"0.68223184",
"0.67487365",
"0.67440003",
"0.66867036",
"0.66656435",
"0.66466",
"0.66466",
"0.6604338",
"0.6538614",
"0.64481294",
"0.6425405",
"0.63895315",
"0.6342366",
"0.62757784... | 0.80610305 | 0 |
Parse name from transcript.py | def parse_name(self, transcript: str) -> None:
name_match = re.match(
r".*(?=Unofficial\ UNDERGRADUATE\ ACADEMIC\ RECORD)", transcript, RE_OPT
)
if not name_match:
raise ValueError("Name not found")
self.name = name_match.group(0).strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _extract_name(line: str) -> str:\n tokens = line[19:-2].split(\" {\")\n name = tokens[0]\n return name",
"def extract_name():\n def _extract_name(quoted_name):\n return e.String(quoted_name.subexpression.name)\n yield (\"(λ &[name] . str)\", _extract_name)",
"def normalize... | [
"0.67706597",
"0.6600971",
"0.6434612",
"0.6400358",
"0.63124406",
"0.6125592",
"0.6096095",
"0.5982468",
"0.5980192",
"0.59672374",
"0.59672374",
"0.59490603",
"0.5941414",
"0.5938341",
"0.5930466",
"0.58824676",
"0.585673",
"0.5793568",
"0.57555103",
"0.5717023",
"0.5699183... | 0.7940865 | 0 |
Parse your major from header text from transcript. We assume only 1 major.txt | def parse_major(self, header_text: str) -> None:
major_match = re.search(r"(?<=Major:)\s*?\K.*?(?=\n)", header_text, RE_OPT)
if not major_match:
raise ValueError("Major not found")
self.major = major_match.group(0).strip() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_file(self):\n for num, line in enumerate(self._text):\n if \"CRYSTAL STRUCTURE SOLUTION\" in line:\n line = line.strip().strip('+').strip()\n if 'SHELXTL' in line:\n self.version = 'SHELXT ' + line.split()[-1]\n if line.strip()... | [
"0.5932609",
"0.5545021",
"0.55099136",
"0.5414231",
"0.5382304",
"0.5346737",
"0.5331041",
"0.5311994",
"0.531047",
"0.530684",
"0.5269898",
"0.5235252",
"0.5231675",
"0.5227878",
"0.5195393",
"0.51859796",
"0.51827645",
"0.5154253",
"0.51536715",
"0.5147933",
"0.5146444",
... | 0.7362173 | 0 |
Get the string containing the study plan for major, year.txt | def get_plan_str(self, transcript_text: str) -> str:
first_sem_match = re.search(r".*?---\K\d*\s\w*(?=---)", transcript_text)
if not first_sem_match:
raise ValueError("Could not identify any semesters on transcript")
first_sem = first_sem_match.group(0)
year = first_sem.split... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toStudentString(self):\r\n return \"{0}th year, section {1}, {2} {3}\".format(self.batch, self.batch_id, self.batch, self.batch_id)",
"def get_study_info(study_link):\n template = \"https://clinicaltrials.gov{}\"\n study_link = study_link.replace(' ', '+')\n return template.format(study_link)",
"... | [
"0.5759961",
"0.5740661",
"0.55176777",
"0.54886985",
"0.54849267",
"0.54849267",
"0.54542637",
"0.540274",
"0.53715056",
"0.5368447",
"0.5324546",
"0.52980024",
"0.5286384",
"0.5250701",
"0.52098906",
"0.51978225",
"0.5183057",
"0.517186",
"0.51508987",
"0.51380044",
"0.5078... | 0.7479043 | 0 |
Initialize the plan from your study plan. | def initialize_plan(self, transcript_s: str) -> None:
plan_s = self.get_plan_str(transcript_s)
def get_term_match(transcript_partial: str) -> Match[str]:
match_obj: Match[str] = re.search(r".*?\KTERM\s\d+", transcript_partial)
return match_obj
def remove_semester(transc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, plan):\n self.plan = plan",
"def __init__(self, plan):\n if not isinstance(plan, list):\n raise Exception(\"plan must be an array\")\n\n if isinstance(plan[0], bytes):\n plan = [b.decode() for b in plan]\n\n self.plan = plan\n self.struc... | [
"0.7267575",
"0.6585836",
"0.6249185",
"0.62291306",
"0.61962235",
"0.6167639",
"0.6142796",
"0.6136162",
"0.6063726",
"0.5969",
"0.5874807",
"0.5846044",
"0.5811439",
"0.5790529",
"0.5689726",
"0.5654252",
"0.56441087",
"0.5600788",
"0.55727863",
"0.55713284",
"0.5564441",
... | 0.75677145 | 0 |
Fill plan from list of courses taken or to be taken from. | def fill_plan(self, course_list: List[Course]) -> None:
for transcript_course in course_list:
for semester in self.plan:
if not transcript_course.fulfilled:
for sem_course in semester.required_courses:
if not transcript_course.fulfilled and... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plans(self, plans):\n\n self._plans = plans",
"def plans():",
"def prepare_courses_for_radio():\n\n three_closest_courses = get_four_future_courses()\n radio_courses = []\n\n for course in three_closest_courses:\n radio_courses.append(\n (int(course.id), str(reformat_date(... | [
"0.5745251",
"0.5555351",
"0.5535741",
"0.53383607",
"0.5170188",
"0.5145405",
"0.5131272",
"0.51145476",
"0.511275",
"0.50931793",
"0.50925535",
"0.5055467",
"0.5043333",
"0.5004512",
"0.50022566",
"0.49984032",
"0.49984032",
"0.49809438",
"0.496869",
"0.494874",
"0.4945807"... | 0.6983211 | 0 |
Fill out course plan to `Output.txt`. | def output_schedule(self) -> None:
with open("Output.txt", "w") as out_file:
for sem in self.plan:
out_file.write(sem.title.center(15 + 20 + 50 + 5) + "\n\n")
for course in sem.required_courses:
if course.special:
out_file.w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_plan(self, course_list: List[Course]) -> None:\n for transcript_course in course_list:\n for semester in self.plan:\n if not transcript_course.fulfilled:\n for sem_course in semester.required_courses:\n if not transcript_course.ful... | [
"0.69774544",
"0.6132013",
"0.58467",
"0.5616664",
"0.5551132",
"0.5532871",
"0.5524847",
"0.5466864",
"0.5435297",
"0.53716224",
"0.5353881",
"0.53022265",
"0.52745134",
"0.5272175",
"0.5258501",
"0.52572674",
"0.5232525",
"0.52317876",
"0.5226153",
"0.51966196",
"0.5183298"... | 0.75233394 | 0 |
Return a boolean to indicate if we need to reschedule another iteration. | def should_reschedule(self, iteration):
if not self.max_iterations:
return True
return iteration < self.max_iterations | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_reschedule(self) -> bool:\n return pulumi.get(self, \"can_reschedule\")",
"def IsRerun(self):\n return self.prev_test_context is not None",
"def _run_next(self):\n result = False\n if not self._stopped.is_set():\n schedule = self._schedules[self._index]\n s... | [
"0.70374215",
"0.6660025",
"0.6553066",
"0.65326685",
"0.6445832",
"0.63582665",
"0.6331798",
"0.6214566",
"0.6214566",
"0.6210432",
"0.61921537",
"0.6192061",
"0.61500096",
"0.61474705",
"0.61352",
"0.6112631",
"0.6099831",
"0.6082851",
"0.60724115",
"0.6069472",
"0.60326743... | 0.8408634 | 0 |
Return False if word already in trie, otherwise return True and add | def check_present_and_add(self, word):
current_node = self.root_node
is_new_word = False
# iterate through trie adding missing notes
for char in word:
if char not in current_node:
is_new_word = True
current_node[char] = {}
current_node = current_node[char]
# mark e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, word):\n current_node = self.root\n\n for char in word:\n if char not in current_node.children: # checks if that char does not already exists in the children Trie\n current_node.children[char] = TrieNode() # if it doesnt add it to the children dict\n\n ... | [
"0.79426163",
"0.7905646",
"0.7855985",
"0.7796953",
"0.77269894",
"0.77027094",
"0.7695847",
"0.76716083",
"0.76421124",
"0.7621175",
"0.7495033",
"0.7321256",
"0.73114586",
"0.73099375",
"0.72996986",
"0.7260195",
"0.7251777",
"0.72487164",
"0.72439677",
"0.7241073",
"0.723... | 0.8097152 | 0 |
Unittest skip test decorator. Allow to skip test by device properties depends of current device state (adb or fastboot). | def SkipByDefault(ifPlatform=None, ifDeviceName=None, ifProductName=None, ifAndroidVersion=None,
ifSystem=None, rule='=='):
def find_test_suite(test_hash, test_name):
"""
Find TestSuite by TestCase name and TestSuite name
Args:
test_hash (int): Hash of Test f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_skip():\n pytest.skip('for a reason!')",
"def skip(reason):\r\n def decorator(test_item):\r\n if not (isinstance(test_item, type) and issubclass(test_item, TestCase)):\r\n @wraps(test_item)\r\n def skip_wrapper(*args, **kwargs):\r\n raise SkipTest(reason... | [
"0.731332",
"0.73006344",
"0.7269145",
"0.71260417",
"0.70326555",
"0.7011175",
"0.69509566",
"0.69364035",
"0.6851535",
"0.6660015",
"0.6556984",
"0.64773405",
"0.6464635",
"0.64352125",
"0.63621885",
"0.63304764",
"0.62907916",
"0.6282096",
"0.6253213",
"0.6171742",
"0.6162... | 0.7698371 | 0 |
Find TestSuite by TestCase name and TestSuite name | def find_test_suite(test_hash, test_name):
for case in CONFIG.UNITTEST.SELECTED_TEST_CASES:
for suite in case['suites']:
if id(getattr(suite['class'], test_name, False)) == test_hash:
return case, suite
return None, None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getTestSuite():\n\n suite1 = unittest.TestLoader().loadTestsFromTestCase(TestDataProcs)\n return unittest.TestSuite([suite1,suite2])",
"def suite():\n return unittest.TestLoader().loadTestsFromName(__name__)",
"def suite():\r\n\r\n current = os.path.dirname(os.path.realpath(__file__))\r\n to... | [
"0.6834528",
"0.6731077",
"0.6609728",
"0.6553881",
"0.6402515",
"0.63987714",
"0.6395349",
"0.6268248",
"0.6221758",
"0.6153603",
"0.61010283",
"0.6086706",
"0.6083515",
"0.6069983",
"0.6064627",
"0.60581553",
"0.60326403",
"0.60255474",
"0.6000137",
"0.59969836",
"0.5996854... | 0.74916726 | 0 |
Return of times a number is followed by a greater number. | def find_greater_numbers(nums):
times = 0
for loop in range(len(nums) - 1):
for follow in range(loop + 1, len(nums)):
if (nums[loop] < nums[follow]):
times+= 1
return times | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_larger(threshold, values):\n num = sum([1 for n in values if (n>threshold)])\n return num",
"def method2(self, nums):\n N = len(nums)\n inc = 1\n dec = 1\n \n for i in range(1, N):\n if nums[i] > nums[i - 1]:\n dec = inc + 1\n ... | [
"0.6521131",
"0.6293176",
"0.6216243",
"0.618306",
"0.61723506",
"0.61360794",
"0.5882969",
"0.58383435",
"0.5834305",
"0.5789546",
"0.578565",
"0.57627386",
"0.5739861",
"0.5720951",
"0.5677948",
"0.5669948",
"0.56539357",
"0.5648016",
"0.56313425",
"0.56189483",
"0.5597008"... | 0.7132922 | 0 |
Initializes a new job from an AWS Sagemaker training job. | def from_training_job(cls, job: TrainingJob) -> Job:
return Job(
job.hyperparameters["model"],
job.hyperparameters["dataset"],
_extract_configuration(job),
_extract_performance(job),
source_job=job,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, job_id=None, job_name=None, last_computed=None, job_status=None, featurestore_id=None, featuregroup_id=None, training_dataset_id=None): # noqa: E501 # noqa: E501\n self._job_id = None\n self._job_name = None\n self._last_computed = None\n self._job_status = None\n ... | [
"0.6974186",
"0.69443613",
"0.6886832",
"0.6838701",
"0.6632409",
"0.65334994",
"0.647273",
"0.6436026",
"0.6360837",
"0.63528246",
"0.6348602",
"0.63071483",
"0.6221539",
"0.6203113",
"0.6202876",
"0.6177251",
"0.61259747",
"0.60521895",
"0.59542644",
"0.5915276",
"0.5908832... | 0.7630248 | 0 |
Loads the job from the file system at the specified directory. This should only be called on a directory where a job has previously been saved. | def load(cls, directory: Path) -> Job:
model = directory.parts[-3]
dataset = directory.parts[-2]
with (directory / "config.json").open("r") as f:
config = json.load(f)
with (directory / "performance.json").open("r") as f:
performance = json.load(f)
retur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(path):\n with open(join(path, 'job.pkl'), 'rb') as file:\n job = pickle.load(file)\n job.path = path\n return job",
"def _load(self, directory):\n pass",
"def load_jobs_from_directory(directory: Path) -> list[Job]:\n return [\n Job.load(directory / mode... | [
"0.6961555",
"0.6703387",
"0.66424996",
"0.6361777",
"0.5992419",
"0.5933627",
"0.591502",
"0.5861527",
"0.57417893",
"0.5651837",
"0.5651327",
"0.5627353",
"0.56262046",
"0.5625828",
"0.5612192",
"0.5520089",
"0.5515587",
"0.5500061",
"0.54896057",
"0.5486257",
"0.5486257",
... | 0.70247656 | 0 |
Returns the list of performances for all models associated with this job. The variances of all metrics will be set to 0. | def performances(self) -> list[Performance]:
return [
Performance(
training_time=Metric(p["training"]["duration"], 0),
latency=Metric(self.static_metrics["latency"], 0),
num_model_parameters=Metric(
self.static_metrics["num_model_pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllMetrics(self):\n result = self.getReportMetrics()\n result.update(self.getOptimizationMetrics())\n return result",
"def metrics(self) -> list[dict[str, dict[str, float | int]]]:\n return self.performance[\"performances\"]",
"def get_all_metrics(self):\n up_time = self.uptime()\... | [
"0.6068686",
"0.5906195",
"0.5847855",
"0.5822046",
"0.5807015",
"0.5726623",
"0.57113206",
"0.5709921",
"0.57070005",
"0.567055",
"0.5655657",
"0.5631146",
"0.5530707",
"0.5509825",
"0.5500033",
"0.549014",
"0.5486122",
"0.548038",
"0.54691386",
"0.5466722",
"0.54654914",
... | 0.70373994 | 0 |
Loads the forecasts on the test set for the model with the specified index. | def get_forecast(self, index: int) -> QuantileForecasts:
# If this job was initialized from Sagemaker, load it from the Sagemaker job
if self.source_job is not None:
with self.source_job.artifact(cache=False) as artifact:
return QuantileForecasts.load(
art... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forecast(self) -> TSDataset:\n future = self.ts.make_future(self.horizon)\n predictions = self.model.forecast(future)\n return predictions",
"def run_forecast(data_start_date='1980-01-01', forecast_end_date='2015-12-01',\n test_date_start='2010-01-01', test_model=True):\n... | [
"0.57880366",
"0.5744425",
"0.57172304",
"0.5592051",
"0.55167764",
"0.5447123",
"0.53842187",
"0.53667367",
"0.5348867",
"0.53257644",
"0.5312602",
"0.53022736",
"0.5291294",
"0.5263494",
"0.5256597",
"0.5193148",
"0.51615494",
"0.5150959",
"0.5131784",
"0.51103663",
"0.5109... | 0.69861263 | 0 |
Stores all data associated with the training job in an autogenerated, unique folder within the provided directory. The job is stored under `//`. Storing jobs via this function allows to decouple experimental results completely from AWS Sagemaker. | def save(self, path: Path, include_forecasts: bool = True) -> None:
assert self.source_job is not None, (
"Job cannot be saved if it was not initialized from an AWS"
" Sagemaker job."
)
# First, we generate the folder name
components = [f"seed-{self.config['seed'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_and_save(self, checkpoint_dir):\n dataset = self._read_dataset(self._train_dataset_path)\n features, labels = self.get_features_and_labels(dataset)\n self._model.partial_fit(features, labels, classes=self._classes)\n checkpoint_path = self._save_model(checkpoint_dir)\n ... | [
"0.60246444",
"0.60179603",
"0.5973554",
"0.5933822",
"0.59281415",
"0.5919202",
"0.58733636",
"0.58628786",
"0.58610374",
"0.5848583",
"0.58481985",
"0.58428925",
"0.58290136",
"0.57720685",
"0.5761287",
"0.5758138",
"0.57482207",
"0.57354796",
"0.57298106",
"0.56943464",
"0... | 0.63213784 | 0 |
Returns all jobs loaded from the provided analysis object. | def load_jobs_from_analysis(analysis: Analysis) -> list[Job]:
return [Job.from_training_job(job) for job in analysis] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jobs(self):\n return self.get_jobs()",
"def get_all_jobs(self) -> List[DocumentReference]:\n return self.get_all_documents(Type._JOBS)",
"def get(self):\n # TODO: auth\n return list(self.app.db.jobs.find())",
"def get_jobs(self):\n return list(self._jobs.values())",
"def ... | [
"0.70309585",
"0.6807044",
"0.67928964",
"0.673053",
"0.66298825",
"0.65959454",
"0.6585272",
"0.6544419",
"0.6532224",
"0.65096277",
"0.648383",
"0.64493287",
"0.64476347",
"0.64060575",
"0.6394272",
"0.6394272",
"0.6389176",
"0.6376901",
"0.637029",
"0.63524526",
"0.6307169... | 0.7795471 | 0 |
Returns all jobs stored in the provided directory, assuming that the directory is structured as `//`. | def load_jobs_from_directory(directory: Path) -> list[Job]:
return [
Job.load(directory / model / dataset / job)
for model in os.listdir(directory)
if (directory / model).is_dir() and model in MODEL_REGISTRY
for dataset in os.listdir(directory / model)
if (directory / model /... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_jobs():\n jobs = [os.path.join(JOBS_DIR, job)\n for job in os.listdir(JOBS_DIR)\n if job != '.gitignore']\n return jobs",
"def scan(directory, cnx):\n print(\"Scanning {}\".format(directory))\n dirs = filter(\n os.path.isdir, map(lambda x: os.path.join(directory, ... | [
"0.7101815",
"0.7073514",
"0.63525575",
"0.6316615",
"0.6290108",
"0.61629045",
"0.6120791",
"0.607188",
"0.60673183",
"0.6064078",
"0.60472614",
"0.60102427",
"0.5994958",
"0.5975588",
"0.59644175",
"0.59509385",
"0.5919864",
"0.58661395",
"0.5861758",
"0.5835227",
"0.582544... | 0.76136386 | 0 |
Visualize dispatch algorithm for a specific week for a single household | def plot_dispatch(pv, demand, E, week=30):
sliced_index = (pv.index.week==week)
pv_sliced = pv[sliced_index]
demand_sliced = demand[sliced_index]
self_consumption = E['inv2load'][sliced_index]
direct_self_consumption = np.minimum(pv_sliced,demand_sliced)# E['inv2load'][sliced_index]
indire... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def visualize(houses:pd.DataFrame) -> None:\n #price_distribution(houses)\n #prop_types(houses)\n #zip_code(houses)\n #year_built(houses)\n #bed_bath(houses)\n return",
"def visualize(self):\n NUM_AFFINITY = 4\n NUM_WILL = 7\n\n # Colors for the tasks and categories\n ... | [
"0.60725814",
"0.60562783",
"0.60288304",
"0.5942266",
"0.5782377",
"0.576781",
"0.57077605",
"0.567477",
"0.5649515",
"0.5626534",
"0.5605493",
"0.5590499",
"0.5579009",
"0.5564213",
"0.5499756",
"0.5481687",
"0.5472014",
"0.547183",
"0.5444558",
"0.54214567",
"0.54148793",
... | 0.6540731 | 0 |
Self consumption maximization pv + battery dispatch algorithm. | def dispatch_max_sc(pv, demand, inv_size,param, return_series=False):
bat_size_e_adj = param['BatteryCapacity']
bat_size_p_adj = param['MaxPower']
n_bat = param['BatteryEfficiency']
n_inv = param['InverterEfficiency']
timestep = param['timestep']
# We work with np.ndarrays as they are much faste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_self_consumption(parameter, ppv, pl, pvmod=True, ideal=False):\r\n # Maximize self consumption for AC-coupled systems\r\n if parameter['Top'] == 'AC':\r\n\r\n # DC power output of the PV generator\r\n if pvmod: # ppv: Normalized DC power output of the PV generator in kW/kWp \r\n ... | [
"0.7099125",
"0.6329282",
"0.6030916",
"0.6005008",
"0.5968238",
"0.59144497",
"0.59016675",
"0.5891479",
"0.58658767",
"0.58223945",
"0.5814258",
"0.5807276",
"0.5765354",
"0.5725443",
"0.5704908",
"0.56763446",
"0.5657277",
"0.56351614",
"0.56341165",
"0.56318754",
"0.56187... | 0.6717923 | 1 |
Create a dictionary mapping socket module constants to their names. | def get_constants(prefix):
return dict( (getattr(socket, n), n)
for n in dir(socket)
if n.startswith(prefix)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_constants(prefix):\n return {getattr(socket, name): name \n for name in dir(socket) if name.startswith(prefix)}",
"def get_constants(prefix):\n return {\n getattr(socket, n): n\n for n in dir(socket)\n if n.startswith(prefix)\n }",
"def __get... | [
"0.7476185",
"0.7366134",
"0.6547015",
"0.59885144",
"0.59645367",
"0.5868489",
"0.57556474",
"0.5736098",
"0.5703377",
"0.5569116",
"0.556135",
"0.5496659",
"0.544311",
"0.5371399",
"0.5357571",
"0.53449243",
"0.5299994",
"0.528858",
"0.52786213",
"0.52697486",
"0.52286804",... | 0.7401871 | 1 |
Setter of objects directory | def setObjectsDir(self,objects_dir):
self.objects_dir=objects_dir | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPath(*args):",
"def __set__(self, obj, val):\n try:\n self._resolve(val)\n except IOError, e:\n Parameterized(name=\"%s.%s\"%(obj.name,self._attrib_name)).warning('%s'%(e.args[0]))\n\n super(Path,self).__set__(obj,val)",
"def set_current_dirs(self, mothur_obj):... | [
"0.62088525",
"0.61558336",
"0.6144854",
"0.6050441",
"0.6027813",
"0.5930473",
"0.5870149",
"0.5842584",
"0.58333504",
"0.57564485",
"0.5753472",
"0.57248926",
"0.5719998",
"0.5706201",
"0.56961006",
"0.56953025",
"0.5679261",
"0.56726664",
"0.5662841",
"0.5648167",
"0.56438... | 0.84115267 | 0 |
This functions gets the coordinates of the centroids of each object detected inside an image. All the objects must be inside a folder, and there must be an image per each detected object. This functions is a complement of shrimps_cropper | def getCentroids(self):
images=[]
centroids_dict={}
#Find all images of the objects
for file in os.listdir(objects_dir):
if file.endswith(self.extension):
images.append(os.path.join(self.objects_dir, file)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def centroids(img):\n _, _, _, centr = cv2.connectedComponentsWithStats(img)\n return centr[1:]",
"def calculateCentroid(self,image):\n\t\tim=cv2.imread(image,0) #reads it in greyscale\n\t\tret,thresh = cv2.threshold(img_copy,128,255,cv2.THRESH_OTSU)\n\t\tim2,contours,hierarchy = cv2.findContours(thresh, 1... | [
"0.73876834",
"0.7351047",
"0.6899893",
"0.68582845",
"0.6782333",
"0.6656481",
"0.66332096",
"0.6574279",
"0.6565449",
"0.6565449",
"0.65211433",
"0.64808935",
"0.6450141",
"0.64330935",
"0.63999873",
"0.63962567",
"0.63778263",
"0.6364939",
"0.63535494",
"0.633664",
"0.6326... | 0.80762154 | 0 |
This functions parses a dict with the centroid of objects to a csv) | def centroidsToCsv(centroids_dict):
file=open("centroids.csv","w")
file.write("image,cx,cy"+"\n")
for k,v in centroids_dict:
cx,cy=v
cx,cy=int(cx),int(cy)
line=k+","+str(cx)+","+str(cy)+"\n"
file.write(line)
file.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def csv_dict_reader(file_obj):\r\n with open('heatmap_data_10_200_out.csv','wb') as file:\r\n\t reader = csv.DictReader(file_obj, delimiter=',')\r\n\t for line in reader:\r\n\t \t# data = \"{location: new google.maps.LatLng(\" + str(line[\"latitude\"]) + \", \" + str(line[\"longitude\"]) + \") , weigh... | [
"0.6368715",
"0.5846054",
"0.5694363",
"0.5678723",
"0.5633493",
"0.5523089",
"0.54001737",
"0.5350426",
"0.5316303",
"0.529523",
"0.5271692",
"0.5223157",
"0.5211816",
"0.51917857",
"0.5166618",
"0.51250046",
"0.51180184",
"0.5116083",
"0.5112225",
"0.5065884",
"0.5059796",
... | 0.73368704 | 0 |
Serializes metric function or `Metric` instance. | def serialize(metric, use_legacy_format=False):
if use_legacy_format:
return legacy_serialization.serialize_keras_object(metric)
return serialize_keras_object(metric) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_metric(self, metric_name: str, metric_value: Union[float, int]):\n self._metrics.append(Metric(metric_name, metric_value))",
"def to_metric(self):\r\n if self.units != 'metric':\r\n self.units = 'metric'\r\n for statement in self.statements:\r\n statem... | [
"0.58285487",
"0.56885976",
"0.54272646",
"0.54066837",
"0.5406057",
"0.5391582",
"0.5391467",
"0.5368178",
"0.5352632",
"0.53402895",
"0.53305924",
"0.5266467",
"0.5261219",
"0.52502483",
"0.5236375",
"0.5234931",
"0.5217899",
"0.5208372",
"0.517548",
"0.51666504",
"0.513628... | 0.61697525 | 0 |
Deserializes a serialized metric class/function instance. | def deserialize(config, custom_objects=None, use_legacy_format=False):
if use_legacy_format:
return legacy_serialization.deserialize_keras_object(
config,
module_objects=globals(),
custom_objects=custom_objects,
printable_module_name="metric function",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _deserialize_data(self):\n try:\n self._func_name, self._instance, self._args, self._kwargs = self.serializer.loads(self.data)\n except Exception as e:\n raise DeserializationError() from e",
"def deserialize_object(d):\n pass",
"def set_deserializer(func):\n\n glo... | [
"0.6018332",
"0.5611933",
"0.55370784",
"0.5534467",
"0.5452773",
"0.54252684",
"0.5355446",
"0.5322647",
"0.526982",
"0.5247967",
"0.5172395",
"0.51657826",
"0.51657385",
"0.5151879",
"0.515065",
"0.5117543",
"0.50881195",
"0.5087222",
"0.5069456",
"0.5067931",
"0.5064629",
... | 0.59808713 | 1 |
Retrieves a Keras metric as a `function`/`Metric` class instance. The `identifier` may be the string name of a metric function or class. >>> metric = tf.keras.metrics.get("categorical_crossentropy") >>> type(metric) >>> metric = tf.keras.metrics.get("CategoricalCrossentropy") >>> type(metric) You can also specify `conf... | def get(identifier):
if isinstance(identifier, dict):
use_legacy_format = "module" not in identifier
return deserialize(identifier, use_legacy_format=use_legacy_format)
elif isinstance(identifier, str):
return deserialize(str(identifier))
elif callable(identifier):
return ide... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_metric_function(metric, output_shape=None, loss_fn=None):\n if metric not in ['accuracy', 'acc', 'crossentropy', 'ce']:\n return metrics_module.get(metric)\n\n is_sparse_categorical_crossentropy = (\n isinstance(loss_fn, losses.SparseCategoricalCrossentropy) or\n (isinstance(loss_fn, losses.... | [
"0.64331776",
"0.5918581",
"0.58575666",
"0.56548023",
"0.56092954",
"0.5603099",
"0.56016564",
"0.55089456",
"0.5492291",
"0.5395595",
"0.5324814",
"0.5318652",
"0.5310939",
"0.5292794",
"0.5289496",
"0.5235254",
"0.5227662",
"0.5165119",
"0.5161693",
"0.5140593",
"0.5140334... | 0.65417695 | 0 |
Import predicted chemical shifts from a ShiftX2 results file. | def import_pred_shifts(self, input_file, filetype, offset=None):
# If no offset value is defined, use the default one
if offset==None:
offset = self.pars["pred_offset"]
if filetype == "shiftx2":
preds_long = pd.read_csv(input_file)
if any(pre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_model_shiftby_performances(lines):\n performances = {}\n patients = [str(x) for x in range(13)]\n # current_model = ''\n # shifts = [-100, -75, -50, -25, 25, 50, 100, 125, 150, 175, 200, 225, 250]\n for i, line in enumerate(lines):\n words = line.split(' ')\n if (len(words) ==... | [
"0.5446786",
"0.54203486",
"0.540608",
"0.5116226",
"0.5098462",
"0.50775564",
"0.4867958",
"0.4835102",
"0.47848338",
"0.4767698",
"0.476049",
"0.47403774",
"0.47100824",
"0.47084942",
"0.46752083",
"0.46631467",
"0.46558896",
"0.46472603",
"0.46404696",
"0.4615915",
"0.4597... | 0.7031838 | 0 |
Add dummy rows to obs and preds to bring them to the same length. Also discard any atom types that aren't present in both obs and preds. | def add_dummy_rows(self):
obs = self.obs.copy()
preds = self.preds.copy()
# Delete any prolines in preds
preds = preds.drop(preds.index[preds["Res_type"]=="P"])
# Restrict atom types
# self.pars["atom_set"] is the set of atoms to be used in the ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dummy(DF, cols=None):\n\treturn pandas.concat((pandas.get_dummies(DF[col]) for col in (DF.columns if cols is None else cols)), \n\t\t\t\t\t\taxis=1, keys = DF.columns)",
"def _maybe_one_hot(self, obs):\n if self.toOneHot:\n obs = np.reshape(obs, (1, -1))\n ints = obs.dot(self.mul... | [
"0.51797813",
"0.51567936",
"0.50105745",
"0.500534",
"0.49335837",
"0.488771",
"0.48698184",
"0.48424566",
"0.48196307",
"0.48162004",
"0.47961143",
"0.47877845",
"0.47824016",
"0.47317788",
"0.47302616",
"0.47042045",
"0.46973348",
"0.46867436",
"0.46791512",
"0.4661607",
"... | 0.76919025 | 0 |
Use the Hungarian algorithm to find the highest probability matching (ie. the one with the lowest log probability sum), with constraints. Returns a data frame with the SS_names and Res_names of the matching. (Doesn't change the internal state of the NAPS_assigner instance.) | def find_best_assignments(self, inc=None, exc=None):
obs = self.obs
preds = self.preds
log_prob_matrix = deepcopy(self.log_prob_matrix)
if inc is not None:
# Check for conflicting entries in inc
conflicts = inc["SS_name"].duplicated(keep=False) | inc["Res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_alt_assignments(self, N=1, by_ss=True, verbose=False):\n \n obs = self.obs\n preds = self.preds\n log_prob_matrix = self.log_prob_matrix\n #best_match_indexes = self.best_match_indexes\n best_matching = self.assign_df.loc[:,[\"SS_name\",\"Res_name\"]]\n bes... | [
"0.6946215",
"0.572618",
"0.5638922",
"0.5520695",
"0.53825295",
"0.5375298",
"0.5357782",
"0.5261661",
"0.52132386",
"0.5193686",
"0.5179454",
"0.5141006",
"0.51400214",
"0.5137029",
"0.5104018",
"0.5080617",
"0.50650793",
"0.50535953",
"0.50358266",
"0.5029988",
"0.5026849"... | 0.5761263 | 1 |
Make a dataframe with full assignment information, given a dataframe of SS_name and Res_name. Matching may have additional columns, which will also be kept. | def make_assign_df(self, matching, set_assign_df=False):
obs = self.obs
preds = self.preds
log_prob_matrix = self.log_prob_matrix
valid_atoms = list(self.pars["atom_set"])
extra_cols = set(matching.columns).difference({"SS_name","Res_name"})
assign_df = pd.merge(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_alt_assignments(self, N=1, by_ss=True, verbose=False):\n \n obs = self.obs\n preds = self.preds\n log_prob_matrix = self.log_prob_matrix\n #best_match_indexes = self.best_match_indexes\n best_matching = self.assign_df.loc[:,[\"SS_name\",\"Res_name\"]]\n bes... | [
"0.6295066",
"0.54382235",
"0.53736186",
"0.5232949",
"0.51283914",
"0.51053727",
"0.5041124",
"0.49908632",
"0.49721557",
"0.4964747",
"0.48737735",
"0.48627257",
"0.48425636",
"0.48329255",
"0.48052752",
"0.47999734",
"0.47995454",
"0.47951612",
"0.47880265",
"0.47661024",
... | 0.68792164 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.