repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
csirtgadgets/csirtgsdk-py | csirtgsdk/feed.py | Feed.show | def show(self, user, name, limit=None, lasttime=None):
"""
Returns a specific Feed from the API
:param user: feed username
:param name: feed name
:param limit: limit the results
:param lasttime: only show >= lasttime
:return: dict
Example:
re... | python | def show(self, user, name, limit=None, lasttime=None):
"""
Returns a specific Feed from the API
:param user: feed username
:param name: feed name
:param limit: limit the results
:param lasttime: only show >= lasttime
:return: dict
Example:
re... | [
"def",
"show",
"(",
"self",
",",
"user",
",",
"name",
",",
"limit",
"=",
"None",
",",
"lasttime",
"=",
"None",
")",
":",
"uri",
"=",
"self",
".",
"client",
".",
"remote",
"+",
"'/users/{0}/feeds/{1}'",
".",
"format",
"(",
"user",
",",
"name",
")",
... | Returns a specific Feed from the API
:param user: feed username
:param name: feed name
:param limit: limit the results
:param lasttime: only show >= lasttime
:return: dict
Example:
ret = feed.show('csirtgadgets', 'port-scanners', limit=5) | [
"Returns",
"a",
"specific",
"Feed",
"from",
"the",
"API"
] | 5a7ed9c5e6fa27170366ecbdef710dc80d537dc2 | https://github.com/csirtgadgets/csirtgsdk-py/blob/5a7ed9c5e6fa27170366ecbdef710dc80d537dc2/csirtgsdk/feed.py#L82-L96 | train |
codenerix/django-codenerix | codenerix/context.py | codenerix | def codenerix(request):
'''
Codenerix CONTEXT
'''
# Get values
DEBUG = getattr(settings, 'DEBUG', False)
VERSION = getattr(settings, 'VERSION', _('WARNING: No version set to this code, add VERSION contant to your configuration'))
# Set environment
return {
'DEBUG': DEBUG,
... | python | def codenerix(request):
'''
Codenerix CONTEXT
'''
# Get values
DEBUG = getattr(settings, 'DEBUG', False)
VERSION = getattr(settings, 'VERSION', _('WARNING: No version set to this code, add VERSION contant to your configuration'))
# Set environment
return {
'DEBUG': DEBUG,
... | [
"def",
"codenerix",
"(",
"request",
")",
":",
"# Get values",
"DEBUG",
"=",
"getattr",
"(",
"settings",
",",
"'DEBUG'",
",",
"False",
")",
"VERSION",
"=",
"getattr",
"(",
"settings",
",",
"'VERSION'",
",",
"_",
"(",
"'WARNING: No version set to this code, add VE... | Codenerix CONTEXT | [
"Codenerix",
"CONTEXT"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/context.py#L28-L41 | train |
CTPUG/wafer | wafer/users/views.py | ProfileView.build_object | def build_object(self, obj):
"""Override django-bakery to skip profiles that raise 404"""
try:
build_path = self.get_build_path(obj)
self.request = self.create_request(build_path)
self.request.user = AnonymousUser()
self.set_kwargs(obj)
self.bu... | python | def build_object(self, obj):
"""Override django-bakery to skip profiles that raise 404"""
try:
build_path = self.get_build_path(obj)
self.request = self.create_request(build_path)
self.request.user = AnonymousUser()
self.set_kwargs(obj)
self.bu... | [
"def",
"build_object",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"build_path",
"=",
"self",
".",
"get_build_path",
"(",
"obj",
")",
"self",
".",
"request",
"=",
"self",
".",
"create_request",
"(",
"build_path",
")",
"self",
".",
"request",
".",
"u... | Override django-bakery to skip profiles that raise 404 | [
"Override",
"django",
"-",
"bakery",
"to",
"skip",
"profiles",
"that",
"raise",
"404"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/users/views.py#L49-L59 | train |
CTPUG/wafer | wafer/schedule/views.py | make_schedule_row | def make_schedule_row(schedule_day, slot, seen_items):
"""Create a row for the schedule table."""
row = ScheduleRow(schedule_day, slot)
skip = {}
expanding = {}
all_items = list(slot.scheduleitem_set
.select_related('talk', 'page', 'venue')
.all())
for ... | python | def make_schedule_row(schedule_day, slot, seen_items):
"""Create a row for the schedule table."""
row = ScheduleRow(schedule_day, slot)
skip = {}
expanding = {}
all_items = list(slot.scheduleitem_set
.select_related('talk', 'page', 'venue')
.all())
for ... | [
"def",
"make_schedule_row",
"(",
"schedule_day",
",",
"slot",
",",
"seen_items",
")",
":",
"row",
"=",
"ScheduleRow",
"(",
"schedule_day",
",",
"slot",
")",
"skip",
"=",
"{",
"}",
"expanding",
"=",
"{",
"}",
"all_items",
"=",
"list",
"(",
"slot",
".",
... | Create a row for the schedule table. | [
"Create",
"a",
"row",
"for",
"the",
"schedule",
"table",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L57-L108 | train |
CTPUG/wafer | wafer/schedule/views.py | generate_schedule | def generate_schedule(today=None):
"""Helper function which creates an ordered list of schedule days"""
# We create a list of slots and schedule items
schedule_days = {}
seen_items = {}
for slot in Slot.objects.all().order_by('end_time', 'start_time', 'day'):
day = slot.get_day()
if ... | python | def generate_schedule(today=None):
"""Helper function which creates an ordered list of schedule days"""
# We create a list of slots and schedule items
schedule_days = {}
seen_items = {}
for slot in Slot.objects.all().order_by('end_time', 'start_time', 'day'):
day = slot.get_day()
if ... | [
"def",
"generate_schedule",
"(",
"today",
"=",
"None",
")",
":",
"# We create a list of slots and schedule items",
"schedule_days",
"=",
"{",
"}",
"seen_items",
"=",
"{",
"}",
"for",
"slot",
"in",
"Slot",
".",
"objects",
".",
"all",
"(",
")",
".",
"order_by",
... | Helper function which creates an ordered list of schedule days | [
"Helper",
"function",
"which",
"creates",
"an",
"ordered",
"list",
"of",
"schedule",
"days"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L111-L126 | train |
CTPUG/wafer | wafer/schedule/views.py | ScheduleXmlView.get_context_data | def get_context_data(self, **kwargs):
"""Allow adding a 'render_description' parameter"""
context = super(ScheduleXmlView, self).get_context_data(**kwargs)
if self.request.GET.get('render_description', None) == '1':
context['render_description'] = True
else:
conte... | python | def get_context_data(self, **kwargs):
"""Allow adding a 'render_description' parameter"""
context = super(ScheduleXmlView, self).get_context_data(**kwargs)
if self.request.GET.get('render_description', None) == '1':
context['render_description'] = True
else:
conte... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"context",
"=",
"super",
"(",
"ScheduleXmlView",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"if",
"self",
".",
"request",
".",
"GET",
".",
"get",
... | Allow adding a 'render_description' parameter | [
"Allow",
"adding",
"a",
"render_description",
"parameter"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L164-L171 | train |
CTPUG/wafer | wafer/schedule/views.py | ICalView.get | def get(self, request):
"""Create a iCal file from the schedule"""
# Heavily inspired by https://djangosnippets.org/snippets/2223/ and
# the icalendar documentation
calendar = Calendar()
site = get_current_site(request)
calendar.add('prodid', '-//%s Schedule//%s//' % (sit... | python | def get(self, request):
"""Create a iCal file from the schedule"""
# Heavily inspired by https://djangosnippets.org/snippets/2223/ and
# the icalendar documentation
calendar = Calendar()
site = get_current_site(request)
calendar.add('prodid', '-//%s Schedule//%s//' % (sit... | [
"def",
"get",
"(",
"self",
",",
"request",
")",
":",
"# Heavily inspired by https://djangosnippets.org/snippets/2223/ and",
"# the icalendar documentation",
"calendar",
"=",
"Calendar",
"(",
")",
"site",
"=",
"get_current_site",
"(",
"request",
")",
"calendar",
".",
"ad... | Create a iCal file from the schedule | [
"Create",
"a",
"iCal",
"file",
"from",
"the",
"schedule"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/views.py#L344-L367 | train |
CTPUG/wafer | wafer/pages/views.py | slug | def slug(request, url):
"""Look up a page by url (which is a tree of slugs)"""
page = None
if url:
for slug in url.split('/'):
if not slug:
continue
try:
page = Page.objects.get(slug=slug, parent=page)
except Page.DoesNotExist:
... | python | def slug(request, url):
"""Look up a page by url (which is a tree of slugs)"""
page = None
if url:
for slug in url.split('/'):
if not slug:
continue
try:
page = Page.objects.get(slug=slug, parent=page)
except Page.DoesNotExist:
... | [
"def",
"slug",
"(",
"request",
",",
"url",
")",
":",
"page",
"=",
"None",
"if",
"url",
":",
"for",
"slug",
"in",
"url",
".",
"split",
"(",
"'/'",
")",
":",
"if",
"not",
"slug",
":",
"continue",
"try",
":",
"page",
"=",
"Page",
".",
"objects",
"... | Look up a page by url (which is a tree of slugs) | [
"Look",
"up",
"a",
"page",
"by",
"url",
"(",
"which",
"is",
"a",
"tree",
"of",
"slugs",
")"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/views.py#L88-L117 | train |
CTPUG/wafer | wafer/pages/views.py | ShowPage.build_object | def build_object(self, obj):
"""Override django-bakery to skip pages marked exclude_from_static"""
if not obj.exclude_from_static:
super(ShowPage, self).build_object(obj) | python | def build_object(self, obj):
"""Override django-bakery to skip pages marked exclude_from_static"""
if not obj.exclude_from_static:
super(ShowPage, self).build_object(obj) | [
"def",
"build_object",
"(",
"self",
",",
"obj",
")",
":",
"if",
"not",
"obj",
".",
"exclude_from_static",
":",
"super",
"(",
"ShowPage",
",",
"self",
")",
".",
"build_object",
"(",
"obj",
")"
] | Override django-bakery to skip pages marked exclude_from_static | [
"Override",
"django",
"-",
"bakery",
"to",
"skip",
"pages",
"marked",
"exclude_from_static"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/views.py#L23-L26 | train |
CTPUG/wafer | wafer/talks/views.py | TalkView.build_object | def build_object(self, obj):
"""Override django-bakery to skip talks that raise 403"""
try:
super(TalkView, self).build_object(obj)
except PermissionDenied:
# We cleanup the directory created
self.unbuild_object(obj) | python | def build_object(self, obj):
"""Override django-bakery to skip talks that raise 403"""
try:
super(TalkView, self).build_object(obj)
except PermissionDenied:
# We cleanup the directory created
self.unbuild_object(obj) | [
"def",
"build_object",
"(",
"self",
",",
"obj",
")",
":",
"try",
":",
"super",
"(",
"TalkView",
",",
"self",
")",
".",
"build_object",
"(",
"obj",
")",
"except",
"PermissionDenied",
":",
"# We cleanup the directory created",
"self",
".",
"unbuild_object",
"(",... | Override django-bakery to skip talks that raise 403 | [
"Override",
"django",
"-",
"bakery",
"to",
"skip",
"talks",
"that",
"raise",
"403"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L61-L67 | train |
CTPUG/wafer | wafer/talks/views.py | TalkView.get_object | def get_object(self, *args, **kwargs):
'''Only talk owners can see talks, unless they've been accepted'''
object_ = super(TalkView, self).get_object(*args, **kwargs)
if not object_.can_view(self.request.user):
raise PermissionDenied
return object_ | python | def get_object(self, *args, **kwargs):
'''Only talk owners can see talks, unless they've been accepted'''
object_ = super(TalkView, self).get_object(*args, **kwargs)
if not object_.can_view(self.request.user):
raise PermissionDenied
return object_ | [
"def",
"get_object",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"object_",
"=",
"super",
"(",
"TalkView",
",",
"self",
")",
".",
"get_object",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"object_",
".",
"ca... | Only talk owners can see talks, unless they've been accepted | [
"Only",
"talk",
"owners",
"can",
"see",
"talks",
"unless",
"they",
"ve",
"been",
"accepted"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L74-L79 | train |
CTPUG/wafer | wafer/talks/views.py | TalkView.render_to_response | def render_to_response(self, *args, **kwargs):
'''Canonicalize the URL if the slug changed'''
if self.request.path != self.object.get_absolute_url():
return HttpResponseRedirect(self.object.get_absolute_url())
return super(TalkView, self).render_to_response(*args, **kwargs) | python | def render_to_response(self, *args, **kwargs):
'''Canonicalize the URL if the slug changed'''
if self.request.path != self.object.get_absolute_url():
return HttpResponseRedirect(self.object.get_absolute_url())
return super(TalkView, self).render_to_response(*args, **kwargs) | [
"def",
"render_to_response",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"request",
".",
"path",
"!=",
"self",
".",
"object",
".",
"get_absolute_url",
"(",
")",
":",
"return",
"HttpResponseRedirect",
"(",
"self",
... | Canonicalize the URL if the slug changed | [
"Canonicalize",
"the",
"URL",
"if",
"the",
"slug",
"changed"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L81-L85 | train |
CTPUG/wafer | wafer/talks/views.py | TalkWithdraw.delete | def delete(self, request, *args, **kwargs):
"""Override delete to only withdraw"""
talk = self.get_object()
talk.status = WITHDRAWN
talk.save()
revisions.set_user(self.request.user)
revisions.set_comment("Talk Withdrawn")
return HttpResponseRedirect(self.success_u... | python | def delete(self, request, *args, **kwargs):
"""Override delete to only withdraw"""
talk = self.get_object()
talk.status = WITHDRAWN
talk.save()
revisions.set_user(self.request.user)
revisions.set_comment("Talk Withdrawn")
return HttpResponseRedirect(self.success_u... | [
"def",
"delete",
"(",
"self",
",",
"request",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"talk",
"=",
"self",
".",
"get_object",
"(",
")",
"talk",
".",
"status",
"=",
"WITHDRAWN",
"talk",
".",
"save",
"(",
")",
"revisions",
".",
"set_user... | Override delete to only withdraw | [
"Override",
"delete",
"to",
"only",
"withdraw"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/talks/views.py#L173-L180 | train |
CTPUG/wafer | wafer/utils.py | order_results_by | def order_results_by(*fields):
"""A decorator that applies an ordering to the QuerySet returned by a
function.
"""
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kw):
result = f(*args, **kw)
return result.order_by(*fields)
return wrapper
... | python | def order_results_by(*fields):
"""A decorator that applies an ordering to the QuerySet returned by a
function.
"""
def decorator(f):
@functools.wraps(f)
def wrapper(*args, **kw):
result = f(*args, **kw)
return result.order_by(*fields)
return wrapper
... | [
"def",
"order_results_by",
"(",
"*",
"fields",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"result",
"=",
"f",
"(",
"*",
"ar... | A decorator that applies an ordering to the QuerySet returned by a
function. | [
"A",
"decorator",
"that",
"applies",
"an",
"ordering",
"to",
"the",
"QuerySet",
"returned",
"by",
"a",
"function",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/utils.py#L21-L31 | train |
CTPUG/wafer | wafer/utils.py | cache_result | def cache_result(cache_key, timeout):
"""A decorator for caching the result of a function."""
def decorator(f):
cache_name = settings.WAFER_CACHE
@functools.wraps(f)
def wrapper(*args, **kw):
cache = caches[cache_name]
result = cache.get(cache_key)
if... | python | def cache_result(cache_key, timeout):
"""A decorator for caching the result of a function."""
def decorator(f):
cache_name = settings.WAFER_CACHE
@functools.wraps(f)
def wrapper(*args, **kw):
cache = caches[cache_name]
result = cache.get(cache_key)
if... | [
"def",
"cache_result",
"(",
"cache_key",
",",
"timeout",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"cache_name",
"=",
"settings",
".",
"WAFER_CACHE",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
... | A decorator for caching the result of a function. | [
"A",
"decorator",
"for",
"caching",
"the",
"result",
"of",
"a",
"function",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/utils.py#L34-L54 | train |
CTPUG/wafer | wafer/utils.py | PaginatedBuildableListView.build_queryset | def build_queryset(self):
"""Override django-bakery's build logic to fake pagination."""
paths = [(os.path.join(self.build_prefix, 'index.html'), {})]
self.request = None
queryset = self.get_queryset()
paginator = self.get_paginator(queryset, self.get_paginate_by(queryset))
... | python | def build_queryset(self):
"""Override django-bakery's build logic to fake pagination."""
paths = [(os.path.join(self.build_prefix, 'index.html'), {})]
self.request = None
queryset = self.get_queryset()
paginator = self.get_paginator(queryset, self.get_paginate_by(queryset))
... | [
"def",
"build_queryset",
"(",
"self",
")",
":",
"paths",
"=",
"[",
"(",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"build_prefix",
",",
"'index.html'",
")",
",",
"{",
"}",
")",
"]",
"self",
".",
"request",
"=",
"None",
"queryset",
"=",
"self... | Override django-bakery's build logic to fake pagination. | [
"Override",
"django",
"-",
"bakery",
"s",
"build",
"logic",
"to",
"fake",
"pagination",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/utils.py#L83-L101 | train |
codenerix/django-codenerix | codenerix/forms.py | BaseForm.get_groups | def get_groups(self, gs=None, processed=[], initial=True):
'''
<--------------------------------------- 12 columns ------------------------------------>
<--- 6 columns ---> <--- 6 columns --->
------------------------------------------ -----------... | python | def get_groups(self, gs=None, processed=[], initial=True):
'''
<--------------------------------------- 12 columns ------------------------------------>
<--- 6 columns ---> <--- 6 columns --->
------------------------------------------ -----------... | [
"def",
"get_groups",
"(",
"self",
",",
"gs",
"=",
"None",
",",
"processed",
"=",
"[",
"]",
",",
"initial",
"=",
"True",
")",
":",
"# Check if language is set",
"if",
"not",
"self",
".",
"__language",
":",
"raise",
"IOError",
"(",
"\"ERROR: No language suplie... | <--------------------------------------- 12 columns ------------------------------------>
<--- 6 columns ---> <--- 6 columns --->
------------------------------------------ ------------------------------------------
| Info ... | [
"<",
"---------------------------------------",
"12",
"columns",
"------------------------------------",
">",
"<",
"---",
"6",
"columns",
"---",
">",
"<",
"---",
"6",
"columns",
"---",
">",
"------------------------------------------",
"-----------------------------------------... | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/forms.py#L95-L502 | train |
CTPUG/wafer | wafer/context_processors.py | site_info | def site_info(request):
'''Expose the site's info to templates'''
site = get_current_site(request)
context = {
'WAFER_CONFERENCE_NAME': site.name,
'WAFER_CONFERENCE_DOMAIN': site.domain,
}
return context | python | def site_info(request):
'''Expose the site's info to templates'''
site = get_current_site(request)
context = {
'WAFER_CONFERENCE_NAME': site.name,
'WAFER_CONFERENCE_DOMAIN': site.domain,
}
return context | [
"def",
"site_info",
"(",
"request",
")",
":",
"site",
"=",
"get_current_site",
"(",
"request",
")",
"context",
"=",
"{",
"'WAFER_CONFERENCE_NAME'",
":",
"site",
".",
"name",
",",
"'WAFER_CONFERENCE_DOMAIN'",
":",
"site",
".",
"domain",
",",
"}",
"return",
"c... | Expose the site's info to templates | [
"Expose",
"the",
"site",
"s",
"info",
"to",
"templates"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L6-L13 | train |
CTPUG/wafer | wafer/context_processors.py | navigation_info | def navigation_info(request):
'''Expose whether to display the navigation header and footer'''
if request.GET.get('wafer_hide_navigation') == "1":
nav_class = "wafer-invisible"
else:
nav_class = "wafer-visible"
context = {
'WAFER_NAVIGATION_VISIBILITY': nav_class,
}
retur... | python | def navigation_info(request):
'''Expose whether to display the navigation header and footer'''
if request.GET.get('wafer_hide_navigation') == "1":
nav_class = "wafer-invisible"
else:
nav_class = "wafer-visible"
context = {
'WAFER_NAVIGATION_VISIBILITY': nav_class,
}
retur... | [
"def",
"navigation_info",
"(",
"request",
")",
":",
"if",
"request",
".",
"GET",
".",
"get",
"(",
"'wafer_hide_navigation'",
")",
"==",
"\"1\"",
":",
"nav_class",
"=",
"\"wafer-invisible\"",
"else",
":",
"nav_class",
"=",
"\"wafer-visible\"",
"context",
"=",
"... | Expose whether to display the navigation header and footer | [
"Expose",
"whether",
"to",
"display",
"the",
"navigation",
"header",
"and",
"footer"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L16-L25 | train |
CTPUG/wafer | wafer/context_processors.py | registration_settings | def registration_settings(request):
'''Expose selected settings to templates'''
context = {}
for setting in (
'WAFER_SSO',
'WAFER_HIDE_LOGIN',
'WAFER_REGISTRATION_OPEN',
'WAFER_REGISTRATION_MODE',
'WAFER_TALKS_OPEN',
'WAFER_VIDEO_LICENS... | python | def registration_settings(request):
'''Expose selected settings to templates'''
context = {}
for setting in (
'WAFER_SSO',
'WAFER_HIDE_LOGIN',
'WAFER_REGISTRATION_OPEN',
'WAFER_REGISTRATION_MODE',
'WAFER_TALKS_OPEN',
'WAFER_VIDEO_LICENS... | [
"def",
"registration_settings",
"(",
"request",
")",
":",
"context",
"=",
"{",
"}",
"for",
"setting",
"in",
"(",
"'WAFER_SSO'",
",",
"'WAFER_HIDE_LOGIN'",
",",
"'WAFER_REGISTRATION_OPEN'",
",",
"'WAFER_REGISTRATION_MODE'",
",",
"'WAFER_TALKS_OPEN'",
",",
"'WAFER_VIDEO... | Expose selected settings to templates | [
"Expose",
"selected",
"settings",
"to",
"templates"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/context_processors.py#L37-L49 | train |
codenerix/django-codenerix | codenerix/models_people.py | GenPerson.profiles | def profiles(self):
'''
return the rolls this people is related with
'''
limit = []
if self.is_admin():
limit.append(_("Administrator"))
limit.sort()
return limit | python | def profiles(self):
'''
return the rolls this people is related with
'''
limit = []
if self.is_admin():
limit.append(_("Administrator"))
limit.sort()
return limit | [
"def",
"profiles",
"(",
"self",
")",
":",
"limit",
"=",
"[",
"]",
"if",
"self",
".",
"is_admin",
"(",
")",
":",
"limit",
".",
"append",
"(",
"_",
"(",
"\"Administrator\"",
")",
")",
"limit",
".",
"sort",
"(",
")",
"return",
"limit"
] | return the rolls this people is related with | [
"return",
"the",
"rolls",
"this",
"people",
"is",
"related",
"with"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/models_people.py#L114-L124 | train |
markchil/gptools | gptools/kernel/matern.py | matern_function | def matern_function(Xi, Xj, *args):
r"""Matern covariance function of arbitrary dimension, for use with :py:class:`ArbitraryKernel`.
The Matern kernel has the following hyperparameters, always referenced in
the order listed:
= ===== ====================================
0 sigma prefactor
... | python | def matern_function(Xi, Xj, *args):
r"""Matern covariance function of arbitrary dimension, for use with :py:class:`ArbitraryKernel`.
The Matern kernel has the following hyperparameters, always referenced in
the order listed:
= ===== ====================================
0 sigma prefactor
... | [
"def",
"matern_function",
"(",
"Xi",
",",
"Xj",
",",
"*",
"args",
")",
":",
"num_dim",
"=",
"len",
"(",
"args",
")",
"-",
"2",
"nu",
"=",
"args",
"[",
"1",
"]",
"if",
"isinstance",
"(",
"Xi",
",",
"scipy",
".",
"ndarray",
")",
":",
"if",
"isins... | r"""Matern covariance function of arbitrary dimension, for use with :py:class:`ArbitraryKernel`.
The Matern kernel has the following hyperparameters, always referenced in
the order listed:
= ===== ====================================
0 sigma prefactor
1 nu order of kernel
2 l1 le... | [
"r",
"Matern",
"covariance",
"function",
"of",
"arbitrary",
"dimension",
"for",
"use",
"with",
":",
"py",
":",
"class",
":",
"ArbitraryKernel",
".",
"The",
"Matern",
"kernel",
"has",
"the",
"following",
"hyperparameters",
"always",
"referenced",
"in",
"the",
"... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L44-L100 | train |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_k | def _compute_k(self, tau):
r"""Evaluate the kernel directly at the given values of `tau`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
Returns
-------
k : :py:class:`Array`, (`M`,)
... | python | def _compute_k(self, tau):
r"""Evaluate the kernel directly at the given values of `tau`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
Returns
-------
k : :py:class:`Array`, (`M`,)
... | [
"def",
"_compute_k",
"(",
"self",
",",
"tau",
")",
":",
"y",
",",
"r2l2",
"=",
"self",
".",
"_compute_y",
"(",
"tau",
",",
"return_r2l2",
"=",
"True",
")",
"k",
"=",
"2.0",
"**",
"(",
"1.0",
"-",
"self",
".",
"nu",
")",
"/",
"scipy",
".",
"spec... | r"""Evaluate the kernel directly at the given values of `tau`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
Returns
-------
k : :py:class:`Array`, (`M`,)
:math:`k(\tau)` (less the :math... | [
"r",
"Evaluate",
"the",
"kernel",
"directly",
"at",
"the",
"given",
"values",
"of",
"tau",
".",
"Parameters",
"----------",
"tau",
":",
":",
"py",
":",
"class",
":",
"Matrix",
"(",
"M",
"D",
")",
"M",
"inputs",
"with",
"dimension",
"D",
".",
"Returns",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L296-L312 | train |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_y | def _compute_y(self, tau, return_r2l2=False):
r"""Covert tau to :math:`y=2\nu\sum_i(\tau_i^2/l_i^2)`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
return_r2l2 : bool, optional
Set to True to return a tu... | python | def _compute_y(self, tau, return_r2l2=False):
r"""Covert tau to :math:`y=2\nu\sum_i(\tau_i^2/l_i^2)`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
return_r2l2 : bool, optional
Set to True to return a tu... | [
"def",
"_compute_y",
"(",
"self",
",",
"tau",
",",
"return_r2l2",
"=",
"False",
")",
":",
"r2l2",
"=",
"self",
".",
"_compute_r2l2",
"(",
"tau",
")",
"y",
"=",
"2.0",
"*",
"self",
".",
"nu",
"*",
"r2l2",
"if",
"return_r2l2",
":",
"return",
"(",
"y"... | r"""Covert tau to :math:`y=2\nu\sum_i(\tau_i^2/l_i^2)`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
return_r2l2 : bool, optional
Set to True to return a tuple of (`y`, `r2l2`). Default is False
(on... | [
"r",
"Covert",
"tau",
"to",
":",
"math",
":",
"y",
"=",
"2",
"\\",
"nu",
"\\",
"sum_i",
"(",
"\\",
"tau_i^2",
"/",
"l_i^2",
")",
".",
"Parameters",
"----------",
"tau",
":",
":",
"py",
":",
"class",
":",
"Matrix",
"(",
"M",
"D",
")",
"M",
"inpu... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L314-L337 | train |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_y_wrapper | def _compute_y_wrapper(self, *args):
r"""Convert tau to :math:`y=\sqrt{2\nu\sum_i(\tau_i^2/l_i^2)}`.
Takes `tau` as an argument list for compatibility with :py:func:`mpmath.diff`.
Parameters
----------
tau[0] : scalar float
First element of `tau`.
... | python | def _compute_y_wrapper(self, *args):
r"""Convert tau to :math:`y=\sqrt{2\nu\sum_i(\tau_i^2/l_i^2)}`.
Takes `tau` as an argument list for compatibility with :py:func:`mpmath.diff`.
Parameters
----------
tau[0] : scalar float
First element of `tau`.
... | [
"def",
"_compute_y_wrapper",
"(",
"self",
",",
"*",
"args",
")",
":",
"return",
"self",
".",
"_compute_y",
"(",
"scipy",
".",
"atleast_2d",
"(",
"scipy",
".",
"asarray",
"(",
"args",
",",
"dtype",
"=",
"float",
")",
")",
")"
] | r"""Convert tau to :math:`y=\sqrt{2\nu\sum_i(\tau_i^2/l_i^2)}`.
Takes `tau` as an argument list for compatibility with :py:func:`mpmath.diff`.
Parameters
----------
tau[0] : scalar float
First element of `tau`.
tau[1] : And so on...
... | [
"r",
"Convert",
"tau",
"to",
":",
"math",
":",
"y",
"=",
"\\",
"sqrt",
"{",
"2",
"\\",
"nu",
"\\",
"sum_i",
"(",
"\\",
"tau_i^2",
"/",
"l_i^2",
")",
"}",
".",
"Takes",
"tau",
"as",
"an",
"argument",
"list",
"for",
"compatibility",
"with",
":",
"p... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L339-L355 | train |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_dk_dy | def _compute_dk_dy(self, y, n):
r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Par... | python | def _compute_dk_dy(self, y, n):
r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Par... | [
"def",
"_compute_dk_dy",
"(",
"self",
",",
"y",
",",
"n",
")",
":",
"return",
"2.0",
"**",
"(",
"1",
"-",
"self",
".",
"nu",
")",
"/",
"(",
"scipy",
".",
"special",
".",
"gamma",
"(",
"self",
".",
"nu",
")",
")",
"*",
"yn2Kn2Der",
"(",
"self",
... | r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Parameters
----------
y : :... | [
"r",
"Evaluate",
"the",
"derivative",
"of",
"the",
"outer",
"form",
"of",
"the",
"Matern",
"kernel",
".",
"Uses",
"the",
"general",
"Leibniz",
"rule",
"to",
"compute",
"the",
"n",
"-",
"th",
"derivative",
"of",
":",
"..",
"math",
"::",
"f",
"(",
"y",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L357-L378 | train |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_dy_dtau | def _compute_dy_dtau(self, tau, b, r2l2):
r"""Evaluate the derivative of the inner argument of the Matern kernel.
Take the derivative of
.. math::
y = 2 \nu \sum_i(\tau_i^2 / l_i^2)
Parameters
----------
tau : :py:class:`Mat... | python | def _compute_dy_dtau(self, tau, b, r2l2):
r"""Evaluate the derivative of the inner argument of the Matern kernel.
Take the derivative of
.. math::
y = 2 \nu \sum_i(\tau_i^2 / l_i^2)
Parameters
----------
tau : :py:class:`Mat... | [
"def",
"_compute_dy_dtau",
"(",
"self",
",",
"tau",
",",
"b",
",",
"r2l2",
")",
":",
"if",
"len",
"(",
"b",
")",
"==",
"0",
":",
"return",
"self",
".",
"_compute_y",
"(",
"tau",
")",
"elif",
"len",
"(",
"b",
")",
"==",
"1",
":",
"return",
"4.0"... | r"""Evaluate the derivative of the inner argument of the Matern kernel.
Take the derivative of
.. math::
y = 2 \nu \sum_i(\tau_i^2 / l_i^2)
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimen... | [
"r",
"Evaluate",
"the",
"derivative",
"of",
"the",
"inner",
"argument",
"of",
"the",
"Matern",
"kernel",
".",
"Take",
"the",
"derivative",
"of",
"..",
"math",
"::",
"y",
"=",
"2",
"\\",
"nu",
"\\",
"sum_i",
"(",
"\\",
"tau_i^2",
"/",
"l_i^2",
")",
"P... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L380-L410 | train |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_dk_dtau_on_partition | def _compute_dk_dtau_on_partition(self, tau, p):
"""Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Overrides the version from :py:class:`gptools.kernel.core.ChainRuleKernel`
in order to get the correct behavior at the origin.
Paramet... | python | def _compute_dk_dtau_on_partition(self, tau, p):
"""Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Overrides the version from :py:class:`gptools.kernel.core.ChainRuleKernel`
in order to get the correct behavior at the origin.
Paramet... | [
"def",
"_compute_dk_dtau_on_partition",
"(",
"self",
",",
"tau",
",",
"p",
")",
":",
"# Find the derivative order:",
"n",
"=",
"len",
"(",
"p",
")",
"y",
",",
"r2l2",
"=",
"self",
".",
"_compute_y",
"(",
"tau",
",",
"return_r2l2",
"=",
"True",
")",
"# Ke... | Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Overrides the version from :py:class:`gptools.kernel.core.ChainRuleKernel`
in order to get the correct behavior at the origin.
Parameters
----------
tau : :py:class:`Matrix`, (`M... | [
"Evaluate",
"the",
"term",
"inside",
"the",
"sum",
"of",
"Faa",
"di",
"Bruno",
"s",
"formula",
"for",
"the",
"given",
"partition",
".",
"Overrides",
"the",
"version",
"from",
":",
"py",
":",
"class",
":",
"gptools",
".",
"kernel",
".",
"core",
".",
"Ch... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L412-L459 | train |
coursera/courseraoauth2client | courseraoauth2client/utils.py | add_logging_parser | def add_logging_parser(main_parser):
"Build an argparse argument parser to parse the command line."
main_parser.set_defaults(setup_logging=set_logging_level)
verbosity_group = main_parser.add_mutually_exclusive_group(required=False)
verbosity_group.add_argument(
'--verbose',
'-v',
... | python | def add_logging_parser(main_parser):
"Build an argparse argument parser to parse the command line."
main_parser.set_defaults(setup_logging=set_logging_level)
verbosity_group = main_parser.add_mutually_exclusive_group(required=False)
verbosity_group.add_argument(
'--verbose',
'-v',
... | [
"def",
"add_logging_parser",
"(",
"main_parser",
")",
":",
"main_parser",
".",
"set_defaults",
"(",
"setup_logging",
"=",
"set_logging_level",
")",
"verbosity_group",
"=",
"main_parser",
".",
"add_mutually_exclusive_group",
"(",
"required",
"=",
"False",
")",
"verbosi... | Build an argparse argument parser to parse the command line. | [
"Build",
"an",
"argparse",
"argument",
"parser",
"to",
"parse",
"the",
"command",
"line",
"."
] | 4edd991defe26bfc768ab28a30368cace40baf44 | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/utils.py#L28-L52 | train |
coursera/courseraoauth2client | courseraoauth2client/utils.py | set_logging_level | def set_logging_level(args):
"Computes and sets the logging level from the parsed arguments."
root_logger = logging.getLogger()
level = logging.INFO
logging.getLogger('requests.packages.urllib3').setLevel(logging.WARNING)
if "verbose" in args and args.verbose is not None:
logging.getLogger('... | python | def set_logging_level(args):
"Computes and sets the logging level from the parsed arguments."
root_logger = logging.getLogger()
level = logging.INFO
logging.getLogger('requests.packages.urllib3').setLevel(logging.WARNING)
if "verbose" in args and args.verbose is not None:
logging.getLogger('... | [
"def",
"set_logging_level",
"(",
"args",
")",
":",
"root_logger",
"=",
"logging",
".",
"getLogger",
"(",
")",
"level",
"=",
"logging",
".",
"INFO",
"logging",
".",
"getLogger",
"(",
"'requests.packages.urllib3'",
")",
".",
"setLevel",
"(",
"logging",
".",
"W... | Computes and sets the logging level from the parsed arguments. | [
"Computes",
"and",
"sets",
"the",
"logging",
"level",
"from",
"the",
"parsed",
"arguments",
"."
] | 4edd991defe26bfc768ab28a30368cace40baf44 | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/utils.py#L55-L83 | train |
codenerix/django-codenerix | codenerix/authbackend.py | check_auth | def check_auth(user):
'''
Check if the user should or shouldn't be inside the system:
- If the user is staff or superuser: LOGIN GRANTED
- If the user has a Person and it is not "disabled": LOGIN GRANTED
- Elsewhere: LOGIN DENIED
'''
# Initialize authentication
auth = None
person = ... | python | def check_auth(user):
'''
Check if the user should or shouldn't be inside the system:
- If the user is staff or superuser: LOGIN GRANTED
- If the user has a Person and it is not "disabled": LOGIN GRANTED
- Elsewhere: LOGIN DENIED
'''
# Initialize authentication
auth = None
person = ... | [
"def",
"check_auth",
"(",
"user",
")",
":",
"# Initialize authentication",
"auth",
"=",
"None",
"person",
"=",
"None",
"# Check if there is an user",
"if",
"user",
":",
"# It means that Django accepted the user and it is active",
"if",
"user",
".",
"is_staff",
"or",
"us... | Check if the user should or shouldn't be inside the system:
- If the user is staff or superuser: LOGIN GRANTED
- If the user has a Person and it is not "disabled": LOGIN GRANTED
- Elsewhere: LOGIN DENIED | [
"Check",
"if",
"the",
"user",
"should",
"or",
"shouldn",
"t",
"be",
"inside",
"the",
"system",
":",
"-",
"If",
"the",
"user",
"is",
"staff",
"or",
"superuser",
":",
"LOGIN",
"GRANTED",
"-",
"If",
"the",
"user",
"has",
"a",
"Person",
"and",
"it",
"is"... | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L42-L77 | train |
codenerix/django-codenerix | codenerix/authbackend.py | ActiveDirectoryGroupMembershipSSLBackend.debug | def debug(self, msg):
'''
Handle the debugging to a file
'''
# If debug is not disabled
if self.__debug is not False:
# If never was set, try to set it up
if self.__debug is None:
# Check what do we have inside settings
de... | python | def debug(self, msg):
'''
Handle the debugging to a file
'''
# If debug is not disabled
if self.__debug is not False:
# If never was set, try to set it up
if self.__debug is None:
# Check what do we have inside settings
de... | [
"def",
"debug",
"(",
"self",
",",
"msg",
")",
":",
"# If debug is not disabled",
"if",
"self",
".",
"__debug",
"is",
"not",
"False",
":",
"# If never was set, try to set it up",
"if",
"self",
".",
"__debug",
"is",
"None",
":",
"# Check what do we have inside setting... | Handle the debugging to a file | [
"Handle",
"the",
"debugging",
"to",
"a",
"file"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L407-L429 | train |
codenerix/django-codenerix | codenerix/authbackend.py | ActiveDirectoryGroupMembershipSSLBackend.authenticate | def authenticate(self, *args, **kwargs):
'''
Authenticate the user agains LDAP
'''
# Get config
username = kwargs.get("username", None)
password = kwargs.get("password", None)
# Check user in Active Directory (authorization == None if can not connect to Active D... | python | def authenticate(self, *args, **kwargs):
'''
Authenticate the user agains LDAP
'''
# Get config
username = kwargs.get("username", None)
password = kwargs.get("password", None)
# Check user in Active Directory (authorization == None if can not connect to Active D... | [
"def",
"authenticate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get config",
"username",
"=",
"kwargs",
".",
"get",
"(",
"\"username\"",
",",
"None",
")",
"password",
"=",
"kwargs",
".",
"get",
"(",
"\"password\"",
",",
"Non... | Authenticate the user agains LDAP | [
"Authenticate",
"the",
"user",
"agains",
"LDAP"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L493-L527 | train |
codenerix/django-codenerix | codenerix/authbackend.py | ActiveDirectoryGroupMembershipSSLBackend.get_or_create_user | def get_or_create_user(self, username, password):
'''
Get or create the given user
'''
# Get the groups for this user
info = self.get_ad_info(username, password)
self.debug("INFO found: {}".format(info))
# Find the user
try:
user = User.objec... | python | def get_or_create_user(self, username, password):
'''
Get or create the given user
'''
# Get the groups for this user
info = self.get_ad_info(username, password)
self.debug("INFO found: {}".format(info))
# Find the user
try:
user = User.objec... | [
"def",
"get_or_create_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"# Get the groups for this user",
"info",
"=",
"self",
".",
"get_ad_info",
"(",
"username",
",",
"password",
")",
"self",
".",
"debug",
"(",
"\"INFO found: {}\"",
".",
"format"... | Get or create the given user | [
"Get",
"or",
"create",
"the",
"given",
"user"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L633-L681 | train |
codenerix/django-codenerix | codenerix/authbackend.py | ActiveDirectoryGroupMembershipSSLBackend.synchronize | def synchronize(self, user, info):
'''
It tries to do a group synchronization if possible
This methods should be redeclared by the developer
'''
self.debug("Synchronize!")
# Remove all groups from this user
user.groups.clear()
# For all domains found fo... | python | def synchronize(self, user, info):
'''
It tries to do a group synchronization if possible
This methods should be redeclared by the developer
'''
self.debug("Synchronize!")
# Remove all groups from this user
user.groups.clear()
# For all domains found fo... | [
"def",
"synchronize",
"(",
"self",
",",
"user",
",",
"info",
")",
":",
"self",
".",
"debug",
"(",
"\"Synchronize!\"",
")",
"# Remove all groups from this user",
"user",
".",
"groups",
".",
"clear",
"(",
")",
"# For all domains found for this user",
"for",
"domain"... | It tries to do a group synchronization if possible
This methods should be redeclared by the developer | [
"It",
"tries",
"to",
"do",
"a",
"group",
"synchronization",
"if",
"possible",
"This",
"methods",
"should",
"be",
"redeclared",
"by",
"the",
"developer"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/authbackend.py#L698-L717 | train |
markchil/gptools | gptools/kernel/core.py | Kernel.set_hyperparams | def set_hyperparams(self, new_params):
"""Sets the free hyperparameters to the new parameter values in new_params.
Parameters
----------
new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),)
New parameter values, ordered as dictated ... | python | def set_hyperparams(self, new_params):
"""Sets the free hyperparameters to the new parameter values in new_params.
Parameters
----------
new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),)
New parameter values, ordered as dictated ... | [
"def",
"set_hyperparams",
"(",
"self",
",",
"new_params",
")",
":",
"new_params",
"=",
"scipy",
".",
"asarray",
"(",
"new_params",
",",
"dtype",
"=",
"float",
")",
"if",
"len",
"(",
"new_params",
")",
"==",
"len",
"(",
"self",
".",
"free_params",
")",
... | Sets the free hyperparameters to the new parameter values in new_params.
Parameters
----------
new_params : :py:class:`Array` or other Array-like, (len(:py:attr:`self.free_params`),)
New parameter values, ordered as dictated by the docstring for the
class. | [
"Sets",
"the",
"free",
"hyperparameters",
"to",
"the",
"new",
"parameter",
"values",
"in",
"new_params",
".",
"Parameters",
"----------",
"new_params",
":",
":",
"py",
":",
"class",
":",
"Array",
"or",
"other",
"Array",
"-",
"like",
"(",
"len",
"(",
":",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L236-L256 | train |
markchil/gptools | gptools/kernel/core.py | Kernel._compute_r2l2 | def _compute_r2l2(self, tau, return_l=False):
r"""Compute the anisotropic :math:`r^2/l^2` term for the given `tau`.
Here, :math:`\tau=X_i-X_j` is the difference vector. Computes
.. math::
\frac{r^2}{l^2} = \sum_i\frac{\tau_i^2}{l_{i}^{2}}
Assume... | python | def _compute_r2l2(self, tau, return_l=False):
r"""Compute the anisotropic :math:`r^2/l^2` term for the given `tau`.
Here, :math:`\tau=X_i-X_j` is the difference vector. Computes
.. math::
\frac{r^2}{l^2} = \sum_i\frac{\tau_i^2}{l_{i}^{2}}
Assume... | [
"def",
"_compute_r2l2",
"(",
"self",
",",
"tau",
",",
"return_l",
"=",
"False",
")",
":",
"l_mat",
"=",
"scipy",
".",
"tile",
"(",
"self",
".",
"params",
"[",
"-",
"self",
".",
"num_dim",
":",
"]",
",",
"(",
"tau",
".",
"shape",
"[",
"0",
"]",
... | r"""Compute the anisotropic :math:`r^2/l^2` term for the given `tau`.
Here, :math:`\tau=X_i-X_j` is the difference vector. Computes
.. math::
\frac{r^2}{l^2} = \sum_i\frac{\tau_i^2}{l_{i}^{2}}
Assumes that the length parameters are the last `num_dim` el... | [
"r",
"Compute",
"the",
"anisotropic",
":",
"math",
":",
"r^2",
"/",
"l^2",
"term",
"for",
"the",
"given",
"tau",
".",
"Here",
":",
"math",
":",
"\\",
"tau",
"=",
"X_i",
"-",
"X_j",
"is",
"the",
"difference",
"vector",
".",
"Computes",
"..",
"math",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L349-L386 | train |
markchil/gptools | gptools/kernel/core.py | BinaryKernel.enforce_bounds | def enforce_bounds(self, v):
"""Set `enforce_bounds` for both of the kernels to a new value.
"""
self._enforce_bounds = v
self.k1.enforce_bounds = v
self.k2.enforce_bounds = v | python | def enforce_bounds(self, v):
"""Set `enforce_bounds` for both of the kernels to a new value.
"""
self._enforce_bounds = v
self.k1.enforce_bounds = v
self.k2.enforce_bounds = v | [
"def",
"enforce_bounds",
"(",
"self",
",",
"v",
")",
":",
"self",
".",
"_enforce_bounds",
"=",
"v",
"self",
".",
"k1",
".",
"enforce_bounds",
"=",
"v",
"self",
".",
"k2",
".",
"enforce_bounds",
"=",
"v"
] | Set `enforce_bounds` for both of the kernels to a new value. | [
"Set",
"enforce_bounds",
"for",
"both",
"of",
"the",
"kernels",
"to",
"a",
"new",
"value",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L426-L431 | train |
markchil/gptools | gptools/kernel/core.py | BinaryKernel.free_param_bounds | def free_param_bounds(self):
"""Returns the bounds of the free hyperparameters.
Returns
-------
free_param_bounds : :py:class:`Array`
Array of the bounds of the free parameters, in order.
"""
return scipy.concatenate((self.k1.free_param_bounds, self.k... | python | def free_param_bounds(self):
"""Returns the bounds of the free hyperparameters.
Returns
-------
free_param_bounds : :py:class:`Array`
Array of the bounds of the free parameters, in order.
"""
return scipy.concatenate((self.k1.free_param_bounds, self.k... | [
"def",
"free_param_bounds",
"(",
"self",
")",
":",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"k1",
".",
"free_param_bounds",
",",
"self",
".",
"k2",
".",
"free_param_bounds",
")",
")"
] | Returns the bounds of the free hyperparameters.
Returns
-------
free_param_bounds : :py:class:`Array`
Array of the bounds of the free parameters, in order. | [
"Returns",
"the",
"bounds",
"of",
"the",
"free",
"hyperparameters",
".",
"Returns",
"-------",
"free_param_bounds",
":",
":",
"py",
":",
"class",
":",
"Array",
"Array",
"of",
"the",
"bounds",
"of",
"the",
"free",
"parameters",
"in",
"order",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L443-L451 | train |
markchil/gptools | gptools/kernel/core.py | BinaryKernel.free_param_names | def free_param_names(self):
"""Returns the names of the free hyperparameters.
Returns
-------
free_param_names : :py:class:`Array`
Array of the names of the free parameters, in order.
"""
return scipy.concatenate((self.k1.free_param_names, self.k2.fre... | python | def free_param_names(self):
"""Returns the names of the free hyperparameters.
Returns
-------
free_param_names : :py:class:`Array`
Array of the names of the free parameters, in order.
"""
return scipy.concatenate((self.k1.free_param_names, self.k2.fre... | [
"def",
"free_param_names",
"(",
"self",
")",
":",
"return",
"scipy",
".",
"concatenate",
"(",
"(",
"self",
".",
"k1",
".",
"free_param_names",
",",
"self",
".",
"k2",
".",
"free_param_names",
")",
")"
] | Returns the names of the free hyperparameters.
Returns
-------
free_param_names : :py:class:`Array`
Array of the names of the free parameters, in order. | [
"Returns",
"the",
"names",
"of",
"the",
"free",
"hyperparameters",
".",
"Returns",
"-------",
"free_param_names",
":",
":",
"py",
":",
"class",
":",
"Array",
"Array",
"of",
"the",
"names",
"of",
"the",
"free",
"parameters",
"in",
"order",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L454-L462 | train |
markchil/gptools | gptools/kernel/core.py | BinaryKernel.set_hyperparams | def set_hyperparams(self, new_params):
"""Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length o... | python | def set_hyperparams(self, new_params):
"""Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length o... | [
"def",
"set_hyperparams",
"(",
"self",
",",
"new_params",
")",
":",
"new_params",
"=",
"scipy",
".",
"asarray",
"(",
"new_params",
",",
"dtype",
"=",
"float",
")",
"if",
"len",
"(",
"new_params",
")",
"==",
"len",
"(",
"self",
".",
"free_params",
")",
... | Set the (free) hyperparameters.
Parameters
----------
new_params : :py:class:`Array` or other Array-like
New values of the free parameters.
Raises
------
ValueError
If the length of `new_params` is not consistent with :py:attr:`se... | [
"Set",
"the",
"(",
"free",
")",
"hyperparameters",
".",
"Parameters",
"----------",
"new_params",
":",
":",
"py",
":",
"class",
":",
"Array",
"or",
"other",
"Array",
"-",
"like",
"New",
"values",
"of",
"the",
"free",
"parameters",
".",
"Raises",
"------",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L473-L493 | train |
markchil/gptools | gptools/kernel/core.py | ChainRuleKernel._compute_dk_dtau | def _compute_dk_dtau(self, tau, n):
r"""Evaluate :math:`dk/d\tau` at the specified locations with the specified derivatives.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
n : :py:class:`Array`, (`D`,)
De... | python | def _compute_dk_dtau(self, tau, n):
r"""Evaluate :math:`dk/d\tau` at the specified locations with the specified derivatives.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
n : :py:class:`Array`, (`D`,)
De... | [
"def",
"_compute_dk_dtau",
"(",
"self",
",",
"tau",
",",
"n",
")",
":",
"# Construct the derivative pattern:",
"# For each dimension, this will contain the index of the dimension",
"# repeated a number of times equal to the order of derivative with",
"# respect to that dimension.",
"# Ex... | r"""Evaluate :math:`dk/d\tau` at the specified locations with the specified derivatives.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
n : :py:class:`Array`, (`D`,)
Degree of derivative with respect to each dime... | [
"r",
"Evaluate",
":",
"math",
":",
"dk",
"/",
"d",
"\\",
"tau",
"at",
"the",
"specified",
"locations",
"with",
"the",
"specified",
"derivatives",
".",
"Parameters",
"----------",
"tau",
":",
":",
"py",
":",
"class",
":",
"Matrix",
"(",
"M",
"D",
")",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L671-L707 | train |
markchil/gptools | gptools/kernel/core.py | ChainRuleKernel._compute_dk_dtau_on_partition | def _compute_dk_dtau_on_partition(self, tau, p):
"""Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
p : list of :py:class:`Array`
... | python | def _compute_dk_dtau_on_partition(self, tau, p):
"""Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
p : list of :py:class:`Array`
... | [
"def",
"_compute_dk_dtau_on_partition",
"(",
"self",
",",
"tau",
",",
"p",
")",
":",
"y",
",",
"r2l2",
"=",
"self",
".",
"_compute_y",
"(",
"tau",
",",
"return_r2l2",
"=",
"True",
")",
"# Compute the d^(|pi|)f/dy term:",
"dk_dtau",
"=",
"self",
".",
"_comput... | Evaluate the term inside the sum of Faa di Bruno's formula for the given partition.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
p : list of :py:class:`Array`
Each element is a block of the partition representi... | [
"Evaluate",
"the",
"term",
"inside",
"the",
"sum",
"of",
"Faa",
"di",
"Bruno",
"s",
"formula",
"for",
"the",
"given",
"partition",
".",
"Parameters",
"----------",
"tau",
":",
":",
"py",
":",
"class",
":",
"Matrix",
"(",
"M",
"D",
")",
"M",
"inputs",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L709-L732 | train |
markchil/gptools | gptools/kernel/core.py | ArbitraryKernel._mask_cov_func | def _mask_cov_func(self, *args):
"""Masks the covariance function into a form usable by :py:func:`mpmath.diff`.
Parameters
----------
*args : `num_dim` * 2 floats
The individual elements of Xi and Xj to be passed to :py:attr:`cov_func`.
"""
# Have to ... | python | def _mask_cov_func(self, *args):
"""Masks the covariance function into a form usable by :py:func:`mpmath.diff`.
Parameters
----------
*args : `num_dim` * 2 floats
The individual elements of Xi and Xj to be passed to :py:attr:`cov_func`.
"""
# Have to ... | [
"def",
"_mask_cov_func",
"(",
"self",
",",
"*",
"args",
")",
":",
"# Have to do it in two cases to get the 1d unwrapped properly:",
"if",
"self",
".",
"num_dim",
"==",
"1",
":",
"return",
"self",
".",
"cov_func",
"(",
"args",
"[",
"0",
"]",
",",
"args",
"[",
... | Masks the covariance function into a form usable by :py:func:`mpmath.diff`.
Parameters
----------
*args : `num_dim` * 2 floats
The individual elements of Xi and Xj to be passed to :py:attr:`cov_func`. | [
"Masks",
"the",
"covariance",
"function",
"into",
"a",
"form",
"usable",
"by",
":",
"py",
":",
"func",
":",
"mpmath",
".",
"diff",
".",
"Parameters",
"----------",
"*",
"args",
":",
"num_dim",
"*",
"2",
"floats",
"The",
"individual",
"elements",
"of",
"X... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/core.py#L858-L870 | train |
markchil/gptools | gptools/mean.py | constant | def constant(X, n, mu, hyper_deriv=None):
"""Function implementing a constant mean suitable for use with :py:class:`MeanFunction`.
"""
if (n == 0).all():
if hyper_deriv is not None:
return scipy.ones(X.shape[0])
else:
return mu * scipy.ones(X.shape[0])
else:
... | python | def constant(X, n, mu, hyper_deriv=None):
"""Function implementing a constant mean suitable for use with :py:class:`MeanFunction`.
"""
if (n == 0).all():
if hyper_deriv is not None:
return scipy.ones(X.shape[0])
else:
return mu * scipy.ones(X.shape[0])
else:
... | [
"def",
"constant",
"(",
"X",
",",
"n",
",",
"mu",
",",
"hyper_deriv",
"=",
"None",
")",
":",
"if",
"(",
"n",
"==",
"0",
")",
".",
"all",
"(",
")",
":",
"if",
"hyper_deriv",
"is",
"not",
"None",
":",
"return",
"scipy",
".",
"ones",
"(",
"X",
"... | Function implementing a constant mean suitable for use with :py:class:`MeanFunction`. | [
"Function",
"implementing",
"a",
"constant",
"mean",
"suitable",
"for",
"use",
"with",
":",
"py",
":",
"class",
":",
"MeanFunction",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L293-L302 | train |
markchil/gptools | gptools/mean.py | mtanh | def mtanh(alpha, z):
"""Modified hyperbolic tangent function mtanh(z; alpha).
Parameters
----------
alpha : float
The core slope of the mtanh.
z : float or array
The coordinate of the mtanh.
"""
z = scipy.asarray(z)
ez = scipy.exp(z)
enz = 1.0 / ez
return ((1... | python | def mtanh(alpha, z):
"""Modified hyperbolic tangent function mtanh(z; alpha).
Parameters
----------
alpha : float
The core slope of the mtanh.
z : float or array
The coordinate of the mtanh.
"""
z = scipy.asarray(z)
ez = scipy.exp(z)
enz = 1.0 / ez
return ((1... | [
"def",
"mtanh",
"(",
"alpha",
",",
"z",
")",
":",
"z",
"=",
"scipy",
".",
"asarray",
"(",
"z",
")",
"ez",
"=",
"scipy",
".",
"exp",
"(",
"z",
")",
"enz",
"=",
"1.0",
"/",
"ez",
"return",
"(",
"(",
"1",
"+",
"alpha",
"*",
"z",
")",
"*",
"e... | Modified hyperbolic tangent function mtanh(z; alpha).
Parameters
----------
alpha : float
The core slope of the mtanh.
z : float or array
The coordinate of the mtanh. | [
"Modified",
"hyperbolic",
"tangent",
"function",
"mtanh",
"(",
"z",
";",
"alpha",
")",
".",
"Parameters",
"----------",
"alpha",
":",
"float",
"The",
"core",
"slope",
"of",
"the",
"mtanh",
".",
"z",
":",
"float",
"or",
"array",
"The",
"coordinate",
"of",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L321-L334 | train |
markchil/gptools | gptools/mean.py | mtanh_profile | def mtanh_profile(X, n, x0, delta, alpha, h, b, hyper_deriv=None):
"""Profile used with the mtanh function to fit profiles, suitable for use with :py:class:`MeanFunction`.
Only supports univariate data!
Parameters
----------
X : array, (`M`, 1)
The points to evaluate at.
n : ar... | python | def mtanh_profile(X, n, x0, delta, alpha, h, b, hyper_deriv=None):
"""Profile used with the mtanh function to fit profiles, suitable for use with :py:class:`MeanFunction`.
Only supports univariate data!
Parameters
----------
X : array, (`M`, 1)
The points to evaluate at.
n : ar... | [
"def",
"mtanh_profile",
"(",
"X",
",",
"n",
",",
"x0",
",",
"delta",
",",
"alpha",
",",
"h",
",",
"b",
",",
"hyper_deriv",
"=",
"None",
")",
":",
"X",
"=",
"X",
"[",
":",
",",
"0",
"]",
"z",
"=",
"(",
"x0",
"-",
"X",
")",
"/",
"delta",
"i... | Profile used with the mtanh function to fit profiles, suitable for use with :py:class:`MeanFunction`.
Only supports univariate data!
Parameters
----------
X : array, (`M`, 1)
The points to evaluate at.
n : array, (1,)
The order of derivative to compute. Only up to first der... | [
"Profile",
"used",
"with",
"the",
"mtanh",
"function",
"to",
"fit",
"profiles",
"suitable",
"for",
"use",
"with",
":",
"py",
":",
"class",
":",
"MeanFunction",
".",
"Only",
"supports",
"univariate",
"data!",
"Parameters",
"----------",
"X",
":",
"array",
"("... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L336-L419 | train |
markchil/gptools | gptools/mean.py | linear | def linear(X, n, *args, **kwargs):
"""Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`.
The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`.
Parameters
----------
X : array, (`M`, `D`)
The points to evaluate the model at.
n :... | python | def linear(X, n, *args, **kwargs):
"""Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`.
The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`.
Parameters
----------
X : array, (`M`, `D`)
The points to evaluate the model at.
n :... | [
"def",
"linear",
"(",
"X",
",",
"n",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"hyper_deriv",
"=",
"kwargs",
".",
"pop",
"(",
"'hyper_deriv'",
",",
"None",
")",
"m",
"=",
"scipy",
".",
"asarray",
"(",
"args",
"[",
":",
"-",
"1",
"]",... | Linear mean function of arbitrary dimension, suitable for use with :py:class:`MeanFunction`.
The form is :math:`m_0 * X[:, 0] + m_1 * X[:, 1] + \dots + b`.
Parameters
----------
X : array, (`M`, `D`)
The points to evaluate the model at.
n : array of non-negative int, (`D`)
... | [
"Linear",
"mean",
"function",
"of",
"arbitrary",
"dimension",
"suitable",
"for",
"use",
"with",
":",
"py",
":",
"class",
":",
"MeanFunction",
".",
"The",
"form",
"is",
":",
"math",
":",
"m_0",
"*",
"X",
"[",
":",
"0",
"]",
"+",
"m_1",
"*",
"X",
"["... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/mean.py#L446-L484 | train |
CTPUG/wafer | wafer/schedule/models.py | update_schedule_items | def update_schedule_items(*args, **kw):
"""We save all the schedule items associated with this slot, so
the last_update time is updated to reflect any changes to the
timing of the slots"""
slot = kw.pop('instance', None)
if not slot:
return
for item in slot.scheduleitem_set.all():
... | python | def update_schedule_items(*args, **kw):
"""We save all the schedule items associated with this slot, so
the last_update time is updated to reflect any changes to the
timing of the slots"""
slot = kw.pop('instance', None)
if not slot:
return
for item in slot.scheduleitem_set.all():
... | [
"def",
"update_schedule_items",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"slot",
"=",
"kw",
".",
"pop",
"(",
"'instance'",
",",
"None",
")",
"if",
"not",
"slot",
":",
"return",
"for",
"item",
"in",
"slot",
".",
"scheduleitem_set",
".",
"all",... | We save all the schedule items associated with this slot, so
the last_update time is updated to reflect any changes to the
timing of the slots | [
"We",
"save",
"all",
"the",
"schedule",
"items",
"associated",
"with",
"this",
"slot",
"so",
"the",
"last_update",
"time",
"is",
"updated",
"to",
"reflect",
"any",
"changes",
"to",
"the",
"timing",
"of",
"the",
"slots"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/models.py#L287-L303 | train |
CTPUG/wafer | wafer/compare/admin.py | make_diff | def make_diff(current, revision):
"""Create the difference between the current revision and a previous version"""
the_diff = []
dmp = diff_match_patch()
for field in (set(current.field_dict.keys()) | set(revision.field_dict.keys())):
# These exclusions really should be configurable
if f... | python | def make_diff(current, revision):
"""Create the difference between the current revision and a previous version"""
the_diff = []
dmp = diff_match_patch()
for field in (set(current.field_dict.keys()) | set(revision.field_dict.keys())):
# These exclusions really should be configurable
if f... | [
"def",
"make_diff",
"(",
"current",
",",
"revision",
")",
":",
"the_diff",
"=",
"[",
"]",
"dmp",
"=",
"diff_match_patch",
"(",
")",
"for",
"field",
"in",
"(",
"set",
"(",
"current",
".",
"field_dict",
".",
"keys",
"(",
")",
")",
"|",
"set",
"(",
"r... | Create the difference between the current revision and a previous version | [
"Create",
"the",
"difference",
"between",
"the",
"current",
"revision",
"and",
"a",
"previous",
"version"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L61-L107 | train |
CTPUG/wafer | wafer/compare/admin.py | CompareVersionAdmin.compare_view | def compare_view(self, request, object_id, version_id, extra_context=None):
"""Actually compare two versions."""
opts = self.model._meta
object_id = unquote(object_id)
# get_for_object's ordering means this is always the latest revision.
# The reversion we want to compare to
... | python | def compare_view(self, request, object_id, version_id, extra_context=None):
"""Actually compare two versions."""
opts = self.model._meta
object_id = unquote(object_id)
# get_for_object's ordering means this is always the latest revision.
# The reversion we want to compare to
... | [
"def",
"compare_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"version_id",
",",
"extra_context",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"object_id",
"=",
"unquote",
"(",
"object_id",
")",
"# get_for_object's ord... | Actually compare two versions. | [
"Actually",
"compare",
"two",
"versions",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L129-L154 | train |
CTPUG/wafer | wafer/compare/admin.py | CompareVersionAdmin.comparelist_view | def comparelist_view(self, request, object_id, extra_context=None):
"""Allow selecting versions to compare."""
opts = self.model._meta
object_id = unquote(object_id)
current = get_object_or_404(self.model, pk=object_id)
# As done by reversion's history_view
action_list = ... | python | def comparelist_view(self, request, object_id, extra_context=None):
"""Allow selecting versions to compare."""
opts = self.model._meta
object_id = unquote(object_id)
current = get_object_or_404(self.model, pk=object_id)
# As done by reversion's history_view
action_list = ... | [
"def",
"comparelist_view",
"(",
"self",
",",
"request",
",",
"object_id",
",",
"extra_context",
"=",
"None",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"object_id",
"=",
"unquote",
"(",
"object_id",
")",
"current",
"=",
"get_object_or_404",
... | Allow selecting versions to compare. | [
"Allow",
"selecting",
"versions",
"to",
"compare",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/compare/admin.py#L156-L177 | train |
codenerix/django-codenerix | codenerix/views.py | grv | def grv(struct, position):
'''
This function helps to convert date information for showing proper filtering
'''
if position == 'year':
size = 4
else:
size = 2
if (struct[position][2]):
rightnow = str(struct[position][0]).zfill(size)
else:
if position == 'year... | python | def grv(struct, position):
'''
This function helps to convert date information for showing proper filtering
'''
if position == 'year':
size = 4
else:
size = 2
if (struct[position][2]):
rightnow = str(struct[position][0]).zfill(size)
else:
if position == 'year... | [
"def",
"grv",
"(",
"struct",
",",
"position",
")",
":",
"if",
"position",
"==",
"'year'",
":",
"size",
"=",
"4",
"else",
":",
"size",
"=",
"2",
"if",
"(",
"struct",
"[",
"position",
"]",
"[",
"2",
"]",
")",
":",
"rightnow",
"=",
"str",
"(",
"st... | This function helps to convert date information for showing proper filtering | [
"This",
"function",
"helps",
"to",
"convert",
"date",
"information",
"for",
"showing",
"proper",
"filtering"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L96-L112 | train |
codenerix/django-codenerix | codenerix/views.py | GenBase._setup | def _setup(self, request):
'''
Entry point for this class, here we decide basic stuff
'''
# Get details from self
info = model_inspect(self)
self._appname = getattr(self, 'appname', info['appname'])
self._modelname = getattr(self, 'modelname', info['modelname'])
... | python | def _setup(self, request):
'''
Entry point for this class, here we decide basic stuff
'''
# Get details from self
info = model_inspect(self)
self._appname = getattr(self, 'appname', info['appname'])
self._modelname = getattr(self, 'modelname', info['modelname'])
... | [
"def",
"_setup",
"(",
"self",
",",
"request",
")",
":",
"# Get details from self",
"info",
"=",
"model_inspect",
"(",
"self",
")",
"self",
".",
"_appname",
"=",
"getattr",
"(",
"self",
",",
"'appname'",
",",
"info",
"[",
"'appname'",
"]",
")",
"self",
".... | Entry point for this class, here we decide basic stuff | [
"Entry",
"point",
"for",
"this",
"class",
"here",
"we",
"decide",
"basic",
"stuff"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L610-L631 | train |
codenerix/django-codenerix | codenerix/views.py | GenBase.get_template_names | def get_template_names(self):
'''
Build the list of templates related to this user
'''
# Get user template
template_model = getattr(self, 'template_model', "{0}/{1}_{2}".format(self._appname.lower(), self._modelname.lower(), self.get_template_names_key))
template_model_e... | python | def get_template_names(self):
'''
Build the list of templates related to this user
'''
# Get user template
template_model = getattr(self, 'template_model', "{0}/{1}_{2}".format(self._appname.lower(), self._modelname.lower(), self.get_template_names_key))
template_model_e... | [
"def",
"get_template_names",
"(",
"self",
")",
":",
"# Get user template",
"template_model",
"=",
"getattr",
"(",
"self",
",",
"'template_model'",
",",
"\"{0}/{1}_{2}\"",
".",
"format",
"(",
"self",
".",
"_appname",
".",
"lower",
"(",
")",
",",
"self",
".",
... | Build the list of templates related to this user | [
"Build",
"the",
"list",
"of",
"templates",
"related",
"to",
"this",
"user"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L633-L646 | train |
codenerix/django-codenerix | codenerix/views.py | GenBase.get_context_data | def get_context_data(self, **kwargs):
'''
Set a base context
'''
# Call the base implementation first to get a context
context = super(GenBase, self).get_context_data(**kwargs)
# Update general context with the stuff we already calculated
if hasattr(self, 'html_... | python | def get_context_data(self, **kwargs):
'''
Set a base context
'''
# Call the base implementation first to get a context
context = super(GenBase, self).get_context_data(**kwargs)
# Update general context with the stuff we already calculated
if hasattr(self, 'html_... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Call the base implementation first to get a context",
"context",
"=",
"super",
"(",
"GenBase",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"# Update general ... | Set a base context | [
"Set",
"a",
"base",
"context"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L648-L668 | train |
codenerix/django-codenerix | codenerix/views.py | GenList.dispatch | def dispatch(self, *args, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Get if this class is working as only a base render and List funcionality shouldn't be enabled
onlybase = getattr(self, "onlybase", False)
# REST not available when only... | python | def dispatch(self, *args, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Get if this class is working as only a base render and List funcionality shouldn't be enabled
onlybase = getattr(self, "onlybase", False)
# REST not available when only... | [
"def",
"dispatch",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Get if this class is working as only a base render and List funcionality shouldn't be enabled",
"onlybase",
"=",
"getattr",
"(",
"self",
",",
"\"onlybase\"",
",",
"False",
")",
"# ... | Entry point for this class, here we decide basic stuff | [
"Entry",
"point",
"for",
"this",
"class",
"here",
"we",
"decide",
"basic",
"stuff"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L1180-L1287 | train |
codenerix/django-codenerix | codenerix/views.py | GenList.get_queryset | def get_queryset(self, raw_query=False):
# Call the base implementation
if not self.haystack:
queryset = super(GenList, self).get_queryset()
else:
queryset = SearchQuerySet().models(self.model)
# Optional tweak methods
Mfields = None
MlimitQ = Non... | python | def get_queryset(self, raw_query=False):
# Call the base implementation
if not self.haystack:
queryset = super(GenList, self).get_queryset()
else:
queryset = SearchQuerySet().models(self.model)
# Optional tweak methods
Mfields = None
MlimitQ = Non... | [
"def",
"get_queryset",
"(",
"self",
",",
"raw_query",
"=",
"False",
")",
":",
"# Call the base implementation",
"if",
"not",
"self",
".",
"haystack",
":",
"queryset",
"=",
"super",
"(",
"GenList",
",",
"self",
")",
".",
"get_queryset",
"(",
")",
"else",
":... | raise Exception("FOUND: {} -- __foreignkeys: {} -- __columns: {} -- autorules_keys: {} -- \
query_select_related: {} -- query_renamed: {} -- query_optimizer: {} | use_extra: {}| -- \
query: {} -- meta.fields: {} -- fields_related_model: {} -- query_verifier: {}\
-- ??? {} == {}".form... | [
"raise",
"Exception",
"(",
"FOUND",
":",
"{}",
"--",
"__foreignkeys",
":",
"{}",
"--",
"__columns",
":",
"{}",
"--",
"autorules_keys",
":",
"{}",
"--",
"\\",
"query_select_related",
":",
"{}",
"--",
"query_renamed",
":",
"{}",
"--",
"query_optimizer",
":",
... | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L1353-L2336 | train |
codenerix/django-codenerix | codenerix/views.py | GenList.get_context_data | def get_context_data(self, **kwargs):
'''
Generic list view with validation included and object transfering support
'''
# Call the base implementation first to get a context
context = super(GenList, self).get_context_data(**kwargs)
# Update general context with the stuff... | python | def get_context_data(self, **kwargs):
'''
Generic list view with validation included and object transfering support
'''
# Call the base implementation first to get a context
context = super(GenList, self).get_context_data(**kwargs)
# Update general context with the stuff... | [
"def",
"get_context_data",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"# Call the base implementation first to get a context",
"context",
"=",
"super",
"(",
"GenList",
",",
"self",
")",
".",
"get_context_data",
"(",
"*",
"*",
"kwargs",
")",
"# Update general ... | Generic list view with validation included and object transfering support | [
"Generic",
"list",
"view",
"with",
"validation",
"included",
"and",
"object",
"transfering",
"support"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L2338-L2417 | train |
codenerix/django-codenerix | codenerix/views.py | GenList.get_context_json | def get_context_json(self, context):
'''
Return a base answer for a json answer
'''
# Initialize answer
answer = {}
# Metadata builder
answer['meta'] = self.__jcontext_metadata(context)
# Filter builder
answer['filter'] = self.__jcontext_filter(c... | python | def get_context_json(self, context):
'''
Return a base answer for a json answer
'''
# Initialize answer
answer = {}
# Metadata builder
answer['meta'] = self.__jcontext_metadata(context)
# Filter builder
answer['filter'] = self.__jcontext_filter(c... | [
"def",
"get_context_json",
"(",
"self",
",",
"context",
")",
":",
"# Initialize answer",
"answer",
"=",
"{",
"}",
"# Metadata builder",
"answer",
"[",
"'meta'",
"]",
"=",
"self",
".",
"__jcontext_metadata",
"(",
"context",
")",
"# Filter builder",
"answer",
"[",... | Return a base answer for a json answer | [
"Return",
"a",
"base",
"answer",
"for",
"a",
"json",
"answer"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L2609-L2630 | train |
codenerix/django-codenerix | codenerix/views.py | GenList.set_context_json | def set_context_json(self, jsonquery):
'''
Get a json parameter and rebuild the context back to a dictionary (probably kwargs)
'''
# Make sure we are getting dicts
if type(jsonquery) != dict:
raise IOError("set_json_context() method can be called only with dictionari... | python | def set_context_json(self, jsonquery):
'''
Get a json parameter and rebuild the context back to a dictionary (probably kwargs)
'''
# Make sure we are getting dicts
if type(jsonquery) != dict:
raise IOError("set_json_context() method can be called only with dictionari... | [
"def",
"set_context_json",
"(",
"self",
",",
"jsonquery",
")",
":",
"# Make sure we are getting dicts",
"if",
"type",
"(",
"jsonquery",
")",
"!=",
"dict",
":",
"raise",
"IOError",
"(",
"\"set_json_context() method can be called only with dictionaries, you gave me a '{}'\"",
... | Get a json parameter and rebuild the context back to a dictionary (probably kwargs) | [
"Get",
"a",
"json",
"parameter",
"and",
"rebuild",
"the",
"context",
"back",
"to",
"a",
"dictionary",
"(",
"probably",
"kwargs",
")"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L2632-L2682 | train |
codenerix/django-codenerix | codenerix/views.py | GenModify.dispatch | def dispatch(self, request, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Check if this is a webservice request
self.json_worker = (bool(getattr(self.request, "authtoken", False))) or (self.json is True)
self.__authtoken = (bool(getattr(self... | python | def dispatch(self, request, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Check if this is a webservice request
self.json_worker = (bool(getattr(self.request, "authtoken", False))) or (self.json is True)
self.__authtoken = (bool(getattr(self... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check if this is a webservice request",
"self",
".",
"json_worker",
"=",
"(",
"bool",
"(",
"getattr",
"(",
"self",
".",
"request",
",",
"\"authtoken\"",
",",
"False",
")",
... | Entry point for this class, here we decide basic stuff | [
"Entry",
"point",
"for",
"this",
"class",
"here",
"we",
"decide",
"basic",
"stuff"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3004-L3030 | train |
codenerix/django-codenerix | codenerix/views.py | GenModify.get_form | def get_form(self, form_class=None):
'''
Set form groups to the groups specified in the view if defined
'''
formobj = super(GenModify, self).get_form(form_class)
# Set requested group to this form
selfgroups = getattr(self, "form_groups", None)
if selfgroups:
... | python | def get_form(self, form_class=None):
'''
Set form groups to the groups specified in the view if defined
'''
formobj = super(GenModify, self).get_form(form_class)
# Set requested group to this form
selfgroups = getattr(self, "form_groups", None)
if selfgroups:
... | [
"def",
"get_form",
"(",
"self",
",",
"form_class",
"=",
"None",
")",
":",
"formobj",
"=",
"super",
"(",
"GenModify",
",",
"self",
")",
".",
"get_form",
"(",
"form_class",
")",
"# Set requested group to this form",
"selfgroups",
"=",
"getattr",
"(",
"self",
"... | Set form groups to the groups specified in the view if defined | [
"Set",
"form",
"groups",
"to",
"the",
"groups",
"specified",
"in",
"the",
"view",
"if",
"defined"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3316-L3335 | train |
codenerix/django-codenerix | codenerix/views.py | GenDelete.dispatch | def dispatch(self, request, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Delete method must happen with POST not with GET
if request.method == 'POST':
# Check if this is a webservice request
self.__authtoken = (bool(getattr(... | python | def dispatch(self, request, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Delete method must happen with POST not with GET
if request.method == 'POST':
# Check if this is a webservice request
self.__authtoken = (bool(getattr(... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Delete method must happen with POST not with GET",
"if",
"request",
".",
"method",
"==",
"'POST'",
":",
"# Check if this is a webservice request",
"self",
".",
"__authtoken",
"=",
... | Entry point for this class, here we decide basic stuff | [
"Entry",
"point",
"for",
"this",
"class",
"here",
"we",
"decide",
"basic",
"stuff"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3415-L3432 | train |
codenerix/django-codenerix | codenerix/views.py | GenDetail.dispatch | def dispatch(self, request, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Check if this is a REST query to pusth the answer to responde in JSON
if bool(self.request.META.get('HTTP_X_REST', False)):
self.json = True
# Check if th... | python | def dispatch(self, request, **kwargs):
'''
Entry point for this class, here we decide basic stuff
'''
# Check if this is a REST query to pusth the answer to responde in JSON
if bool(self.request.META.get('HTTP_X_REST', False)):
self.json = True
# Check if th... | [
"def",
"dispatch",
"(",
"self",
",",
"request",
",",
"*",
"*",
"kwargs",
")",
":",
"# Check if this is a REST query to pusth the answer to responde in JSON",
"if",
"bool",
"(",
"self",
".",
"request",
".",
"META",
".",
"get",
"(",
"'HTTP_X_REST'",
",",
"False",
... | Entry point for this class, here we decide basic stuff | [
"Entry",
"point",
"for",
"this",
"class",
"here",
"we",
"decide",
"basic",
"stuff"
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3490-L3530 | train |
codenerix/django-codenerix | codenerix/views.py | GenDetail.get_filled_structure | def get_filled_structure(self, subgroup=None):
'''
method in charged of filling an structure containing the object fields
values taking into account the 'group' attribute from the corresponding
form object, which is necesary to fill the details form as it is configured
in the 'gr... | python | def get_filled_structure(self, subgroup=None):
'''
method in charged of filling an structure containing the object fields
values taking into account the 'group' attribute from the corresponding
form object, which is necesary to fill the details form as it is configured
in the 'gr... | [
"def",
"get_filled_structure",
"(",
"self",
",",
"subgroup",
"=",
"None",
")",
":",
"# initilize the result structure",
"result",
"=",
"[",
"]",
"# the object corresponding model content is taken into a dictionary",
"object_content",
"=",
"model_to_dict",
"(",
"self",
".",
... | method in charged of filling an structure containing the object fields
values taking into account the 'group' attribute from the corresponding
form object, which is necesary to fill the details form as it is configured
in the 'group' attribute | [
"method",
"in",
"charged",
"of",
"filling",
"an",
"structure",
"containing",
"the",
"object",
"fields",
"values",
"taking",
"into",
"account",
"the",
"group",
"attribute",
"from",
"the",
"corresponding",
"form",
"object",
"which",
"is",
"necesary",
"to",
"fill",... | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/views.py#L3532-L3668 | train |
codenerix/django-codenerix | codenerix/djng/widgets.py | flatatt | def flatatt(attrs):
"""
Pilfered from `django.forms.utils`:
Convert a dictionary of attributes to a single string.
The returned string will contain a leading space followed by key="value",
XML-style pairs. In the case of a boolean value, the key will appear
without a value. Otherwise, the value ... | python | def flatatt(attrs):
"""
Pilfered from `django.forms.utils`:
Convert a dictionary of attributes to a single string.
The returned string will contain a leading space followed by key="value",
XML-style pairs. In the case of a boolean value, the key will appear
without a value. Otherwise, the value ... | [
"def",
"flatatt",
"(",
"attrs",
")",
":",
"key_value_attrs",
"=",
"[",
"]",
"boolean_attrs",
"=",
"[",
"]",
"for",
"attr",
",",
"value",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bool",
")",
":",
"if",
"val... | Pilfered from `django.forms.utils`:
Convert a dictionary of attributes to a single string.
The returned string will contain a leading space followed by key="value",
XML-style pairs. In the case of a boolean value, the key will appear
without a value. Otherwise, the value is formatted through its own dic... | [
"Pilfered",
"from",
"django",
".",
"forms",
".",
"utils",
":",
"Convert",
"a",
"dictionary",
"of",
"attributes",
"to",
"a",
"single",
"string",
".",
"The",
"returned",
"string",
"will",
"contain",
"a",
"leading",
"space",
"followed",
"by",
"key",
"=",
"val... | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/widgets.py#L11-L41 | train |
markchil/gptools | gptools/kernel/rational_quadratic.py | RationalQuadraticKernel._compute_k | def _compute_k(self, tau):
r"""Evaluate the kernel directly at the given values of `tau`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
Returns
-------
k : :py:class:`Array`, (`M`,)
... | python | def _compute_k(self, tau):
r"""Evaluate the kernel directly at the given values of `tau`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
Returns
-------
k : :py:class:`Array`, (`M`,)
... | [
"def",
"_compute_k",
"(",
"self",
",",
"tau",
")",
":",
"y",
"=",
"self",
".",
"_compute_y",
"(",
"tau",
")",
"return",
"y",
"**",
"(",
"-",
"self",
".",
"params",
"[",
"1",
"]",
")"
] | r"""Evaluate the kernel directly at the given values of `tau`.
Parameters
----------
tau : :py:class:`Matrix`, (`M`, `D`)
`M` inputs with dimension `D`.
Returns
-------
k : :py:class:`Array`, (`M`,)
:math:`k(\tau)` (less t... | [
"r",
"Evaluate",
"the",
"kernel",
"directly",
"at",
"the",
"given",
"values",
"of",
"tau",
".",
"Parameters",
"----------",
"tau",
":",
":",
"py",
":",
"class",
":",
"Matrix",
"(",
"M",
"D",
")",
"M",
"inputs",
"with",
"dimension",
"D",
".",
"Returns",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/rational_quadratic.py#L74-L88 | train |
markchil/gptools | gptools/kernel/rational_quadratic.py | RationalQuadraticKernel._compute_dk_dy | def _compute_dk_dy(self, y, n):
"""Evaluate the derivative of the outer form of the RQ kernel.
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int
Order of derivative to compute.
... | python | def _compute_dk_dy(self, y, n):
"""Evaluate the derivative of the outer form of the RQ kernel.
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int
Order of derivative to compute.
... | [
"def",
"_compute_dk_dy",
"(",
"self",
",",
"y",
",",
"n",
")",
":",
"p",
"=",
"fixed_poch",
"(",
"1.0",
"-",
"self",
".",
"params",
"[",
"1",
"]",
"-",
"n",
",",
"n",
")",
"return",
"p",
"*",
"y",
"**",
"(",
"-",
"self",
".",
"params",
"[",
... | Evaluate the derivative of the outer form of the RQ kernel.
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int
Order of derivative to compute.
Returns
-------
dk_dy :... | [
"Evaluate",
"the",
"derivative",
"of",
"the",
"outer",
"form",
"of",
"the",
"RQ",
"kernel",
".",
"Parameters",
"----------",
"y",
":",
":",
"py",
":",
"class",
":",
"Array",
"(",
"M",
")",
"M",
"inputs",
"to",
"evaluate",
"at",
".",
"n",
":",
"non",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/rational_quadratic.py#L116-L132 | train |
CTPUG/wafer | wafer/pages/management/commands/load_pages.py | Command.get_parent | def get_parent(self, directory):
"""
Given a directory name, return the Page representing it in the menu
heirarchy.
"""
assert settings.PAGE_DIR.startswith('/')
assert settings.PAGE_DIR.endswith('/')
parents = directory[len(settings.PAGE_DIR):]
page = No... | python | def get_parent(self, directory):
"""
Given a directory name, return the Page representing it in the menu
heirarchy.
"""
assert settings.PAGE_DIR.startswith('/')
assert settings.PAGE_DIR.endswith('/')
parents = directory[len(settings.PAGE_DIR):]
page = No... | [
"def",
"get_parent",
"(",
"self",
",",
"directory",
")",
":",
"assert",
"settings",
".",
"PAGE_DIR",
".",
"startswith",
"(",
"'/'",
")",
"assert",
"settings",
".",
"PAGE_DIR",
".",
"endswith",
"(",
"'/'",
")",
"parents",
"=",
"directory",
"[",
"len",
"("... | Given a directory name, return the Page representing it in the menu
heirarchy. | [
"Given",
"a",
"directory",
"name",
"return",
"the",
"Page",
"representing",
"it",
"in",
"the",
"menu",
"heirarchy",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/pages/management/commands/load_pages.py#L24-L38 | train |
CTPUG/wafer | wafer/registration/templatetags/wafer_sso.py | wafer_sso_url | def wafer_sso_url(context, sso_method):
'''
Return the correct URL to SSO with the given method.
'''
request = context.request
url = reverse(getattr(views, '%s_login' % sso_method))
if 'next' in request.GET:
url += '?' + urlencode({'next': request.GET['next']})
return url | python | def wafer_sso_url(context, sso_method):
'''
Return the correct URL to SSO with the given method.
'''
request = context.request
url = reverse(getattr(views, '%s_login' % sso_method))
if 'next' in request.GET:
url += '?' + urlencode({'next': request.GET['next']})
return url | [
"def",
"wafer_sso_url",
"(",
"context",
",",
"sso_method",
")",
":",
"request",
"=",
"context",
".",
"request",
"url",
"=",
"reverse",
"(",
"getattr",
"(",
"views",
",",
"'%s_login'",
"%",
"sso_method",
")",
")",
"if",
"'next'",
"in",
"request",
".",
"GE... | Return the correct URL to SSO with the given method. | [
"Return",
"the",
"correct",
"URL",
"to",
"SSO",
"with",
"the",
"given",
"method",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/templatetags/wafer_sso.py#L11-L19 | train |
coursera/courseraoauth2client | courseraoauth2client/commands/config.py | authorize | def authorize(args):
"""
Authorizes Coursera's OAuth2 client for using coursera.org API servers for
a specific application
"""
oauth2_instance = oauth2.build_oauth2(args.app, args)
oauth2_instance.build_authorizer()
logging.info('Application "%s" authorized!', args.app) | python | def authorize(args):
"""
Authorizes Coursera's OAuth2 client for using coursera.org API servers for
a specific application
"""
oauth2_instance = oauth2.build_oauth2(args.app, args)
oauth2_instance.build_authorizer()
logging.info('Application "%s" authorized!', args.app) | [
"def",
"authorize",
"(",
"args",
")",
":",
"oauth2_instance",
"=",
"oauth2",
".",
"build_oauth2",
"(",
"args",
".",
"app",
",",
"args",
")",
"oauth2_instance",
".",
"build_authorizer",
"(",
")",
"logging",
".",
"info",
"(",
"'Application \"%s\" authorized!'",
... | Authorizes Coursera's OAuth2 client for using coursera.org API servers for
a specific application | [
"Authorizes",
"Coursera",
"s",
"OAuth2",
"client",
"for",
"using",
"coursera",
".",
"org",
"API",
"servers",
"for",
"a",
"specific",
"application"
] | 4edd991defe26bfc768ab28a30368cace40baf44 | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L31-L38 | train |
coursera/courseraoauth2client | courseraoauth2client/commands/config.py | check_auth | def check_auth(args):
"""
Checks courseraoauth2client's connectivity to the coursera.org API servers
for a specific application
"""
oauth2_instance = oauth2.build_oauth2(args.app, args)
auth = oauth2_instance.build_authorizer()
my_profile_url = (
'https://api.coursera.org/api/externa... | python | def check_auth(args):
"""
Checks courseraoauth2client's connectivity to the coursera.org API servers
for a specific application
"""
oauth2_instance = oauth2.build_oauth2(args.app, args)
auth = oauth2_instance.build_authorizer()
my_profile_url = (
'https://api.coursera.org/api/externa... | [
"def",
"check_auth",
"(",
"args",
")",
":",
"oauth2_instance",
"=",
"oauth2",
".",
"build_oauth2",
"(",
"args",
".",
"app",
",",
"args",
")",
"auth",
"=",
"oauth2_instance",
".",
"build_authorizer",
"(",
")",
"my_profile_url",
"=",
"(",
"'https://api.coursera.... | Checks courseraoauth2client's connectivity to the coursera.org API servers
for a specific application | [
"Checks",
"courseraoauth2client",
"s",
"connectivity",
"to",
"the",
"coursera",
".",
"org",
"API",
"servers",
"for",
"a",
"specific",
"application"
] | 4edd991defe26bfc768ab28a30368cace40baf44 | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L41-L79 | train |
coursera/courseraoauth2client | courseraoauth2client/commands/config.py | display_auth_cache | def display_auth_cache(args):
'''
Writes to the screen the state of the authentication cache. (For debugging
authentication issues.) BEWARE: DO NOT email the output of this command!!!
You must keep the tokens secure. Treat them as passwords.
'''
oauth2_instance = oauth2.build_oauth2(args.app, ar... | python | def display_auth_cache(args):
'''
Writes to the screen the state of the authentication cache. (For debugging
authentication issues.) BEWARE: DO NOT email the output of this command!!!
You must keep the tokens secure. Treat them as passwords.
'''
oauth2_instance = oauth2.build_oauth2(args.app, ar... | [
"def",
"display_auth_cache",
"(",
"args",
")",
":",
"oauth2_instance",
"=",
"oauth2",
".",
"build_oauth2",
"(",
"args",
".",
"app",
",",
"args",
")",
"if",
"not",
"args",
".",
"quiet",
">",
"0",
":",
"token",
"=",
"oauth2_instance",
".",
"token_cache",
"... | Writes to the screen the state of the authentication cache. (For debugging
authentication issues.) BEWARE: DO NOT email the output of this command!!!
You must keep the tokens secure. Treat them as passwords. | [
"Writes",
"to",
"the",
"screen",
"the",
"state",
"of",
"the",
"authentication",
"cache",
".",
"(",
"For",
"debugging",
"authentication",
"issues",
".",
")",
"BEWARE",
":",
"DO",
"NOT",
"email",
"the",
"output",
"of",
"this",
"command!!!",
"You",
"must",
"k... | 4edd991defe26bfc768ab28a30368cace40baf44 | https://github.com/coursera/courseraoauth2client/blob/4edd991defe26bfc768ab28a30368cace40baf44/courseraoauth2client/commands/config.py#L82-L105 | train |
markchil/gptools | gptools/kernel/gibbs.py | tanh_warp_arb | def tanh_warp_arb(X, l1, l2, lw, x0):
r"""Warps the `X` coordinate with the tanh model
.. math::
l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w}
Parameters
----------
X : :py:class:`Array`, (`M`,) or scalar float
`M` locations to evaluate length sca... | python | def tanh_warp_arb(X, l1, l2, lw, x0):
r"""Warps the `X` coordinate with the tanh model
.. math::
l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w}
Parameters
----------
X : :py:class:`Array`, (`M`,) or scalar float
`M` locations to evaluate length sca... | [
"def",
"tanh_warp_arb",
"(",
"X",
",",
"l1",
",",
"l2",
",",
"lw",
",",
"x0",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"scipy",
".",
"ndarray",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"scipy",
".",
"matrix",
")",
":",
"X",
"=",
"scipy"... | r"""Warps the `X` coordinate with the tanh model
.. math::
l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w}
Parameters
----------
X : :py:class:`Array`, (`M`,) or scalar float
`M` locations to evaluate length scale at.
l1 : positive float
Sma... | [
"r",
"Warps",
"the",
"X",
"coordinate",
"with",
"the",
"tanh",
"model",
"..",
"math",
"::",
"l",
"=",
"\\",
"frac",
"{",
"l_1",
"+",
"l_2",
"}",
"{",
"2",
"}",
"-",
"\\",
"frac",
"{",
"l_1",
"-",
"l_2",
"}",
"{",
"2",
"}",
"\\",
"tanh",
"\\",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L37-L67 | train |
markchil/gptools | gptools/kernel/gibbs.py | gauss_warp_arb | def gauss_warp_arb(X, l1, l2, lw, x0):
r"""Warps the `X` coordinate with a Gaussian-shaped divot.
.. math::
l = l_1 - (l_1 - l_2) \exp\left ( -4\ln 2\frac{(X-x_0)^2}{l_{w}^{2}} \right )
Parameters
----------
X : :py:class:`Array`, (`M`,) or scalar float
`M` locatio... | python | def gauss_warp_arb(X, l1, l2, lw, x0):
r"""Warps the `X` coordinate with a Gaussian-shaped divot.
.. math::
l = l_1 - (l_1 - l_2) \exp\left ( -4\ln 2\frac{(X-x_0)^2}{l_{w}^{2}} \right )
Parameters
----------
X : :py:class:`Array`, (`M`,) or scalar float
`M` locatio... | [
"def",
"gauss_warp_arb",
"(",
"X",
",",
"l1",
",",
"l2",
",",
"lw",
",",
"x0",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"scipy",
".",
"ndarray",
")",
":",
"if",
"isinstance",
"(",
"X",
",",
"scipy",
".",
"matrix",
")",
":",
"X",
"=",
"scipy... | r"""Warps the `X` coordinate with a Gaussian-shaped divot.
.. math::
l = l_1 - (l_1 - l_2) \exp\left ( -4\ln 2\frac{(X-x_0)^2}{l_{w}^{2}} \right )
Parameters
----------
X : :py:class:`Array`, (`M`,) or scalar float
`M` locations to evaluate length scale at.
l1 : po... | [
"r",
"Warps",
"the",
"X",
"coordinate",
"with",
"a",
"Gaussian",
"-",
"shaped",
"divot",
".",
"..",
"math",
"::",
"l",
"=",
"l_1",
"-",
"(",
"l_1",
"-",
"l_2",
")",
"\\",
"exp",
"\\",
"left",
"(",
"-",
"4",
"\\",
"ln",
"2",
"\\",
"frac",
"{",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L69-L99 | train |
markchil/gptools | gptools/kernel/gibbs.py | tanh_warp | def tanh_warp(x, n, l1, l2, lw, x0):
r"""Implements a tanh warping function and its derivative.
.. math::
l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w}
Parameters
----------
x : float or array of float
Locations to evaluate the function at.
n ... | python | def tanh_warp(x, n, l1, l2, lw, x0):
r"""Implements a tanh warping function and its derivative.
.. math::
l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w}
Parameters
----------
x : float or array of float
Locations to evaluate the function at.
n ... | [
"def",
"tanh_warp",
"(",
"x",
",",
"n",
",",
"l1",
",",
"l2",
",",
"lw",
",",
"x0",
")",
":",
"if",
"n",
"==",
"0",
":",
"return",
"(",
"l1",
"+",
"l2",
")",
"/",
"2.0",
"-",
"(",
"l1",
"-",
"l2",
")",
"/",
"2.0",
"*",
"scipy",
".",
"ta... | r"""Implements a tanh warping function and its derivative.
.. math::
l = \frac{l_1 + l_2}{2} - \frac{l_1 - l_2}{2}\tanh\frac{x-x_0}{l_w}
Parameters
----------
x : float or array of float
Locations to evaluate the function at.
n : int
Derivative order to take. U... | [
"r",
"Implements",
"a",
"tanh",
"warping",
"function",
"and",
"its",
"derivative",
".",
"..",
"math",
"::",
"l",
"=",
"\\",
"frac",
"{",
"l_1",
"+",
"l_2",
"}",
"{",
"2",
"}",
"-",
"\\",
"frac",
"{",
"l_1",
"-",
"l_2",
"}",
"{",
"2",
"}",
"\\",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L401-L438 | train |
markchil/gptools | gptools/kernel/gibbs.py | double_tanh_warp | def double_tanh_warp(x, n, lcore, lmid, ledge, la, lb, xa, xb):
r"""Implements a sum-of-tanh warping function and its derivative.
.. math::
l = a\tanh\frac{x-x_a}{l_a} + b\tanh\frac{x-x_b}{l_b}
Parameters
----------
x : float or array of float
Locations to evaluate the... | python | def double_tanh_warp(x, n, lcore, lmid, ledge, la, lb, xa, xb):
r"""Implements a sum-of-tanh warping function and its derivative.
.. math::
l = a\tanh\frac{x-x_a}{l_a} + b\tanh\frac{x-x_b}{l_b}
Parameters
----------
x : float or array of float
Locations to evaluate the... | [
"def",
"double_tanh_warp",
"(",
"x",
",",
"n",
",",
"lcore",
",",
"lmid",
",",
"ledge",
",",
"la",
",",
"lb",
",",
"xa",
",",
"xb",
")",
":",
"a",
",",
"b",
",",
"c",
"=",
"scipy",
".",
"dot",
"(",
"[",
"[",
"-",
"0.5",
",",
"0",
",",
"0.... | r"""Implements a sum-of-tanh warping function and its derivative.
.. math::
l = a\tanh\frac{x-x_a}{l_a} + b\tanh\frac{x-x_b}{l_b}
Parameters
----------
x : float or array of float
Locations to evaluate the function at.
n : int
Derivative order to take. Used for... | [
"r",
"Implements",
"a",
"sum",
"-",
"of",
"-",
"tanh",
"warping",
"function",
"and",
"its",
"derivative",
".",
"..",
"math",
"::",
"l",
"=",
"a",
"\\",
"tanh",
"\\",
"frac",
"{",
"x",
"-",
"x_a",
"}",
"{",
"l_a",
"}",
"+",
"b",
"\\",
"tanh",
"\... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L479-L528 | train |
markchil/gptools | gptools/kernel/gibbs.py | cubic_bucket_warp | def cubic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise cubic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | python | def cubic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise cubic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | [
"def",
"cubic_bucket_warp",
"(",
"x",
",",
"n",
",",
"l1",
",",
"l2",
",",
"l3",
",",
"x0",
",",
"w1",
",",
"w2",
",",
"w3",
")",
":",
"x1",
"=",
"x0",
"-",
"w2",
"/",
"2.0",
"-",
"w1",
"/",
"2.0",
"x2",
"=",
"x0",
"+",
"w2",
"/",
"2.0",
... | Warps the length scale with a piecewise cubic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first derivatives are supported.
l1 : positive float
Length... | [
"Warps",
"the",
"length",
"scale",
"with",
"a",
"piecewise",
"cubic",
"bucket",
"shape",
".",
"Parameters",
"----------",
"x",
":",
"float",
"or",
"array",
"-",
"like",
"of",
"float",
"Locations",
"to",
"evaluate",
"length",
"scale",
"at",
".",
"n",
":",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L572-L620 | train |
markchil/gptools | gptools/kernel/gibbs.py | quintic_bucket_warp | def quintic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise quintic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | python | def quintic_bucket_warp(x, n, l1, l2, l3, x0, w1, w2, w3):
"""Warps the length scale with a piecewise quintic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first d... | [
"def",
"quintic_bucket_warp",
"(",
"x",
",",
"n",
",",
"l1",
",",
"l2",
",",
"l3",
",",
"x0",
",",
"w1",
",",
"w2",
",",
"w3",
")",
":",
"x1",
"=",
"x0",
"-",
"w2",
"/",
"2.0",
"-",
"w1",
"/",
"2.0",
"x2",
"=",
"x0",
"+",
"w2",
"/",
"2.0"... | Warps the length scale with a piecewise quintic "bucket" shape.
Parameters
----------
x : float or array-like of float
Locations to evaluate length scale at.
n : non-negative int
Derivative order to evaluate. Only first derivatives are supported.
l1 : positive float
Length s... | [
"Warps",
"the",
"length",
"scale",
"with",
"a",
"piecewise",
"quintic",
"bucket",
"shape",
"."
] | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L660-L723 | train |
markchil/gptools | gptools/kernel/gibbs.py | exp_gauss_warp | def exp_gauss_warp(X, n, l0, *msb):
"""Length scale function which is an exponential of a sum of Gaussians.
The centers and widths of the Gaussians are free parameters.
The length scale function is given by
.. math::
l = l_0 \exp\left ( \sum_{i=1}^{N}\beta_i\exp\left ( -\... | python | def exp_gauss_warp(X, n, l0, *msb):
"""Length scale function which is an exponential of a sum of Gaussians.
The centers and widths of the Gaussians are free parameters.
The length scale function is given by
.. math::
l = l_0 \exp\left ( \sum_{i=1}^{N}\beta_i\exp\left ( -\... | [
"def",
"exp_gauss_warp",
"(",
"X",
",",
"n",
",",
"l0",
",",
"*",
"msb",
")",
":",
"X",
"=",
"scipy",
".",
"asarray",
"(",
"X",
",",
"dtype",
"=",
"float",
")",
"msb",
"=",
"scipy",
".",
"asarray",
"(",
"msb",
",",
"dtype",
"=",
"float",
")",
... | Length scale function which is an exponential of a sum of Gaussians.
The centers and widths of the Gaussians are free parameters.
The length scale function is given by
.. math::
l = l_0 \exp\left ( \sum_{i=1}^{N}\beta_i\exp\left ( -\frac{(x-\mu_i)^2}{2\sigma_i^2} \right ) \ri... | [
"Length",
"scale",
"function",
"which",
"is",
"an",
"exponential",
"of",
"a",
"sum",
"of",
"Gaussians",
".",
"The",
"centers",
"and",
"widths",
"of",
"the",
"Gaussians",
"are",
"free",
"parameters",
".",
"The",
"length",
"scale",
"function",
"is",
"given",
... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/gibbs.py#L763-L814 | train |
codenerix/django-codenerix | codenerix/djng/field_mixins.py | MultipleFieldMixin.get_multiple_choices_required | def get_multiple_choices_required(self):
"""
Add only the required message, but no 'ng-required' attribute to the input fields,
otherwise all Checkboxes of a MultipleChoiceField would require the property "checked".
"""
errors = []
if self.required:
for key, m... | python | def get_multiple_choices_required(self):
"""
Add only the required message, but no 'ng-required' attribute to the input fields,
otherwise all Checkboxes of a MultipleChoiceField would require the property "checked".
"""
errors = []
if self.required:
for key, m... | [
"def",
"get_multiple_choices_required",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"if",
"self",
".",
"required",
":",
"for",
"key",
",",
"msg",
"in",
"self",
".",
"error_messages",
".",
"items",
"(",
")",
":",
"if",
"key",
"==",
"'required'",
":"... | Add only the required message, but no 'ng-required' attribute to the input fields,
otherwise all Checkboxes of a MultipleChoiceField would require the property "checked". | [
"Add",
"only",
"the",
"required",
"message",
"but",
"no",
"ng",
"-",
"required",
"attribute",
"to",
"the",
"input",
"fields",
"otherwise",
"all",
"Checkboxes",
"of",
"a",
"MultipleChoiceField",
"would",
"require",
"the",
"property",
"checked",
"."
] | 1f5527b352141caaee902b37b2648791a06bd57d | https://github.com/codenerix/django-codenerix/blob/1f5527b352141caaee902b37b2648791a06bd57d/codenerix/djng/field_mixins.py#L177-L187 | train |
CTPUG/wafer | wafer/registration/sso.py | sso | def sso(user, desired_username, name, email, profile_fields=None):
"""
Create a user, if the provided `user` is None, from the parameters.
Then log the user in, and return it.
"""
if not user:
if not settings.REGISTRATION_OPEN:
raise SSOError('Account registration is closed')
... | python | def sso(user, desired_username, name, email, profile_fields=None):
"""
Create a user, if the provided `user` is None, from the parameters.
Then log the user in, and return it.
"""
if not user:
if not settings.REGISTRATION_OPEN:
raise SSOError('Account registration is closed')
... | [
"def",
"sso",
"(",
"user",
",",
"desired_username",
",",
"name",
",",
"email",
",",
"profile_fields",
"=",
"None",
")",
":",
"if",
"not",
"user",
":",
"if",
"not",
"settings",
".",
"REGISTRATION_OPEN",
":",
"raise",
"SSOError",
"(",
"'Account registration is... | Create a user, if the provided `user` is None, from the parameters.
Then log the user in, and return it. | [
"Create",
"a",
"user",
"if",
"the",
"provided",
"user",
"is",
"None",
"from",
"the",
"parameters",
".",
"Then",
"log",
"the",
"user",
"in",
"and",
"return",
"it",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/registration/sso.py#L24-L41 | train |
markchil/gptools | gptools/gp_utils.py | parallel_compute_ll_matrix | def parallel_compute_ll_matrix(gp, bounds, num_pts, num_proc=None):
"""Compute matrix of the log likelihood over the parameter space in parallel.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each... | python | def parallel_compute_ll_matrix(gp, bounds, num_pts, num_proc=None):
"""Compute matrix of the log likelihood over the parameter space in parallel.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each... | [
"def",
"parallel_compute_ll_matrix",
"(",
"gp",
",",
"bounds",
",",
"num_pts",
",",
"num_proc",
"=",
"None",
")",
":",
"if",
"num_proc",
"is",
"None",
":",
"num_proc",
"=",
"multiprocessing",
".",
"cpu_count",
"(",
")",
"present_free_params",
"=",
"gp",
".",... | Compute matrix of the log likelihood over the parameter space in parallel.
Parameters
----------
bounds : 2-tuple or list of 2-tuples with length equal to the number of free parameters
Bounds on the range to use for each of the parameters. If a single
2-tuple is given, it will be used f... | [
"Compute",
"matrix",
"of",
"the",
"log",
"likelihood",
"over",
"the",
"parameter",
"space",
"in",
"parallel",
".",
"Parameters",
"----------",
"bounds",
":",
"2",
"-",
"tuple",
"or",
"list",
"of",
"2",
"-",
"tuples",
"with",
"length",
"equal",
"to",
"the",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L45-L117 | train |
markchil/gptools | gptools/gp_utils.py | slice_plot | def slice_plot(*args, **kwargs):
"""Constructs a plot that lets you look at slices through a multidimensional array.
Parameters
----------
vals : array, (`M`, `D`, `P`, ...)
Multidimensional array to visualize.
x_vals_1 : array, (`M`,)
Values along the first dimension.
x_val... | python | def slice_plot(*args, **kwargs):
"""Constructs a plot that lets you look at slices through a multidimensional array.
Parameters
----------
vals : array, (`M`, `D`, `P`, ...)
Multidimensional array to visualize.
x_vals_1 : array, (`M`,)
Values along the first dimension.
x_val... | [
"def",
"slice_plot",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"names",
"=",
"kwargs",
".",
"get",
"(",
"'names'",
",",
"None",
")",
"n",
"=",
"kwargs",
".",
"get",
"(",
"'n'",
",",
"100",
")",
"num_axes",
"=",
"len",
"(",
"args",
")... | Constructs a plot that lets you look at slices through a multidimensional array.
Parameters
----------
vals : array, (`M`, `D`, `P`, ...)
Multidimensional array to visualize.
x_vals_1 : array, (`M`,)
Values along the first dimension.
x_vals_2 : array, (`D`,)
Values along... | [
"Constructs",
"a",
"plot",
"that",
"lets",
"you",
"look",
"at",
"slices",
"through",
"a",
"multidimensional",
"array",
".",
"Parameters",
"----------",
"vals",
":",
"array",
"(",
"M",
"D",
"P",
"...",
")",
"Multidimensional",
"array",
"to",
"visualize",
".",... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L134-L236 | train |
markchil/gptools | gptools/gp_utils.py | arrow_respond | def arrow_respond(slider, event):
"""Event handler for arrow key events in plot windows.
Pass the slider object to update as a masked argument using a lambda function::
lambda evt: arrow_respond(my_slider, evt)
Parameters
----------
slider : Slider instance associated with... | python | def arrow_respond(slider, event):
"""Event handler for arrow key events in plot windows.
Pass the slider object to update as a masked argument using a lambda function::
lambda evt: arrow_respond(my_slider, evt)
Parameters
----------
slider : Slider instance associated with... | [
"def",
"arrow_respond",
"(",
"slider",
",",
"event",
")",
":",
"if",
"event",
".",
"key",
"==",
"'right'",
":",
"slider",
".",
"set_val",
"(",
"min",
"(",
"slider",
".",
"val",
"+",
"1",
",",
"slider",
".",
"valmax",
")",
")",
"elif",
"event",
".",... | Event handler for arrow key events in plot windows.
Pass the slider object to update as a masked argument using a lambda function::
lambda evt: arrow_respond(my_slider, evt)
Parameters
----------
slider : Slider instance associated with this handler.
event : Event to be ha... | [
"Event",
"handler",
"for",
"arrow",
"key",
"events",
"in",
"plot",
"windows",
".",
"Pass",
"the",
"slider",
"object",
"to",
"update",
"as",
"a",
"masked",
"argument",
"using",
"a",
"lambda",
"function",
"::",
"lambda",
"evt",
":",
"arrow_respond",
"(",
"my... | 225db52bfe6baef1516529ad22177aa2cf7b71e4 | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/gp_utils.py#L238-L253 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.debit | def debit(self, amount, credit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.po... | python | def debit(self, amount, credit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.po... | [
"def",
"debit",
"(",
"self",
",",
"amount",
",",
"credit_account",
",",
"description",
",",
"debit_memo",
"=",
"\"\"",
",",
"credit_memo",
"=",
"\"\"",
",",
"datetime",
"=",
"None",
")",
":",
"assert",
"amount",
">=",
"0",
"return",
"self",
".",
"post",
... | Post a debit of 'amount' and a credit of -amount against this account and credit_account respectively.
note amount must be non-negative. | [
"Post",
"a",
"debit",
"of",
"amount",
"and",
"a",
"credit",
"of",
"-",
"amount",
"against",
"this",
"account",
"and",
"credit_account",
"respectively",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L143-L150 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.credit | def credit(self, amount, debit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.pos... | python | def credit(self, amount, debit_account, description, debit_memo="", credit_memo="", datetime=None):
""" Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.
note amount must be non-negative.
"""
assert amount >= 0
return self.pos... | [
"def",
"credit",
"(",
"self",
",",
"amount",
",",
"debit_account",
",",
"description",
",",
"debit_memo",
"=",
"\"\"",
",",
"credit_memo",
"=",
"\"\"",
",",
"datetime",
"=",
"None",
")",
":",
"assert",
"amount",
">=",
"0",
"return",
"self",
".",
"post",
... | Post a credit of 'amount' and a debit of -amount against this account and credit_account respectively.
note amount must be non-negative. | [
"Post",
"a",
"credit",
"of",
"amount",
"and",
"a",
"debit",
"of",
"-",
"amount",
"against",
"this",
"account",
"and",
"credit_account",
"respectively",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L152-L158 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.post | def post(self, amount, other_account, description, self_memo="", other_memo="", datetime=None):
""" Post a transaction of 'amount' against this account and the negative amount against 'other_account'.
This will show as a debit or credit against this account when amount > 0 or amount < 0 respectively.
... | python | def post(self, amount, other_account, description, self_memo="", other_memo="", datetime=None):
""" Post a transaction of 'amount' against this account and the negative amount against 'other_account'.
This will show as a debit or credit against this account when amount > 0 or amount < 0 respectively.
... | [
"def",
"post",
"(",
"self",
",",
"amount",
",",
"other_account",
",",
"description",
",",
"self_memo",
"=",
"\"\"",
",",
"other_memo",
"=",
"\"\"",
",",
"datetime",
"=",
"None",
")",
":",
"#Note: debits are always positive, credits are always negative. They should be... | Post a transaction of 'amount' against this account and the negative amount against 'other_account'.
This will show as a debit or credit against this account when amount > 0 or amount < 0 respectively. | [
"Post",
"a",
"transaction",
"of",
"amount",
"against",
"this",
"account",
"and",
"the",
"negative",
"amount",
"against",
"other_account",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L161-L183 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.balance | def balance(self, date=None):
""" returns the account balance as of 'date' (datetime stamp) or now(). """
qs = self._entries()
if date:
qs = qs.filter(transaction__t_stamp__lt=date)
r = qs.aggregate(b=Sum('amount'))
b = r['b']
flip = self._DEBIT_IN_DB()
... | python | def balance(self, date=None):
""" returns the account balance as of 'date' (datetime stamp) or now(). """
qs = self._entries()
if date:
qs = qs.filter(transaction__t_stamp__lt=date)
r = qs.aggregate(b=Sum('amount'))
b = r['b']
flip = self._DEBIT_IN_DB()
... | [
"def",
"balance",
"(",
"self",
",",
"date",
"=",
"None",
")",
":",
"qs",
"=",
"self",
".",
"_entries",
"(",
")",
"if",
"date",
":",
"qs",
"=",
"qs",
".",
"filter",
"(",
"transaction__t_stamp__lt",
"=",
"date",
")",
"r",
"=",
"qs",
".",
"aggregate",... | returns the account balance as of 'date' (datetime stamp) or now(). | [
"returns",
"the",
"account",
"balance",
"as",
"of",
"date",
"(",
"datetime",
"stamp",
")",
"or",
"now",
"()",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L185-L203 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.totals | def totals(self, start=None, end=None):
"""Returns a Totals object containing the sum of all debits, credits
and net change over the period of time from start to end.
'start' is inclusive, 'end' is exclusive
"""
qs = self._entries_range(start=start, end=end)
qs_positive... | python | def totals(self, start=None, end=None):
"""Returns a Totals object containing the sum of all debits, credits
and net change over the period of time from start to end.
'start' is inclusive, 'end' is exclusive
"""
qs = self._entries_range(start=start, end=end)
qs_positive... | [
"def",
"totals",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"qs",
"=",
"self",
".",
"_entries_range",
"(",
"start",
"=",
"start",
",",
"end",
"=",
"end",
")",
"qs_positive",
"=",
"qs",
".",
"filter",
"(",
"amount__gt... | Returns a Totals object containing the sum of all debits, credits
and net change over the period of time from start to end.
'start' is inclusive, 'end' is exclusive | [
"Returns",
"a",
"Totals",
"object",
"containing",
"the",
"sum",
"of",
"all",
"debits",
"credits",
"and",
"net",
"change",
"over",
"the",
"period",
"of",
"time",
"from",
"start",
"to",
"end",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L220-L246 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | AccountBase.ledger | def ledger(self, start=None, end=None):
"""Returns a list of entries for this account.
Ledger returns a sequence of LedgerEntry's matching the criteria
in chronological order. The returned sequence can be boolean-tested
(ie. test that nothing was returned).
If 'start' is given,... | python | def ledger(self, start=None, end=None):
"""Returns a list of entries for this account.
Ledger returns a sequence of LedgerEntry's matching the criteria
in chronological order. The returned sequence can be boolean-tested
(ie. test that nothing was returned).
If 'start' is given,... | [
"def",
"ledger",
"(",
"self",
",",
"start",
"=",
"None",
",",
"end",
"=",
"None",
")",
":",
"DEBIT_IN_DB",
"=",
"self",
".",
"_DEBIT_IN_DB",
"(",
")",
"flip",
"=",
"1",
"if",
"self",
".",
"_positive_credit",
"(",
")",
":",
"flip",
"*=",
"-",
"1",
... | Returns a list of entries for this account.
Ledger returns a sequence of LedgerEntry's matching the criteria
in chronological order. The returned sequence can be boolean-tested
(ie. test that nothing was returned).
If 'start' is given, only entries on or after that datetime are
... | [
"Returns",
"a",
"list",
"of",
"entries",
"for",
"this",
"account",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L248-L288 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | BookSetBase.get_third_party | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self
return ThirdPartySubAccount(actual_acco... | python | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self
return ThirdPartySubAccount(actual_acco... | [
"def",
"get_third_party",
"(",
"self",
",",
"third_party",
")",
":",
"actual_account",
"=",
"third_party",
".",
"get_account",
"(",
")",
"assert",
"actual_account",
".",
"get_bookset",
"(",
")",
"==",
"self",
"return",
"ThirdPartySubAccount",
"(",
"actual_account"... | Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset. | [
"Return",
"the",
"account",
"for",
"the",
"given",
"third",
"-",
"party",
".",
"Raise",
"<something",
">",
"if",
"the",
"third",
"party",
"doesn",
"t",
"belong",
"to",
"this",
"bookset",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L371-L375 | train |
SwingTix/bookkeeper | swingtix/bookkeeper/account_api.py | ProjectBase.get_third_party | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self.get_bookset()
return ProjectAccount(ac... | python | def get_third_party(self, third_party):
"""Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset."""
actual_account = third_party.get_account()
assert actual_account.get_bookset() == self.get_bookset()
return ProjectAccount(ac... | [
"def",
"get_third_party",
"(",
"self",
",",
"third_party",
")",
":",
"actual_account",
"=",
"third_party",
".",
"get_account",
"(",
")",
"assert",
"actual_account",
".",
"get_bookset",
"(",
")",
"==",
"self",
".",
"get_bookset",
"(",
")",
"return",
"ProjectAcc... | Return the account for the given third-party. Raise <something> if the third party doesn't belong to this bookset. | [
"Return",
"the",
"account",
"for",
"the",
"given",
"third",
"-",
"party",
".",
"Raise",
"<something",
">",
"if",
"the",
"third",
"party",
"doesn",
"t",
"belong",
"to",
"this",
"bookset",
"."
] | 2035099fd78b1d0906403ec836a4b7e7144a6bbc | https://github.com/SwingTix/bookkeeper/blob/2035099fd78b1d0906403ec836a4b7e7144a6bbc/swingtix/bookkeeper/account_api.py#L392-L397 | train |
CTPUG/wafer | wafer/schedule/admin.py | find_overlapping_slots | def find_overlapping_slots(all_slots):
"""Find any slots that overlap"""
overlaps = set([])
for slot in all_slots:
# Because slots are ordered, we can be more efficient than this
# N^2 loop, but this is simple and, since the number of slots
# should be low, this should be "fast enoug... | python | def find_overlapping_slots(all_slots):
"""Find any slots that overlap"""
overlaps = set([])
for slot in all_slots:
# Because slots are ordered, we can be more efficient than this
# N^2 loop, but this is simple and, since the number of slots
# should be low, this should be "fast enoug... | [
"def",
"find_overlapping_slots",
"(",
"all_slots",
")",
":",
"overlaps",
"=",
"set",
"(",
"[",
"]",
")",
"for",
"slot",
"in",
"all_slots",
":",
"# Because slots are ordered, we can be more efficient than this",
"# N^2 loop, but this is simple and, since the number of slots",
... | Find any slots that overlap | [
"Find",
"any",
"slots",
"that",
"overlap"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L24-L51 | train |
CTPUG/wafer | wafer/schedule/admin.py | find_non_contiguous | def find_non_contiguous(all_items):
"""Find any items that have slots that aren't contiguous"""
non_contiguous = []
for item in all_items:
if item.slots.count() < 2:
# No point in checking
continue
last_slot = None
for slot in item.slots.all().order_by('end_ti... | python | def find_non_contiguous(all_items):
"""Find any items that have slots that aren't contiguous"""
non_contiguous = []
for item in all_items:
if item.slots.count() < 2:
# No point in checking
continue
last_slot = None
for slot in item.slots.all().order_by('end_ti... | [
"def",
"find_non_contiguous",
"(",
"all_items",
")",
":",
"non_contiguous",
"=",
"[",
"]",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"slots",
".",
"count",
"(",
")",
"<",
"2",
":",
"# No point in checking",
"continue",
"last_slot",
"=",
"No... | Find any items that have slots that aren't contiguous | [
"Find",
"any",
"items",
"that",
"have",
"slots",
"that",
"aren",
"t",
"contiguous"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L55-L69 | train |
CTPUG/wafer | wafer/schedule/admin.py | validate_items | def validate_items(all_items):
"""Find errors in the schedule. Check for:
- pending / rejected talks in the schedule
- items with both talks and pages assigned
- items with neither talks nor pages assigned
"""
validation = []
for item in all_items:
if item.talk is... | python | def validate_items(all_items):
"""Find errors in the schedule. Check for:
- pending / rejected talks in the schedule
- items with both talks and pages assigned
- items with neither talks nor pages assigned
"""
validation = []
for item in all_items:
if item.talk is... | [
"def",
"validate_items",
"(",
"all_items",
")",
":",
"validation",
"=",
"[",
"]",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"talk",
"is",
"not",
"None",
"and",
"item",
".",
"page",
"is",
"not",
"None",
":",
"validation",
".",
"append",
... | Find errors in the schedule. Check for:
- pending / rejected talks in the schedule
- items with both talks and pages assigned
- items with neither talks nor pages assigned | [
"Find",
"errors",
"in",
"the",
"schedule",
".",
"Check",
"for",
":",
"-",
"pending",
"/",
"rejected",
"talks",
"in",
"the",
"schedule",
"-",
"items",
"with",
"both",
"talks",
"and",
"pages",
"assigned",
"-",
"items",
"with",
"neither",
"talks",
"nor",
"p... | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L72-L86 | train |
CTPUG/wafer | wafer/schedule/admin.py | find_duplicate_schedule_items | def find_duplicate_schedule_items(all_items):
"""Find talks / pages assigned to mulitple schedule items"""
duplicates = []
seen_talks = {}
for item in all_items:
if item.talk and item.talk in seen_talks:
duplicates.append(item)
if seen_talks[item.talk] not in duplicates:
... | python | def find_duplicate_schedule_items(all_items):
"""Find talks / pages assigned to mulitple schedule items"""
duplicates = []
seen_talks = {}
for item in all_items:
if item.talk and item.talk in seen_talks:
duplicates.append(item)
if seen_talks[item.talk] not in duplicates:
... | [
"def",
"find_duplicate_schedule_items",
"(",
"all_items",
")",
":",
"duplicates",
"=",
"[",
"]",
"seen_talks",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"if",
"item",
".",
"talk",
"and",
"item",
".",
"talk",
"in",
"seen_talks",
":",
"duplicates... | Find talks / pages assigned to mulitple schedule items | [
"Find",
"talks",
"/",
"pages",
"assigned",
"to",
"mulitple",
"schedule",
"items"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L89-L103 | train |
CTPUG/wafer | wafer/schedule/admin.py | find_clashes | def find_clashes(all_items):
"""Find schedule items which clash (common slot and venue)"""
clashes = {}
seen_venue_slots = {}
for item in all_items:
for slot in item.slots.all():
pos = (item.venue, slot)
if pos in seen_venue_slots:
if seen_venue_slots[pos]... | python | def find_clashes(all_items):
"""Find schedule items which clash (common slot and venue)"""
clashes = {}
seen_venue_slots = {}
for item in all_items:
for slot in item.slots.all():
pos = (item.venue, slot)
if pos in seen_venue_slots:
if seen_venue_slots[pos]... | [
"def",
"find_clashes",
"(",
"all_items",
")",
":",
"clashes",
"=",
"{",
"}",
"seen_venue_slots",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"for",
"slot",
"in",
"item",
".",
"slots",
".",
"all",
"(",
")",
":",
"pos",
"=",
"(",
"item",
".... | Find schedule items which clash (common slot and venue) | [
"Find",
"schedule",
"items",
"which",
"clash",
"(",
"common",
"slot",
"and",
"venue",
")"
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L106-L120 | train |
CTPUG/wafer | wafer/schedule/admin.py | find_invalid_venues | def find_invalid_venues(all_items):
"""Find venues assigned slots that aren't on the allowed list
of days."""
venues = {}
for item in all_items:
valid = False
item_days = list(item.venue.days.all())
for slot in item.slots.all():
for day in item_days:
... | python | def find_invalid_venues(all_items):
"""Find venues assigned slots that aren't on the allowed list
of days."""
venues = {}
for item in all_items:
valid = False
item_days = list(item.venue.days.all())
for slot in item.slots.all():
for day in item_days:
... | [
"def",
"find_invalid_venues",
"(",
"all_items",
")",
":",
"venues",
"=",
"{",
"}",
"for",
"item",
"in",
"all_items",
":",
"valid",
"=",
"False",
"item_days",
"=",
"list",
"(",
"item",
".",
"venue",
".",
"days",
".",
"all",
"(",
")",
")",
"for",
"slot... | Find venues assigned slots that aren't on the allowed list
of days. | [
"Find",
"venues",
"assigned",
"slots",
"that",
"aren",
"t",
"on",
"the",
"allowed",
"list",
"of",
"days",
"."
] | a20af3c399267f76373dc342f4d542a9bc457c35 | https://github.com/CTPUG/wafer/blob/a20af3c399267f76373dc342f4d542a9bc457c35/wafer/schedule/admin.py#L123-L138 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.