query
stringlengths
10
2k
document
stringlengths
20
51.2k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Test that the endpoint 404's without the required query params.
def test_get_student_progress_url_noparams(self): url = reverse('get_student_progress_url', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url) self.assertEqual(response.status_code, 400)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_unknown_routes():\n response = client.get(\"/unknown_endpoint\",\n headers={\"content-type\": \"application/json\"})\n assert response.status_code == status.HTTP_404_NOT_FOUND\n assert response.json() == {\"detail\": \"Not Found\"}", "def test_not_found(self):\n ...
[ "0.76273507", "0.74569935", "0.74342585", "0.74233854", "0.73182976", "0.72709227", "0.725553", "0.72376686", "0.7213635", "0.7202286", "0.71978575", "0.71494853", "0.7132387", "0.7127603", "0.7112248", "0.70984423", "0.7087103", "0.70561755", "0.70496106", "0.70481944", "0.7...
0.0
-1
Test that the endpoint 400's when requesting an unknown email.
def test_get_student_progress_url_nostudent(self): url = reverse('get_student_progress_url', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url) self.assertEqual(response.status_code, 400)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_wrong_email(self):\n self.response = self.client.post(\n \"/api/users/\",\n {\"user\": {\n \"username\": \"Iroqua\",\n \"email\": 'kakegmailcom',\n \"password\": \"irquoa12345678\",\n }\n ...
[ "0.75909275", "0.7540097", "0.7515859", "0.74790764", "0.7442328", "0.7442328", "0.73178846", "0.73069215", "0.7300411", "0.7289706", "0.72311187", "0.71744967", "0.7157915", "0.7145603", "0.7132887", "0.71205425", "0.71030885", "0.7085266", "0.70549953", "0.70486224", "0.702...
0.0
-1
Make sure no one can delete all students state on a problem.
def test_reset_student_attempts_deletall(self): url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, 'all_students': True, 'delete_module':...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_problem_state(self):\r\n # get descriptor:\r\n problem_url_name = 'H1P1'\r\n self.define_option_problem(problem_url_name)\r\n location = InstructorTaskModuleTestCase.problem_location(problem_url_name)\r\n descriptor = self.module_store.get_item(location)\r\n ...
[ "0.7232713", "0.69238216", "0.68307036", "0.6628616", "0.64701957", "0.63899887", "0.62811315", "0.6252546", "0.61361283", "0.6134564", "0.6060548", "0.6010347", "0.6004661", "0.5999508", "0.5929472", "0.59165776", "0.58634615", "0.5760752", "0.5754379", "0.5729251", "0.57186...
0.61073
10
Test reset single student attempts.
def test_reset_student_attempts_single(self): url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, 'unique_student_identifier': self.student.email, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _test_reset_with_student(self, use_email):\r\n num_students = 10\r\n initial_attempts = 3\r\n input_state = json.dumps({'attempts': initial_attempts})\r\n students = self._create_students_with_state(num_students, input_state)\r\n # check that entries were set correctly\r\n ...
[ "0.8037322", "0.7738103", "0.7482297", "0.733004", "0.7322325", "0.7287467", "0.7273572", "0.7202903", "0.71968645", "0.71313024", "0.7002455", "0.69234407", "0.6922141", "0.6874573", "0.6669791", "0.66598415", "0.66525304", "0.6650981", "0.66234785", "0.64644676", "0.6446487...
0.81933945
0
Test delete single student state.
def test_reset_student_attempts_delete(self): url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, 'unique_student_identifier': self.student.email, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_student_state_delete(self):\r\n staff_page = self._goto_staff_page()\r\n staff_page.answer_problem()\r\n\r\n staff_debug_page = staff_page.open_staff_debug_info()\r\n staff_debug_page.delete_state()\r\n msg = staff_debug_page.idash_msg[0]\r\n self.assertEqual(u'Su...
[ "0.865069", "0.7538233", "0.7359624", "0.7215197", "0.7188686", "0.7152515", "0.70723647", "0.70596075", "0.70404065", "0.7024382", "0.70071524", "0.69883734", "0.69714725", "0.6937336", "0.69249743", "0.69211954", "0.6918943", "0.67561865", "0.67492056", "0.6730391", "0.6727...
0.65523297
38
Test failure with both unique_student_identifier and all_students.
def test_reset_student_attempts_nonsense(self): url = reverse('reset_student_attempts', kwargs={'course_id': self.course.id.to_deprecated_string()}) response = self.client.get(url, { 'problem_to_reset': self.problem_urlname, 'unique_student_identifier': self.student.email, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_careers_invalid_student(self):\n student_id = '1234567890'\n result = self.ucuenca.careers(student_id)\n self.assertFalse(result)", "def test_careers_invalid_student(self):\n student_id = '1234567890'\n result = self.ucuenca.schedule(student_id)\n self.assertFal...
[ "0.70976245", "0.70511615", "0.69708294", "0.6922918", "0.68911207", "0.6890079", "0.678238", "0.6539998", "0.6530534", "0.6428217", "0.6414026", "0.6316636", "0.6305442", "0.6297082", "0.623938", "0.6229456", "0.62264955", "0.62217826", "0.6208791", "0.6206848", "0.6206404",...
0.6383644
11
Makes a course, which will be the same for all tests. Set up mako middleware, which is necessary for template rendering to happen.
def setUp(self): self.course = CourseFactory.create(org='Me', number='19.002', display_name='test_course') self.url = '/courses/Me/19.002/test_course/hint_manager' self.user = UserFactory.create(username='robot', email='robot@edx.org', password='test', is_staff=True) self.c = Client(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_course(self, **kwargs):\r\n self.course = CourseFactory.create(**kwargs)\r\n user = UserFactory.create()\r\n CourseEnrollmentFactory.create(user=user, course_id=self.course.id)\r\n self.client.login(username=user.username, password='test')", "def setup_course(self, default_st...
[ "0.6357065", "0.6348594", "0.62423724", "0.61993754", "0.61960626", "0.61756575", "0.6150704", "0.61429083", "0.6122019", "0.6115055", "0.60621125", "0.60491884", "0.60463667", "0.6035501", "0.6011603", "0.6002316", "0.5975123", "0.59541535", "0.5923809", "0.590394", "0.58464...
0.52931887
82
Do email on unenroll test
def test_unenrollment_email_on(self): course = self.course # Create invited, but not registered, user cea = CourseEnrollmentAllowed(email='student4_0@test.com', course_id=course.id) cea.save() url = reverse('instructor_dashboard_legacy', kwargs={'course_id': course.id....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_unenrollment_email_off(self):\r\n\r\n course = self.course\r\n\r\n # Run the Un-enroll students command\r\n url = reverse('instructor_dashboard_legacy', kwargs={'course_id': course.id.to_deprecated_string()})\r\n response = self.client.post(\r\n url,\r\n {...
[ "0.7855488", "0.7124918", "0.68363863", "0.67587876", "0.67370117", "0.66923386", "0.6670878", "0.6536341", "0.64965767", "0.64877313", "0.6459615", "0.6446645", "0.64450765", "0.6431678", "0.64287513", "0.64205307", "0.63741577", "0.63562536", "0.6310344", "0.6290454", "0.62...
0.7729784
1
Test attempt to find a unit that does not exist.
def test_find_unit_notfound(self): url = "i4x://MITx/999/chapter/notfound" with self.assertRaises(tools.DashboardError): tools.find_unit(self.course, url)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_not_found(self):\n self.library.get.when.called_with('dummy!!!')\\\n .should.throw(ViolationDoesNotExists)", "def test_find_unit_success(self):\r\n url = self.homework.location.to_deprecated_string()\r\n self.assertEqual(tools.find_unit(self.course, url), self.homework)",...
[ "0.7114424", "0.68915933", "0.6681315", "0.6493727", "0.630693", "0.6250928", "0.62388325", "0.6206083", "0.61974794", "0.61947477", "0.6193187", "0.6187541", "0.61813515", "0.617901", "0.6154803", "0.6137136", "0.61201143", "0.6115628", "0.6112432", "0.6077666", "0.60713315"...
0.7937228
0
Get the extended due date out of a student's state for a particular unit.
def get_extended_due(course, unit, student): student_module = StudentModule.objects.get( student_id=student.id, course_id=course.id, module_state_key=unit.location ) state = json.loads(student_module.state) extended = state.get('extended_due', None) if extended: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_extended_due_date(node):\r\n if isinstance(node, dict):\r\n get = node.get\r\n else:\r\n get = partial(getattr, node)\r\n due_date = get('due', None)\r\n if not due_date:\r\n return due_date\r\n extended = get('extended_due', None)\r\n if not extended or extended < du...
[ "0.6478142", "0.61064816", "0.5798429", "0.56518686", "0.55424297", "0.5470411", "0.54561317", "0.5440282", "0.5404665", "0.5263184", "0.5137398", "0.5135319", "0.5085515", "0.5055226", "0.5038273", "0.49803868", "0.49548233", "0.49032375", "0.48978332", "0.4882335", "0.48291...
0.8051273
0
Respond with json which contains a html formatted grade summary.
def get_grading_config(request, course_id): course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id) course = get_course_with_access( request.user, 'staff', course_id, depth=None ) grading_config_summary = analytics.basic.dump_grading_context(course) response_payload = {...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_grade_summary(self):\r\n\r\n fake_request = self.factory.get(\r\n reverse('progress', kwargs={'course_id': self.course.id.to_deprecated_string()})\r\n )\r\n\r\n return grades.grade(self.student_user, fake_request, self.course)", "def publish_grade(self):\r\n score =...
[ "0.70836025", "0.68142325", "0.65221184", "0.65056247", "0.61898106", "0.6055478", "0.6010255", "0.5943439", "0.5874262", "0.5857717", "0.58093345", "0.57940614", "0.5703752", "0.56907433", "0.5662783", "0.5656776", "0.565612", "0.5636849", "0.5612003", "0.5612003", "0.561200...
0.51881456
68
Do the actual work of enrolling multiple students, presented as a string of emails separated by commas or returns `course` is course object `course_key` id of course (a CourseKey) `students` string of student emails separated by commas or returns (a `str`) `overload` unenrolls all existing students (a `boolean`) `auto_...
def _do_enroll_students(course, course_key, students, overload=False, auto_enroll=False, email_students=False, is_shib_course=False): new_students, new_students_lc = get_and_clean_student_list(students) status = dict([x, 'unprocessed'] for x in new_students) if overload: # delete all but staff ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_unenroll_students(course_key, students, email_students=False):\r\n\r\n old_students, __ = get_and_clean_student_list(students)\r\n status = dict([x, 'unprocessed'] for x in old_students)\r\n\r\n stripped_site_name = microsite.get_value(\r\n 'SITE_NAME',\r\n settings.SITE_NAME\r\n ...
[ "0.73913974", "0.7184309", "0.69980854", "0.6950554", "0.65752554", "0.6484366", "0.6301392", "0.6280819", "0.59799385", "0.5869413", "0.5835276", "0.5800029", "0.57036513", "0.5692975", "0.554304", "0.5541269", "0.54815274", "0.54316115", "0.5425975", "0.5391872", "0.5348550...
0.84432316
0
Do the actual work of unenrolling multiple students, presented as a string of emails separated by commas or returns `course_key` is id of course (a `str`) `students` is string of student emails separated by commas or returns (a `str`) `email_students` is user input preference (a `boolean`)
def _do_unenroll_students(course_key, students, email_students=False): old_students, __ = get_and_clean_student_list(students) status = dict([x, 'unprocessed'] for x in old_students) stripped_site_name = microsite.get_value( 'SITE_NAME', settings.SITE_NAME ) if email_stude...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _do_enroll_students(course, course_key, students, overload=False, auto_enroll=False, email_students=False, is_shib_course=False):\r\n\r\n new_students, new_students_lc = get_and_clean_student_list(students)\r\n status = dict([x, 'unprocessed'] for x in new_students)\r\n\r\n if overload: # delete all ...
[ "0.75279284", "0.68005556", "0.62982047", "0.6248675", "0.6184625", "0.60958314", "0.5868771", "0.5748954", "0.57025135", "0.5657984", "0.56309193", "0.5570905", "0.55344766", "0.5480158", "0.54674697", "0.5408557", "0.54004216", "0.534299", "0.5337152", "0.5331284", "0.52651...
0.8146474
0
Used to return whether course has Shibboleth as the enrollment domain Returns a boolean indicating if Shibboleth authentication is set for this course.
def uses_shib(course): return course.enrollment_domain and course.enrollment_domain.startswith(SHIBBOLETH_DOMAIN_PREFIX)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_frozensand_auth_available(self):\n cvar = self.getCvar('auth')\n if cvar:\n auth = cvar.getInt()\n return auth != 0\n else:\n return False", "def is_bothell_student():\n return _is_member('uw_affiliation_bothell-student')", "def can_log_in_without...
[ "0.6333624", "0.63209385", "0.60733056", "0.60253274", "0.5950663", "0.5888397", "0.58029085", "0.5799935", "0.575448", "0.5749943", "0.5730417", "0.57285565", "0.5707601", "0.5704415", "0.5689181", "0.5684532", "0.5653466", "0.56510985", "0.56244993", "0.5612999", "0.5612999...
0.71210855
0
Returns a query of InstructorTask objects of historical tasks for a given course, that optionally match a particular problem, a student, and/or a task type.
def get_instructor_task_history(course_id, usage_key=None, student=None, task_type=None): instructor_tasks = InstructorTask.objects.filter(course_id=course_id) if usage_key is not None or student is not None: _, task_key = encode_problem_and_student_input(usage_key, student) instructor_tasks...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_instructor_tasks(request, course_id):\r\n course_id = SlashSeparatedCourseKey.from_deprecated_string(course_id)\r\n problem_location_str = strip_if_string(request.GET.get('problem_location_str', False))\r\n student = request.GET.get('unique_student_identifier', None)\r\n if student is not None...
[ "0.65488404", "0.61440825", "0.59696007", "0.5707948", "0.5291595", "0.52794075", "0.50911635", "0.5065719", "0.49736443", "0.4962771", "0.49608666", "0.49594453", "0.4900265", "0.4893526", "0.48062918", "0.480628", "0.47841793", "0.47489244", "0.47483975", "0.47216037", "0.4...
0.7933572
0
Request to have bulk email sent as a background task. The specified CourseEmail object will be sent be updated for all students who have enrolled in a course. Parameters are the `course_key` and the `email_id`, the id of the CourseEmail object. AlreadyRunningError is raised if the same recipients are already being emai...
def submit_bulk_course_email(request, course_key, email_id): # Assume that the course is defined, and that the user has already been verified to have # appropriate access to the course. But make sure that the email exists. # We also pull out the To argument here, so that is displayed in # the Instru...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def send_course_email(entry_id, email_id, to_list, global_email_context, subtask_status_dict):\r\n subtask_status = SubtaskStatus.from_dict(subtask_status_dict)\r\n current_task_id = subtask_status.task_id\r\n num_to_send = len(to_list)\r\n log.info(u\"Preparing to send email %s to %d recipients as sub...
[ "0.7318897", "0.69380397", "0.6340705", "0.6218016", "0.6187487", "0.6075581", "0.6073056", "0.6047216", "0.56511575", "0.55919176", "0.5430858", "0.5350784", "0.5329142", "0.52013063", "0.51885784", "0.5099049", "0.5065114", "0.50421995", "0.501506", "0.50110334", "0.4991763...
0.7269977
1
Writes InstructorTask immediately, ensuring the transaction is committed. Autocommit annotation makes sure the database entry is committed. When called from any view that is wrapped by TransactionMiddleware, and thus in a "commitonsuccess" transaction, this autocommit here will cause any pending transaction to be commi...
def save_now(self): self.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_entry(self, task_state=QUEUING, task_output=None, student=None):\r\n task_id = str(uuid4())\r\n progress_json = json.dumps(task_output) if task_output is not None else None\r\n task_input, task_key = encode_problem_and_student_input(self.problem_url, student)\r\n\r\n instruc...
[ "0.581261", "0.564315", "0.56253386", "0.55883914", "0.5566898", "0.55200106", "0.54693055", "0.5436027", "0.5352525", "0.53494203", "0.5262044", "0.5203551", "0.51582974", "0.5141835", "0.50968885", "0.50957483", "0.5095544", "0.509162", "0.50912595", "0.5083141", "0.5079993...
0.0
-1
Construct a SubtaskStatus object from a dict representation.
def from_dict(self, d): options = dict(d) task_id = options['task_id'] del options['task_id'] return SubtaskStatus.create(task_id, **options)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_dict(cls, dikt) -> 'Status':\n return deserialize_model(dikt, cls)", "def from_dict(cls, d):\n assert \"status\" in d\n assert \"metadata\" in d\n return cls(**d)", "def from_dict(cls, dic: Dict[str, Any]) -> \"CircuitStatus\":\n invalid = ValueError(f\"Dictionary in...
[ "0.69388247", "0.6624793", "0.63764083", "0.6188561", "0.5860819", "0.58341485", "0.5809772", "0.5791887", "0.57916886", "0.575009", "0.5673962", "0.56518036", "0.5595291", "0.5595291", "0.5595291", "0.5595291", "0.5595291", "0.5595291", "0.5595291", "0.5595291", "0.5595291",...
0.85692203
0
Return unicode version of a SubtaskStatus object representation.
def __unicode__(self): return unicode(repr(self))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\r\n return 'SubtaskStatus<%r>' % (self.to_dict(),)", "def _get_status(self):\n return u'%s' % (self.get_status_display())", "def get_status_string(self, instance):\n return instance.get_status_string()", "def getStatusString(self, statClass=None):\n return self...
[ "0.76498955", "0.7149843", "0.6560451", "0.64144146", "0.6339036", "0.6335985", "0.6335985", "0.6335985", "0.62577313", "0.61613923", "0.6157769", "0.5995477", "0.59939104", "0.59725016", "0.5912668", "0.58700436", "0.5868594", "0.585438", "0.5830045", "0.5805582", "0.5805582...
0.0
-1
Performs generic update by visiting StudentModule instances with the update_fcn provided. StudentModule instances are those that match the specified `course_id` and `module_state_key`. If `student_identifier` is not None, it is used as an additional filter to limit the modules to those belonging to that student. If `st...
def perform_module_state_update(update_fcn, filter_fcn, _entry_id, course_id, task_input, action_name): # get start time for task: start_time = time() usage_key = course_id.make_usage_key_from_deprecated_string(task_input.get('problem_url')) student_identifier = task_input.get('student') # ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update(self, semester, year, abbreviation=None, course_number=None):\n print({\n 'message': 'Updating sections.',\n 'semester': semester,\n 'year': year,\n 'abbreviation': abbreviation,\n 'course_number': course_number,\n })\n\n # Get ...
[ "0.48865286", "0.4651076", "0.46448565", "0.45772892", "0.44674945", "0.4357609", "0.43028846", "0.4301227", "0.4245412", "0.42068353", "0.41992727", "0.4169671", "0.41687134", "0.4112973", "0.41019654", "0.40921256", "0.40789858", "0.40758258", "0.40679386", "0.40644053", "0...
0.6711263
0
Gets task_id from `xmodule_instance_args` dict, or returns default value if missing.
def _get_task_id_from_xmodule_args(xmodule_instance_args): return xmodule_instance_args.get('task_id', UNKNOWN_TASK_ID) if xmodule_instance_args is not None else UNKNOWN_TASK_ID
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_module_task_instance_id(task_instances):\n for id in task_instances:\n if task_instances[id] == 'module_node':\n return id\n return None", "def _get_xmodule_instance_args(request, task_id):\r\n request_info = {'username': request.user.username,\r\n 'ip': requ...
[ "0.64487135", "0.63873464", "0.6165406", "0.6165406", "0.6165406", "0.6165406", "0.61532056", "0.61532056", "0.61532056", "0.5989508", "0.5917978", "0.5917978", "0.5917978", "0.5917978", "0.5917978", "0.5917978", "0.591669", "0.591669", "0.591669", "0.58214414", "0.5805892", ...
0.9169862
0
Resets problem attempts to zero for specified `student_module`. Returns a status of UPDATE_STATUS_SUCCEEDED if a problem has nonzero attempts that are being reset, and UPDATE_STATUS_SKIPPED otherwise.
def reset_attempts_module_state(xmodule_instance_args, _module_descriptor, student_module): update_status = UPDATE_STATUS_SKIPPED problem_state = json.loads(student_module.state) if student_module.state else {} if 'attempts' in problem_state: old_number_of_attempts = problem_state["attempts"] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset_student_attempts(course_id, student, module_state_key, delete_module=False):\r\n # Reset the student's score in the submissions API\r\n # Currently this is used only by open assessment (ORA 2)\r\n # We need to do this *before* retrieving the `StudentModule` model,\r\n # because it's possible ...
[ "0.74907523", "0.7418054", "0.6959918", "0.6813743", "0.65834594", "0.63682973", "0.6318397", "0.6176371", "0.6157453", "0.6005991", "0.593754", "0.5908689", "0.5829373", "0.5678886", "0.56081903", "0.558727", "0.5568876", "0.55141956", "0.54067314", "0.5380785", "0.5339182",...
0.73063356
2
Delete the StudentModule entry. Always returns UPDATE_STATUS_SUCCEEDED, indicating success, if it doesn't raise an exception due to database error.
def delete_problem_module_state(xmodule_instance_args, _module_descriptor, student_module): student_module.delete() # get request-related tracking information from args passthrough, # and supplement with task-specific information: track_function = _get_track_function_for_task(student_module.student,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_one_student_module(self, student_module_id):\r\n delete_gap = datetime.timedelta(seconds=self.DELETE_GAP_SECS)\r\n\r\n history = self.get_history_for_student_modules(student_module_id)\r\n if not history:\r\n self.say(\"No history for student_module_id {}\".format(student_...
[ "0.68517745", "0.60478526", "0.6017909", "0.60012686", "0.600123", "0.59568393", "0.5944815", "0.59186727", "0.58459353", "0.57623935", "0.57585216", "0.5724174", "0.5718405", "0.56320786", "0.55920947", "0.55573004", "0.5488279", "0.5450774", "0.5441209", "0.54177046", "0.54...
0.66762227
1
Create CourseEmail object for testing.
def _define_course_email(self): course_email = CourseEmail.create(self.course.id, self.instructor, SEND_TO_ALL, "Test Subject", "<p>This is a test message</p>") return course_email.id # pylint: disable=E1101
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create(cls, course_id, sender, to_option, subject, html_message, text_message=None):\r\n # automatically generate the stripped version of the text from the HTML markup:\r\n if text_message is None:\r\n text_message = html_to_text(html_message)\r\n\r\n # perform some validation h...
[ "0.6610431", "0.6319418", "0.6296033", "0.6288986", "0.626332", "0.6261424", "0.6113796", "0.60265356", "0.60219306", "0.59862846", "0.5974546", "0.5948644", "0.5947371", "0.5937756", "0.5906658", "0.59005165", "0.58994913", "0.5875557", "0.58478785", "0.582927", "0.5825503",...
0.791801
0
Create a course in the store, with a chapter and section.
def initialize_course(self): self.module_store = editable_modulestore() # Create the course self.course = CourseFactory.create(org=TEST_COURSE_ORG, number=TEST_COURSE_NUMBER, display_name=TEST_COURSE_NAM...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _create_course(self):\r\n # If the course already exists, this will respond\r\n # with a 200 and an error message, which we ignore.\r\n response = self.session.post(\r\n STUDIO_BASE_URL + '/course/',\r\n data=self._encode_post_dict(self._course_dict),\r\n h...
[ "0.7513528", "0.7366163", "0.7325783", "0.7244521", "0.72005594", "0.7131308", "0.71219623", "0.710888", "0.7046536", "0.6956679", "0.6943545", "0.6813308", "0.68087673", "0.67974037", "0.6785923", "0.6761018", "0.6721924", "0.66961175", "0.6642304", "0.66115123", "0.6543633"...
0.6877884
11
Creates an instructor for the test course.
def create_instructor(self, username): return self._create_user(username, is_staff=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_instructor(course, user_email):\r\n CourseStaffRole(course.id).add_users(User.objects.get(email=user_email))", "def setUp(self):\r\n instructor = AdminFactory.create()\r\n self.client.login(username=instructor.username, password='test')\r\n self.student = UserFactory.create(usern...
[ "0.73090726", "0.7018322", "0.6877909", "0.66854095", "0.66353685", "0.66095227", "0.65404195", "0.6386914", "0.63615924", "0.6322487", "0.6317931", "0.6300028", "0.6297555", "0.62963325", "0.62712795", "0.62574595", "0.6245043", "0.62291163", "0.6196758", "0.612726", "0.6102...
0.70621425
1
Return a staff grading service instanceif settings.MOCK_STAFF_GRADING is True, returns a mock one, otherwise a real one. Caches the result, so changing the setting after the first call to this function will have no effect.
def staff_grading_service(): global _service if _service is not None: return _service if settings.MOCK_STAFF_GRADING: _service = MockStaffGradingService() else: _service = StaffGradingService(settings.OPEN_ENDED_GRADING_INTERFACE) return _service
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rp_service():\n service = PyTestServiceClass()\n with mock.patch('reportportal_client.service.'\n 'ReportPortalService.get_project_settings'):\n service.init_service(\"endpoint\", \"project\", \"uuid\", 20, False, [])\n return service", "def staff_client(staff_user):\n ...
[ "0.533929", "0.51559466", "0.50780475", "0.5057295", "0.4933919", "0.4900129", "0.48547044", "0.4845172", "0.4784794", "0.47633433", "0.47608936", "0.4738235", "0.47070655", "0.47015113", "0.4681705", "0.46563852", "0.46511114", "0.46499425", "0.46447313", "0.46214905", "0.46...
0.8617978
0
Get all the problems for the given course id
def get_problem_list(request, course_id): assert(isinstance(course_id, basestring)) course_key = SlashSeparatedCourseKey.from_deprecated_string(course_id) _check_access(request.user, course_key) try: response = staff_grading_service().get_problem_list(course_key, unique_id_for_user(request....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_problem(id):\n return query(WEB_EXAMPLE_BASE + f\"/classical/problem/{id}\")", "def get_problem_list(self, course_id, user_id):\r\n return {'success': True, 'error': 'No problems found.'}", "def student_problem_list(request, course_id):\r\n assert isinstance(course_id, basestring)\r\n c...
[ "0.69521195", "0.68883324", "0.6732685", "0.64816433", "0.6371245", "0.6260643", "0.61050576", "0.59805775", "0.5852007", "0.5767134", "0.57430094", "0.5710242", "0.5698768", "0.56832296", "0.56481683", "0.5631257", "0.55970865", "0.55960125", "0.55952173", "0.55488116", "0.5...
0.6705553
3
Makes a given user an instructor in a course.
def make_instructor(course, user_email): CourseStaffRole(course.id).add_users(User.objects.get(email=user_email))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_user_role_instructor(self):\r\n self.assertEqual(\r\n 'instructor',\r\n access.get_user_role(self.course_instructor, self.course_key)\r\n )\r\n # Masquerade instructor\r\n self.course_instructor.masquerade_as_student = True\r\n self.assertEqual(\r\n...
[ "0.70984286", "0.6903377", "0.65852636", "0.64216083", "0.6356622", "0.6260626", "0.6232254", "0.62312317", "0.6101803", "0.6004632", "0.5930786", "0.5806674", "0.57863736", "0.57250303", "0.57074535", "0.57062227", "0.5701061", "0.56637883", "0.563791", "0.562358", "0.562206...
0.81249624
0
Test to see if a staff grading response missing a problem list is given the appropriate error. Mock the staff grading service to enable the key to be missing.
def test_get_problem_list_missing(self): # Get a valid user object. instructor = User.objects.get(email=self.instructor) # Mock a request object. request = Mock( user=instructor, ) # Get the response and load its content. response = json.load...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_problem_list(self):\r\n # Initialize a StudentProblemList object.\r\n student_problem_list = utils.StudentProblemList(self.course.id, unique_id_for_user(self.user))\r\n # Get the initial problem list from ORA.\r\n success = student_problem_list.fetch_from_grading_service()\...
[ "0.6716093", "0.66281366", "0.6420914", "0.636489", "0.63610905", "0.63391227", "0.6310623", "0.6224385", "0.62060493", "0.61739874", "0.6170853", "0.61468095", "0.61381453", "0.6136411", "0.6129348", "0.6120097", "0.6099651", "0.6098176", "0.60862905", "0.60794973", "0.60401...
0.80815697
0
The open_ended_nopath course contains a peer grading module with no path to it. Ensure that the exception is caught.
def test_peer_grading_nopath(self): found, url = views.find_peer_grading_module(self.course) self.assertEqual(found, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_invalid_link(self):\r\n\r\n # Setup the peer grading module with no linked locations.\r\n peer_grading = self._create_peer_grading_with_linked_problem(self.coe_location, valid_linked_descriptor=False)\r\n\r\n self.assertFalse(peer_grading.use_for_single_location_local)\r\n self...
[ "0.620648", "0.59255975", "0.59156513", "0.5879027", "0.5825214", "0.58168024", "0.5732118", "0.5669049", "0.5655204", "0.5580385", "0.54458916", "0.54449356", "0.5443615", "0.544071", "0.5418937", "0.5411832", "0.5411352", "0.53771347", "0.5299863", "0.52932686", "0.5276106"...
0.7117479
0
Reverses the URL given the name and the course id, and then adds a trailing slash if it does not exist yet.
def _reverse_with_slash(url_name, course_key): ajax_url = _reverse_without_slash(url_name, course_key) if not ajax_url.endswith('/'): ajax_url += '/' return ajax_url
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_url(self, url_name, **kwargs):\r\n kwargs['course_id'] = self.course.id.to_deprecated_string()\r\n url = reverse(url_name, kwargs=kwargs)\r\n return url", "def reverse_course_url(handler_name, course_key, kwargs=None):\r\n return reverse_url(handler_name, 'course_key_string', cou...
[ "0.65422827", "0.62883353", "0.61074126", "0.6088143", "0.5914163", "0.58570033", "0.58561814", "0.58112377", "0.57579124", "0.56985545", "0.56956285", "0.5659031", "0.56393206", "0.56319344", "0.55908954", "0.5549545", "0.5544354", "0.5515478", "0.55030507", "0.5498452", "0....
0.71544003
0
Return the total cost of the cart. If the order has been purchased, returns total of all purchased and not refunded items.
def total_cost(self): return sum(i.line_cost for i in self.orderitem_set.filter(status=self.status)) # pylint: disable=E1101
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_total_cost(self):\n total_cost = sum([item.quantity * item.product.price for item in self.orderitem_set.all()])\n return total_cost - total_cost * (self.discount / Decimal('100'))", "def get_total_price(self):\n return sum(Decimal(item[\"price\"]) * item[\"qty\"] for item in self.car...
[ "0.7591926", "0.7448113", "0.7356034", "0.7061043", "0.7052951", "0.6997924", "0.6948375", "0.6941635", "0.67957914", "0.6772559", "0.6727689", "0.6640529", "0.65943736", "0.6526761", "0.6509452", "0.643423", "0.6351423", "0.6330201", "0.63169664", "0.6285466", "0.6260375", ...
0.7039261
5
This is called on each item in a purchased order to generate receipt instructions. This should return a list of `ReceiptInstruction`s in HTML string Default implementation is to return an empty set
def generate_receipt_instructions(self): return self.pk_with_subclass, set([])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_receipt_instructions(self):\r\n instruction_set = set([]) # heh. not ia32 or alpha or sparc\r\n instruction_dict = {}\r\n order_items = OrderItem.objects.filter(order=self).select_subclasses()\r\n for item in order_items:\r\n item_pk_with_subclass, set_of_html =...
[ "0.7299013", "0.6180348", "0.5956724", "0.556433", "0.5525899", "0.551104", "0.54994094", "0.52535695", "0.518073", "0.51657504", "0.51160586", "0.5102118", "0.508872", "0.50636494", "0.5001514", "0.49311066", "0.49265817", "0.49100325", "0.49065134", "0.49057338", "0.4850279...
0.64888245
1
Individual instructions for this order item. Currently, only used for emails.
def additional_instruction_text(self): return ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def payment_instructions_email_notification(sender, **kwargs):\n subject_template_name = \\\n 'shop_simplenotifications/payment_instructions_subject.txt'\n body_text_template_name = \\\n 'shop_simplenotifications/payment_instructions_body.txt'\n body_html_template_name = \\\n ...
[ "0.6496379", "0.6359569", "0.6101439", "0.5710146", "0.5531663", "0.5513537", "0.5508521", "0.55007744", "0.54983526", "0.54732394", "0.5458282", "0.5454725", "0.5418465", "0.5409941", "0.5403464", "0.5289292", "0.5275741", "0.52719814", "0.52366364", "0.52291566", "0.5217176...
0.530039
15
Returns a Decimal indicating the total sum of field_to_aggregate for all verified certificates with a particular status.
def verified_certificates_monetary_field_sum(cls, course_id, status, field_to_aggregate): query = use_read_replica_if_available( CertificateItem.objects.filter(course_id=course_id, mode='verified', status=status)).aggregate(Sum(field_to_aggregate))[field_to_aggregate + '__sum'] if query i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def total(self):\n return sum(self.d.values())", "def total(self):\n total = sum(self.d.values())\n return total", "def get_amount_total(self, status_in=None):\n\n if self.amount_asked == 0:\n # No money asked, return 0\n return 0\n\n donations = self.do...
[ "0.5705002", "0.57005703", "0.5563251", "0.5551011", "0.55076605", "0.5500678", "0.5472538", "0.5461857", "0.5445194", "0.5427406", "0.540702", "0.5406389", "0.5394715", "0.53592676", "0.5325043", "0.52847654", "0.52838236", "0.5269062", "0.5269062", "0.5264054", "0.52239347"...
0.80775017
0
Tests when request.user is anonymous
def test_anonymous_user(self): self.request.user = AnonymousUser() context = user_has_cart_context_processor(self.request) self.assertFalse(context['display_shopping_cart'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_anonymous():\n return False", "def is_anonymous(self):\n return False", "def is_anonymous(self):\n return False", "def is_anonymous(self):\n return False", "def is_anonymous(self):\n return False", "def is_anonymous(self):\n return False", "def is_anonym...
[ "0.7923685", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086", "0.76446086",...
0.738461
26
Gets date from the date input string. Lets the ValueError raised by invalid strings be processed by the caller
def _get_date_from_str(date_input): return datetime.datetime.strptime(date_input.strip(), "%Y-%m-%d").replace(tzinfo=pytz.UTC)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_date(string):\n try:\n return _date.fromordinal(_dateparse(string).toordinal())\n except ValueError:\n print(string)\n raise", "def get_date(string):\r\n string = re.sub(' +', ' ', string)\r\n try:\r\n return dateutil.parser.parse(string)\r\n except (TypeError,...
[ "0.8449815", "0.82806003", "0.76503235", "0.76054347", "0.7600885", "0.75827515", "0.7554315", "0.75491595", "0.7537543", "0.75221276", "0.7476491", "0.742677", "0.7392624", "0.7373445", "0.7355658", "0.7335214", "0.7332161", "0.7301806", "0.729752", "0.7278864", "0.72500086"...
0.7572758
6
Make a course with an enrolled loggedin student.
def make_course(self, **kwargs): self.course = CourseFactory.create(**kwargs) user = UserFactory.create() CourseEnrollmentFactory.create(user=user, course_id=self.course.id) self.client.login(username=user.username, password='test')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _enroll_students_in_course(self, course_id, num_students):\r\n\r\n for _ in range(num_students):\r\n random_id = uuid4().hex[:8]\r\n self.create_student(username='student{0}'.format(random_id))", "def make_instructor(course, user_email):\r\n CourseStaffRole(course.id).add_user...
[ "0.6796461", "0.6735769", "0.6447574", "0.6361991", "0.62330806", "0.6229796", "0.6222386", "0.6109277", "0.6096426", "0.60927624", "0.60905296", "0.60611725", "0.5981217", "0.5970277", "0.594234", "0.59390914", "0.59236777", "0.5898158", "0.5880509", "0.5874405", "0.5874024"...
0.71020615
0
Returns the earliest allowed date given the settings
def _earliest_allowed_date(cls): DAYS_GOOD_FOR = settings.VERIFY_STUDENT["DAYS_GOOD_FOR"] allowed_date = ( datetime.now(pytz.UTC) - timedelta(days=DAYS_GOOD_FOR) ) return allowed_date
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_min_date(self):\n\n to_datetime = lambda x: datetime.datetime.strptime(x, \"%Y-%m-%dT%H:%M:%S\")\n all_dates = [to_datetime(event['start']['dateTime'][:-2]) for event in self.formatted_events]\n self.min_date = min(all_dates).isoformat() + 'Z'", "def EarliestDate(self, default=None)...
[ "0.68468267", "0.6650262", "0.64732134", "0.63508254", "0.62767076", "0.60864097", "0.592203", "0.5917619", "0.5834462", "0.57954395", "0.5755648", "0.57552457", "0.57447207", "0.572836", "0.5725991", "0.5725991", "0.57241", "0.5711439", "0.5711439", "0.56884533", "0.5674032"...
0.7683548
0
Return whether or not a user has satisfactorily proved their identity. Depending on the policy, this can expire after some period of time, so a user might have to renew periodically. If window=None, then this will check for the user's initial verification. If window is set to anything else, it will check for the reveri...
def user_is_verified(cls, user, earliest_allowed_date=None, window=None): return cls.objects.filter( user=user, status="approved", created_at__gte=(earliest_allowed_date or cls._earliest_allowed_date()), window=window )....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_is_reverified_for_all(cls, course_id, user):\r\n all_windows = MidcourseReverificationWindow.objects.filter(course_id=course_id)\r\n # if there are no windows for a course, then return True right off\r\n if (not all_windows.exists()):\r\n return True\r\n\r\n for wind...
[ "0.61679226", "0.58022946", "0.5570247", "0.5476613", "0.53044313", "0.5272967", "0.5216934", "0.51996803", "0.51518387", "0.5129546", "0.51214105", "0.51", "0.5098827", "0.5096458", "0.50818264", "0.50355756", "0.5032734", "0.5023336", "0.5011437", "0.500395", "0.49993813", ...
0.61305
1
Return whether the user has a complete verification attempt that is or might be good. This means that it's approved, been submitted, or would have been submitted but had an nonuser error when it was being submitted. It's basically any situation in which the user has signed off on the contents of the attempt, and we hav...
def user_has_valid_or_pending(cls, user, earliest_allowed_date=None, window=None): valid_statuses = ['submitted', 'approved'] if not window: valid_statuses.append('must_retry') return cls.objects.filter( user=user, status__in=valid_statuses, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def user_is_reverified_for_all(cls, course_id, user):\r\n all_windows = MidcourseReverificationWindow.objects.filter(course_id=course_id)\r\n # if there are no windows for a course, then return True right off\r\n if (not all_windows.exists()):\r\n return True\r\n\r\n for wind...
[ "0.6374043", "0.5945802", "0.5845985", "0.5834968", "0.5758649", "0.5753475", "0.56104064", "0.55671126", "0.5530573", "0.5510684", "0.5476002", "0.54675895", "0.54385823", "0.5434844", "0.54216486", "0.5367905", "0.5363408", "0.5352211", "0.534659", "0.5323862", "0.531379", ...
0.52880466
21
We dynamically generate this, since we want it the expiration clock to start when the message is created, not when the record is created.
def image_url(self, name): s3_key = self._generate_s3_key(name) return s3_key.generate_url(self.IMAGE_LINK_DURATION)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __create_periodic_id() -> str:\n now = datetime.now()\n return now.strftime(\"%m%d%Y%H%M%S%f\")", "def default_nonce_duration():\n return now() + timedelta(hours=4)", "def _get_expiration(self, expiration_seconds):\n timestamp = time.time()\n if self.nbf:\n timesta...
[ "0.63432837", "0.6188565", "0.61277246", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863", "0.61187863",...
0.0
-1
Returns a (message, signature) pair.
def generate_signed_message(method, headers_dict, body_dict, access_key, secret_key): message = signing_format_message(method, headers_dict, body_dict) # hmac needs a byte string for it's starting key, can't be unicode. hashed = hmac.new(secret_key.encode('utf-8'), message, sha256) signature = bin...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_signature(self, message):\n signature = calc_signature(message, self.negotiate_flags,\n self.outgoing_signing_key,\n self.outgoing_seq_num, self.outgoing_handle)\n self.outgoing_seq_num += 1\n\n return signature.get_da...
[ "0.69328547", "0.6875788", "0.67261523", "0.6641716", "0.654831", "0.64438194", "0.6381863", "0.636468", "0.61872125", "0.6179429", "0.6133339", "0.6131305", "0.61154884", "0.6094848", "0.60602313", "0.60468835", "0.5998134", "0.597583", "0.59702283", "0.5955403", "0.5955403"...
0.6348616
8
Return a canonical string representation of the body of a JSON request or response. This canonical representation will be used as an input to the hashing used to generate a signature.
def body_string(body_dict, prefix=""): body_list = [] for key, value in sorted(body_dict.items()): if isinstance(value, (list, tuple)): for i, arr in enumerate(value): if isinstance(arr, dict): body_list.append(body_string(arr, u"{}.{}.".format(key, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def canonical(_signed: Json) -> bytes:\n return encode_canonical(_signed).encode(\"utf-8\")", "def json_bytes_signed_canonical(request) -> bytes:\n return get_test_data(request, __name__, \"config_signed_canonical.json\")", "def get_body_encoded(self):\r\n return self.encode(self.get_body())", "...
[ "0.64851564", "0.64305073", "0.63884443", "0.63317037", "0.62814695", "0.6263795", "0.62118083", "0.60983294", "0.58452034", "0.5830343", "0.58282983", "0.5760582", "0.57008636", "0.56922144", "0.5651879", "0.56438905", "0.5634697", "0.55728424", "0.55456954", "0.54639137", "...
0.54094017
22
Mocks our interface when we post to Software Secure. Does basic assertions on the fields we send over to make sure we're not missing headers or giving total garbage.
def mock_software_secure_post(url, headers=None, data=None, **kwargs): data_dict = json.loads(data) # Basic sanity checking on the keys EXPECTED_KEYS = [ "EdX-ID", "ExpectedName", "PhotoID", "PhotoIDKey", "SendResponseTo", "UserPhoto", "UserPhotoKey", ] for key in EXPECTED_K...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_posthardwares(self):\n pass", "def test_post(self):\n return self.doRequest(self.url, method=\"POST\", body=self.input)", "def test_smoker_post(self):\n pass", "def test_post_method(self):\n self.getPage('/', method='POST')\n self.assertStatus('200 OK')\n se...
[ "0.67868197", "0.6662738", "0.6363582", "0.6278706", "0.6215255", "0.6186413", "0.6132883", "0.6101543", "0.60560906", "0.6046275", "0.6010708", "0.5948403", "0.59463745", "0.59409714", "0.5921196", "0.59193605", "0.59090036", "0.59058946", "0.58999574", "0.58999527", "0.5896...
0.6790272
0
Returns a list of tags to be used when recording metrics about this model. Each field named in ``self.metric_tag_fields`` is used as a tag value, under the key ``.``. The tag model_class is used to record the class name of the model.
def _metric_tags(self): tags = [ u'{}.{}:{}'.format(self.__class__.__name__, attr, self[attr]) for attr in self.metric_tag_fields if attr in self.attributes ] tags.append(u'model_class:{}'.format(self.__class__.__name__)) return tags
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _model_tags(kwargs, key):\r\n if key not in kwargs:\r\n return []\r\n\r\n instance = kwargs[key]\r\n tags = [\r\n u'{}.{}:{}'.format(key, attr, getattr(instance, attr))\r\n for attr in getattr(instance, 'MODEL_TAGS', [])\r\n ]\r\n tags.append(u'model_class:{}'.format(instanc...
[ "0.69428706", "0.63780844", "0.63172203", "0.6283918", "0.62662905", "0.62333345", "0.62113625", "0.6201754", "0.61887705", "0.6149658", "0.60473865", "0.60473865", "0.60473865", "0.60473865", "0.60473865", "0.60473865", "0.60473865", "0.60473865", "0.602904", "0.60115695", "...
0.8656133
0
Test that any template directories added are not cleared when microsites are enabled.
def test_add_lookup_to_main(self): add_lookup('main', 'external_module', __name__) directories = LOOKUP['main'].directories self.assertEqual(len([dir for dir in directories if 'external_module' in dir]), 1) # This should not clear the directories list startup.enable_micr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_nothing_to_do(self):\n self.assertEqual(\n list(\n template_finder.templates_for_engine({\n 'BACKEND': 'django.templates.backends.jinja2.Jinja2',\n 'APP_DIRS': False,\n 'DIRS': []\n })\n ),\...
[ "0.71455675", "0.685664", "0.6701827", "0.65415615", "0.64797086", "0.64574105", "0.63358957", "0.632496", "0.6290378", "0.62421703", "0.620422", "0.6203438", "0.61802316", "0.61779976", "0.6139001", "0.60872376", "0.6074142", "0.60721785", "0.6066129", "0.60603505", "0.60466...
0.0
-1
Find the full path where we only have a relative path from somewhere in the tree.
def find_full_path(path_to_file): for subdir, dirs, files in os.walk("."): full = os.path.relpath(os.path.join(subdir, path_to_file)) if os.path.exists(full): return full
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_relative_path(path: str):\n return os.path.relpath(path, get_project_root())", "def get_relative_path(path):\r\n components = split_all(path)\r\n if len(components) <= 1:\r\n return os.curdir\r\n else:\r\n parents = [os.pardir] * (len(components) - 1)\r\n return os.path.j...
[ "0.73987085", "0.718169", "0.71174496", "0.71128243", "0.71045965", "0.7103729", "0.69916934", "0.69544184", "0.69524413", "0.6879394", "0.68687284", "0.68513036", "0.6783289", "0.67756116", "0.6726694", "0.6716709", "0.67023325", "0.669447", "0.6685958", "0.66793376", "0.667...
0.7174663
2
Transformer Positionwise feedforward layer Linear > LayerNorm > ReLU > Linear
def __init__(self, d_model: int, d_ff: int, dropout: float = 0.1, gelu=False): super(PositionwiseFF, self).__init__() self.ff1 = nn.Linear(d_model, d_ff) self.ff2 = nn.Linear(d_ff, d_model) self.drop = nn.Dropout(dropout) self.activation = nn.ReLU() if not gelu else nn.GELU()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def forward(self, x):\r\n y = self.en_fc1(x)\r\n y = F.relu(y)\r\n y = self.en_fc2(y)\r\n y = F.relu(y)\r\n y = self.en_fc3(y)\r\n y = F.relu(y)\r\n\r\n mean = self.en_mu(y)\r\n stddev_p = self.en_log(y)\r\n \r\n n = x.shape[0]\r\n z = to...
[ "0.6735191", "0.66128975", "0.6596757", "0.64257777", "0.64192736", "0.6406104", "0.6381359", "0.62900966", "0.62851137", "0.62843585", "0.6284113", "0.6280609", "0.6273557", "0.6272971", "0.62656444", "0.6264572", "0.62473524", "0.62233007", "0.6217012", "0.620232", "0.61818...
0.0
-1
Recall metric. Only computes a batchwise average of recall. Computes the recall, a metric for multilabel classification of how many relevant items are selected.
def recall(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) possible_positives = K.sum(K.round(K.clip(y_true, 0, 1))) recall = true_positives / (possible_positives + K.epsilon()) return recall
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recall(y_true, y_pred, average, labels):\n\n y_true, y_pred = check_metric_args(y_true, y_pred, average, labels)\n\n result = None\n\n m = len(y_true)\n n = len(labels)\n\n confusion_matrix = get_confusion_matrix(y_true, y_pred, labels).T\n\n if average == \"micro\":\n numerator = np.t...
[ "0.7605139", "0.7447918", "0.74042726", "0.72813445", "0.7209321", "0.71659344", "0.7157751", "0.7145294", "0.7145294", "0.7145294", "0.7145294", "0.7145294", "0.7145294", "0.7131868", "0.71009445", "0.7066122", "0.7064758", "0.7062941", "0.7062941", "0.7062941", "0.7062941",...
0.70971656
26
Precision metric. Only computes a batchwise average of precision. Computes the precision, a metric for multilabel classification of how many selected items are relevant.
def precision(y_true, y_pred): true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1))) predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1))) precision = true_positives / (predicted_positives + K.epsilon()) return precision
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def precision(self):\n self.overall_precision = precision_score(\n self.y_true, self.y_pred, average = self.average_type).round(self.digits_count_fp)\n self.classes_precision = precision_score(\n self.y_true, self.y_pred, average = None).round(self.digits_count_fp)", "def comp...
[ "0.74892753", "0.72888154", "0.7159203", "0.7152673", "0.7065861", "0.6985656", "0.6965553", "0.69546396", "0.69123477", "0.6835058", "0.68175006", "0.68092614", "0.68046975", "0.68046975", "0.68046975", "0.68046975", "0.68046975", "0.68046975", "0.67853945", "0.6757285", "0....
0.6754717
37
Redirect all 404's back to index.
def error_redirect(err): error = err return render_template('error.html', title='That doesn\'t exist!', error=error)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redir_index():\n return redirect(url_for(\"index\"), code=301)", "def index_route(self, request, *args, **kwargs):\n raise Http404()", "def handler404(request):\n response = render_to_response('404.html', {})\n response.status_code = 404 # Other errors can be similarly configured\n retu...
[ "0.72915065", "0.6961599", "0.6768519", "0.6732918", "0.66903865", "0.6627663", "0.6602853", "0.65982217", "0.6560572", "0.6506695", "0.65051603", "0.6485597", "0.6483828", "0.64766526", "0.6458036", "0.64454263", "0.64454263", "0.6444101", "0.643362", "0.64002496", "0.639115...
0.5702177
97
Redirect all 404's back to index.
def error_redirect1(err): error = err return render_template('error.html', title='Something went wrong!', error=error)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def redir_index():\n return redirect(url_for(\"index\"), code=301)", "def index_route(self, request, *args, **kwargs):\n raise Http404()", "def handler404(request):\n response = render_to_response('404.html', {})\n response.status_code = 404 # Other errors can be similarly configured\n retu...
[ "0.72927064", "0.69612926", "0.6767013", "0.6734605", "0.66891044", "0.66262126", "0.66021824", "0.6596294", "0.6559022", "0.6505608", "0.6503716", "0.6484068", "0.6482078", "0.64759713", "0.6457048", "0.6444384", "0.6444384", "0.6443046", "0.6432565", "0.6398894", "0.6389968...
0.0
-1
Sets 32bit Register at address to its current value AND mask.
def _andReg(address, mask): _setReg(address, _getReg(address)&mask)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AND(self, value):\n self.reg.A = self.reg.A & value\n self.reg.Z = self.reg.A == 0\n self.reg.N = self.reg.A >> 7", "def StoreBits32(self, val):\n tmp_val = struct.pack(\">L\", val)\n self.StoreBits( (StrToList(tmp_val), 32))", "def _orReg(address, mask):\n _setReg(address, _g...
[ "0.6218239", "0.6178094", "0.6145405", "0.604082", "0.6011764", "0.597896", "0.5920385", "0.5842555", "0.5815956", "0.5442112", "0.54379654", "0.5405124", "0.5378268", "0.5316772", "0.5316483", "0.5306635", "0.5291436", "0.52633566", "0.52633566", "0.52633566", "0.52633566", ...
0.75926846
0
Sets 32bit Register at address to its current value OR mask.
def _orReg(address, mask): _setReg(address, _getReg(address)|mask)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _andReg(address, mask):\n _setReg(address, _getReg(address)&mask)", "def mask_write_holding_register(self, addr, and_mask, or_mask):\r\n return self._arm.mask_write_holding_register(addr, and_mask, or_mask)", "def _xorReg(address, mask):\n _setReg(address, _getReg(address)^mask)", "def write...
[ "0.661059", "0.6510427", "0.62442124", "0.61368185", "0.6031873", "0.5974622", "0.57189107", "0.5696905", "0.5660869", "0.5594645", "0.5528746", "0.5500725", "0.5496436", "0.5435099", "0.5426017", "0.5336081", "0.5313084", "0.5293482", "0.52715623", "0.52532643", "0.52274793"...
0.723622
0
Returns the WordCloudExample HTML file as First page.
def hello_world(): return send_from_directory('../templates/','WordCloudExample.html')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_main_page(self):\n if OPENFDA_BASIC:\n with open(\"openfda_basic.html\") as html_file:\n html = html_file.read()\n else:\n with open(\"openfda.html\") as html_file:\n html = html_file.read()\n\n return html", "def create_page():\n ...
[ "0.6393573", "0.59574986", "0.5939777", "0.57960767", "0.5787789", "0.57830226", "0.5774106", "0.57696897", "0.5755559", "0.57261825", "0.56939834", "0.5679388", "0.56758684", "0.56516945", "0.5581753", "0.5571499", "0.5556872", "0.55491525", "0.553583", "0.5522415", "0.55205...
0.6254095
1
Gets rid of white spaces in the string
def clean_white_spaces(string): try: # in case it is in byte value string = string.decode('utf-8') except: pass res = '' words = string.split() for word in words: res = res + str(word) return res
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _clean(self, string):\n return re.sub('\\s+', ' ', string).strip()", "def strip_space(string):\n return string.replace(' ', '')", "def _removeWhitespaces(self, s):\n return s.translate({ord(c): None for c in string.whitespace})", "def _clean(s):\n return re.sub(r'\\s+', ' ', s.strip()...
[ "0.8461944", "0.83643025", "0.8285029", "0.81550986", "0.8130436", "0.81294054", "0.80921954", "0.80311143", "0.80099595", "0.8004847", "0.789648", "0.788229", "0.78779185", "0.78217655", "0.7780404", "0.7780404", "0.7741662", "0.7732168", "0.77244365", "0.7719778", "0.768139...
0.74174553
34
set up the age of the SNR
def set_age(self, age): self.age = float(age)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increase_age(self,s):\n self.age += 1\n self.days = 0\n if self.age >= 35 and self.sexual_activity == 1:\n self.sexual_activity = 0\n s.high_sexual_activity.remove(self.identifier)\n \n #exclude age == 65; they will be replaced next timestep\n if ...
[ "0.6779851", "0.6555387", "0.6551954", "0.65393966", "0.64863384", "0.64863384", "0.64759344", "0.6471183", "0.6438864", "0.63680434", "0.63438296", "0.62973636", "0.628602", "0.6239691", "0.6216694", "0.6123595", "0.6067421", "0.59138006", "0.59138006", "0.59128416", "0.5903...
0.62841964
13
get the flux density [Jy]
def get_flux_density(self): if self.no_flux is False: return self.snu_at_1GHz else: return -1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def magnetic_flux_density(self, xyz):\n return self.mu * self.magnetic_field(xyz)", "def magnetic_flux_density(self, xyz):\n return self.mu * self.magnetic_field(xyz)", "def current_density(self, xyz):\n\n j = self.electric_field(xyz) / self.rho\n return j", "def density(self):\n ...
[ "0.6926476", "0.6926476", "0.6667997", "0.64086103", "0.6408508", "0.6395405", "0.63695216", "0.63695216", "0.6274421", "0.62743795", "0.6267669", "0.6265436", "0.6265436", "0.6265436", "0.6236846", "0.6227681", "0.61775833", "0.61490834", "0.6144082", "0.61405843", "0.613095...
0.7367613
0
Get the state of a system or device manager.
def getState(self, node, name=None): if name: info = self.getDevice(node, name) else: info = self.getNode(node, includeDevices=False) if info is None: self.log.error("could not get state because '%s%s' does not exist", node, "/" + name if name else "") ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_status(self):\n\n return self._system", "def get_state(self):\n\t\treturn call_sdk_function('PrlVmInfo_GetState', self.handle)", "def get_device_state(self):\n\t\treturn call_sdk_function('PrlSrvCfgDev_GetDeviceState', self.handle)", "def _check_status(self):\n self.system_status_lock.a...
[ "0.69382536", "0.6720774", "0.6601647", "0.64235556", "0.6415433", "0.6381158", "0.63278985", "0.6323413", "0.6314273", "0.62470645", "0.620131", "0.6181521", "0.6167063", "0.6156207", "0.60894835", "0.60710543", "0.6062", "0.60499316", "0.60459334", "0.603783", "0.60289824",...
0.6313068
9
Get node name of the active system manager
def getSystemManagerNodeName(self): return self.resolveAlias("system-manager")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def nodeNames(self):\n if self.role == Roles.ACTIVE or self.role == Roles.PASSIVE:\n return Backend().configuration.getNodeNames()\n else:\n return [self.node, \"system-manager\"]", "def get_systemname(self) -> str:\n\n return self.send(self.cmd.GET_SYSTEMNAME)", "def...
[ "0.7169453", "0.7153669", "0.7056501", "0.7014763", "0.6929623", "0.6929623", "0.66431314", "0.65186805", "0.647011", "0.64472264", "0.6386227", "0.6386217", "0.63397", "0.63397", "0.6314814", "0.63140166", "0.6312605", "0.6288193", "0.6288151", "0.62700975", "0.62196714", ...
0.862772
0
Get the target state of a node or device manager.
def getTargetState(self, node, name=None): return self.getProperty(node, name, "targetState")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getState(self, node, name=None):\n if name:\n info = self.getDevice(node, name)\n else:\n info = self.getNode(node, includeDevices=False)\n if info is None:\n self.log.error(\"could not get state because '%s%s' does not exist\", node, \"/\" + name if name e...
[ "0.67073286", "0.636545", "0.62677693", "0.6227858", "0.61815363", "0.6134403", "0.6080721", "0.6073023", "0.60675305", "0.60612214", "0.6000093", "0.5997831", "0.5978507", "0.5961503", "0.5959053", "0.5942982", "0.5942982", "0.5936118", "0.5932551", "0.59243435", "0.59243435...
0.8004959
0
Check if a map contains the operating point in Point. Return true if it does.
def chcek_exist(df, Point): exist = (df.OperatingPoint == Point) exist = exist.sum() if exist == 0: return False else: return True
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_point_in(self, point):\n return (self.upperleft[0] <= point[0] <= self.upperright[0] and self.upperleft[1] <= point[1] <= self.bottomleft[1])", "def is_point_in(self, point):\n return (self.upperleft[0] <= point[0] <= self.upperright[0] and self.upperleft[1] <= point[1] <= self.bottomleft[1]...
[ "0.7002525", "0.7002525", "0.69642365", "0.6867689", "0.68494034", "0.6799356", "0.67858833", "0.67801744", "0.6764194", "0.6760928", "0.67540145", "0.67071027", "0.66901827", "0.66654634", "0.6591006", "0.658441", "0.6519512", "0.6518316", "0.64951074", "0.6448482", "0.64255...
0.6165376
44
Returns maximum distance from model root body to any radial point of the model. Helps us put models programmatically without them flying away due to a huge initial contact force. Must be defined by subclass.
def horizontal_radius(self): raise NotImplementedError
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def radius(self):\n c = self.centroid()\n dmax = -np.inf\n for vertex in self.path.vertices:\n d = np.linalg.norm(vertex - c)\n if d > dmax:\n dmax = d\n return d", "def _get_max_rupture_projection_radius(self):\n if self.max_radius: # alre...
[ "0.6269141", "0.60971344", "0.60292387", "0.5935078", "0.57182455", "0.569411", "0.5625765", "0.5624292", "0.5598283", "0.55874425", "0.5579753", "0.55528295", "0.55412287", "0.55264217", "0.5512764", "0.5474461", "0.5459132", "0.5451573", "0.54471385", "0.54331595", "0.54286...
0.0
-1
Exclude all shared materials and their associated names from being prefixed.
def exclude_from_prefixing(self, inp): # Automatically return False if this is not of type "str" if type(inp) is not str: return False # Only return True if the string matches the name of a common material return True if inp in self.shared_materials or inp in self.shared_text...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exclude_from_prefixing(self, inp):\n raise NotImplementedError", "def _mine_and_mine_only(self):\n self.my_name = self.my_name + \"internal_only\"\n return self.my_name", "def ignore_shift(self, name: str, scope: str = \"global\") -> None:\n for producer in self.producers[scope]...
[ "0.5734337", "0.55874205", "0.5545257", "0.541644", "0.53634715", "0.5321092", "0.5208589", "0.520008", "0.5197312", "0.518341", "0.5178467", "0.51196426", "0.50862026", "0.50827384", "0.5051099", "0.50492746", "0.5024831", "0.5004887", "0.5003429", "0.5001554", "0.4989821", ...
0.68964094
0
Convert a list of breaks into color stops using colors from colorBrewer see for a list of color options to pass
def create_color_stops(breaks, colors='RdYlGn', color_ramps=color_ramps): num_breaks = len(breaks) if colors not in color_ramps.keys(): raise ValueError('color does not exist in colorBrewer!') else: stops = [] try: ramp = color_ramps[colors][num_breaks] except Ke...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def split_colours(colours_list, colours_required):\n colour_range = spectra.range(colours_list, colours_required)\n return [colour.hexcode for colour in colour_range]", "def create_color_gradient():\n colors = []\n step = 10\n for red, green in zip(range(255,-step, -step), range(0, 255, step)):\n ...
[ "0.6407138", "0.63700545", "0.61385924", "0.6106763", "0.58567655", "0.5856366", "0.58235633", "0.5725703", "0.5700481", "0.5699615", "0.5697772", "0.55516046", "0.55107975", "0.5473857", "0.54645777", "0.5463048", "0.5462215", "0.54535705", "0.5406793", "0.53813434", "0.5337...
0.8064218
0
Compute the average precision, given the recall and precision curves.
def ap_per_class(tp, conf, pred_cls, target_cls, plot=False, save_dir='.', names=()): # Sort by objectness i = np.argsort(-conf) tp, conf, pred_cls = tp[i], conf[i], pred_cls[i] # Find unique classes unique_classes = np.unique(target_cls) nc = unique_classes.shape[0] # number of classes, numb...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_average_precision(precision, recall):\n # identical but faster version of new_precision[i] = old_precision[i:].max()\n precision = np.concatenate([[0.0], precision, [0.0]])\n for i in range(len(precision) - 1, 0, -1):\n precision[i - 1] = np.maximum(precision[i - 1], precision[i])\n\n ...
[ "0.8369102", "0.8134599", "0.7751303", "0.77249914", "0.77176386", "0.76930445", "0.7691593", "0.7649439", "0.7649439", "0.76263905", "0.7558535", "0.7536666", "0.7476259", "0.7272741", "0.7250122", "0.72290015", "0.72106946", "0.71999353", "0.7183111", "0.7161319", "0.712975...
0.0
-1
Compute the average precision, given the recall and precision curves Arguments
def compute_ap(recall, precision): # Append sentinel values to beginning and end mrec = np.concatenate(([0.], recall, [recall[-1] + 0.01])) mpre = np.concatenate(([1.], precision, [0.])) # Compute the precision envelope mpre = np.flip(np.maximum.accumulate(np.flip(mpre))) # Integrate area und...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_average_precision(precision, recall):\n # identical but faster version of new_precision[i] = old_precision[i:].max()\n precision = np.concatenate([[0.0], precision, [0.0]])\n for i in range(len(precision) - 1, 0, -1):\n precision[i - 1] = np.maximum(precision[i - 1], precision[i])\n\n ...
[ "0.7998209", "0.7814368", "0.7661775", "0.7579263", "0.7565002", "0.75568396", "0.7521316", "0.7521316", "0.7513875", "0.7445203", "0.7427849", "0.7369071", "0.72841954", "0.7088598", "0.7048953", "0.69920945", "0.69428986", "0.693964", "0.6881087", "0.687361", "0.68703425", ...
0.75236815
6
computes total mass of protein string
def compute_ps_mass(ps): return sum(AA_mass_table[it] for it in ps)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def calculate_protein_mass(protein: str):\n result = 0\n for p in protein:\n result += monoisotopic_mass_table[p]\n return result", "def compute_protien_mass(protien_string):\r\n\r\n p={'A':'71.03711','C':'103.00919','D':'115.02694','E':'129.04259','F':'147.06841','G':'57.02146','H':'137.05891...
[ "0.8527499", "0.7814632", "0.71131325", "0.6895967", "0.6567382", "0.64781564", "0.64781564", "0.64417624", "0.6438086", "0.6416438", "0.6408489", "0.63897187", "0.63688815", "0.63340926", "0.6307983", "0.63003814", "0.62859464", "0.6201219", "0.61902165", "0.61716217", "0.61...
0.68054867
4
r"""Compute first K eigenvalues and eigenvectors for the input mesh.
def eigenpairs(pos:torch.Tensor, faces:torch.Tensor, K:int, double_precision:bool=False): if pos.shape[-1] != 3: raise ValueError("Vertices positions must have shape [n,3]") if faces.shape[-1] != 3: raise ValueError("Face indices must have shape [m,3]") n = pos.shape[0] device = pos...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def eigen_decomposition(self):\n w, V = linalg.eigh(self.K)\n c = w[::-1]\n if isinstance(self.num_xi, float):\n percent_energy = np.cumsum(c) / np.sum(c)\n self.num_xi = np.arange(c.shape[0])[percent_energy < self.num_xi][-1] # num_xi changes\n self.Lambda = w[::...
[ "0.67197657", "0.64468926", "0.6410238", "0.6403065", "0.6234247", "0.6233675", "0.6227761", "0.6221456", "0.62132734", "0.61754483", "0.61382437", "0.6093789", "0.6082508", "0.60816807", "0.606017", "0.6038999", "0.60159475", "0.60137403", "0.59930927", "0.5983795", "0.59654...
0.5637447
39
Get an abundance estimate for a specific molecule constrained by a starting composition.
def constrained_abundance_estimate(composition, formula): if isinstance(formula, pt.core.Element): return getattr(composition, str(formula.element), 0.0) elif isinstance(formula, pt.formulas.Formula): prod = 1.0 for a in formula.atoms.keys(): prod *= getattr(compositi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_reference_abundance(molecule, reference=\"Chondrite_PON\", unknown_val=1000):\r\n norm = get_reference_composition(reference).comp # in ppm\r\n abund = 10 ** 6 # 100%\r\n for iso in molecule.atoms.keys():\r\n el = get_element_name(iso)\r\n abund *= getattr(norm, el)\r\n if not n...
[ "0.6467673", "0.6355639", "0.5703614", "0.5620207", "0.5497103", "0.5466885", "0.5453627", "0.516978", "0.5150242", "0.51328117", "0.51144964", "0.5089101", "0.5055741", "0.5054814", "0.500796", "0.4966787", "0.49629903", "0.49479887", "0.49465194", "0.49420145", "0.4939658",...
0.743893
0
Returns Optional[Task] Return the next task from pending tasks.
def next(self) -> Optional[Task]: if len(self._pending_tasks) == 0: return None else: task = self._pending_tasks.pop(0) task.status = 'Running' self._dump_tasks_info() return task
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first(self) -> Task:\n return self._tasks[0]", "def _next(self):\n if self._queue_lock.acquire(False):\n raise AssertionError('Expected _queue_lock to be held here')\n\n queue_ids = list(self._queues.keys())\n if not queue_ids:\n raise StopIteration()\n\n ...
[ "0.6894754", "0.6737872", "0.63431937", "0.62931347", "0.61219484", "0.60873413", "0.6079237", "0.60312504", "0.60270953", "0.5975317", "0.5954035", "0.5914081", "0.5888238", "0.5881377", "0.58798057", "0.57916296", "0.5790562", "0.5744203", "0.5742638", "0.5730412", "0.57161...
0.8657597
0
Returns Optional[Tuple[int, Module, Dict[str, Dict[str, Tensor]], float, List[Dict]]] If self._best_task_id is not None, return best task id, best compact model, masks on the compact model, score, config list used in this task.
def get_best_result(self) -> Optional[Tuple[int, Module, Dict[str, Dict[str, Tensor]], float, List[Dict]]]: if self._best_task_id is not None: compact_model = torch.load(Path(self._log_dir_root, 'best_result', 'model.pth')) compact_model_masks = torch.load(Path(self._log_dir_root, 'best_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_known_model(self) -> Tuple[Optional[Path], int]:\n return self._get_first_model(sort='total_score', desc=False)", "def get_best_model(self):\n return self.best_model", "def load_best_model(self) -> Optional[nn.Module]:\n if self.save_best_model:\n return torch.load(...
[ "0.60978276", "0.5686422", "0.5641088", "0.5608317", "0.54577166", "0.5396419", "0.5324968", "0.5258665", "0.5226702", "0.50803006", "0.50573176", "0.5056448", "0.5051767", "0.49857846", "0.49674678", "0.49573007", "0.49454924", "0.49398708", "0.49235117", "0.49194413", "0.49...
0.7922498
0
Run registered sideeffects functions, or suppress as appropriate. If TEST_MODE is on, or the _suppress attr is True, then the sideeffects are not run, but the `suppressed_side_effect` signal is sent this is primarily used by the disable_side_effects context manager to register which sideeffects events were suppressed (...
def run_side_effects( self, label: str, *args: Any, return_value: Any | None = None, **kwargs: Any ) -> None: # TODO: this is all becoming over-complex - need to simplify this self.try_bind_all(label, *args, return_value=return_value, **kwargs) if self.is_suppressed: self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def run_side_effects(self, label, *args, **kwargs):\n if self._suppress or settings.TEST_MODE:\n self.suppressed_side_effect.send(Registry, label=label)\n else:\n self._run_side_effects(label, *args, **kwargs)", "def run_side_effects(label, *args, **kwargs):\n _registry.run...
[ "0.77596134", "0.62188977", "0.57858396", "0.54831564", "0.54831564", "0.54623073", "0.5333266", "0.5331853", "0.51878864", "0.51855046", "0.5176331", "0.51709163", "0.51554793", "0.51375425", "0.5098361", "0.50622994", "0.5054258", "0.50185883", "0.4965279", "0.4947686", "0....
0.6697634
1
Calling the equal method of individual class
def is_equal(self, a, b): return a.X[0] == b.X[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, *args):\r\n pass", "def __eq__(self, *args):\r\n pass", "def __eq__(self, *args):\r\n pass", "def __eq__(self, *args):\r\n pass", "def __eq__(self, *args):\r\n pass", "def __eq__(self, *args):\r\n pass", "def __eq__(self, *args):\r\n pas...
[ "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.78128225", "0.7749571", "0.7749571", "0.7749571", "0.7749571", "0.7749571", "0.7749571", "0.7749571", "0.7749571", "0.7749571", "0.77...
0.0
-1
SetRed(self, unsigned char red)
def SetRed(self, *args): return _itkRGBAPixelPython.itkRGBAPixelUC_SetRed(self, *args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetRed(self, *args):\n return _itkRGBAPixelPython.itkRGBAPixelUS_SetRed(self, *args)", "def set_color(self, color):\n\t\tpass", "def set_color(self, color):\n pass", "def set_color(self, new_color):\n self.color = new_color", "def setColour(self, col):\n\t\tself.colour = col", ...
[ "0.75813806", "0.7536735", "0.7344114", "0.7184503", "0.70742196", "0.70552737", "0.6992874", "0.6924945", "0.6920068", "0.6835013", "0.67964596", "0.6759402", "0.6713185", "0.6699522", "0.6684791", "0.66464853", "0.66419274", "0.6618542", "0.6601625", "0.6579732", "0.6528085...
0.7515455
2
SetAlpha(self, unsigned char alpha)
def SetAlpha(self, *args): return _itkRGBAPixelPython.itkRGBAPixelUC_SetAlpha(self, *args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_alpha(self, alpha=1.0):\r\n self.unif[17] = alpha", "def set_alpha(self, alpha):\n if alpha < 0 or alpha > 255:\n raise ValueError(\"alpha must be betweeen 0 and 255\")\n\n self.alpha = alpha\n self.draw_alpha()", "def Alpha(self, alpha):\r\n if alpha >= 0 and ...
[ "0.8624867", "0.8498782", "0.7913778", "0.7662783", "0.76120174", "0.7318815", "0.7282577", "0.72586536", "0.719182", "0.71140647", "0.69426155", "0.6747364", "0.6728293", "0.67148745", "0.66524816", "0.6627103", "0.6569059", "0.6569059", "0.6558669", "0.65446573", "0.6544612...
0.7531966
5
GetGreen(self) > unsigned char
def GetGreen(self): return _itkRGBAPixelPython.itkRGBAPixelUC_GetGreen(self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetGreen(self):\n return _itkRGBAPixelPython.itkRGBAPixelUS_GetGreen(self)", "def green(self) -> float:\n return self._green", "def _get_red(self):\n return self.__red", "def _get_red(self):\n return self.__red", "def _get_red(self):\n return self.__red", "def get_green(self, x...
[ "0.7757071", "0.6997148", "0.66741973", "0.66741973", "0.66741973", "0.6579547", "0.65188175", "0.64474165", "0.6405906", "0.63860404", "0.63859606", "0.63859606", "0.63859606", "0.63859606", "0.6360879", "0.6310414", "0.6310081", "0.6303455", "0.62977844", "0.62881804", "0.6...
0.7807268
0
GetAlpha(self) > unsigned char
def GetAlpha(self): return _itkRGBAPixelPython.itkRGBAPixelUC_GetAlpha(self)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def alpha(self):\r\n return self.unif[17]", "def Alpha(self):\r\n return self._alpha", "def alpha(self):\n return self._alpha", "def alpha(self):\n return self._alpha", "def alpha(self):\n return self._alpha", "def GetAlpha(self):\n return _itkRGBAPixelPython.itkRGBA...
[ "0.77711654", "0.7648692", "0.7561222", "0.7561222", "0.7561222", "0.7325783", "0.7294006", "0.7085725", "0.7085725", "0.7085725", "0.70076334", "0.68817025", "0.686803", "0.6830011", "0.6587833", "0.6570612", "0.65030503", "0.6472681", "0.64357424", "0.64217657", "0.6410446"...
0.73160714
6
SetRed(self, unsigned short red)
def SetRed(self, *args): return _itkRGBAPixelPython.itkRGBAPixelUS_SetRed(self, *args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def SetRed(self, *args):\n return _itkRGBAPixelPython.itkRGBAPixelUC_SetRed(self, *args)", "def set_color(self, color):\n\t\tpass", "def set_red_light(self, value):\n self.diffuse_light[0] = value\n self.redraw()", "def set_color(self, color):\n pass", "def set_red(self, x, y, n...
[ "0.7172088", "0.6978187", "0.69523084", "0.6836532", "0.6752291", "0.6691894", "0.6600353", "0.6582643", "0.6579854", "0.65559113", "0.6452694", "0.64251447", "0.64027774", "0.64008504", "0.6364981", "0.63438857", "0.63438857", "0.63438857", "0.63438857", "0.63337183", "0.631...
0.7351484
0
SetAlpha(self, unsigned short alpha)
def SetAlpha(self, *args): return _itkRGBAPixelPython.itkRGBAPixelUS_SetAlpha(self, *args)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_alpha(self, alpha=1.0):\r\n self.unif[17] = alpha", "def set_alpha(self, alpha):\n if alpha < 0 or alpha > 255:\n raise ValueError(\"alpha must be betweeen 0 and 255\")\n\n self.alpha = alpha\n self.draw_alpha()", "def setAlpha ( self, newalpha ):\n if isinsta...
[ "0.8468083", "0.8247519", "0.77029246", "0.76867765", "0.731059", "0.72367746", "0.71374744", "0.7079116", "0.70613253", "0.680565", "0.6737243", "0.66448486", "0.6636099", "0.65424705", "0.65351564", "0.63638407", "0.63360435", "0.63360435", "0.6320243", "0.63141924", "0.630...
0.75407827
4
Partitions of maximal length d obtained by adding one box to alpha.
def box_added(alpha, d): for i, j in alpha.addable_cells(): if i < d: yield alpha.add_cell(i)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def draw_partition(x, alpha=1., d=0.):\n N = len(x)\n counts = draw_counts(N, alpha, d)\n return partition_from_counts(x, counts)", "def scale(self, alpha):\n\t\tc = SparseVector(self.d)\n\t\tfor i in self.st.keys():\n\t\t\tc.put(i, alpha*self.get(i))\n\t\treturn c", "def vec_scale (x, alpha):\n re...
[ "0.6375728", "0.53194374", "0.5272806", "0.5224247", "0.51456696", "0.50985205", "0.5094632", "0.50734544", "0.5028231", "0.5022217", "0.49939504", "0.49575457", "0.49399137", "0.49236852", "0.49144474", "0.48831764", "0.48796207", "0.4875385", "0.4864747", "0.4852798", "0.48...
0.62318295
1
In [CLM+18], we prove that F^std_d(N) = 1 c/N + o(1/N), where c = (d^2 1) / 4. Return the coefficient c.
def F_std_coeff(d): return (d ** 2 - 1) / 4
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def F_std(d, N):\n # memoize specht() and weyl() results (but only for current call)\n specht_mem, weyl_mem = memoize(specht), memoize(weyl)\n\n return sum(\n d ** (-N - 2)\n * sum(sqrt(specht_mem(mu) * weyl_mem(d, mu)) for mu in box_added(alpha, d)) ** 2\n for alpha in Partitions(n=N...
[ "0.6799228", "0.677994", "0.6686549", "0.66811514", "0.6469309", "0.6449495", "0.63842624", "0.6373738", "0.6367725", "0.61738074", "0.6154859", "0.6137632", "0.61302537", "0.60925955", "0.6025479", "0.6012864", "0.59758687", "0.59605235", "0.59530413", "0.5936472", "0.591500...
0.82082343
0
Returns Initializer object for random features.
def _get_random_features_initializer(initializer, shape): def _get_cauchy_samples(loc, scale, shape): probs = np.random.uniform(low=0., high=1., size=shape) return loc + scale * np.tan(np.pi * (probs - 0.5)) random_features_initializer = initializer if isinstance(initializer, six.string_types): if i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, n_features):\n self.W = np.random.randn(n_features)\n self.b = np.random.randn()", "def __init__(self, features=None):\n self.features = features", "def __init__(self):\n self.py = random.getstate()\n self.np = np.random.get_state()\n self.torch = to...
[ "0.65802395", "0.6515194", "0.6460532", "0.6398399", "0.6382705", "0.6305797", "0.62939703", "0.6184989", "0.6106009", "0.607909", "0.6076938", "0.60457796", "0.6036244", "0.602245", "0.600969", "0.6000016", "0.59779567", "0.59610957", "0.591976", "0.5912642", "0.5912126", ...
0.71402645
0
Constructor. Any message fields that are implicitly/explicitly set to None will be assigned a default value. The recommend use is keyword arguments as this is more robust to future message changes. You cannot mix inorder arguments and keyword arguments.
def __init__(self, *args, **kwds): if args or kwds: super(RobotDescription, self).__init__(*args, **kwds) #message fields cannot be None, assign default values for those that are if self.header is None: self.header = std_msgs.msg.Header() if self.robot_id is None: self.robot_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, *args, **kwds):\n if args or kwds:\n super(KomodoSpeechRecCommand, self).__init__(*args, **kwds)\n #message fields cannot be None, assign default values for those that are\n if self.header is None:\n self.header = std_msgs.msg.Header()\n if self.cmd is None:\n ...
[ "0.77939296", "0.7720264", "0.7720264", "0.76866186", "0.7626193", "0.756387", "0.74395823", "0.7416946", "0.73519075", "0.7308225", "0.72806025", "0.72379386", "0.72272825", "0.7224187", "0.7224187", "0.7218873", "0.7211484", "0.7211484", "0.7211484", "0.7211484", "0.7211484...
0.7200424
30
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`.
def plot_confusion_matrix(cm, classes=None, normalize=False, title='Fraud Confusion matrix', cmap=plt.cm.Blues): if classes is None: classes = ['Not Fraud', 'Fraud'] if normalize: cm = cm.astype('float') / cm.sum(axis=...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n...
[ "0.81920755", "0.8093736", "0.8028212", "0.8017333", "0.79923165", "0.7989431", "0.79789335", "0.7974398", "0.795948", "0.79555666", "0.7935652", "0.7932704", "0.7932632", "0.7929465", "0.7924336", "0.7922666", "0.79221356", "0.7921299", "0.79209703", "0.7920307", "0.7916008"...
0.0
-1
Identifies if news was already read
def was_read(link): return neg.find_one({'hash': get_hash(link)}) or pos.find_one({'hash': get_hash(link)}) \ or saved.find_one({'hash': get_hash(link)})
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_been_read(entry):\n if ARGV.get(DEBUG_OPT):\n err_print(READLIST)\n title = entry.title\n date = date_parser.parse(entry.updated)\n if str(date.timestamp()) + '|' + title in READLIST:\n return True\n return False", "def update_read(self, article):\n read_statistics = R...
[ "0.68708295", "0.68273175", "0.6606158", "0.62999636", "0.62620246", "0.62406355", "0.62107277", "0.61495423", "0.60827327", "0.59883356", "0.5900586", "0.5837851", "0.5820115", "0.57989013", "0.57280874", "0.57084185", "0.5643455", "0.5565291", "0.554228", "0.5541957", "0.55...
0.62176293
6
Initialise a pendulum with the given physical parameters and initial condition Starting angle and velocity in radians
def __init__( self, length: np.float64, mass: np.float64, starting_angle: np.float64, starting_angular_vely: np.float64, ): # Initialise physical params # There's only one for a 1d pendulum self._angular_freq = np.sqrt(mass * EARTH_GRAVITY / length) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def pendulum(pos):\n\n def x_dot(x, y):\n return y\n\n def y_dot(x, y):\n return -np.sin(x)\n\n return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])])", "def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulu...
[ "0.63931054", "0.6386793", "0.61375815", "0.5981282", "0.58934575", "0.5841456", "0.58352935", "0.57500523", "0.57010734", "0.5653845", "0.5650132", "0.5622449", "0.5612734", "0.5586467", "0.5586412", "0.5547694", "0.5532221", "0.55168724", "0.5509905", "0.5504314", "0.549022...
0.7574158
0
returns a string of the unixtime in human readable format from a unixtime. Includes microseconds
def get_humantime(unixtime): return str(pd.datetime.utcfromtimestamp(int(unixtime)/1000000.0))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unixTimeToString_NEW(ut):\n intTime = int(ut)\n frac = ut - intTime\n #print \"\\nfrac is %f, conv is %f\" % (frac, round(frac*1000))\n y, m, d, ho, mi, se, junk1, junk2, junk3 = gmtime(intTime)\n #print \"ut is %f, s is %4d_%02d_%02d_%02d_%02d_%02d.%03d\\n\" % (ut, y, m, d, ho, mi, se, int(frac...
[ "0.7332276", "0.6777042", "0.67690486", "0.6705465", "0.6648891", "0.6646402", "0.65994304", "0.65783906", "0.64680284", "0.64481825", "0.64299846", "0.6390984", "0.63901377", "0.63865596", "0.6359825", "0.6355346", "0.63509506", "0.63496387", "0.63375", "0.631404", "0.630647...
0.75916433
0
Computes the Euclidean distance between two points in Ndimensions
def EuclideanDistance( self, a, b ): return sqrt( self.EuclideanDistanceSq(a,b) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def euclidean_distance(x1: np.ndarray, x2: np.ndarray) -> float:\n return np.sqrt(np.square(x1 - x2).sum())", "def euclidean_distance(x1, x2):\n return np.sqrt(np.sum(np.square(np.subtract(x1, x2))))", "def euclidean_distance(x1, x2):\n return np.sqrt(np.sum(np.power(x1 - x2, 2)))", "def euclidean_d...
[ "0.82408017", "0.81753665", "0.8064152", "0.8030597", "0.79996204", "0.79600483", "0.78372294", "0.7815949", "0.77571756", "0.7753871", "0.7716396", "0.7712579", "0.7712069", "0.76682335", "0.7647232", "0.764369", "0.7605381", "0.75972676", "0.755448", "0.7544787", "0.7536579...
0.7221146
63
Returns starting state of the board.
def initial_state(): return [[EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY], [EMPTY, EMPTY, EMPTY]]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)", "def start_state():\n return chess.Board()", "def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))...
[ "0.8081514", "0.7890486", "0.7534929", "0.72789717", "0.72789717", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", "0.72262055", ...
0.0
-1
Returns player who has the next turn on a board.
def player(board): if terminal(board): return 7 numX = 0 numO = 0 for i in board: for j in i: if j == X: numX = numX + 1 elif j == O: numO = numO + 1 if numX == numO: return X else: return O
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None", "def next_player(self,board, prev_player):\r\n...
[ "0.7910244", "0.75209105", "0.7420068", "0.73686534", "0.71957153", "0.69778067", "0.6961665", "0.6925798", "0.69210964", "0.69015396", "0.6847539", "0.68413377", "0.683742", "0.6827424", "0.6774534", "0.6774534", "0.6769414", "0.67142314", "0.67074484", "0.66566026", "0.6616...
0.5980904
90
Returns the optimal action for the current player on the board.
def minimax(board): play = player(board) bestMove = (-1, -1) if play == X: bestVal = -1000 # Traverse all cells, evaluate minimax function for # all empty cells. And return the cell with optimal # value. for i in range(3) : for j in range(3) : ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction", "def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min...
[ "0.776646", "0.76322705", "0.75855505", "0.75283474", "0.7517416", "0.7466207", "0.7460458", "0.7425433", "0.74162185", "0.7394051", "0.73746026", "0.7333437", "0.7315163", "0.73061115", "0.7284637", "0.726456", "0.726456", "0.7250356", "0.72329557", "0.7203253", "0.7172992",...
0.0
-1
Get a random element from the set.
def getRandom(self) -> int: if not self.array: return -1 rand = randrange(0, len(self.array)) return self.array[rand]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getRandom(self):\n return self.nums[random.randint(0, len(self.nums) - 1)]\n\n # Your RandomizedSet object will be instantiated and called as such:\n # obj = RandomizedSet()\n # param_1 = obj.insert(val)\n # param_2 = obj.remove(val)\n # param_3 = obj.getRandom()", "...
[ "0.77046293", "0.7387685", "0.72949284", "0.7218086", "0.68716115", "0.6845313", "0.6832245", "0.6773854", "0.67219", "0.6701913", "0.66641307", "0.663437", "0.6620679", "0.66106117", "0.65985644", "0.65661675", "0.6476396", "0.64626694", "0.6441839", "0.64149344", "0.6399851...
0.0
-1
Send PUT request with JSON data to specified URL.
def put_json(client, url, data, headers={}): return client.put(url, data=json.dumps(data), content_type='application/json', headers=headers)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _put(self, url, data=None):\n url = urljoin(self.base_url, url)\n try:\n r = self._make_request(**dict(\n method='PUT',\n url=url,\n json=data,\n auth=self.auth,\n timeout=self.timeout,\n hooks=se...
[ "0.8409202", "0.80568355", "0.7946428", "0.7938671", "0.78804874", "0.78606063", "0.7838862", "0.7805675", "0.7796141", "0.76985455", "0.7634603", "0.7592184", "0.75747657", "0.7561558", "0.7541785", "0.7401592", "0.7377634", "0.71985894", "0.7101245", "0.7070201", "0.6970025...
0.78621984
5
Test that endpoints only work for post
def test_post_only(db, client, dev_endpoints): resp = client.get("/__dev/reset-db/") assert resp.status_code == 200 assert resp.json()["status"] == "fail" assert resp.json()["message"] == "Only POST is supported"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_post(self):\n self.assertEqual(\n status.HTTP_405_METHOD_NOT_ALLOWED, self.response.status_code)", "def test_post(self):\n pass", "def test_POST(self):\n if not self.url:\n return\n response = self.client.post(self.url, {}, format='json')\n self...
[ "0.80206585", "0.77948767", "0.77747047", "0.7428679", "0.74131", "0.7403813", "0.73148733", "0.73117787", "0.7310411", "0.7298676", "0.7267179", "0.72451943", "0.72319615", "0.7228256", "0.72280794", "0.7199235", "0.7186223", "0.7184814", "0.71505326", "0.71505326", "0.71280...
0.7615308
3
Test that endpoints only work for post
def test_idempotent(transactional_db, client, dev_endpoints): resp = client.post("/__dev/reset-db/") assert Study.objects.count() == 4 studies_1 = [study.kf_id for study in Study.objects.all()] resp = client.post("/__dev/reset-db/") assert Study.objects.count() == 4 studies_2 = [study.kf_id fo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_post(self):\n self.assertEqual(\n status.HTTP_405_METHOD_NOT_ALLOWED, self.response.status_code)", "def test_post(self):\n pass", "def test_POST(self):\n if not self.url:\n return\n response = self.client.post(self.url, {}, format='json')\n self...
[ "0.80200654", "0.77959156", "0.7774648", "0.7614873", "0.7428673", "0.7411442", "0.7401865", "0.7315372", "0.7312858", "0.73085624", "0.7298978", "0.72682166", "0.72425044", "0.72306764", "0.7229485", "0.7228705", "0.72002596", "0.71871406", "0.71830744", "0.7148652", "0.7148...
0.0
-1
Test case with bad api_object_id in init.
async def test_init_2(self, veil_cli): try: VeilApiObject(client=veil_cli, api_object_prefix='domain', api_object_id='badUUID') except TypeError as err: assert str(err) == 'badUUID is not a uuid string.' else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_api_object_url_2(self, api_object, server_address):\n try:\n api_object.api_object_id = None\n api_object.api_object_url\n except AttributeError:\n assert True\n else:\n raise AssertionError()", "def test_api_key_error(api):\n\twith pytest...
[ "0.70019066", "0.6730877", "0.67193955", "0.66855717", "0.66680956", "0.66654456", "0.66636664", "0.6569394", "0.64519536", "0.64519536", "0.64519536", "0.6436752", "0.63841844", "0.6375519", "0.637095", "0.6356298", "0.6347119", "0.634593", "0.6336195", "0.63140965", "0.6296...
0.7256771
0
Test case for api object uuid property.
def test_api_object_uuid(self, api_object): assert isinstance(api_object.uuid_, uuid.UUID)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_uuid_assignment(self):\n game = Game()\n game.uuid = '01234567-abcd-abcd-abcd-0123456789ab'\n assert isinstance(game.uuid, uuid.UUID), 'Value should be a UUID.'", "def test_uuid_created():\n assert type(sc.current.id) == str", "def test_get_shortuuid_uuid(self):\n id = g...
[ "0.75046074", "0.72849876", "0.7063137", "0.7058961", "0.7058961", "0.7058961", "0.7004175", "0.6999575", "0.6968674", "0.69423217", "0.6861506", "0.6861506", "0.68296564", "0.6826702", "0.6816908", "0.6805512", "0.67477834", "0.6740138", "0.66669154", "0.6665168", "0.6648068...
0.86536944
0