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
This is a literal copy from Django 1.4.5's django.contrib.auth.forms.PasswordResetForm Except removing the requirement of active users Validates that a user exists with the given email address.
def clean_email(self): email = self.cleaned_data["email"] #The line below contains the only change, removing is_active=True self.users_cache = User.objects.filter(email__iexact=email) if not len(self.users_cache): raise forms.ValidationError(self.error_messages['unknown'...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean_email(self):\n e = self.cleaned_data['email']\n try:\n user = User.objects.get(email=e)\n if not user.is_active:\n msg = 'This user account has not been confirmed yet'\n raise forms.ValidationError(msg)\n except User.DoesNotExist:\n...
[ "0.7146594", "0.7004448", "0.69335", "0.68365496", "0.677685", "0.67715335", "0.66902065", "0.6648026", "0.65728104", "0.65689206", "0.6554774", "0.6496926", "0.64882326", "0.64882326", "0.6393904", "0.6367969", "0.6359575", "0.62443936", "0.62304884", "0.62285453", "0.622133...
0.74721104
0
Sets the current session id for the loggedin user. If session_id doesn't match the existing session, deletes the old session object.
def set_login_session(self, session_id=None): meta = self.get_meta() old_login = meta.get('session_id', None) if old_login: SessionStore(session_key=old_login).delete() meta['session_id'] = session_id self.set_meta(meta) self.save()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def session_id(self, session_id):\n\n self._session_id = session_id", "def fusion_api_set_active_session(self, sessionId):\n return self.loginsession.set_active_session(sessionId)", "def current_session(self, session):\n if self._session is None:\n self._session = session\n ...
[ "0.7095222", "0.64716756", "0.6417081", "0.6182248", "0.6111594", "0.60996133", "0.603091", "0.59598655", "0.59457064", "0.5921676", "0.5891849", "0.5882615", "0.58649325", "0.57768625", "0.5763832", "0.5746535", "0.5732168", "0.5692491", "0.5682528", "0.56458145", "0.5643521...
0.788767
0
Create an enrollment for a user in a class. By default this enrollment is not active. This is useful for when an enrollment needs to go through some sort of approval process before being activated. If you don't need this functionality, just call `enroll()` instead. Returns a CoursewareEnrollment object. `user` is a Dja...
def get_or_create_enrollment(cls, user, course_key): # If we're passing in a newly constructed (i.e. not yet persisted) User, # save it to the database so that it can have an ID that we can throw # into our CourseEnrollment object. Otherwise, we'll get an # IntegrityError for having ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enroll_user(self, course_id, user_id, enrollment_type, params=None):\n url = COURSES_API.format(course_id) + \"/enrollments\"\n\n if not params:\n params = {}\n\n params[\"user_id\"] = user_id\n params[\"type\"] = enrollment_type\n\n data = self._post_resource(url,...
[ "0.7140559", "0.6983252", "0.6414807", "0.61193687", "0.61051506", "0.59396815", "0.572343", "0.5683322", "0.56608087", "0.56514066", "0.5624812", "0.561167", "0.5593199", "0.5532542", "0.5503346", "0.539898", "0.5387906", "0.5374578", "0.532843", "0.528175", "0.52354854", ...
0.7378477
0
Returns the count of active enrollments in a course. 'course_id' is the course_id to return enrollments
def num_enrolled_in(cls, course_id): enrollment_number = CourseEnrollment.objects.filter(course_id=course_id, is_active=1).count() return enrollment_number
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enrollment_counts(cls, course_id):\r\n # Unfortunately, Django's \"group by\"-style queries look super-awkward\r\n query = use_read_replica_if_available(cls.objects.filter(course_id=course_id, is_active=True).values('mode').order_by().annotate(Count('mode')))\r\n total = 0\r\n d = d...
[ "0.7108038", "0.6677328", "0.65596485", "0.6161133", "0.6034845", "0.5924553", "0.5897866", "0.58174455", "0.57859766", "0.5565401", "0.5537507", "0.5386586", "0.53825843", "0.5372256", "0.5357564", "0.5353452", "0.53508955", "0.53038985", "0.53026855", "0.525594", "0.5236743...
0.80532056
0
Enroll a user in a course. This saves immediately. Returns a CoursewareEnrollment object. `user` is a Django User object. If it hasn't been saved yet (no `.id` attribute), this method will automatically save it before adding an enrollment for it. `course_id` is our usual course_id string (e.g. "edX/Test101/2013_Fall) `...
def enroll(cls, user, course_key, mode="honor"): enrollment = cls.get_or_create_enrollment(user, course_key) enrollment.update_enrollment(is_active=True, mode=mode) return enrollment
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enroll_user(self, course_id, user_id, enrollment_type, params=None):\n url = COURSES_API.format(course_id) + \"/enrollments\"\n\n if not params:\n params = {}\n\n params[\"user_id\"] = user_id\n params[\"type\"] = enrollment_type\n\n data = self._post_resource(url,...
[ "0.6606526", "0.63822657", "0.6289116", "0.5848981", "0.5527508", "0.5401529", "0.5377017", "0.5262468", "0.5126439", "0.5015214", "0.49989623", "0.49759045", "0.49429756", "0.48449138", "0.4819715", "0.48171312", "0.47825545", "0.47725224", "0.47632962", "0.47576535", "0.475...
0.7833605
0
Enroll a user in a course given their email. This saves immediately. Note that enrolling by email is generally done in big batches and the error rate is high. For that reason, we supress User lookup errors by default. Returns a CoursewareEnrollment object. If the User does not exist and `ignore_errors` is set to `True`...
def enroll_by_email(cls, email, course_id, mode="honor", ignore_errors=True): try: user = User.objects.get(email=email) return cls.enroll(user, course_id, mode) except User.DoesNotExist: err_msg = u"Tried to enroll email {} into course {}, but user not found" ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def enroll(cls, user, course_key, mode=\"honor\"):\r\n enrollment = cls.get_or_create_enrollment(user, course_key)\r\n enrollment.update_enrollment(is_active=True, mode=mode)\r\n return enrollment", "def enroll_email(course_id, student_email, auto_enroll=False, email_students=False, email_pa...
[ "0.63766026", "0.6243725", "0.6197174", "0.6185827", "0.5631164", "0.55101246", "0.54032266", "0.52868265", "0.52621436", "0.5198377", "0.51689893", "0.51214594", "0.5044339", "0.50237703", "0.50000846", "0.4999728", "0.49391964", "0.49346426", "0.4933416", "0.4909336", "0.49...
0.8455767
0
Returns True if the user is enrolled in the course (the entry must exist and it must have `is_active=True`). Otherwise, returns False. `user` is a Django User object. If it hasn't been saved yet (no `.id` attribute), this method will automatically save it before adding an enrollment for it. `course_id` is our usual cou...
def is_enrolled(cls, user, course_key): try: record = CourseEnrollment.objects.get(user=user, course_id=course_key) return record.is_active except cls.DoesNotExist: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def registered_for_course(course, user):\r\n if user is None:\r\n return False\r\n if user.is_authenticated():\r\n return CourseEnrollment.is_enrolled(user, course.id)\r\n else:\r\n return False", "def is_enrolled_by_partial(cls, user, course_id_partial):\r\n assert isinstanc...
[ "0.7730067", "0.681923", "0.65862364", "0.6518063", "0.65150696", "0.642899", "0.63572323", "0.6219756", "0.617431", "0.61617404", "0.60868394", "0.59965044", "0.5941638", "0.5837158", "0.58308893", "0.5825274", "0.5742023", "0.56750727", "0.5642006", "0.5615826", "0.5613434"...
0.78165495
0
Returns `True` if the user is enrolled in a course that starts with `course_id_partial`. Otherwise, returns False. Can be used to determine whether a student is enrolled in a course whose run name is unknown. `user` is a Django User object. If it hasn't been saved yet (no `.id` attribute), this method will automaticall...
def is_enrolled_by_partial(cls, user, course_id_partial): assert isinstance(course_id_partial, SlashSeparatedCourseKey) assert not course_id_partial.run # None or empty string course_key = SlashSeparatedCourseKey(course_id_partial.org, course_id_partial.course, '') querystring = uni...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def registered_for_course(course, user):\r\n if user is None:\r\n return False\r\n if user.is_authenticated():\r\n return CourseEnrollment.is_enrolled(user, course.id)\r\n else:\r\n return False", "def is_enrolled(cls, user, course_key):\r\n try:\r\n record = Cours...
[ "0.68920684", "0.6780503", "0.60950685", "0.5967443", "0.5861764", "0.57591337", "0.57509834", "0.57324886", "0.5629314", "0.55705076", "0.53870934", "0.5345784", "0.53432274", "0.53147435", "0.5308263", "0.52769953", "0.52618206", "0.5251431", "0.5212418", "0.5208681", "0.52...
0.8621292
0
Returns the enrollment mode for the given user for the given course `user` is a Django User object `course_id` is our usual course_id string (e.g. "edX/Test101/2013_Fall) Returns the mode for both inactive and active users. Returns None if the courseenrollment record does not exist.
def enrollment_mode_for_user(cls, user, course_id): try: record = CourseEnrollment.objects.get(user=user, course_id=course_id) if hasattr(record, 'mode'): return record.mode else: return None except cls.DoesNotExist: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_or_create_enrollment(cls, user, course_key):\r\n # If we're passing in a newly constructed (i.e. not yet persisted) User,\r\n # save it to the database so that it can have an ID that we can throw\r\n # into our CourseEnrollment object. Otherwise, we'll get an\r\n # IntegrityErro...
[ "0.62607247", "0.6021436", "0.59298754", "0.5719734", "0.56795824", "0.55543935", "0.54904306", "0.5411434", "0.52710724", "0.52540463", "0.5253146", "0.5123631", "0.5114968", "0.51139224", "0.5103257", "0.5044605", "0.50381285", "0.4925809", "0.48937887", "0.48906556", "0.48...
0.8831459
0
Makes this `CourseEnrollment` record active. Saves immediately.
def activate(self): self.update_enrollment(is_active=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_course(self):\r\n self.course.save()\r\n self.store.update_item(self.course, self.user.id)", "def enroll(cls, user, course_key, mode=\"honor\"):\r\n enrollment = cls.get_or_create_enrollment(user, course_key)\r\n enrollment.update_enrollment(is_active=True, mode=mode)\r\n ...
[ "0.6672084", "0.61749154", "0.58876204", "0.5737564", "0.566249", "0.56342596", "0.54359615", "0.5400029", "0.53778374", "0.53182286", "0.52745575", "0.5268056", "0.5256823", "0.5223961", "0.52102697", "0.5201415", "0.5187189", "0.51868", "0.51829445", "0.51770014", "0.516190...
0.63996094
1
Makes this `CourseEnrollment` record inactive. Saves immediately. An inactive record means that the student is not enrolled in this course.
def deactivate(self): self.update_enrollment(is_active=False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_inactive(self):\n if self.active is False:\n return\n self.active = False\n self.save()\n self.question_set.update(active=False)", "def set_inactive(self):\n self.active = False", "def inactive(self, inactive):\n\n self._inactive = inactive", "def ...
[ "0.6868252", "0.6836602", "0.68070126", "0.66502184", "0.66335607", "0.65185076", "0.6286433", "0.62089175", "0.6182305", "0.6182305", "0.6177649", "0.6177649", "0.5949933", "0.5812713", "0.58075947", "0.57904595", "0.57829225", "0.5701479", "0.5701479", "0.5621189", "0.55979...
0.71121716
0
Overriding eq b/c the django impl relies on the primary key which requires fetch. sometimes we just want to compare roles w/o doing another fetch.
def __eq__(self, other): return type(self) == type(other) and self._key == other._key
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __eq__(self, other):\n if isinstance(other, Role):\n return self.id == other.id\n return False", "def __eq__(self, other):\n if isinstance(other, AbstractUser):\n if other.pk == self.pk:\n return True", "def __eq__(self, other):\n\n return se...
[ "0.71962476", "0.66203463", "0.6583306", "0.6549511", "0.651545", "0.65104514", "0.64997816", "0.6429432", "0.6387197", "0.6374176", "0.6362612", "0.6359437", "0.63514864", "0.6310919", "0.6301392", "0.6245221", "0.6231131", "0.62040997", "0.6200743", "0.6200743", "0.61882013...
0.58216566
90
Return whether the supplied django user has access to this role.
def has_user(self, user): # pylint: disable=unused-argument return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_access(self, user):\n if user.is_superuser:\n return True\n return self.user_objects(user).filter(id=self.id).exists()", "def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())", "def has_user(self, user):\r\n if not (user.is_authen...
[ "0.8219169", "0.8182423", "0.78580076", "0.7779436", "0.77403975", "0.7479206", "0.7466809", "0.7419583", "0.7404688", "0.73980886", "0.73544854", "0.7353622", "0.7346202", "0.72992194", "0.72992194", "0.7283807", "0.7283807", "0.7283807", "0.72788197", "0.7276261", "0.727455...
0.7177364
29
Return whether the supplied django user has access to this role.
def has_user(self, user): if not (user.is_authenticated() and user.is_active): return False # pylint: disable=protected-access if not hasattr(user, '_roles'): user._roles = set( CourseAccessRole.objects.filter(user=user).all() ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_access(self, user):\n if user.is_superuser:\n return True\n return self.user_objects(user).filter(id=self.id).exists()", "def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())", "def has_access(user, role):\r\n if not user.is_active:\r...
[ "0.8219169", "0.8182423", "0.7779436", "0.77403975", "0.7479206", "0.7466809", "0.7419583", "0.7404688", "0.73980886", "0.73544854", "0.7353622", "0.7346202", "0.72992194", "0.72992194", "0.7283807", "0.7283807", "0.7283807", "0.72788197", "0.7276261", "0.72745514", "0.723943...
0.78580076
2
Return whether the role's user has the configured role access to the passed course
def has_course(self, course_key): if not (self.user.is_authenticated() and self.user.is_active): return False # pylint: disable=protected-access if not hasattr(self.user, '_roles'): self.user._roles = list( CourseAccessRole.objects.filter(user=self...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_course_access(user, course_key, role=CourseStaffRole):\r\n if GlobalStaff().has_user(user):\r\n return True\r\n return auth.has_access(user, role(course_key))", "def has_access(user, role):\r\n if not user.is_active:\r\n return False\r\n # do cheapest check first even tho it's n...
[ "0.80847645", "0.77856076", "0.7421205", "0.73838055", "0.7380726", "0.72803915", "0.72062564", "0.7204507", "0.7112901", "0.7073232", "0.70506495", "0.7038531", "0.70124", "0.6978081", "0.69505054", "0.69438916", "0.68786967", "0.68637633", "0.68520164", "0.6827804", "0.6820...
0.78669333
1
Test that the certificate verification status for courses is visible on the dashboard.
def test_verification_status_visible(self): self.client.login(username="jack", password="test") self.check_verification_status_on('verified', 'You\'re enrolled as a verified student') self.check_verification_status_on('honor', 'You\'re enrolled as an honor code student') self.check_v...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_render_certificate(self):\n GeneratedCertificate.objects.create(\n user=self.student, course_id=self.course.id, status=u'downloadable')\n\n url = '{}?is_bigcourse=0'.format(reverse(\n 'completion_data_view', kwargs={\n 'course_id': self.course.id}))\n ...
[ "0.74383616", "0.68999356", "0.68266726", "0.6727905", "0.6640755", "0.6617161", "0.6552059", "0.6524235", "0.65242064", "0.6490257", "0.6424915", "0.64165956", "0.63495046", "0.6344894", "0.6322051", "0.6312357", "0.6310058", "0.62999064", "0.6259211", "0.6245071", "0.624102...
0.7159026
1
Get requests are not allowed in this view.
def test_change_name_get_request(self): change_name_url = self.get_url() resp = self.client.get(change_name_url) self.assertEquals(resp.status_code, 405)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_request_should_not_work(self):\n response = self.client.get(reverse('user-list'))\n self.assertEqual(response.status_code, status.HTTP_405_METHOD_NOT_ALLOWED)", "def test_get(self):\n self.assertEqual(403, self.response.status_code)", "def test_view_disabled(self, method, url)...
[ "0.72224736", "0.70104456", "0.694097", "0.6921517", "0.6710956", "0.67100316", "0.66999775", "0.6634647", "0.66314983", "0.6630442", "0.6605501", "0.6571584", "0.6567739", "0.6530049", "0.65007627", "0.6469867", "0.64157397", "0.6335186", "0.6335186", "0.63291913", "0.632919...
0.0
-1
Name will be changed when provided with proper data.
def test_change_name_post_request(self): self.client.login(username=self.student.username, password='test') change_name_url = self.get_url() resp = self.client.post(change_name_url, { 'new_name': 'waqas', 'rationale': 'change identity' }) response_d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name(self, name):\n pass", "def new_name(self,new_name):\n self.name = new_name", "def set_name(self, newname=\"\"):\n self.name = newname", "def updateName(self,name):\n self.name = name", "def set_name(self, name):\n\t\tself.name_ = name", "def set_name(self,name):\r\n ...
[ "0.8112363", "0.807322", "0.7923137", "0.7856427", "0.7834635", "0.7737086", "0.7734624", "0.7734624", "0.7733786", "0.7733786", "0.7733786", "0.7733786", "0.7722875", "0.7705378", "0.7698956", "0.7660599", "0.7660599", "0.7660599", "0.7660599", "0.7660599", "0.7660599", "0...
0.0
-1
Empty string for name is not allowed in this view.
def test_change_name_without_name(self): self.client.login(username=self.student.username, password='test') change_name_url = self.get_url() resp = self.client.post(change_name_url, { 'new_name': '', 'rationale': 'change identity' }) response_data =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate_name(self, value):\n if value in DEFAULT_EXCLUDE_USER:\n raise serializers.ValidationError(\n _(\"The name in the option can't be handle by the user.\")\n )\n return value", "def sanitize_name(self):\n self._name = self.get_name().strip()", ...
[ "0.68229246", "0.6715576", "0.6680498", "0.6547387", "0.64992654", "0.64992654", "0.6485127", "0.64693224", "0.64504045", "0.64207244", "0.63784295", "0.63691366", "0.6360546", "0.62842757", "0.6280928", "0.6272215", "0.624839", "0.62331957", "0.6220168", "0.62066483", "0.619...
0.0
-1
Send the reactivation email to the specified user, and return the response as json data.
def reactivation_email(self, user): return json.loads(reactivation_email_for_user(user).content)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resend_email(self, userdict):\n return self.post('resend', userdict)", "def test_resend_activation_email(self):\n\n data = {\n 'email': self.user.email,\n }\n\n response = self.client.post(\n reverse('user-resend-activation-email'),\n data,\n ...
[ "0.8085905", "0.69143134", "0.6648101", "0.6634908", "0.6626058", "0.6620164", "0.6619495", "0.6576334", "0.65187675", "0.6486719", "0.645788", "0.64557457", "0.6409443", "0.6403825", "0.6366313", "0.6351299", "0.6314131", "0.6313797", "0.63041633", "0.6299468", "0.62549937",...
0.82657325
0
Assert that the correct reactivation email has been sent
def assertReactivateEmailSent(self, email_user): context = { 'name': self.user.profile.name, 'key': self.registration.activation_key } self.assertEmailUser( email_user, 'emails/activation_email_subject.txt', context, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_resend_activation_email(self):\n\n data = {\n 'email': self.user.email,\n }\n\n response = self.client.post(\n reverse('user-resend-activation-email'),\n data,\n format='json',\n )\n\n self.assertEqual(\n response.st...
[ "0.8166055", "0.7825875", "0.76856244", "0.76492906", "0.75132716", "0.75004435", "0.7489112", "0.7475548", "0.7459711", "0.7444266", "0.7357771", "0.7317938", "0.7296712", "0.7291502", "0.7277682", "0.72435796", "0.7168408", "0.71235716", "0.71235716", "0.70915186", "0.70834...
0.79012835
1
Test that trying to send a reactivation email to an unregistered user fails without throwing a 500 error.
def test_reactivation_for_unregistered_user(self, email_user): response_data = self.reactivation_email(self.unregisteredUser) self.assertFalse(response_data['success'])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_resend_activation_email_nonexistent_user(self):\n self.assertFalse(self.registration_profile.objects.resend_activation_mail(\n email=self.user_info['email'],\n site=Site.objects.get_current(),\n ))\n self.assertEqual(len(mail.outbox), 0)", "def test_resend_acti...
[ "0.77715456", "0.7558301", "0.7490376", "0.74862164", "0.73582506", "0.7197142", "0.71969754", "0.7192023", "0.7180173", "0.7055008", "0.6975497", "0.6974426", "0.69621396", "0.69346046", "0.69336003", "0.68888724", "0.68862057", "0.6873676", "0.68682384", "0.685412", "0.6850...
0.8027544
0
Assert that `response_data` indicates a failed request that returns `expected_error`
def assertFailedRequest(self, response_data, expected_error): self.assertFalse(response_data['success']) self.assertEquals(expected_error, response_data['error']) self.assertFalse(self.user.email_user.called)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_has_valid_error(self, response, expected_code):\r\n assert 'error' in response\r\n assert len(response) == 1\r\n \r\n error = response['error']\r\n assert 'code' in error\r\n assert error['code'] == expected_code\r\n assert 'title' in ...
[ "0.7768885", "0.73554707", "0.7321401", "0.7292439", "0.7279918", "0.7225186", "0.7105003", "0.7070842", "0.7043141", "0.6956134", "0.69441", "0.69305193", "0.68871444", "0.68672603", "0.6862983", "0.6813965", "0.68026507", "0.6766954", "0.6756625", "0.67560077", "0.6749247",...
0.7993835
0
Test that a request to change a users email to `email` fails
def check_duplicate_email(self, email): request = self.req_factory.post('unused_url', data={ 'new_email': email, 'password': 'test', }) request.user = self.user self.assertFailedRequest(self.run_request(request), 'An account with this e-mail already exists.'...
{ "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.7811929", "0.76686877", "0.7522492", "0.750185", "0.74855906", "0.7406764", "0.73464584", "0.7328143", "0.7306048", "0.7294938", "0.72597957", "0.7248387", "0.7240983", "0.7240777", "0.7240111", "0.72241485", "0.72045904", "0.7189616", "0.7188958", "0.7188948", "0.71778035...
0.68548244
43
Test that we check for email addresses in a case insensitive way
def test_capitalized_duplicate_email(self): UserFactory.create(email=self.new_email) self.check_duplicate_email(self.new_email.capitalize())
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def testEmailIsLowercase(self):\r\n res = self.app.post(\r\n '/signup_process',\r\n params={\r\n 'email': 'CAPITALTesting@Dummy.cOm'\r\n }\r\n )\r\n self.assertIn('capitaltesting@dummy.com', res.body)", "def clean_email(email: str):\n return...
[ "0.7338998", "0.69861436", "0.69697773", "0.68071944", "0.6801585", "0.6738174", "0.67115617", "0.6661262", "0.6654972", "0.66433054", "0.66379213", "0.6623409", "0.66210634", "0.6620848", "0.6602621", "0.65695965", "0.65023524", "0.65016025", "0.6490787", "0.64899856", "0.64...
0.6824978
3
Tests the _get_course_enrollment_domain utility function
def test__get_course_enrollment_domain(self): self.assertIsNone(_get_course_enrollment_domain(SlashSeparatedCourseKey("I", "DONT", "EXIST"))) self.assertIsNone(_get_course_enrollment_domain(self.course.id)) self.assertEqual(self.shib_course.enrollment_domain, _get_course_enrollment_domain(sel...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_course_enrollment_domain(course_id):\r\n course = course_from_id(course_id)\r\n if course is None:\r\n return None\r\n\r\n return course.enrollment_domain", "def test_enrollment_limit_by_domain(self):\r\n\r\n # create 2 course, one with limited enrollment one without\r\n sh...
[ "0.7585905", "0.66969025", "0.6277624", "0.6275051", "0.6169587", "0.6083696", "0.5886884", "0.5843808", "0.5842421", "0.5780312", "0.56177866", "0.56075865", "0.56006795", "0.5597345", "0.55823344", "0.5581136", "0.5454488", "0.54488647", "0.54074997", "0.5397526", "0.539727...
0.8723002
0
Assert against the password reuse policy
def test_accounts_password_reuse(self): user = self._user_factory_with_history() staff = self._user_factory_with_history(is_staff=True) # students need to user at least one different passwords before reuse self.assertFalse(PasswordHistory.is_allowable_password_reuse(user, "test")) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_allow_all_password_reuse(self):\r\n student_email, _ = self._setup_user()\r\n user = User.objects.get(email=student_email)\r\n\r\n err_msg = 'You are re-using a password that you have used recently.'\r\n\r\n token = default_token_generator.make_token(user)\r\n uidb36 = i...
[ "0.78366774", "0.74049175", "0.7348687", "0.7111708", "0.7027426", "0.6958932", "0.68592095", "0.6795516", "0.67804545", "0.666231", "0.6659604", "0.66497666", "0.66492426", "0.66221935", "0.65911466", "0.6527108", "0.64929116", "0.64578027", "0.6455304", "0.6448413", "0.6442...
0.7736162
1
Get the relevant set of (Course, CourseEnrollment) pairs to be displayed on a student's dashboard.
def get_course_enrollment_pairs(user, course_org_filter, org_filter_out_set): for enrollment in CourseEnrollment.enrollments_for_user(user): course = course_from_id(enrollment.course_id) if course: # if we are in a Microsite, then filter out anything that is not # attr...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(self, request):\r\n\r\n if not request.user.is_staff:\r\n raise Http404\r\n data = []\r\n\r\n for course in self.get_courses(): # pylint: disable=unused-variable\r\n datum = [course.display_name, course.id]\r\n datum += [CourseEnrollment.objects.filter...
[ "0.69612515", "0.6830837", "0.67581666", "0.6727524", "0.6644779", "0.661844", "0.64402866", "0.6352517", "0.6327727", "0.63082385", "0.6300798", "0.62826115", "0.6281018", "0.6253526", "0.6179871", "0.61505145", "0.61313766", "0.60913146", "0.6061187", "0.60574996", "0.60433...
0.6360812
7
Log a request for a new name.
def change_name_request(request): if not request.user.is_authenticated(): raise Http404 try: pnc = PendingNameChange.objects.get(user=request.user.id) except PendingNameChange.DoesNotExist: pnc = PendingNameChange() pnc.user = request.user pnc.new_name = request.POS...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def rename(self, name):\n self._name = name\n self._logger = logging.getLogger(name)\n self._logger.setLevel(self._level)", "def new_name(self,new_name):\n self.name = new_name", "def log_request(self, r):\n\n token = r.headers.get(self.header, None)\n r.token = token\...
[ "0.6776591", "0.63237995", "0.6148524", "0.6136387", "0.6124137", "0.6035182", "0.6035182", "0.6020648", "0.6016895", "0.6005768", "0.5976083", "0.5938317", "0.59233046", "0.59114826", "0.58799183", "0.58590287", "0.5838", "0.58375263", "0.58150095", "0.5804136", "0.5804136",...
0.6423141
1
Clean out the django test database defined in the
def reset_data(scenario): LOGGER.debug("Flushing the test database...") call_command('flush', interactive=False, verbosity=0) world.absorb({}, 'scenario_dict')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tearDown(self):\n self.db.drop_all()\n pass", "def tearDown(self):\n db.drop_all()", "def tearDown(self):\n db.drop_all()", "def tearDown(self):\r\n testing.tearDown()\r\n empty_db()", "def tearDown(self):\r\n testing.tearDown()\r\n empty_db()", ...
[ "0.85230094", "0.84714645", "0.84714645", "0.8427433", "0.8427433", "0.8427433", "0.8427433", "0.8427433", "0.8427433", "0.8427433", "0.8427433", "0.8427433", "0.8360271", "0.8322765", "0.8322765", "0.8322765", "0.8322765", "0.8322765", "0.8322765", "0.83152175", "0.82975817"...
0.0
-1
Return the URL path without GET parameters. Removes the trailing slash if there is one.
def path_only(self): path = urlparse.urlparse(self.path).path if path.endswith('/'): return path[:-1] else: return path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path_only(self):\n path = six.moves.urllib.parse.urlparse(self.path).path\n if path.endswith('/'):\n return path[:-1]\n else:\n return path", "def noTrailingSlash(path):\n return path.split('/')[0]", "def strip_path(self):\n return self.path.replace(...
[ "0.7436799", "0.73581016", "0.72805315", "0.68738854", "0.6776068", "0.671468", "0.66718966", "0.6469924", "0.64689356", "0.642675", "0.63856494", "0.6337378", "0.63072467", "0.63021487", "0.63020474", "0.6229538", "0.61979043", "0.617663", "0.61744183", "0.6167393", "0.61432...
0.7571658
0
Return a boolean indicating whether the URL path is a valid LTI endpoint.
def _is_correct_lti_request(self): lti_endpoint = self.server.config.get('lti_endpoint', self.DEFAULT_LTI_ENDPOINT) return lti_endpoint in self.path
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def endpoint_checker(url):\r\n if \"/arcgis/rest/services/\" and \"http\" in url:\r\n return True\r\n return False", "def validate_url(path):\n parsed = urlparse(path)\n return bool(parsed.scheme) and bool(parsed.netloc)", "def _isurl(self, path):\n\n # We do this ...
[ "0.7341699", "0.6833077", "0.67892146", "0.66866297", "0.66594404", "0.6637703", "0.6550192", "0.6490747", "0.6377443", "0.63298935", "0.63296336", "0.6272638", "0.62223756", "0.62044024", "0.6187291", "0.61833763", "0.61770356", "0.6160633", "0.6131669", "0.61157304", "0.611...
0.7207584
1
Return the `StudentState` (named tuple) for the student with ID `student_id`. The student state can be modified by the caller.
def student_state(self, student_id): # Create the student state if it does not already exist if student_id not in self._students: student = StudentState() self._students[student_id] = student # Retrieve the student state return self._students[student_id]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_student_by_id(student_id, subject=None): # noqa: E501\n return student_service.get_student_by_id(student_id, subject)", "def get_student_by_id(student_id, subject=None): # noqa: E501\n return student_service.get_student_by_id(student_id=student_id, subject=subject)", "def get_state(self, entity...
[ "0.62054515", "0.61724967", "0.58840036", "0.5816144", "0.5612195", "0.5589868", "0.5565291", "0.5551631", "0.5547084", "0.5499683", "0.54612553", "0.54538107", "0.5420329", "0.5418386", "0.5414493", "0.537369", "0.53659314", "0.5346916", "0.53304887", "0.5302085", "0.5292371...
0.8876522
0
Construt a URL to the stub ORA peergrading service.
def _peer_url(self, path): return "http://127.0.0.1:{port}/peer_grading/{path}/".format( port=self.server.port, path=path )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def url(vmanage_host,vmanage_port,api):\r\n \"\"\" function to get the url provide api endpoint \"\"\"\r\n \r\n return f\"https://{vmanage_host}:{vmanage_port}{api}\"", "def _get_base_url(self):\n return 'https://'+self.get_address_and_port_string()", "def _base_url(self):\n # URL Protoc...
[ "0.59476006", "0.5768176", "0.5696858", "0.5628683", "0.5458847", "0.5406022", "0.53909755", "0.5322266", "0.5307993", "0.5303519", "0.52845997", "0.5274928", "0.5247171", "0.5241153", "0.5226338", "0.52255696", "0.5213747", "0.5202742", "0.51973397", "0.519239", "0.51679426"...
0.67431074
0
Assert that the `response` was successful and contained `expected_json` (dict) as its content.
def _assert_response(self, response, expected_json): self.assertTrue(response.ok) self.assertEqual(response.json(), expected_json)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_response_correct(self, response, expected_status, expected_content):\n assert response.status_code == expected_status\n parsed_content = json.loads(response.content.decode('utf-8'))\n assert parsed_content == expected_content", "def assertJSON(self, response, expected_status=200):...
[ "0.82083833", "0.80850685", "0.80588615", "0.7598792", "0.75858647", "0.7509003", "0.75015426", "0.7440616", "0.7423003", "0.74110144", "0.73909265", "0.72439057", "0.71992344", "0.7119761", "0.7078766", "0.70487344", "0.7045893", "0.68752044", "0.68252486", "0.67974705", "0....
0.8782504
0
Verify that the stub sent a POST request back to us with the expected data. `callback_url` is the URL we expect the stub to POST to `expected_header` is the header (a string) we expect to receive with the grade. `expected_body` is the content (a string) we expect to receive with the grade. Raises an `AssertionError` if...
def _check_grade_response(self, callback_url, expected_header, expected_body): # Check the response posted back to us # This is the default response expected_callback_dict = { 'xqueue_header': expected_header, 'xqueue_body': expected_body, } # Che...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_post_and_compare_resp(url, json_req, expected_post_json_resp,\n check_util=default_full_compare):\n post_resp_obj = RestClientApis.http_post_and_check_success(url, json_req)\n if post_resp_obj.success:\n success = check_util(json.loads(expected_po...
[ "0.58381534", "0.58326954", "0.569037", "0.56319946", "0.56220007", "0.56219786", "0.56001675", "0.55726564", "0.5556676", "0.55272514", "0.5512456", "0.5500084", "0.5495573", "0.54831314", "0.54813117", "0.541898", "0.5382962", "0.53817284", "0.53299654", "0.530736", "0.5292...
0.7612864
0
Remove any extra parameters from the path. For example /gizmo.mp4?1397160769634 becomes /gizmo.mp4
def translate_path(self, path): root_dir = self.server.config.get('root_dir') path = '{}{}'.format(root_dir, path) return path.split('?')[0]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _clean_url(self, url):\n return \"\".join(url.split(\"?\")[:1])", "def _trim_path(path):\n if path.endswith(\"/\"):\n path = path[:-1] # remove / at the end\n \n return path", "def spath_stripoptions(spath):\n l = [comp.split(\"?\", 1)[0] for comp in spath.split(\"/\")]\n retur...
[ "0.66153336", "0.65442294", "0.6523427", "0.6320365", "0.6272592", "0.62598324", "0.6130878", "0.6091371", "0.6080526", "0.60177404", "0.60154945", "0.59913576", "0.5986565", "0.59763104", "0.59603435", "0.59603435", "0.5893103", "0.5853464", "0.5822858", "0.5817831", "0.5793...
0.581008
20
Return a boolean indicating whether the element with `css_selector` has the specified `value`. If there are multiple elements matching the css selector, use `index` to indicate which one.
def css_has_value(css_selector, value, index=0): # If we're expecting a non-empty string, give the page # a chance to fill in values if value: wait_for(lambda _: css_value(css_selector, index=index)) return css_value(css_selector, index=index) == value
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_css_selector_found( self, selector_text ):\n try:\n self.driver.find_element_by_css_selector( selector_text )\n return True\n except NoSuchElementException as e:\n return False", "def _does_webelement_with_css_exist(self, css_selector, timeout=60):\n ...
[ "0.62079215", "0.6013161", "0.5752952", "0.5529714", "0.54477036", "0.5400555", "0.53829795", "0.5308203", "0.5300401", "0.5285208", "0.5285208", "0.5268273", "0.51914155", "0.5184578", "0.51611286", "0.5146445", "0.51366544", "0.51126266", "0.510505", "0.5035607", "0.5032942...
0.8053637
0
Gets an enabled provider by its NAME member or throws.
def _get_enabled_provider_by_name(provider_name): enabled_provider = provider.Registry.get(provider_name) if not enabled_provider: raise ValueError('Provider %s not enabled' % provider_name) return enabled_provider
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(cls, provider_name):\r\n cls._check_configured()\r\n return cls._ENABLED.get(provider_name)", "def get_provider(self, name=None):\n return self.gateway and self.gateway.provider or None", "def get_provider(self) -> Optional[Provider]:\n if not self.provider:\n ret...
[ "0.7555431", "0.6913737", "0.65143335", "0.6426864", "0.63684434", "0.63186693", "0.63155586", "0.631395", "0.61639214", "0.6123899", "0.61191756", "0.6058513", "0.60436654", "0.59940314", "0.599148", "0.59005356", "0.5893639", "0.588977", "0.5855317", "0.5852319", "0.5837135...
0.8181524
0
Gets URL for the endpoint that starts the disconnect pipeline.
def get_disconnect_url(provider_name): enabled_provider = _get_enabled_provider_by_name(provider_name) return _get_url('social:disconnect', enabled_provider.BACKEND_CLASS.name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def endpoint_url(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"endpoint_url\")", "def get_cancel_event_endpoint_url() -> str:\n return \"/events/cancel\"", "def get_endpoint_url(endpoint):\n return urljoin(api_url_base(), endpoint)", "def endpoint_uri(self) -> pulumi.Output[O...
[ "0.6332032", "0.6325486", "0.62793434", "0.6244179", "0.6239242", "0.6239242", "0.62246007", "0.6111977", "0.6111977", "0.6106467", "0.6063497", "0.6031224", "0.6028747", "0.6026012", "0.5936247", "0.5931263", "0.5908292", "0.58808976", "0.5866608", "0.5855325", "0.5855325", ...
0.58276385
25
Returns True iff request is running a thirdparty auth pipeline.
def running(request): return request.session.get('partial_pipeline') is not None # Avoid False for {}.
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def AuthenticationRequired(self, req):\n return self._reqauth or bool(self._GetRequestContext(req).handler_access)", "def is_valid_request(self, request):\r\n auth_params = request.META.get(\"HTTP_AUTHORIZATION\", [])\r\n return self.is_in(auth_params) or self.is_in(request.REQUEST)", "def is_...
[ "0.7021468", "0.6401154", "0.63923347", "0.6389174", "0.63669807", "0.63416606", "0.6320821", "0.6300829", "0.625438", "0.6144559", "0.6110792", "0.6082421", "0.6080488", "0.6049787", "0.6049787", "0.6049787", "0.6049787", "0.6049787", "0.6049787", "0.6049787", "0.60208285", ...
0.0
-1
Gets all provider implementations loaded into the Python runtime.
def _get_all(cls): # BaseProvider does so have __subclassess__. pylint: disable-msg=no-member return {klass.NAME: klass for klass in BaseProvider.__subclasses__()}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def registered_providers():\n return list(_DEFAULT_PROVIDER.providers)", "def create_providers(cls) -> Iterable['BaseProvider']:\n return []", "def get(self):\n return get_all_provider()", "def get_all_providers() -> list[str]:\n return list(ALL_PROVIDERS)", "def get_registered_provider...
[ "0.73228127", "0.6997992", "0.68998504", "0.6785165", "0.67183083", "0.6668846", "0.65488505", "0.65488505", "0.65488505", "0.65488505", "0.65488505", "0.65488505", "0.6450924", "0.64102894", "0.6382771", "0.63372976", "0.6176486", "0.6172672", "0.6118169", "0.6087382", "0.60...
0.62336874
16
Gets provider (or None) by backend name.
def get_by_backend_name(cls, backend_name): cls._check_configured() for enabled in cls._ENABLED.values(): if enabled.BACKEND_CLASS.name == backend_name: return enabled
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_backend(name):\n return _DEFAULT_PROVIDER.get_backend(name)", "def get_provider_from_backend(backend):\n known_providers = {\n 'BasicAerProvider': 'qiskit.BasicAer',\n 'AerProvider': 'qiskit.Aer',\n 'IBMQProvider': 'qiskit.IBMQ',\n ...
[ "0.828192", "0.82124585", "0.7499121", "0.72151625", "0.7057464", "0.69706297", "0.6823685", "0.6817349", "0.68002534", "0.679703", "0.67961454", "0.67896307", "0.6786569", "0.67836493", "0.6779632", "0.675681", "0.67446977", "0.66573375", "0.6652679", "0.66136193", "0.661361...
0.70498216
5
Returns the registry to an unconfigured state; for tests only.
def _reset(cls): cls._CONFIGURED = False cls._ENABLED = {}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_unit_registry():\n\n global _unit_registry\n\n # Cache the unit registry for speedier access\n if _unit_registry is None:\n return reload_unit_registry()\n else:\n return _unit_registry", "def internal_registry(self) -> Dict[str, Resource]:\n return self.manager.registry"...
[ "0.6484627", "0.61432344", "0.5990753", "0.59343624", "0.58578163", "0.57263094", "0.55968225", "0.5588259", "0.5574277", "0.55377924", "0.55359685", "0.55290693", "0.5520414", "0.5514114", "0.54663205", "0.5455822", "0.5434441", "0.5425055", "0.5410041", "0.53891915", "0.537...
0.0
-1
Asserts the redirect to the provider's site looks correct. When we hit /auth/login/, we should be redirected to the provider's site. Here we check that we're redirected, but we don't know enough about the provider to check what we're redirected to. Child test implementations may optionally strengthen this assertion wit...
def assert_redirect_to_provider_looks_correct(self, response): self.assertEqual(302, response.status_code) self.assertTrue(response.has_header('Location'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_redirection(self):\n self.assertRedirects(self.response, self.home_url)", "def assert_redirect_to_login_looks_correct(self, response):\r\n self.assertEqual(302, response.status_code)\r\n self.assertEqual('/' + pipeline.AUTH_ENTRY_LOGIN, response.get('Location'))", "def test_redire...
[ "0.78897095", "0.7716403", "0.7588399", "0.75879425", "0.7530676", "0.75176316", "0.7483755", "0.7332662", "0.73299587", "0.7159702", "0.7149981", "0.7083459", "0.7082635", "0.7065466", "0.7063911", "0.7044097", "0.7038989", "0.7035008", "0.70093143", "0.69966704", "0.6886929...
0.85600835
0
Asserts failure on /login for missing social auth looks right.
def assert_json_failure_response_is_missing_social_auth(self, response): self.assertEqual(200, response.status_code) # Yes, it's a 200 even though it's a failure. payload = json.loads(response.content) self.assertFalse(payload.get('success')) self.assertIn('associated with your %s a...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_social_auth_exception(self):\n self._setup_provider_response_with_body(200, json.dumps(\"false\"))\n response = self.client.post(self.url, self.data())\n self._assert_access_token_error(response, \"The provided access_token is not valid.\", \"tpa-invalid-access-token\")\n self....
[ "0.79564476", "0.751747", "0.7470663", "0.743986", "0.7417083", "0.74030674", "0.73998314", "0.7375168", "0.7367762", "0.73613775", "0.73537236", "0.734243", "0.7338388", "0.7290764", "0.7248812", "0.7243264", "0.7196928", "0.7195776", "0.71957606", "0.7168674", "0.7168406", ...
0.0
-1
Asserts the json response indicates success and redirection.
def assert_json_success_response_looks_correct(self, response): self.assertEqual(200, response.status_code) payload = json.loads(response.content) self.assertTrue(payload.get('success')) self.assertEqual(pipeline.get_complete_url(self.PROVIDER_CLASS.BACKEND_CLASS.name), payload.get('...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _assert_response(self, response, expected_json):\r\n self.assertTrue(response.ok)\r\n self.assertEqual(response.json(), expected_json)", "def assert_api_success(response, data: Optional[Any] = None) -> None:\n assert response.status_code == 200\n assert response.json[\"success\"]\n if ...
[ "0.77653325", "0.74859506", "0.7343257", "0.7317693", "0.72720116", "0.726738", "0.71774626", "0.714588", "0.7144", "0.7090904", "0.70569545", "0.7039361", "0.7002685", "0.6979926", "0.69776624", "0.69776624", "0.69776624", "0.69776624", "0.69776624", "0.69776624", "0.6977662...
0.8508594
0
Asserts a GET of /login not in the pipeline looks correct.
def assert_login_response_before_pipeline_looks_correct(self, response): self.assertEqual(200, response.status_code) self.assertIn('Sign in with ' + self.PROVIDER_CLASS.NAME, response.content) self.assert_javascript_would_submit_login_form(False, response) self.assert_signin_button_l...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_login_get(self):\n resp = self.client.get(reverse('login'))\n assert resp.status_code == 405", "def test_emotion_analysis_route_get_redirects_to_login_not_logged_in(self):\n response = self.client.get(reverse_lazy('emotion_analysis'), follow=True)\n self.assertIn(str(reverse_...
[ "0.7755998", "0.7642349", "0.75807256", "0.7471983", "0.7452169", "0.74435353", "0.7439798", "0.74237573", "0.73846203", "0.73828006", "0.73599523", "0.7340876", "0.7339818", "0.73093027", "0.7241252", "0.7233699", "0.71825874", "0.71825874", "0.71825874", "0.71782655", "0.71...
0.0
-1
Verifies that the given password is not correct. The pipeline overrides POST['password'], if any, with random data.
def assert_password_overridden_by_pipeline(self, username, password): self.assertIsNone(auth.authenticate(password=password, username=username))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_4_is_valid_password(self):\n self.factory = RequestFactory()\n response = self.factory.post('', data={'password': '123123123'}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')\n response = is_valid_password(response)\n self.assertContains(response, 'The password is invalid')\n\n ...
[ "0.75809115", "0.74347967", "0.7242612", "0.7219103", "0.7214025", "0.7191598", "0.71436834", "0.7137753", "0.71115756", "0.7092344", "0.7055145", "0.704106", "0.7037769", "0.6990492", "0.69784886", "0.6973296", "0.69534457", "0.6932206", "0.69264543", "0.6899599", "0.6879142...
0.7066382
10
Asserts a response would redirect to /dashboard.
def assert_redirect_to_dashboard_looks_correct(self, response): self.assertEqual(302, response.status_code) # pylint: disable-msg=protected-access self.assertEqual(auth_settings._SOCIAL_AUTH_LOGIN_REDIRECT_URL, response.get('Location'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_redirection(self):\n dashboard_url = reverse('dashboard')\n self.assertRedirects(self.response, dashboard_url)", "def test_login_required_dashboard(self):\r\n response = self.client.get(reverse('dashboard'))\r\n self.assertEqual(response.status_code, 302)\r\n self.asse...
[ "0.8160653", "0.80657554", "0.79460025", "0.7692294", "0.7545598", "0.7512704", "0.7482652", "0.74072605", "0.7371522", "0.73341537", "0.7292923", "0.7195725", "0.715725", "0.715211", "0.71485496", "0.71485496", "0.7148333", "0.71470904", "0.7124662", "0.7122197", "0.71143496...
0.8196601
0
Creates a course context from a `course_id`.
def course_context_from_course_id(course_id): if course_id is None: return {'course_id': '', 'org_id': ''} # TODO: Make this accept any CourseKey, and serialize it using .to_string assert(isinstance(course_id, SlashSeparatedCourseKey)) return { 'course_id': course_id.to_deprecate...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def course_from_id(course_id):\r\n return modulestore().get_course(course_id)", "def create_course(course_request: schemas.CourseRequest, db: Session = Depends(get_db)):\n\n try:\n course = crud.course.create(db, obj_in=course_request)\n\n except Exception as error:\n logger.error(f'Error ...
[ "0.6950164", "0.6848595", "0.6541905", "0.63615614", "0.635656", "0.6337522", "0.6309433", "0.629303", "0.6251289", "0.6241177", "0.6225209", "0.6224854", "0.6111783", "0.6110799", "0.6109285", "0.61025345", "0.60897815", "0.6061051", "0.6027093", "0.6021617", "0.5899673", ...
0.77140164
0
Gets the Django session key from the request or an empty string if it isn't found
def get_session_key(self, request): try: return request.session.session_key except AttributeError: return ''
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_session_key(self):\n return self.session_key", "def getRequest(request):\n return request.session.get('openid_request')", "def _get_key(self):\n if not self.session:\n key = self.key\n else:\n key = self.session.get(\"_signature_key\")\n if key i...
[ "0.70480984", "0.69739455", "0.6854182", "0.6515678", "0.6490848", "0.6459088", "0.6383925", "0.634134", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0.63224477", "0....
0.8748219
0
Serialize datetime and date objects of iso format. datatime objects are converted to UTC.
def default(self, obj): # pylint: disable=method-hidden if isinstance(obj, datetime): if obj.tzinfo is None: # Localize to UTC naive datetime objects obj = UTC.localize(obj) else: # Convert to UTC datetime objects from other timezo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def serialize_datetime(self, obj):\r\n if isinstance(obj, datetime.datetime):\r\n return obj.isoformat()\r\n raise TypeError(\"Type not serializable\")", "def convert_datetime_to_iso(datetime_obj):\r\n return Date().to_json(datetime_obj)", "def _serialize_datetime(val):\n ret...
[ "0.7303232", "0.71552795", "0.70818806", "0.7077715", "0.69812506", "0.68699336", "0.6821228", "0.6711455", "0.6655461", "0.6655461", "0.66330475", "0.662311", "0.6595521", "0.6563139", "0.6556661", "0.654973", "0.6542835", "0.65330005", "0.6514835", "0.6504013", "0.64997196"...
0.62229836
51
Assert that accessing the "url" entry in the given object returns the same object
def assertSelfReferential(self, obj): copy = self.get_json(obj["url"]) self.assertEqual(obj, copy)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_api_object_url_1(self, api_object, server_address):\n expected_url = 'https://{}/api/domain/{}/'.format(server_address, api_object.uuid_)\n assert api_object.api_object_url == expected_url", "def test_api_object_url_2(self, api_object, server_address):\n try:\n api_object...
[ "0.7297684", "0.6914677", "0.65487087", "0.6537969", "0.6535136", "0.6514056", "0.6453913", "0.6393091", "0.63359", "0.62762463", "0.62733483", "0.62340516", "0.62266386", "0.621291", "0.62102616", "0.6192099", "0.6183755", "0.61445385", "0.6138284", "0.6118176", "0.6099121",...
0.809932
0
Assert that the given response has the status code 200
def assertHttpOK(self, response): self.assertEqual(response.status_code, 200)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert200(self, response):\n self.assertEqual(response.status_code, 200)", "def test_status_code(self):\n self.assertEquals(self.response.status_code, 200)", "def assert_status_code(response, status):\n assert response.status_code == status", "def test_status_code(self):\n assert ...
[ "0.87128425", "0.8460173", "0.8263307", "0.81986123", "0.8148805", "0.8132977", "0.79189235", "0.7812347", "0.7804356", "0.7784079", "0.777643", "0.77425003", "0.77189946", "0.76775557", "0.76391155", "0.7634159", "0.75965345", "0.75334007", "0.75325847", "0.75158435", "0.751...
0.8304494
2
Assert that the given response has the status code 405
def assertHttpMethodNotAllowed(self, response): self.assertEqual(response.status_code, 405)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assertHttpMethodNotAllowed(self, resp):\r\n return self.assertEqual(resp.status_code, 405)", "def test_post(self):\n self.assertEqual(\n status.HTTP_405_METHOD_NOT_ALLOWED, self.response.status_code)", "def test_post(self):\n response = self._post()\n self.assertEqual...
[ "0.87156844", "0.8057651", "0.79496497", "0.79141927", "0.7871735", "0.7659559", "0.76557195", "0.7522851", "0.738868", "0.7280964", "0.7178791", "0.71592796", "0.7129279", "0.7111578", "0.70613164", "0.7038993", "0.69983095", "0.6987384", "0.6979501", "0.69706357", "0.696461...
0.8674261
1
Test that the endpoint properly returns empty result sets
def test_get_list_empty(self): result = self.get_json(self.LIST_URI) self.assertEqual(result["count"], 0) self.assertIsNone(result["next"]) self.assertIsNone(result["previous"]) self.assertEqual(result["results"], [])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_get_empty_datasets(self):\n endpoints = [\"elections\", \"races\", \"candidates\", \"votes\", \"types\"]\n for endpoint in endpoints:\n response = self.client.get(\"/api/{}\".format(endpoint),\n headers=[(\"Accept\", \"application/json\")])\n self.assertE...
[ "0.7897591", "0.7503035", "0.74411285", "0.7372945", "0.7369832", "0.7303089", "0.7253778", "0.72344667", "0.71764296", "0.71413857", "0.71376026", "0.7116788", "0.70528096", "0.7040167", "0.6990588", "0.69897306", "0.69806945", "0.69806945", "0.69806945", "0.6971466", "0.693...
0.7580898
1
Converts a datetime to a string representation. This is the default representation used in Studio and LMS. It will use the "DATE_TIME" format in the current language, if provided,
def get_default_time_display(dtime): if dtime is None: return u"" if dtime.tzinfo is not None: try: timezone = u" " + dtime.tzinfo.tzname(dtime) except NotImplementedError: timezone = dtime.strftime('%z') else: timezone = u" UTC" locali...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_datetime_str():\n return time.strftime(\"%Y-%m-%d %H:%M:%S\", time.localtime())", "def get_datetime_string():\n return datetime.now().strftime(DATETIME_FORMAT)", "def dtstr():\n return dt.strftime(dt.now(),'%Y %m %d, %H:%M:%S')", "def convert_datetime_to_string(dt):\n\treturn '{0}-{1}-{2}'.f...
[ "0.7652001", "0.7613477", "0.7409127", "0.7361322", "0.7361322", "0.7351168", "0.7180525", "0.7049873", "0.7048862", "0.7047609", "0.70448947", "0.69839907", "0.6978735", "0.69780505", "0.69604665", "0.6956834", "0.6954638", "0.69366413", "0.69199103", "0.69197464", "0.691951...
0.6402609
47
Converts a datetime to a string representation. If None is passed in for dt, an empty string will be returned. If the format_string is None, or if format_string is improperly formatted, this method will return the value from `get_default_time_display`. Coerces aware datetime to tz=coerce_tz if set. coerce_tz should be ...
def get_time_display(dtime, format_string=None, coerce_tz=None): if dtime is not None and dtime.tzinfo is not None and coerce_tz: try: to_tz = timezone(coerce_tz) except UnknownTimeZoneError: to_tz = UTC dtime = to_tz.normalize(dtime.astimezone(to_tz)) if d...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_date_str(datetime, str_format=\"datetime\", locale=\"en_US\", tz=\"America/New_York\"):\n\ttimezone = pytz.timezone(tz)\n\tdatetime = datetime.astimezone(timezone)\n\n\tif str_format == \"date\":\n\t\treturn dates.format_date(datetime, locale=locale)\n\telif str_format == \"time\":\n\t\treturn dates.format...
[ "0.63170993", "0.58326864", "0.5753917", "0.57477176", "0.56368995", "0.55596244", "0.5544572", "0.5466404", "0.5425899", "0.53827316", "0.5371797", "0.53116333", "0.530943", "0.53062356", "0.52894306", "0.5273784", "0.5254211", "0.52490824", "0.5124557", "0.51224583", "0.509...
0.71669304
0
Hashes `string` into a string representation of a 128bit digest.
def fasthash(string): md4 = hashlib.new("md4") md4.update(string) return md4.hexdigest()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def computeHash(string):\n\tif isBytes(string):\n\t\tstring = string.decode(\"latin-1\")\n\thash_ = 63689\n\tfor char in string:\n\t\thash_ = hash_ * 378551 + ord(char)\n\treturn hash_ % 65536", "def keyhash(string):\n return hashlib.sha1(string.encode('utf-8')).hexdigest()", "def get_256_hash_from_string(s...
[ "0.74687904", "0.7368751", "0.7329079", "0.72857475", "0.71416515", "0.7107941", "0.7097936", "0.7024524", "0.7022516", "0.696209", "0.69589007", "0.6946438", "0.6934859", "0.68810314", "0.6879957", "0.6825508", "0.6807265", "0.6661104", "0.664496", "0.6632878", "0.6620478", ...
0.71339506
5
Validator that enforces minimum length of a password
def validate_password_length(value): message = _("Invalid Length ({0})") code = "length" min_length = getattr(settings, 'PASSWORD_MIN_LENGTH', None) max_length = getattr(settings, 'PASSWORD_MAX_LENGTH', None) if min_length and len(value) < min_length: raise ValidationError(message....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_less_than_min_length_invalid_password(self):\n pass_field = Field(\"\".join(['x' * (int(self.app.config['MIN_PWD_LEN']) - 1)]))\n\n with self.assertRaises(ValidationError):\n valid_password(None, pass_field)", "def is_valid_password(password):\n if len(password) < MIN_LENGTH:...
[ "0.8279733", "0.80082047", "0.79259115", "0.78656924", "0.78482395", "0.7789662", "0.7729586", "0.76835144", "0.7667158", "0.75434864", "0.7506883", "0.7497467", "0.7495052", "0.7428854", "0.7428854", "0.74270916", "0.7376906", "0.7371302", "0.73371094", "0.73065597", "0.7303...
0.80785364
1
Set up data for the test case
def setUp(self): self._request_factory = RequestFactory() self._anon_user = AnonymousUser() self._auth_user = UserFactory.create( email="test@edx.org", username="test", profile__name="Test User" ) # This contains issue_type and course_i...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUp(self):\n self.dataset = get_test_dataset()", "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n # vol...
[ "0.80612", "0.79541", "0.79541", "0.79541", "0.79541", "0.78928304", "0.787814", "0.78112984", "0.76665294", "0.7665707", "0.76270103", "0.760573", "0.7546977", "0.74605364", "0.7458917", "0.7434283", "0.74240744", "0.73241657", "0.73185736", "0.7306994", "0.7290422", "0.72...
0.0
-1
Assert that the given `response` contains correct failure data. It should have a 400 status code, and its content should be a JSON object containing the specified `field` and an `error`.
def _assert_bad_request(self, response, field, zendesk_mock_class, datadog_mock): self.assertEqual(response.status_code, 400) resp_json = json.loads(response.content) self.assertTrue("field" in resp_json) self.assertEqual(resp_json["field"], field) self.assertTrue("error" in...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_has_valid_error(self, response, expected_code):\r\n assert 'error' in response\r\n assert len(response) == 1\r\n \r\n error = response['error']\r\n assert 'code' in error\r\n assert error['code'] == expected_code\r\n assert 'title' in ...
[ "0.7537807", "0.7365843", "0.7321641", "0.7315908", "0.7257253", "0.71344787", "0.6974869", "0.69589365", "0.6928719", "0.69108576", "0.6897674", "0.689316", "0.68004096", "0.67060727", "0.6693329", "0.6678757", "0.66368073", "0.6604464", "0.6559997", "0.6557062", "0.64946485...
0.8021138
0
Generate a request, invoke the view, and assert success. The request will be a POST request from the given `user`, with the given `fields` in the POST body. The response should have a 200 (success) status code.
def _test_success(self, user, fields): resp = self._build_and_run_request(user, fields) self.assertEqual(resp.status_code, 200)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _build_and_run_request(self, user, fields):\r\n req = self._request_factory.post(\r\n \"/submit_feedback\",\r\n data=fields,\r\n HTTP_REFERER=\"test_referer\",\r\n HTTP_USER_AGENT=\"test_user_agent\",\r\n REMOTE_ADDR=\"1.2.3.4\",\r\n SERV...
[ "0.7689661", "0.61725134", "0.60960066", "0.5984209", "0.59357965", "0.5903597", "0.5903052", "0.5878621", "0.5876233", "0.5864054", "0.5818076", "0.58071095", "0.58052665", "0.58052665", "0.5751443", "0.57483053", "0.5732779", "0.57191175", "0.5704708", "0.56840354", "0.5673...
0.73267573
1
Test a request from an anonymous user not specifying `email`.
def test_bad_request_anon_user_no_email(self, zendesk_mock_class, datadog_mock): self._test_bad_request_omit_field(self._anon_user, self._anon_fields, "email", zendesk_mock_class, datadog_mock) self._test_bad_request_empty_field(self._anon_user, self._anon_fields, "email", zendesk_mock_class, datadog_...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_bad_request_anon_user_invalid_email(self, zendesk_mock_class, datadog_mock):\r\n fields = self._anon_fields.copy()\r\n fields[\"email\"] = \"This is not a valid email address!\"\r\n resp = self._build_and_run_request(self._anon_user, fields)\r\n self._assert_bad_request(resp, \...
[ "0.7078291", "0.6990375", "0.69707435", "0.6958209", "0.67805773", "0.6757021", "0.6717861", "0.6687804", "0.66609573", "0.6619616", "0.66160667", "0.66108286", "0.65905464", "0.6584376", "0.6582907", "0.6574041", "0.65425956", "0.653478", "0.65205437", "0.65035605", "0.64823...
0.7320998
0
Test a request from an anonymous user specifying an invalid `email`.
def test_bad_request_anon_user_invalid_email(self, zendesk_mock_class, datadog_mock): fields = self._anon_fields.copy() fields["email"] = "This is not a valid email address!" resp = self._build_and_run_request(self._anon_user, fields) self._assert_bad_request(resp, "email", zendesk_m...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_bad_request_anon_user_no_email(self, zendesk_mock_class, datadog_mock):\r\n self._test_bad_request_omit_field(self._anon_user, self._anon_fields, \"email\", zendesk_mock_class, datadog_mock)\r\n self._test_bad_request_empty_field(self._anon_user, self._anon_fields, \"email\", zendesk_mock_cl...
[ "0.77083385", "0.74361354", "0.7272927", "0.72651345", "0.7209781", "0.7159246", "0.7151123", "0.7126724", "0.7102489", "0.70775807", "0.7047011", "0.7021895", "0.7001493", "0.6976844", "0.69639647", "0.69630444", "0.694798", "0.6946596", "0.69462836", "0.6944042", "0.6936276...
0.7934868
0
Test a valid request from an anonymous user. The response should have a 200 (success) status code, and a ticket with the given information should have been submitted via the Zendesk API.
def test_valid_request_anon_user(self, zendesk_mock_class, datadog_mock): zendesk_mock_instance = zendesk_mock_class.return_value zendesk_mock_instance.create_ticket.return_value = 42 self._test_success(self._anon_user, self._anon_fields) expected_zendesk_calls = [ mock....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_anonymous(self):\n self.logout_user()\n\n response = self.client.get(self.api_link)\n self.assertContains(response, \"sign in to use private threads\", status_code=403)", "def test_valid_request_auth_user(self, zendesk_mock_class, datadog_mock):\r\n zendesk_mock_instance = ze...
[ "0.7026273", "0.69410914", "0.6727108", "0.66756654", "0.6568334", "0.65125704", "0.65104103", "0.6471474", "0.64626473", "0.64600533", "0.6422635", "0.640094", "0.63884693", "0.63600045", "0.6358709", "0.6314055", "0.62782204", "0.62555575", "0.62543875", "0.6254152", "0.624...
0.7491169
0
Test a valid request from an authenticated user. The response should have a 200 (success) status code, and a ticket with the given information should have been submitted via the Zendesk API.
def test_valid_request_auth_user(self, zendesk_mock_class, datadog_mock): zendesk_mock_instance = zendesk_mock_class.return_value zendesk_mock_instance.create_ticket.return_value = 42 self._test_success(self._auth_user, self._auth_fields) expected_zendesk_calls = [ mock....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_valid_request_anon_user(self, zendesk_mock_class, datadog_mock):\r\n zendesk_mock_instance = zendesk_mock_class.return_value\r\n zendesk_mock_instance.create_ticket.return_value = 42\r\n self._test_success(self._anon_user, self._anon_fields)\r\n expected_zendesk_calls = [\r\n ...
[ "0.6972522", "0.68966067", "0.6737699", "0.65787554", "0.6537919", "0.6486657", "0.6386837", "0.6380151", "0.6356856", "0.6313111", "0.6285645", "0.626776", "0.6255982", "0.6252874", "0.62500876", "0.6241517", "0.62134355", "0.6195091", "0.6186", "0.6167732", "0.61661667", ...
0.7600158
0
Test that a GET results in a 405 even with all required fields
def test_get_request(self, zendesk_mock_class, datadog_mock): req = self._request_factory.get("/submit_feedback", data=self._anon_fields) req.user = self._anon_user resp = views.submit_feedback(req) self.assertEqual(resp.status_code, 405) self.assertIn("Allow", resp) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_not_get(self):\n self._environ['REQUEST_METHOD'] = 'POST'\n self.assertResponse('405 %s' % httplib.responses[405], [], '', self.app,\n self._environ)", "def test_bad_method(self):\n\n request = service.get_request('GET', {})\n x = self.start_request_tests(reque...
[ "0.8218913", "0.78943294", "0.7891475", "0.7854829", "0.78534395", "0.7846297", "0.78032255", "0.7760917", "0.763142", "0.7593132", "0.7576753", "0.7450814", "0.7406113", "0.74055684", "0.7357058", "0.7316966", "0.73067904", "0.73049355", "0.73030883", "0.7301614", "0.7274267...
0.0
-1
Test for Zendesk submission not enabled in `settings`. We should raise Http404.
def test_not_enabled(self, zendesk_mock_class, datadog_mock): with self.assertRaises(Http404): self._build_and_run_request(self._anon_user, self._anon_fields)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _is_grade_request(self):\r\n return 'xqueue/submit' in self.path", "def test_email_disabled(self):\r\n test_email = {\r\n 'action': 'Send email',\r\n 'send_to': 'myself',\r\n 'subject': 'test subject for myself',\r\n 'message': 'test message for mysel...
[ "0.5928428", "0.59228474", "0.5897019", "0.58725655", "0.58365035", "0.57742333", "0.57480764", "0.5657538", "0.55934495", "0.5562666", "0.549092", "0.545017", "0.54208314", "0.54159856", "0.53993654", "0.53973407", "0.5387584", "0.5351314", "0.5344013", "0.53336865", "0.5312...
0.65270275
0
Instantiate the Zendesk API. All of `ZENDESK_URL`, `ZENDESK_USER`, and `ZENDESK_API_KEY` must be set in `django.conf.settings`.
def __init__(self): self._zendesk_instance = zendesk.Zendesk( settings.ZENDESK_URL, settings.ZENDESK_USER, settings.ZENDESK_API_KEY, use_api_token=True, api_version=2, # As of 2012-05-08, Zendesk is using a CA that is not ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def configure_news_api(self):\n self.news_api = newsapi.NewsApiClient(self.api_key)", "def __init__(self, api_key, client=Fetcher(FANART_URL)):\n self.api_key = api_key\n self.client = client", "def __init__(self, api_key):\n self.api_key = api_key\n self.base_url = 'https://stud...
[ "0.6366337", "0.61672777", "0.61438835", "0.6111764", "0.6064897", "0.6050864", "0.60081124", "0.5933778", "0.5919267", "0.5886388", "0.58793336", "0.58142966", "0.58046323", "0.57916677", "0.57558", "0.57511824", "0.56647664", "0.56449956", "0.56434727", "0.56291056", "0.562...
0.83392286
0
Return whether this request has an Accept header that matches type
def accepts(request, media_type): accept = parse_accept_header(request.META.get("HTTP_ACCEPT", "")) return media_type in [t for (t, p, q) in accept]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def accepts_header(request: Request) -> str:\n return request.headers.get('ACCEPTS')", "def get_accept_header(\n cls,\n media_type=None,\n version=None,\n ):\n if not media_type:\n media_type = cls.media_type\n if not version:\n version = cls.api_ver...
[ "0.77143264", "0.7027317", "0.6968511", "0.69669265", "0.68842846", "0.68391114", "0.67766905", "0.6767496", "0.66149634", "0.6578305", "0.6555817", "0.6339809", "0.6316563", "0.6171099", "0.6135586", "0.61331725", "0.6113771", "0.6109958", "0.6099325", "0.6072898", "0.605994...
0.79619336
0
Convert all keys in a dictionary to lowercase; keep their original values. Keep in mind that it is possible (but not useful?) to define different variables that have the same lowercase representation. It would be hard to tell which is used in the final dict and which isn't.
def lower_dict(input_dict): return {k.lower(): v for k, v in input_dict.iteritems()}
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _convert_keys_to_lower(self, dictionary: dict) -> dict:\n lower_case_dictionary = OrderedDict()\n\n for key, value in dictionary.items():\n if not key.islower():\n if key.lower() in lower_case_dictionary.keys():\n raise ValueError(f\"Duplicate (case in...
[ "0.83227825", "0.8167523", "0.8093144", "0.8020457", "0.7910776", "0.7852716", "0.7482287", "0.73181957", "0.72900665", "0.7070733", "0.67734855", "0.6521139", "0.62302953", "0.61328846", "0.61094046", "0.6018737", "0.6007649", "0.59416324", "0.58191574", "0.58148676", "0.579...
0.8160106
2
Create dictionaries with both the default and userdefined variables.
def add_defaults(variables, functions, case_sensitive): all_variables = dict(DEFAULT_VARIABLES) all_functions = dict(DEFAULT_FUNCTIONS) all_variables.update(variables) all_functions.update(functions) if not case_sensitive: all_variables = lower_dict(all_variables) all_functi...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_vars():\n return dict()", "def get_user_variable_dict(self):\n user_variable_keys = ['User variable {}'.format(i) for i in range(len(self.user_variables))]\n return dict(zip(user_variable_keys, self.user_variables))", "def dictOfRandomVariables(self):\n return dict()", "de...
[ "0.72018135", "0.65238595", "0.6474267", "0.6463842", "0.6422836", "0.6406818", "0.6375276", "0.63718957", "0.63436824", "0.63163877", "0.63163877", "0.6251024", "0.62344235", "0.6211121", "0.61877567", "0.612581", "0.60028505", "0.59895265", "0.5969718", "0.5935128", "0.5927...
0.6503666
2
When a variable is recognized, store it in `variables_used`.
def vpa(tokens): varname = tokens[0][0] self.variables_used.add(varname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def variables_used (self) :\r\n\t\treturn []", "def variables_used (self) :\r\n\t\t## These names possibly contain dimension specification!\r\n\t\treturn self.variable_names", "def variables_used (self) :\r\n\t\treturn [i[0] for i in self.parameters]", "def variable_uses(self, var):\n def _add_tensor_cons...
[ "0.71859705", "0.6861719", "0.6444601", "0.6341725", "0.628051", "0.62262267", "0.6183813", "0.6129114", "0.60635924", "0.6024506", "0.60103166", "0.5994684", "0.59889793", "0.5938611", "0.5905588", "0.5887613", "0.58472955", "0.5786249", "0.57733333", "0.5752362", "0.5720458...
0.71883875
0
Confirm that all the variables used in the tree are valid/defined. Otherwise, raise an UndefinedVariable containing all bad variables.
def check_variables(self, valid_variables, valid_functions): if self.case_sensitive: casify = lambda x: x else: casify = lambda x: x.lower() # Lowercase for case insens. # Test if casify(X) is valid, but return the actual bad input (i.e. X) bad_vars = set...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _var_check(self):\n missing = set()\n for v in self.variables:\n if getattr(self, v) is None:\n missing.add(v)\n self.missing = missing", "def __validateTemplateVariables(self, vars):\n for requiredVarName in self.varNames():\n if requiredVarNa...
[ "0.70681953", "0.6659539", "0.65979207", "0.6579423", "0.6434802", "0.6393849", "0.63777095", "0.6301834", "0.6286277", "0.6286277", "0.6286277", "0.6286277", "0.6286277", "0.6286277", "0.6286277", "0.6286277", "0.6286277", "0.6249415", "0.6249415", "0.6249415", "0.6249415", ...
0.74288714
0
Ensure division by zero gives an error
def test_raises_zero_division_err(self): with self.assertRaises(ZeroDivisionError): calc.evaluator({}, {}, '1/0') with self.assertRaises(ZeroDivisionError): calc.evaluator({}, {}, '1/0.0') with self.assertRaises(ZeroDivisionError): calc.evaluator({'x': 0...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def division(a, b):\n if b == 0:\n raise ZeroDivisionError", "def test_a_zero_division():\n assert divide(3, 0) is math.nan", "def provoke_and_handle_ZeroDivisionError():\n try:\n print(324/0)\n except ZeroDivisionError as zde:\n print(f\"Sorry! {zde}\")", "def div(num1, num2...
[ "0.81381667", "0.78752923", "0.78022903", "0.75018126", "0.7477701", "0.7467066", "0.74334425", "0.7275257", "0.72364813", "0.71907854", "0.7190727", "0.71648407", "0.71245754", "0.70239943", "0.69644654", "0.68212885", "0.6816249", "0.6756776", "0.67295074", "0.67228734", "0...
0.74719566
5
Check that we get an error with invalid parens.
def test_bad_parens(self): with self.assertRaisesRegexp(Exception, 'Unknown parenthesis'): preview.LatexRendered('x^2', parens='not parens')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sqpp_paren_close_only_failure(self):\n self.failUnlessRaises(SyntaxError,\n self.parser.parse_query,\"expr)\")", "def valid_parentheses(parens):\n while len(parens) >= 1:\n if parens[0] == ')' or parens[-1] == '(':\n return False\n index = ...
[ "0.7269053", "0.7215037", "0.7212856", "0.711161", "0.70397896", "0.70313066", "0.6967492", "0.68716943", "0.6838085", "0.67922956", "0.6694168", "0.6424868", "0.63948977", "0.63007545", "0.6251686", "0.62292147", "0.61351633", "0.60624534", "0.6047185", "0.6039318", "0.60180...
0.7882163
0
Powers should wrap the elements with braces correctly.
def test_power_simple(self): self.assertEquals(preview.latex_preview('2^3^4'), '2^{3^{4}}')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_squiggles_tall(self):\r\n self._each_parens(r'\\left\\{x^y\\right\\}', 'x^y', '{', tall=True)", "def w(n):\n return '{' + n + '}'", "def test_brackets_tall(self):\r\n self._each_parens(r'\\left[x^y\\right]', 'x^y', '[', tall=True)", "def test_nested_format_fields():\n '{0:>{1}}'....
[ "0.58253944", "0.56298673", "0.56159455", "0.560236", "0.55842817", "0.55686", "0.5485601", "0.54357004", "0.54282", "0.53963035", "0.5369961", "0.53450155", "0.53088653", "0.5305812", "0.5194239", "0.51833504", "0.51362795", "0.5122755", "0.5060954", "0.5042795", "0.50388426...
0.0
-1
Sums should combine its elements.
def test_sum(self): # Use 'x' as the first term (instead of, say, '1'), so it can't be # interpreted as a negative number. self.assertEquals( preview.latex_preview('-x+2-3+4', variables=['x']), '-x+2-3+4' )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_elements(arr):\n return sum(arr)", "def sum(cls, vectors):\n result = cls.null()\n for vector in vectors:\n result += vector\n return result", "def _sum(self):\n s = 0\n for element, value in self.items():\n s += value\n return s", "d...
[ "0.7397543", "0.7036866", "0.69950485", "0.69029176", "0.68735254", "0.68635356", "0.67531556", "0.67438287", "0.673329", "0.66964006", "0.6691163", "0.66850996", "0.66544604", "0.6654115", "0.6636665", "0.66256183", "0.6583652", "0.6573945", "0.6569921", "0.6524681", "0.6521...
0.0
-1
Return the maximum score for this problem.
def get_max_score(self): maxscore = 0 for responder in self.responders.values(): maxscore += responder.get_max_score() return maxscore
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def max_score(self):\r\n return self.lcp.get_max_score()", "def max_score(self):\n return max(self._extract_set('score') or [0])", "def max_score(self):\r\n max_score = None\r\n if self.check_if_done_and_scored():\r\n max_score = self._max_score\r\n return max_scor...
[ "0.8710416", "0.8597576", "0.8424312", "0.8421966", "0.8295265", "0.80671924", "0.80230963", "0.78949016", "0.7765432", "0.76982343", "0.76648664", "0.7582319", "0.755832", "0.7429224", "0.74153376", "0.74087185", "0.7347865", "0.7347865", "0.7253463", "0.7225822", "0.7225822...
0.7848112
8
Raises a ValueError if the choice attribute is missing or invalid.
def _validate_options(self): valid_choices = ('correct', 'partially-correct', 'incorrect') for option in self.options: choice = option['choice'] if choice is None: raise ValueError('Missing required choice attribute.') elif choice not in valid_ch...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_choice(self, choice):\n if choice not in self.choices:\n error = \"Invalid Choice please choose from {}\".format(\n \", \".join(self.choices)\n )\n return error\n return choice", "def validate_choice(value, choices):\n if choices is not ...
[ "0.7269779", "0.6628298", "0.6570509", "0.65648717", "0.6383281", "0.628617", "0.6263483", "0.6217514", "0.6144229", "0.61186725", "0.59876925", "0.59606534", "0.59584266", "0.59124005", "0.5864097", "0.58265024", "0.5815236", "0.58008444", "0.5792435", "0.5784101", "0.575685...
0.65178293
4
Initialize name attributes in tags for this response.
def assign_choice_names(self): for index, choice in enumerate(self.xml.xpath('//*[@id=$id]//choice', id=self.xml.get('id'))): choice.set("name", "choice_" + str(index))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, tag):\n self.tag = tag.lower()\n self.attrs = {}\n self.contents = ()", "def start_name(self, attributes):\n self.name = True", "def _init(self, **kwds):\n name = kwds.get('name')\n if name and not self.data.has_key('name'):\n self.set_nam...
[ "0.6213744", "0.61512655", "0.60791516", "0.60166687", "0.6008238", "0.6008238", "0.6002434", "0.5979193", "0.5946934", "0.59344643", "0.5904968", "0.58899677", "0.58783054", "0.585833", "0.5834044", "0.5820954", "0.58202285", "0.57795805", "0.57795805", "0.57729566", "0.5761...
0.0
-1
Initialize name attributes in stanzas in the in this response. Masks the choice names if applicable.
def mc_setup_response(self): i = 0 for response in self.xml.xpath("choicegroup"): # Is Masking enabled? -- check for shuffle or answer-pool features ans_str = response.get("answer-pool") if response.get("shuffle") == "true" or (ans_str is not None and ans_str != ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assign_choice_names(self):\r\n\r\n for index, choice in enumerate(self.xml.xpath('//*[@id=$id]//choice',\r\n id=self.xml.get('id'))):\r\n choice.set(\"name\", \"choice_\" + str(index))", "def __init__(self, name, attrs={}):\n Choic...
[ "0.641977", "0.6032335", "0.6032335", "0.5933803", "0.5707586", "0.5670894", "0.5593813", "0.556715", "0.5551137", "0.55500525", "0.5532684", "0.55285734", "0.5479143", "0.5476805", "0.5458624", "0.54100996", "0.53731376", "0.5369349", "0.5360188", "0.5360188", "0.53286177", ...
0.5119899
53
Returns whether this answer is in a valid form.
def validate_answer(self, answer): try: evaluator(dict(), dict(), answer) return True except (StudentInputError, UndefinedVariable): return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid(self):\n if self.answer_type == 'F':\n return bool(self.text)\n\n if not self.answers.count():\n return False\n if not self.answers.filter(correct=True).count():\n return False\n return True", "def is_valid(self):\n try:\n ...
[ "0.79358566", "0.72665167", "0.7251891", "0.7245691", "0.71738786", "0.71651036", "0.7157576", "0.7150144", "0.71313846", "0.70041555", "0.69793314", "0.6961923", "0.6940886", "0.6911794", "0.69099766", "0.6893721", "0.68805474", "0.68801284", "0.6858607", "0.68464404", "0.68...
0.7121675
9
student_answers is a dict with everything from request.POST, but with the first part of each key removed (the string before the first "_").
def get_score(self, student_answers): _ = self.capa_system.i18n.ugettext log.debug('%s: student_answers=%s', unicode(self), student_answers) # ordered list of answer id's idset = sorted(self.answer_ids) try: # ordered list of answers submission ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def game_post():\n game = Game.current_game\n question = game.current_question\n \n answer_keys = request.form[\"answer_keys\"].split('++')\n print(answer_keys)\n question['user_response'] = answer_keys\n \n return redirect(url_for(\"show_answer\"))", "def _grade_answers(self, student_ans...
[ "0.5712987", "0.5702855", "0.5601402", "0.55010206", "0.5243873", "0.5226696", "0.5201841", "0.51651394", "0.5088438", "0.5079441", "0.499023", "0.4927523", "0.4925778", "0.49232388", "0.4911393", "0.4898891", "0.48921692", "0.48680487", "0.4862841", "0.48573312", "0.48181862...
0.5137766
8
Returns a list of dictionaries mapping variables to random values in range, as expected by tupleize_answers.
def randomize_variables(self, samples): variables = samples.split('@')[0].split(',') numsamples = int(samples.split('@')[1].split('#')[1]) sranges = zip(*map(lambda x: map(float, x.split(",")), samples.split('@')[1].split('#')[0].split(':'))) ranges = dict...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_var_ranges(self):\n\n var_ranges = {}\n for var in self.variables:\n min_to_max = list(range(int(var['min']), int(var['max']) + 1))\n if (var['zero_ok'] == False and 0 in min_to_max):\n min_to_max.remove(0)\n\n var_ranges[var['variable']] =...
[ "0.6688037", "0.6278308", "0.6246931", "0.609172", "0.59954065", "0.5910671", "0.58617646", "0.58567554", "0.581601", "0.5794686", "0.57822543", "0.5749925", "0.5749925", "0.5749925", "0.5749925", "0.571996", "0.5712892", "0.570693", "0.57030886", "0.5702196", "0.56975025", ...
0.68368095
0
An external interface for comparing whether a and b are equal.
def compare_answer(self, ans1, ans2): internal_result = self.check_formula(ans1, ans2, self.samples) return internal_result == "correct"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_equal(self, a, b):\n return a == b", "def is_equal(self, a, b):\n return a is b", "def equals(a, b, **kwargs):\n return lib.equals(a, b, **kwargs)", "def equals(x, y):\n return x == y", "def values_eq(self, a, b):\r\n return a == b", "def check_equivalent(self, a, b):\n ...
[ "0.82037544", "0.8050834", "0.7603017", "0.74143076", "0.7401489", "0.72426057", "0.72110146", "0.7179966", "0.71775335", "0.71373475", "0.71190345", "0.7098635", "0.7085928", "0.70405006", "0.70405006", "0.70180404", "0.70180404", "0.7004666", "0.6949013", "0.6943574", "0.69...
0.0
-1
Returns whether this answer is in a valid form.
def validate_answer(self, answer): var_dict_list = self.randomize_variables(self.samples) try: self.tupleize_answers(answer, var_dict_list) return True except StudentInputError: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_valid(self):\n if self.answer_type == 'F':\n return bool(self.text)\n\n if not self.answers.count():\n return False\n if not self.answers.filter(correct=True).count():\n return False\n return True", "def is_valid(self):\n try:\n ...
[ "0.79358566", "0.72665167", "0.7251891", "0.7245691", "0.71738786", "0.71651036", "0.7157576", "0.7150144", "0.71313846", "0.7121675", "0.70041555", "0.69793314", "0.6961923", "0.6940886", "0.6911794", "0.69099766", "0.6893721", "0.68805474", "0.68801284", "0.6858607", "0.684...
0.6641713
27
Initialize name attributes in and tags for this response.
def assign_choice_names(self): for index, choice in enumerate( self.xml.xpath('//*[@id=$id]//choice', id=self.xml.get('id')) ): # Set the name attribute for <choices> # "bc" is appended at the end to indicate that this is a # binary choice as oppos...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _init(self, **kwds):\n name = kwds.get('name')\n if name and not self.data.has_key('name'):\n self.set_name(name)\n self.characterID = kwds.get('characterID', None)\n self.myName = kwds.get('myName', u'')", "def __init__(self, name):\n self._name = name\n ...
[ "0.6608007", "0.63974166", "0.6388281", "0.6388281", "0.63790745", "0.63524985", "0.6333714", "0.63006604", "0.6296042", "0.62873423", "0.6260436", "0.6242789", "0.6242789", "0.62190235", "0.6184636", "0.61404485", "0.61301494", "0.61277676", "0.61277676", "0.6126331", "0.610...
0.0
-1
Test if problem was saved before queuetime was introduced.
def test_matlab_response_migration_of_queuetime(self, time): state = {'input_state': {'queuestate': 'queued'}} elt = etree.fromstring(self.xml) the_input = self.input_class(test_capa_system(), elt, state) context = the_input._get_render_context() self.assertEqual(the_input...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_is_saved(self):\n raise NotImplementedError()", "def _arrived_at_checkpoint(self, current_time):\n if current_time == self.time_step_to_enqueue:\n self.at_checkpoint = True\n return True\n \n return False", "def test_was_saved_properly(self):\n ...
[ "0.5965715", "0.5937451", "0.57166415", "0.56779236", "0.5674591", "0.558444", "0.5579553", "0.55730873", "0.5571533", "0.5560785", "0.55523884", "0.55513746", "0.55496335", "0.5545887", "0.5543366", "0.5536642", "0.5530792", "0.55225897", "0.55208445", "0.55152154", "0.55126...
0.55050427
21
See if division by zero is handled correctly.
def test_raises_zero_division_err(self): problem = self.build_problem(answer="1") # Answer doesn't matter input_dict = {'1_2_1': '1/0'} with self.assertRaises(StudentInputError): problem.grade_answers(input_dict)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_a_zero_division():\n assert divide(3, 0) is math.nan", "def div(num1, num2):\n try:\n return num1 / num2\n except ZeroDivisionError:\n print(\"Handled division by zero. Returning zero.\")\n return 0", "def division(a, b):\n if b == 0:\n raise ZeroDivisionError",...
[ "0.7745074", "0.72670156", "0.7230568", "0.7223941", "0.7198101", "0.7100653", "0.7035957", "0.7023275", "0.6935529", "0.69189805", "0.66317976", "0.654479", "0.6469731", "0.6404779", "0.64022255", "0.63769746", "0.6362892", "0.6337413", "0.6332116", "0.6330066", "0.6308465",...
0.58165497
49
Look for a child of node using , and return its text if found. Otherwise returns default.
def find_with_default(node, path, default): v = node.find(path) if v is not None: return v.text else: return default
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getvalueofnode(node):\n return node.text if node is not None else None", "def getvalueofnode(node):\n return node.text if node is not None else None", "def getvalueofnode(node):\r\n return node.text if node is not None else None", "def getSingleChildTextByName(rootNode, name):\n try:\n ...
[ "0.648427", "0.648427", "0.6474408", "0.6426533", "0.63447344", "0.63430184", "0.62378263", "0.62205994", "0.61671746", "0.60987604", "0.5969785", "0.5967323", "0.5962256", "0.5941489", "0.5933485", "0.58999634", "0.5873879", "0.5806126", "0.58033127", "0.5795195", "0.5790912...
0.6663002
0
Returns least common multiple of a, b
def lcm(a, b): return a * b / fr.gcd(a, b)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def lowest_common_multiple(a, b):\n # 两个数字相乘后除以最大公约数 = 两个数字的最小公倍数\n return a * b // gcd(a, b)", "def least_common_multiple(number1, number2):\n return number1 * number2 // math.gcd(number1, number2)", "def lcm(a, b):\n\treturn a * b // gcm(a, b)", "def multiple(a, b):\n from fractions import gcd\...
[ "0.83429605", "0.7836764", "0.7458216", "0.73888284", "0.7375107", "0.7359496", "0.7328173", "0.7328173", "0.7318472", "0.72911435", "0.72911435", "0.72911435", "0.72911435", "0.72911435", "0.72911435", "0.72911435", "0.72911435", "0.72911435", "0.72729903", "0.7266998", "0.7...
0.72919863
9
Calculates Miller indices from points.
def miller(points): N = np.cross(points[1] - points[0], points[2] - points[0]) O = np.array([0, 0, 0]) P = points[0] # point of plane Ccs = map(np.array, [[1.0, 0, 0], [0, 1.0, 0], [0, 0, 1.0]]) segments = ([np.dot(P - O, N) / np.dot(ort, N) if np.dot(ort, N) != 0 else ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mi(x,y,k=3,base=2):\n x = [[entry] for entry in x]\n y = [[entry] for entry in y]\n assert len(x)==len(y), \"Lists should have same length\"\n assert k <= len(x) - 1, \"Set k smaller than num. samples - 1\"\n intens = 1e-10 #small noise to break degeneracy, see doc.\n x = [list(p + intens*nr....
[ "0.56746465", "0.56527454", "0.54205555", "0.5327948", "0.53020746", "0.53009456", "0.5292157", "0.5246641", "0.5204253", "0.51441264", "0.5131711", "0.51291674", "0.5088204", "0.50515264", "0.5043654", "0.5038279", "0.50278807", "0.5027244", "0.50236535", "0.5018329", "0.500...
0.6249086
0
Returns the results of running `glob` rooted in the directory `root`. All returned paths are relative to `root`. Uses glob2 globbing
def rooted_glob(root, glob): return remove_root(root, sorted(glob2.glob('{root}/{glob}'.format(root=root, glob=glob))))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def recursive_glob(rootdir=\".\", suffix=\"\"):\n return [\n os.path.join(looproot, filename)\n for looproot, _, filenames in os.walk(rootdir)\n for filename in filenames\n if filename.endswith(suffix)\n ]", "def recursive_glob(rootdir=\".\", suffix=\"\"):\n return [\n ...
[ "0.7450728", "0.7450728", "0.7442848", "0.7340041", "0.71393937", "0.7016672", "0.7016672", "0.6869218", "0.68664217", "0.6713087", "0.6705474", "0.6689252", "0.6601593", "0.65770847", "0.65714496", "0.65665203", "0.65178764", "0.6512332", "0.6494783", "0.6493048", "0.6449013...
0.74299467
3
Returns `paths` made relative to `root`
def remove_root(root, paths): return [pth.replace(root + '/', '') for pth in paths]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def path_generator(initial_root):\n for root, dirs, files in os.walk(initial_root):\n paths = [os.path.join(root, name) for name in files]\n return paths", "def _get_paths():\n paths = [\n '/'\n ]\n return paths", "def relative_to_buildroot(self):\n return [os.path.join(self.rel_path, s...
[ "0.71559507", "0.7140561", "0.7089065", "0.68865377", "0.67784166", "0.66210043", "0.6475747", "0.6430411", "0.6422065", "0.6347496", "0.63331795", "0.62893254", "0.62842345", "0.6279251", "0.6272907", "0.62705755", "0.6264181", "0.62204665", "0.6202016", "0.6170451", "0.6169...
0.6441963
7
Just like mkdtemp, but the directory will be deleted when the process ends.
def mkdtemp_clean(suffix="", prefix="tmp", dir=None): the_dir = tempfile.mkdtemp(suffix=suffix, prefix=prefix, dir=dir) atexit.register(cleanup_tempdir, the_dir) return the_dir
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tempdir():\n return mkdtemp()", "def _mkdtemp(*args, **kwargs):\n import tempfile\n dir_name = tempfile.mkdtemp(*args, **kwargs)\n import atexit, shutil\n ignore_errors = True\n atexit.register(shutil.rmtree, dir_name, ignore_errors)\n return dir_name", "def make_tempdir():\n return...
[ "0.81099033", "0.79376453", "0.77628225", "0.77524245", "0.7712284", "0.7710546", "0.76982856", "0.76848364", "0.7567341", "0.7549575", "0.7549357", "0.75482035", "0.7542636", "0.74853", "0.7463968", "0.7424937", "0.7319628", "0.73169607", "0.73048884", "0.72984034", "0.72873...
0.80315894
1
Returns time duration nicely formated, e.g. "3 minutes 4 seconds"
def pretty_print_seconds(self, num_seconds): # Here _ is the N variant ungettext that does pluralization with a 3-arg call _ = self.runtime.service(self, "i18n").ungettext hours = num_seconds // 3600 sub_hour = num_seconds % 3600 minutes = sub_hour // 60 seconds = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_duration_string(duration):\n\n minutes = duration // 60\n seconds = duration % 60\n return \"the game took {} minutes and {} seconds\".format(minutes, seconds)", "def get_formatted_duration(self, prev_time):\n duration = time() - prev_time\n if duration < 60:\n unit = 's...
[ "0.83102196", "0.79882705", "0.7685889", "0.7620867", "0.7570262", "0.75418675", "0.7527479", "0.7511924", "0.7416218", "0.74104875", "0.74079686", "0.72921383", "0.7274579", "0.7227846", "0.7205824", "0.7185711", "0.71216315", "0.71114576", "0.70641863", "0.70453763", "0.704...
0.6652867
51
Returns a list of XModuleDescriptor instances upon which this module depends.
def get_required_module_descriptors(self): descriptors = [] for location in self.sources_list: try: descriptor = self.system.load_item(location) descriptors.append(descriptor) except ItemNotFoundError: msg = "Invalid module b...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_required_module_descriptors(self):\r\n return []", "def get_required_module_descriptors(self):\r\n\r\n # If use_for_single_location is True, this is linked to an open ended problem.\r\n if self.use_for_single_location:\r\n # Try to load the linked module.\r\n # ...
[ "0.69278216", "0.6646763", "0.66224945", "0.65469325", "0.6481922", "0.6375661", "0.6359771", "0.63494647", "0.6291395", "0.627825", "0.6170072", "0.61385244", "0.61217785", "0.6109443", "0.6072233", "0.60651755", "0.6045723", "0.60291225", "0.6023296", "0.5996008", "0.599245...
0.67117727
1