repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
django-danceschool/django-danceschool
danceschool/prerequisites/handlers.py
checkRequirements
def checkRequirements(sender,**kwargs): ''' Check that the customer meets all prerequisites for the items in the registration. ''' if not getConstant('requirements__enableRequirements'): return logger.debug('Signal to check RegistrationContactForm handled by prerequisites app.') ...
python
def checkRequirements(sender,**kwargs): ''' Check that the customer meets all prerequisites for the items in the registration. ''' if not getConstant('requirements__enableRequirements'): return logger.debug('Signal to check RegistrationContactForm handled by prerequisites app.') ...
[ "def", "checkRequirements", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "if", "not", "getConstant", "(", "'requirements__enableRequirements'", ")", ":", "return", "logger", ".", "debug", "(", "'Signal to check RegistrationContactForm handled by prerequisites app.'",...
Check that the customer meets all prerequisites for the items in the registration.
[ "Check", "that", "the", "customer", "meets", "all", "prerequisites", "for", "the", "items", "in", "the", "registration", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/prerequisites/handlers.py#L22-L74
django-danceschool/django-danceschool
danceschool/core/mixins.py
EmailRecipientMixin.email_recipient
def email_recipient(self, subject, content, **kwargs): ''' This method allows for direct emailing of an object's recipient(s) (default or manually specified), with both object-specific context provided using the get_email_context() method. This is used, for example, to emai...
python
def email_recipient(self, subject, content, **kwargs): ''' This method allows for direct emailing of an object's recipient(s) (default or manually specified), with both object-specific context provided using the get_email_context() method. This is used, for example, to emai...
[ "def", "email_recipient", "(", "self", ",", "subject", ",", "content", ",", "*", "*", "kwargs", ")", ":", "email_kwargs", "=", "{", "}", "for", "list_arg", "in", "[", "'to'", ",", "'cc'", ",", "'bcc'", ",", "]", ":", "email_kwargs", "[", "list_arg", ...
This method allows for direct emailing of an object's recipient(s) (default or manually specified), with both object-specific context provided using the get_email_context() method. This is used, for example, to email an individual registrant or the recipient of an individual invoice.
[ "This", "method", "allows", "for", "direct", "emailing", "of", "an", "object", "s", "recipient", "(", "s", ")", "(", "default", "or", "manually", "specified", ")", "with", "both", "object", "-", "specific", "context", "provided", "using", "the", "get_email_c...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L30-L105
django-danceschool/django-danceschool
danceschool/core/mixins.py
EmailRecipientMixin.get_email_context
def get_email_context(self,**kwargs): ''' This method can be overridden in classes that inherit from this mixin so that additional object-specific context is provided to the email template. This should return a dictionary. By default, only general financial context variabl...
python
def get_email_context(self,**kwargs): ''' This method can be overridden in classes that inherit from this mixin so that additional object-specific context is provided to the email template. This should return a dictionary. By default, only general financial context variabl...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "kwargs", "context", ".", "update", "(", "{", "'currencyCode'", ":", "getConstant", "(", "'general__currencyCode'", ")", ",", "'currencySymbol'", ":", "getConstant", "(...
This method can be overridden in classes that inherit from this mixin so that additional object-specific context is provided to the email template. This should return a dictionary. By default, only general financial context variables are added to the dictionary, and kwargs are just...
[ "This", "method", "can", "be", "overridden", "in", "classes", "that", "inherit", "from", "this", "mixin", "so", "that", "additional", "object", "-", "specific", "context", "is", "provided", "to", "the", "email", "template", ".", "This", "should", "return", "...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L107-L128
django-danceschool/django-danceschool
danceschool/core/mixins.py
GroupRequiredByFieldMixin.get_group_required
def get_group_required(self): ''' Get the group_required value from the object ''' this_object = self.model_object if hasattr(this_object,self.group_required_field): if hasattr(getattr(this_object,self.group_required_field),'name'): return [getattr(this_object,se...
python
def get_group_required(self): ''' Get the group_required value from the object ''' this_object = self.model_object if hasattr(this_object,self.group_required_field): if hasattr(getattr(this_object,self.group_required_field),'name'): return [getattr(this_object,se...
[ "def", "get_group_required", "(", "self", ")", ":", "this_object", "=", "self", ".", "model_object", "if", "hasattr", "(", "this_object", ",", "self", ".", "group_required_field", ")", ":", "if", "hasattr", "(", "getattr", "(", "this_object", ",", "self", "....
Get the group_required value from the object
[ "Get", "the", "group_required", "value", "from", "the", "object" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L179-L185
django-danceschool/django-danceschool
danceschool/core/mixins.py
GroupRequiredByFieldMixin.check_membership
def check_membership(self, groups): ''' Allows for objects with no required groups ''' if not groups or groups == ['']: return True if self.request.user.is_superuser: return True user_groups = self.request.user.groups.values_list("name", flat=True) ...
python
def check_membership(self, groups): ''' Allows for objects with no required groups ''' if not groups or groups == ['']: return True if self.request.user.is_superuser: return True user_groups = self.request.user.groups.values_list("name", flat=True) ...
[ "def", "check_membership", "(", "self", ",", "groups", ")", ":", "if", "not", "groups", "or", "groups", "==", "[", "''", "]", ":", "return", "True", "if", "self", ".", "request", ".", "user", ".", "is_superuser", ":", "return", "True", "user_groups", "...
Allows for objects with no required groups
[ "Allows", "for", "objects", "with", "no", "required", "groups" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L187-L194
django-danceschool/django-danceschool
danceschool/core/mixins.py
GroupRequiredByFieldMixin.dispatch
def dispatch(self, request, *args, **kwargs): ''' This override of dispatch ensures that if no group is required, then the request still goes through without being logged in. ''' self.request = request in_group = False required_group = self.get_group_requir...
python
def dispatch(self, request, *args, **kwargs): ''' This override of dispatch ensures that if no group is required, then the request still goes through without being logged in. ''' self.request = request in_group = False required_group = self.get_group_requir...
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "request", "=", "request", "in_group", "=", "False", "required_group", "=", "self", ".", "get_group_required", "(", ")", "if", "not", "req...
This override of dispatch ensures that if no group is required, then the request still goes through without being logged in.
[ "This", "override", "of", "dispatch", "ensures", "that", "if", "no", "group", "is", "required", "then", "the", "request", "still", "goes", "through", "without", "being", "logged", "in", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L196-L218
django-danceschool/django-danceschool
danceschool/core/mixins.py
TemplateChoiceField.validate
def validate(self,value): ''' Check for empty values, and for an existing template, but do not check if this is one of the initial choices provided. ''' super(ChoiceField,self).validate(value) try: get_template(value) except TemplateDoesNotEx...
python
def validate(self,value): ''' Check for empty values, and for an existing template, but do not check if this is one of the initial choices provided. ''' super(ChoiceField,self).validate(value) try: get_template(value) except TemplateDoesNotEx...
[ "def", "validate", "(", "self", ",", "value", ")", ":", "super", "(", "ChoiceField", ",", "self", ")", ".", "validate", "(", "value", ")", "try", ":", "get_template", "(", "value", ")", "except", "TemplateDoesNotExist", ":", "raise", "ValidationError", "("...
Check for empty values, and for an existing template, but do not check if this is one of the initial choices provided.
[ "Check", "for", "empty", "values", "and", "for", "an", "existing", "template", "but", "do", "not", "check", "if", "this", "is", "one", "of", "the", "initial", "choices", "provided", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L242-L252
django-danceschool/django-danceschool
danceschool/core/mixins.py
PluginTemplateMixin.render
def render(self, context, instance, placeholder): ''' Permits setting of the template in the plugin instance configuration ''' if instance and instance.template: self.render_template = instance.template return super(PluginTemplateMixin,self).render(context,instance,placeholder)
python
def render(self, context, instance, placeholder): ''' Permits setting of the template in the plugin instance configuration ''' if instance and instance.template: self.render_template = instance.template return super(PluginTemplateMixin,self).render(context,instance,placeholder)
[ "def", "render", "(", "self", ",", "context", ",", "instance", ",", "placeholder", ")", ":", "if", "instance", "and", "instance", ".", "template", ":", "self", ".", "render_template", "=", "instance", ".", "template", "return", "super", "(", "PluginTemplateM...
Permits setting of the template in the plugin instance configuration
[ "Permits", "setting", "of", "the", "template", "in", "the", "plugin", "instance", "configuration" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L261-L265
django-danceschool/django-danceschool
danceschool/core/mixins.py
EventOrderMixin.get_annotations
def get_annotations(self): ''' This method gets the annotations for the queryset. Unlike get_ordering() below, it passes the actual Case() and F() objects that will be evaluated with the queryset, returned in a dictionary that is compatible with get_ordering(). ''' ...
python
def get_annotations(self): ''' This method gets the annotations for the queryset. Unlike get_ordering() below, it passes the actual Case() and F() objects that will be evaluated with the queryset, returned in a dictionary that is compatible with get_ordering(). ''' ...
[ "def", "get_annotations", "(", "self", ")", ":", "rule", "=", "getConstant", "(", "'registration__orgRule'", ")", "# Initialize with null values that get filled in based on the logic below.\r", "annotations", "=", "{", "'nullParam'", ":", "Case", "(", "default_value", "=", ...
This method gets the annotations for the queryset. Unlike get_ordering() below, it passes the actual Case() and F() objects that will be evaluated with the queryset, returned in a dictionary that is compatible with get_ordering().
[ "This", "method", "gets", "the", "annotations", "for", "the", "queryset", ".", "Unlike", "get_ordering", "()", "below", "it", "passes", "the", "actual", "Case", "()", "and", "F", "()", "objects", "that", "will", "be", "evaluated", "with", "the", "queryset", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L336-L444
django-danceschool/django-danceschool
danceschool/core/mixins.py
EventOrderMixin.get_ordering
def get_ordering(self, reverseTime=False): ''' This method provides the tuple for ordering of querysets. However, this will only work if the annotations generated by the get_annotations() method above have been added to the queryset. Otherwise, the use of this ordering tuple will f...
python
def get_ordering(self, reverseTime=False): ''' This method provides the tuple for ordering of querysets. However, this will only work if the annotations generated by the get_annotations() method above have been added to the queryset. Otherwise, the use of this ordering tuple will f...
[ "def", "get_ordering", "(", "self", ",", "reverseTime", "=", "False", ")", ":", "# Reverse ordering can be optionally specified in the view class definition.\r", "reverseTime", "=", "getattr", "(", "self", ",", "'reverse_time_ordering'", ",", "reverseTime", ")", "timeParame...
This method provides the tuple for ordering of querysets. However, this will only work if the annotations generated by the get_annotations() method above have been added to the queryset. Otherwise, the use of this ordering tuple will fail because the appropriate column names will not exist ...
[ "This", "method", "provides", "the", "tuple", "for", "ordering", "of", "querysets", ".", "However", "this", "will", "only", "work", "if", "the", "annotations", "generated", "by", "the", "get_annotations", "()", "method", "above", "have", "been", "added", "to",...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L446-L457
django-danceschool/django-danceschool
danceschool/core/mixins.py
SiteHistoryMixin.get_return_page
def get_return_page(self,prior=False): ''' This is just a wrapper for the getReturnPage helper function. ''' siteHistory = self.request.session.get('SITE_HISTORY',{}) return getReturnPage(siteHistory,prior=prior)
python
def get_return_page(self,prior=False): ''' This is just a wrapper for the getReturnPage helper function. ''' siteHistory = self.request.session.get('SITE_HISTORY',{}) return getReturnPage(siteHistory,prior=prior)
[ "def", "get_return_page", "(", "self", ",", "prior", "=", "False", ")", ":", "siteHistory", "=", "self", ".", "request", ".", "session", ".", "get", "(", "'SITE_HISTORY'", ",", "{", "}", ")", "return", "getReturnPage", "(", "siteHistory", ",", "prior", "...
This is just a wrapper for the getReturnPage helper function.
[ "This", "is", "just", "a", "wrapper", "for", "the", "getReturnPage", "helper", "function", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/mixins.py#L487-L490
django-danceschool/django-danceschool
danceschool/core/forms.py
RegistrationContactForm.is_valid
def is_valid(self): ''' For this form to be considered valid, there must be not only no errors, but also no messages on the request that need to be shown. ''' valid = super(RegistrationContactForm,self).is_valid() msgs = messages.get_messages(self._request) # We...
python
def is_valid(self): ''' For this form to be considered valid, there must be not only no errors, but also no messages on the request that need to be shown. ''' valid = super(RegistrationContactForm,self).is_valid() msgs = messages.get_messages(self._request) # We...
[ "def", "is_valid", "(", "self", ")", ":", "valid", "=", "super", "(", "RegistrationContactForm", ",", "self", ")", ".", "is_valid", "(", ")", "msgs", "=", "messages", ".", "get_messages", "(", "self", ".", "_request", ")", "# We only want validation messages t...
For this form to be considered valid, there must be not only no errors, but also no messages on the request that need to be shown.
[ "For", "this", "form", "to", "be", "considered", "valid", "there", "must", "be", "not", "only", "no", "errors", "but", "also", "no", "messages", "on", "the", "request", "that", "need", "to", "be", "shown", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/forms.py#L378-L401
django-danceschool/django-danceschool
danceschool/core/forms.py
RefundForm.clean_total_refund_amount
def clean_total_refund_amount(self): ''' The Javascript should ensure that the hidden input is updated, but double check it here. ''' initial = self.cleaned_data.get('initial_refund_amount', 0) total = self.cleaned_data['total_refund_amount'] summed_refunds = sum([v for k...
python
def clean_total_refund_amount(self): ''' The Javascript should ensure that the hidden input is updated, but double check it here. ''' initial = self.cleaned_data.get('initial_refund_amount', 0) total = self.cleaned_data['total_refund_amount'] summed_refunds = sum([v for k...
[ "def", "clean_total_refund_amount", "(", "self", ")", ":", "initial", "=", "self", ".", "cleaned_data", ".", "get", "(", "'initial_refund_amount'", ",", "0", ")", "total", "=", "self", ".", "cleaned_data", "[", "'total_refund_amount'", "]", "summed_refunds", "="...
The Javascript should ensure that the hidden input is updated, but double check it here.
[ "The", "Javascript", "should", "ensure", "that", "the", "hidden", "input", "is", "updated", "but", "double", "check", "it", "here", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/forms.py#L662-L679
django-danceschool/django-danceschool
danceschool/core/forms.py
SeriesClassesChoiceField._check_values
def _check_values(self, value): """ Given a list of possible PK values, returns a QuerySet of the corresponding objects. Raises a ValidationError if a given value is invalid (not a valid PK, not in the queryset, etc.) """ key = self.to_field_name or 'pk' # dedupli...
python
def _check_values(self, value): """ Given a list of possible PK values, returns a QuerySet of the corresponding objects. Raises a ValidationError if a given value is invalid (not a valid PK, not in the queryset, etc.) """ key = self.to_field_name or 'pk' # dedupli...
[ "def", "_check_values", "(", "self", ",", "value", ")", ":", "key", "=", "self", ".", "to_field_name", "or", "'pk'", "# deduplicate given values to avoid creating many querysets or", "# requiring the database backend deduplicate efficiently.", "try", ":", "value", "=", "fro...
Given a list of possible PK values, returns a QuerySet of the corresponding objects. Raises a ValidationError if a given value is invalid (not a valid PK, not in the queryset, etc.)
[ "Given", "a", "list", "of", "possible", "PK", "values", "returns", "a", "QuerySet", "of", "the", "corresponding", "objects", ".", "Raises", "a", "ValidationError", "if", "a", "given", "value", "is", "invalid", "(", "not", "a", "valid", "PK", "not", "in", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/forms.py#L798-L833
django-danceschool/django-danceschool
danceschool/core/forms.py
SubstituteReportingForm.clean
def clean(self): ''' This code prevents multiple individuals from substituting for the same class and class teacher. It also prevents an individual from substituting for a class in which they are a teacher. ''' super(SubstituteReportingForm,self).clean() occurre...
python
def clean(self): ''' This code prevents multiple individuals from substituting for the same class and class teacher. It also prevents an individual from substituting for a class in which they are a teacher. ''' super(SubstituteReportingForm,self).clean() occurre...
[ "def", "clean", "(", "self", ")", ":", "super", "(", "SubstituteReportingForm", ",", "self", ")", ".", "clean", "(", ")", "occurrences", "=", "self", ".", "cleaned_data", ".", "get", "(", "'occurrences'", ",", "[", "]", ")", "staffMember", "=", "self", ...
This code prevents multiple individuals from substituting for the same class and class teacher. It also prevents an individual from substituting for a class in which they are a teacher.
[ "This", "code", "prevents", "multiple", "individuals", "from", "substituting", "for", "the", "same", "class", "and", "class", "teacher", ".", "It", "also", "prevents", "an", "individual", "from", "substituting", "for", "a", "class", "in", "which", "they", "are...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/forms.py#L868-L888
django-danceschool/django-danceschool
danceschool/core/forms.py
SubstituteReportingForm.save
def save(self, commit=True): ''' If a staff member is reporting substitute teaching for a second time, then we should update the list of occurrences for which they are a substitute on their existing EventStaffMember record, rather than creating a new record and creating database issues. ...
python
def save(self, commit=True): ''' If a staff member is reporting substitute teaching for a second time, then we should update the list of occurrences for which they are a substitute on their existing EventStaffMember record, rather than creating a new record and creating database issues. ...
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "existing_record", "=", "EventStaffMember", ".", "objects", ".", "filter", "(", "staffMember", "=", "self", ".", "cleaned_data", ".", "get", "(", "'staffMember'", ")", ",", "event", "=", "...
If a staff member is reporting substitute teaching for a second time, then we should update the list of occurrences for which they are a substitute on their existing EventStaffMember record, rather than creating a new record and creating database issues.
[ "If", "a", "staff", "member", "is", "reporting", "substitute", "teaching", "for", "a", "second", "time", "then", "we", "should", "update", "the", "list", "of", "occurrences", "for", "which", "they", "are", "a", "substitute", "on", "their", "existing", "Event...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/forms.py#L898-L917
django-danceschool/django-danceschool
danceschool/core/forms.py
StaffMemberBioChangeForm.save
def save(self, commit=True): ''' If the staff member is an instructor, also update the availableForPrivates field on the Instructor record. ''' if getattr(self.instance,'instructor',None): self.instance.instructor.availableForPrivates = self.cleaned_data.pop('availableForPrivates',self.insta...
python
def save(self, commit=True): ''' If the staff member is an instructor, also update the availableForPrivates field on the Instructor record. ''' if getattr(self.instance,'instructor',None): self.instance.instructor.availableForPrivates = self.cleaned_data.pop('availableForPrivates',self.insta...
[ "def", "save", "(", "self", ",", "commit", "=", "True", ")", ":", "if", "getattr", "(", "self", ".", "instance", ",", "'instructor'", ",", "None", ")", ":", "self", ".", "instance", ".", "instructor", ".", "availableForPrivates", "=", "self", ".", "cle...
If the staff member is an instructor, also update the availableForPrivates field on the Instructor record.
[ "If", "the", "staff", "member", "is", "an", "instructor", "also", "update", "the", "availableForPrivates", "field", "on", "the", "Instructor", "record", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/forms.py#L942-L947
django-danceschool/django-danceschool
danceschool/core/models.py
DanceRole.save
def save(self, *args, **kwargs): ''' Just add "s" if no plural name given. ''' if not self.pluralName: self.pluralName = self.name + 's' super(self.__class__, self).save(*args, **kwargs)
python
def save(self, *args, **kwargs): ''' Just add "s" if no plural name given. ''' if not self.pluralName: self.pluralName = self.name + 's' super(self.__class__, self).save(*args, **kwargs)
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "pluralName", ":", "self", ".", "pluralName", "=", "self", ".", "name", "+", "'s'", "super", "(", "self", ".", "__class__", ",", "self", ")...
Just add "s" if no plural name given.
[ "Just", "add", "s", "if", "no", "plural", "name", "given", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L83-L89
django-danceschool/django-danceschool
danceschool/core/models.py
ClassDescription.lastOfferedMonth
def lastOfferedMonth(self): ''' Sometimes a Series is associated with a month other than the one in which the first class begins, so this returns a (year,month) tuple that can be used in admin instead. ''' lastOfferedSeries = self.event_set.order_by('-startTime').first() ...
python
def lastOfferedMonth(self): ''' Sometimes a Series is associated with a month other than the one in which the first class begins, so this returns a (year,month) tuple that can be used in admin instead. ''' lastOfferedSeries = self.event_set.order_by('-startTime').first() ...
[ "def", "lastOfferedMonth", "(", "self", ")", ":", "lastOfferedSeries", "=", "self", ".", "event_set", ".", "order_by", "(", "'-startTime'", ")", ".", "first", "(", ")", "return", "(", "lastOfferedSeries", ".", "year", ",", "lastOfferedSeries", ".", "month", ...
Sometimes a Series is associated with a month other than the one in which the first class begins, so this returns a (year,month) tuple that can be used in admin instead.
[ "Sometimes", "a", "Series", "is", "associated", "with", "a", "month", "other", "than", "the", "one", "in", "which", "the", "first", "class", "begins", "so", "this", "returns", "a", "(", "year", "month", ")", "tuple", "that", "can", "be", "used", "in", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L317-L324
django-danceschool/django-danceschool
danceschool/core/models.py
PricingTier.getBasePrice
def getBasePrice(self,**kwargs): ''' This handles the logic of finding the correct price. If more sophisticated discounting systems are needed, then this PricingTier model can be subclassed, or the discounts and vouchers apps can be used. ''' payAtDoor = kwargs.get('payA...
python
def getBasePrice(self,**kwargs): ''' This handles the logic of finding the correct price. If more sophisticated discounting systems are needed, then this PricingTier model can be subclassed, or the discounts and vouchers apps can be used. ''' payAtDoor = kwargs.get('payA...
[ "def", "getBasePrice", "(", "self", ",", "*", "*", "kwargs", ")", ":", "payAtDoor", "=", "kwargs", ".", "get", "(", "'payAtDoor'", ",", "False", ")", "dropIns", "=", "kwargs", ".", "get", "(", "'dropIns'", ",", "0", ")", "if", "dropIns", ":", "return...
This handles the logic of finding the correct price. If more sophisticated discounting systems are needed, then this PricingTier model can be subclassed, or the discounts and vouchers apps can be used.
[ "This", "handles", "the", "logic", "of", "finding", "the", "correct", "price", ".", "If", "more", "sophisticated", "discounting", "systems", "are", "needed", "then", "this", "PricingTier", "model", "can", "be", "subclassed", "or", "the", "discounts", "and", "v...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L432-L445
django-danceschool/django-danceschool
danceschool/core/models.py
Event.getMonthName
def getMonthName(self): ''' This exists as a separate method because sometimes events should really belong to more than one month (e.g. class series that persist over multiple months). ''' class_counter = Counter([(x.startTime.year, x.startTime.month) for x in self.eventoccurrenc...
python
def getMonthName(self): ''' This exists as a separate method because sometimes events should really belong to more than one month (e.g. class series that persist over multiple months). ''' class_counter = Counter([(x.startTime.year, x.startTime.month) for x in self.eventoccurrenc...
[ "def", "getMonthName", "(", "self", ")", ":", "class_counter", "=", "Counter", "(", "[", "(", "x", ".", "startTime", ".", "year", ",", "x", ".", "startTime", ".", "month", ")", "for", "x", "in", "self", ".", "eventoccurrence_set", ".", "all", "(", ")...
This exists as a separate method because sometimes events should really belong to more than one month (e.g. class series that persist over multiple months).
[ "This", "exists", "as", "a", "separate", "method", "because", "sometimes", "events", "should", "really", "belong", "to", "more", "than", "one", "month", "(", "e", ".", "g", ".", "class", "series", "that", "persist", "over", "multiple", "months", ")", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L622-L636
django-danceschool/django-danceschool
danceschool/core/models.py
Event.name
def name(self): ''' Since other types of events (PublicEvents, class Series, etc.) are subclasses of this class, it is a good idea to override this method for those subclasses, to provide a more intuitive name. However, defining this property at the event level ensures that <obj...
python
def name(self): ''' Since other types of events (PublicEvents, class Series, etc.) are subclasses of this class, it is a good idea to override this method for those subclasses, to provide a more intuitive name. However, defining this property at the event level ensures that <obj...
[ "def", "name", "(", "self", ")", ":", "if", "self", ".", "startTime", ":", "return", "_", "(", "'Event, begins %s'", "%", "(", "self", ".", "startTime", ".", "strftime", "(", "'%a., %B %d, %Y, %I:%M %p'", ")", ")", ")", "else", ":", "return", "_", "(", ...
Since other types of events (PublicEvents, class Series, etc.) are subclasses of this class, it is a good idea to override this method for those subclasses, to provide a more intuitive name. However, defining this property at the event level ensures that <object>.name can always be used to acce...
[ "Since", "other", "types", "of", "events", "(", "PublicEvents", "class", "Series", "etc", ".", ")", "are", "subclasses", "of", "this", "class", "it", "is", "a", "good", "idea", "to", "override", "this", "method", "for", "those", "subclasses", "to", "provid...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L640-L651
django-danceschool/django-danceschool
danceschool/core/models.py
Event.organizer
def organizer(self): ''' Since events can be organized for registration in different ways (e.g. by month, by session, or the interaction of the two), this property is used to make it easy for templates to include necessary organizing information. Note that this method has nothin...
python
def organizer(self): ''' Since events can be organized for registration in different ways (e.g. by month, by session, or the interaction of the two), this property is used to make it easy for templates to include necessary organizing information. Note that this method has nothin...
[ "def", "organizer", "(", "self", ")", ":", "rule", "=", "getConstant", "(", "'registration__orgRule'", ")", "# Default grouping is \"Other\", in case session, month, or weekday are not specified.", "org", "=", "{", "'name'", ":", "_", "(", "'Other'", ")", ",", "'nameFir...
Since events can be organized for registration in different ways (e.g. by month, by session, or the interaction of the two), this property is used to make it easy for templates to include necessary organizing information. Note that this method has nothing to do with the sorting of any queryset ...
[ "Since", "events", "can", "be", "organized", "for", "registration", "in", "different", "ways", "(", "e", ".", "g", ".", "by", "month", "by", "session", "or", "the", "interaction", "of", "the", "two", ")", "this", "property", "is", "used", "to", "make", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L679-L758
django-danceschool/django-danceschool
danceschool/core/models.py
Event.get_default_recipients
def get_default_recipients(self): ''' Overrides EmailRecipientMixin ''' return [x.registration.customer.email for x in self.eventregistration_set.filter(cancelled=False)]
python
def get_default_recipients(self): ''' Overrides EmailRecipientMixin ''' return [x.registration.customer.email for x in self.eventregistration_set.filter(cancelled=False)]
[ "def", "get_default_recipients", "(", "self", ")", ":", "return", "[", "x", ".", "registration", ".", "customer", ".", "email", "for", "x", "in", "self", ".", "eventregistration_set", ".", "filter", "(", "cancelled", "=", "False", ")", "]" ]
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L776-L778
django-danceschool/django-danceschool
danceschool/core/models.py
Event.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Event,self).get_email_context(**kwargs) context.update({ 'id': self.id, 'name': self.__str__(), 'title': self.name, 'start': self.firstOccurrenceTime, ...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Event,self).get_email_context(**kwargs) context.update({ 'id': self.id, 'name': self.__str__(), 'title': self.name, 'start': self.firstOccurrenceTime, ...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "Event", ",", "self", ")", ".", "get_email_context", "(", "*", "*", "kwargs", ")", "context", ".", "update", "(", "{", "'id'", ":", "self", ".",...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L780-L792
django-danceschool/django-danceschool
danceschool/core/models.py
Event.registrationEnabled
def registrationEnabled(self): ''' Just checks if this event ever permits/permitted registration ''' return self.status in [self.RegStatus.enabled,self.RegStatus.heldOpen,self.RegStatus.heldClosed]
python
def registrationEnabled(self): ''' Just checks if this event ever permits/permitted registration ''' return self.status in [self.RegStatus.enabled,self.RegStatus.heldOpen,self.RegStatus.heldClosed]
[ "def", "registrationEnabled", "(", "self", ")", ":", "return", "self", ".", "status", "in", "[", "self", ".", "RegStatus", ".", "enabled", ",", "self", ".", "RegStatus", ".", "heldOpen", ",", "self", ".", "RegStatus", ".", "heldClosed", "]" ]
Just checks if this event ever permits/permitted registration
[ "Just", "checks", "if", "this", "event", "ever", "permits", "/", "permitted", "registration" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L911-L913
django-danceschool/django-danceschool
danceschool/core/models.py
Event.getNumRegistered
def getNumRegistered(self, includeTemporaryRegs=False, dateTime=None): ''' Method allows the inclusion of temporary registrations, as well as exclusion of temporary registrations that are too new (e.g. for discounts based on the first X registrants, we don't want to include people who st...
python
def getNumRegistered(self, includeTemporaryRegs=False, dateTime=None): ''' Method allows the inclusion of temporary registrations, as well as exclusion of temporary registrations that are too new (e.g. for discounts based on the first X registrants, we don't want to include people who st...
[ "def", "getNumRegistered", "(", "self", ",", "includeTemporaryRegs", "=", "False", ",", "dateTime", "=", "None", ")", ":", "count", "=", "self", ".", "eventregistration_set", ".", "filter", "(", "cancelled", "=", "False", ",", "dropIn", "=", "False", ")", ...
Method allows the inclusion of temporary registrations, as well as exclusion of temporary registrations that are too new (e.g. for discounts based on the first X registrants, we don't want to include people who started tp register later than the person in question.
[ "Method", "allows", "the", "inclusion", "of", "temporary", "registrations", "as", "well", "as", "exclusion", "of", "temporary", "registrations", "that", "are", "too", "new", "(", "e", ".", "g", ".", "for", "discounts", "based", "on", "the", "first", "X", "...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L930-L944
django-danceschool/django-danceschool
danceschool/core/models.py
Event.availableRoles
def availableRoles(self): ''' Returns the set of roles for this event. Since roles are not always custom specified for event, this looks for the set of available roles in multiple places. If no roles are found, then the method returns an empty list, in which case it can be assumed that...
python
def availableRoles(self): ''' Returns the set of roles for this event. Since roles are not always custom specified for event, this looks for the set of available roles in multiple places. If no roles are found, then the method returns an empty list, in which case it can be assumed that...
[ "def", "availableRoles", "(", "self", ")", ":", "eventRoles", "=", "self", ".", "eventrole_set", ".", "filter", "(", "capacity__gt", "=", "0", ")", "if", "eventRoles", ".", "count", "(", ")", ">", "0", ":", "return", "[", "x", ".", "role", "for", "x"...
Returns the set of roles for this event. Since roles are not always custom specified for event, this looks for the set of available roles in multiple places. If no roles are found, then the method returns an empty list, in which case it can be assumed that the event's registration is not role-...
[ "Returns", "the", "set", "of", "roles", "for", "this", "event", ".", "Since", "roles", "are", "not", "always", "custom", "specified", "for", "event", "this", "looks", "for", "the", "set", "of", "available", "roles", "in", "multiple", "places", ".", "If", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L952-L964
django-danceschool/django-danceschool
danceschool/core/models.py
Event.numRegisteredForRole
def numRegisteredForRole(self, role, includeTemporaryRegs=False): ''' Accepts a DanceRole object and returns the number of registrations of that role. ''' count = self.eventregistration_set.filter(cancelled=False,dropIn=False,role=role).count() if includeTemporaryRegs: ...
python
def numRegisteredForRole(self, role, includeTemporaryRegs=False): ''' Accepts a DanceRole object and returns the number of registrations of that role. ''' count = self.eventregistration_set.filter(cancelled=False,dropIn=False,role=role).count() if includeTemporaryRegs: ...
[ "def", "numRegisteredForRole", "(", "self", ",", "role", ",", "includeTemporaryRegs", "=", "False", ")", ":", "count", "=", "self", ".", "eventregistration_set", ".", "filter", "(", "cancelled", "=", "False", ",", "dropIn", "=", "False", ",", "role", "=", ...
Accepts a DanceRole object and returns the number of registrations of that role.
[ "Accepts", "a", "DanceRole", "object", "and", "returns", "the", "number", "of", "registrations", "of", "that", "role", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L967-L975
django-danceschool/django-danceschool
danceschool/core/models.py
Event.numRegisteredByRole
def numRegisteredByRole(self): ''' Return a dictionary listing registrations by all available roles (including no role) ''' role_list = list(self.availableRoles) + [None,] return {getattr(x,'name',None):self.numRegisteredForRole(x) for x in role_list}
python
def numRegisteredByRole(self): ''' Return a dictionary listing registrations by all available roles (including no role) ''' role_list = list(self.availableRoles) + [None,] return {getattr(x,'name',None):self.numRegisteredForRole(x) for x in role_list}
[ "def", "numRegisteredByRole", "(", "self", ")", ":", "role_list", "=", "list", "(", "self", ".", "availableRoles", ")", "+", "[", "None", ",", "]", "return", "{", "getattr", "(", "x", ",", "'name'", ",", "None", ")", ":", "self", ".", "numRegisteredFor...
Return a dictionary listing registrations by all available roles (including no role)
[ "Return", "a", "dictionary", "listing", "registrations", "by", "all", "available", "roles", "(", "including", "no", "role", ")" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L978-L983
django-danceschool/django-danceschool
danceschool/core/models.py
Event.capacityForRole
def capacityForRole(self,role): ''' Accepts a DanceRole object and determines the capacity for that role at this event.this Since roles are not always custom specified for events, this looks for the set of available roles in multiple places, and only returns the overall capacity of the e...
python
def capacityForRole(self,role): ''' Accepts a DanceRole object and determines the capacity for that role at this event.this Since roles are not always custom specified for events, this looks for the set of available roles in multiple places, and only returns the overall capacity of the e...
[ "def", "capacityForRole", "(", "self", ",", "role", ")", ":", "if", "isinstance", "(", "role", ",", "DanceRole", ")", ":", "role_id", "=", "role", ".", "id", "else", ":", "role_id", "=", "role", "eventRoles", "=", "self", ".", "eventrole_set", ".", "fi...
Accepts a DanceRole object and determines the capacity for that role at this event.this Since roles are not always custom specified for events, this looks for the set of available roles in multiple places, and only returns the overall capacity of the event if roles are not found elsewhere.
[ "Accepts", "a", "DanceRole", "object", "and", "determines", "the", "capacity", "for", "that", "role", "at", "this", "event", ".", "this", "Since", "roles", "are", "not", "always", "custom", "specified", "for", "events", "this", "looks", "for", "the", "set", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L986-L1022
django-danceschool/django-danceschool
danceschool/core/models.py
Event.soldOutForRole
def soldOutForRole(self,role,includeTemporaryRegs=False): ''' Accepts a DanceRole object and responds if the number of registrations for that role exceeds the capacity for that role at this event. ''' return self.numRegisteredForRole( role,includeTemporaryRegs=include...
python
def soldOutForRole(self,role,includeTemporaryRegs=False): ''' Accepts a DanceRole object and responds if the number of registrations for that role exceeds the capacity for that role at this event. ''' return self.numRegisteredForRole( role,includeTemporaryRegs=include...
[ "def", "soldOutForRole", "(", "self", ",", "role", ",", "includeTemporaryRegs", "=", "False", ")", ":", "return", "self", ".", "numRegisteredForRole", "(", "role", ",", "includeTemporaryRegs", "=", "includeTemporaryRegs", ")", ">=", "(", "self", ".", "capacityFo...
Accepts a DanceRole object and responds if the number of registrations for that role exceeds the capacity for that role at this event.
[ "Accepts", "a", "DanceRole", "object", "and", "responds", "if", "the", "number", "of", "registrations", "for", "that", "role", "exceeds", "the", "capacity", "for", "that", "role", "at", "this", "event", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1024-L1030
django-danceschool/django-danceschool
danceschool/core/models.py
Event.updateRegistrationStatus
def updateRegistrationStatus(self, saveMethod=False): ''' If called via cron job or otherwise, then update the registrationOpen property for this series to reflect any manual override and/or the automatic closing of this series for registration. ''' logger.debug('Beginnin...
python
def updateRegistrationStatus(self, saveMethod=False): ''' If called via cron job or otherwise, then update the registrationOpen property for this series to reflect any manual override and/or the automatic closing of this series for registration. ''' logger.debug('Beginnin...
[ "def", "updateRegistrationStatus", "(", "self", ",", "saveMethod", "=", "False", ")", ":", "logger", ".", "debug", "(", "'Beginning update registration status. saveMethod=%s'", "%", "saveMethod", ")", "modified", "=", "False", "open", "=", "self", ".", "registratio...
If called via cron job or otherwise, then update the registrationOpen property for this series to reflect any manual override and/or the automatic closing of this series for registration.
[ "If", "called", "via", "cron", "job", "or", "otherwise", "then", "update", "the", "registrationOpen", "property", "for", "this", "series", "to", "reflect", "any", "manual", "override", "and", "/", "or", "the", "automatic", "closing", "of", "this", "series", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1051-L1111
django-danceschool/django-danceschool
danceschool/core/models.py
EventOccurrence.allDayForDate
def allDayForDate(self,this_date,timeZone=None): ''' This method determines whether the occurrence lasts the entirety of a specified day in the specified time zone. If no time zone is specified, then it uses the default time zone). Also, give a grace period of a few minutes to ...
python
def allDayForDate(self,this_date,timeZone=None): ''' This method determines whether the occurrence lasts the entirety of a specified day in the specified time zone. If no time zone is specified, then it uses the default time zone). Also, give a grace period of a few minutes to ...
[ "def", "allDayForDate", "(", "self", ",", "this_date", ",", "timeZone", "=", "None", ")", ":", "if", "isinstance", "(", "this_date", ",", "datetime", ")", ":", "d", "=", "this_date", ".", "date", "(", ")", "else", ":", "d", "=", "this_date", "date_star...
This method determines whether the occurrence lasts the entirety of a specified day in the specified time zone. If no time zone is specified, then it uses the default time zone). Also, give a grace period of a few minutes to account for issues with the way events are sometimes entered.
[ "This", "method", "determines", "whether", "the", "occurrence", "lasts", "the", "entirety", "of", "a", "specified", "day", "in", "the", "specified", "time", "zone", ".", "If", "no", "time", "zone", "is", "specified", "then", "it", "uses", "the", "default", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1191-L1211
django-danceschool/django-danceschool
danceschool/core/models.py
EventStaffMember.netHours
def netHours(self): ''' For regular event staff, this is the net hours worked for financial purposes. For Instructors, netHours is caclulated net of any substitutes. ''' if self.specifiedHours is not None: return self.specifiedHours elif self.category in [getC...
python
def netHours(self): ''' For regular event staff, this is the net hours worked for financial purposes. For Instructors, netHours is caclulated net of any substitutes. ''' if self.specifiedHours is not None: return self.specifiedHours elif self.category in [getC...
[ "def", "netHours", "(", "self", ")", ":", "if", "self", ".", "specifiedHours", "is", "not", "None", ":", "return", "self", ".", "specifiedHours", "elif", "self", ".", "category", "in", "[", "getConstant", "(", "'general__eventStaffCategoryAssistant'", ")", ","...
For regular event staff, this is the net hours worked for financial purposes. For Instructors, netHours is caclulated net of any substitutes.
[ "For", "regular", "event", "staff", "this", "is", "the", "net", "hours", "worked", "for", "financial", "purposes", ".", "For", "Instructors", "netHours", "is", "caclulated", "net", "of", "any", "substitutes", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1284-L1294
django-danceschool/django-danceschool
danceschool/core/models.py
Series.shortDescription
def shortDescription(self): ''' Overrides property from Event base class. ''' cd = getattr(self,'classDescription',None) if cd: sd = getattr(cd,'shortDescription','') d = getattr(cd,'description','') return sd if sd else d return ''
python
def shortDescription(self): ''' Overrides property from Event base class. ''' cd = getattr(self,'classDescription',None) if cd: sd = getattr(cd,'shortDescription','') d = getattr(cd,'description','') return sd if sd else d return ''
[ "def", "shortDescription", "(", "self", ")", ":", "cd", "=", "getattr", "(", "self", ",", "'classDescription'", ",", "None", ")", "if", "cd", ":", "sd", "=", "getattr", "(", "cd", ",", "'shortDescription'", ",", "''", ")", "d", "=", "getattr", "(", "...
Overrides property from Event base class.
[ "Overrides", "property", "from", "Event", "base", "class", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1360-L1369
django-danceschool/django-danceschool
danceschool/core/models.py
SeriesTeacher.netHours
def netHours(self): ''' For regular event staff, this is the net hours worked for financial purposes. For Instructors, netHours is calculated net of any substitutes. ''' if self.specifiedHours is not None: return self.specifiedHours return self.event.duration ...
python
def netHours(self): ''' For regular event staff, this is the net hours worked for financial purposes. For Instructors, netHours is calculated net of any substitutes. ''' if self.specifiedHours is not None: return self.specifiedHours return self.event.duration ...
[ "def", "netHours", "(", "self", ")", ":", "if", "self", ".", "specifiedHours", "is", "not", "None", ":", "return", "self", ".", "specifiedHours", "return", "self", ".", "event", ".", "duration", "-", "sum", "(", "[", "sub", ".", "netHours", "for", "sub...
For regular event staff, this is the net hours worked for financial purposes. For Instructors, netHours is calculated net of any substitutes.
[ "For", "regular", "event", "staff", "this", "is", "the", "net", "hours", "worked", "for", "financial", "purposes", ".", "For", "Instructors", "netHours", "is", "calculated", "net", "of", "any", "substitutes", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1466-L1473
django-danceschool/django-danceschool
danceschool/core/models.py
Customer.getSeriesRegistered
def getSeriesRegistered(self,q_filter=Q(),distinct=True,counter=False,**kwargs): ''' Return a list that indicates each series the person has registered for and how many registrations they have for that series (because of couples). This can be filtered by any keyword arguments passed (e.g...
python
def getSeriesRegistered(self,q_filter=Q(),distinct=True,counter=False,**kwargs): ''' Return a list that indicates each series the person has registered for and how many registrations they have for that series (because of couples). This can be filtered by any keyword arguments passed (e.g...
[ "def", "getSeriesRegistered", "(", "self", ",", "q_filter", "=", "Q", "(", ")", ",", "distinct", "=", "True", ",", "counter", "=", "False", ",", "*", "*", "kwargs", ")", ":", "series_set", "=", "Series", ".", "objects", ".", "filter", "(", "q_filter", ...
Return a list that indicates each series the person has registered for and how many registrations they have for that series (because of couples). This can be filtered by any keyword arguments passed (e.g. year and month).
[ "Return", "a", "list", "that", "indicates", "each", "series", "the", "person", "has", "registered", "for", "and", "how", "many", "registrations", "they", "have", "for", "that", "series", "(", "because", "of", "couples", ")", ".", "This", "can", "be", "filt...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1787-L1802
django-danceschool/django-danceschool
danceschool/core/models.py
Customer.getMultiSeriesRegistrations
def getMultiSeriesRegistrations(self,q_filter=Q(),name_series=False,**kwargs): ''' Use the getSeriesRegistered method above to get a list of each series the person has registered for. The return only indicates whether they are registered more than once for the same series (e.g. for keep...
python
def getMultiSeriesRegistrations(self,q_filter=Q(),name_series=False,**kwargs): ''' Use the getSeriesRegistered method above to get a list of each series the person has registered for. The return only indicates whether they are registered more than once for the same series (e.g. for keep...
[ "def", "getMultiSeriesRegistrations", "(", "self", ",", "q_filter", "=", "Q", "(", ")", ",", "name_series", "=", "False", ",", "*", "*", "kwargs", ")", ":", "series_registered", "=", "self", ".", "getSeriesRegistered", "(", "q_filter", ",", "distinct", "=", ...
Use the getSeriesRegistered method above to get a list of each series the person has registered for. The return only indicates whether they are registered more than once for the same series (e.g. for keeping track of dance admissions for couples who register under one name).
[ "Use", "the", "getSeriesRegistered", "method", "above", "to", "get", "a", "list", "of", "each", "series", "the", "person", "has", "registered", "for", ".", "The", "return", "only", "indicates", "whether", "they", "are", "registered", "more", "than", "once", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1804-L1821
django-danceschool/django-danceschool
danceschool/core/models.py
Customer.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Customer,self).get_email_context(**kwargs) context.update({ 'first_name': self.first_name, 'last_name': self.last_name, 'email': self.email, 'fullName': sel...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Customer,self).get_email_context(**kwargs) context.update({ 'first_name': self.first_name, 'last_name': self.last_name, 'email': self.email, 'fullName': sel...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "Customer", ",", "self", ")", ".", "get_email_context", "(", "*", "*", "kwargs", ")", "context", ".", "update", "(", "{", "'first_name'", ":", "se...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1827-L1837
django-danceschool/django-danceschool
danceschool/core/models.py
TemporaryRegistration.getTimeOfClassesRemaining
def getTimeOfClassesRemaining(self,numClasses=0): ''' For checking things like prerequisites, it's useful to check if a requirement is 'almost' met ''' occurrences = EventOccurrence.objects.filter( cancelled=False, event__in=[x.event for x in self.temporaryeventre...
python
def getTimeOfClassesRemaining(self,numClasses=0): ''' For checking things like prerequisites, it's useful to check if a requirement is 'almost' met ''' occurrences = EventOccurrence.objects.filter( cancelled=False, event__in=[x.event for x in self.temporaryeventre...
[ "def", "getTimeOfClassesRemaining", "(", "self", ",", "numClasses", "=", "0", ")", ":", "occurrences", "=", "EventOccurrence", ".", "objects", ".", "filter", "(", "cancelled", "=", "False", ",", "event__in", "=", "[", "x", ".", "event", "for", "x", "in", ...
For checking things like prerequisites, it's useful to check if a requirement is 'almost' met
[ "For", "checking", "things", "like", "prerequisites", "it", "s", "useful", "to", "check", "if", "a", "requirement", "is", "almost", "met" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1952-L1963
django-danceschool/django-danceschool
danceschool/core/models.py
TemporaryRegistration.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(TemporaryRegistration,self).get_email_context(**kwargs) context.update({ 'first_name': self.firstName, 'last_name': self.lastName, 'registrationComments': self.comments...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(TemporaryRegistration,self).get_email_context(**kwargs) context.update({ 'first_name': self.firstName, 'last_name': self.lastName, 'registrationComments': self.comments...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "TemporaryRegistration", ",", "self", ")", ".", "get_email_context", "(", "*", "*", "kwargs", ")", "context", ".", "update", "(", "{", "'first_name'",...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1969-L1985
django-danceschool/django-danceschool
danceschool/core/models.py
TemporaryRegistration.finalize
def finalize(self,**kwargs): ''' This method is called when the payment process has been completed and a registration is ready to be finalized. It also fires the post-registration signal ''' dateTime = kwargs.pop('dateTime', timezone.now()) # If sendEmail is passed as F...
python
def finalize(self,**kwargs): ''' This method is called when the payment process has been completed and a registration is ready to be finalized. It also fires the post-registration signal ''' dateTime = kwargs.pop('dateTime', timezone.now()) # If sendEmail is passed as F...
[ "def", "finalize", "(", "self", ",", "*", "*", "kwargs", ")", ":", "dateTime", "=", "kwargs", ".", "pop", "(", "'dateTime'", ",", "timezone", ".", "now", "(", ")", ")", "# If sendEmail is passed as False, then we won't send an email", "sendEmail", "=", "kwargs",...
This method is called when the payment process has been completed and a registration is ready to be finalized. It also fires the post-registration signal
[ "This", "method", "is", "called", "when", "the", "payment", "process", "has", "been", "completed", "and", "a", "registration", "is", "ready", "to", "be", "finalized", ".", "It", "also", "fires", "the", "post", "-", "registration", "signal" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L1987-L2061
django-danceschool/django-danceschool
danceschool/core/models.py
Registration.warningFlag
def warningFlag(self): ''' When viewing individual event registrations, there are a large number of potential issues that can arise that may warrant scrutiny. This property just checks all of these conditions and indicates if anything is amiss so that the template need not check ...
python
def warningFlag(self): ''' When viewing individual event registrations, there are a large number of potential issues that can arise that may warrant scrutiny. This property just checks all of these conditions and indicates if anything is amiss so that the template need not check ...
[ "def", "warningFlag", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'invoice'", ")", ":", "return", "True", "if", "apps", ".", "is_installed", "(", "'danceschool.financial'", ")", ":", "'''\n If the financial app is installed, then we ...
When viewing individual event registrations, there are a large number of potential issues that can arise that may warrant scrutiny. This property just checks all of these conditions and indicates if anything is amiss so that the template need not check each of these conditions individually repea...
[ "When", "viewing", "individual", "event", "registrations", "there", "are", "a", "large", "number", "of", "potential", "issues", "that", "can", "arise", "that", "may", "warrant", "scrutiny", ".", "This", "property", "just", "checks", "all", "of", "these", "cond...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2102-L2121
django-danceschool/django-danceschool
danceschool/core/models.py
Registration.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Registration,self).get_email_context(**kwargs) context.update({ 'first_name': self.customer.first_name, 'last_name': self.customer.last_name, 'registrationComments': se...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Registration,self).get_email_context(**kwargs) context.update({ 'first_name': self.customer.first_name, 'last_name': self.customer.last_name, 'registrationComments': se...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "Registration", ",", "self", ")", ".", "get_email_context", "(", "*", "*", "kwargs", ")", "context", ".", "update", "(", "{", "'first_name'", ":", ...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2262-L2278
django-danceschool/django-danceschool
danceschool/core/models.py
EventRegistration.warningFlag
def warningFlag(self): ''' When viewing individual event registrations, there are a large number of potential issues that can arise that may warrant scrutiny. This property just checks all of these conditions and indicates if anything is amiss so that the template need not check ...
python
def warningFlag(self): ''' When viewing individual event registrations, there are a large number of potential issues that can arise that may warrant scrutiny. This property just checks all of these conditions and indicates if anything is amiss so that the template need not check ...
[ "def", "warningFlag", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'invoiceitem'", ")", ":", "return", "True", "if", "apps", ".", "is_installed", "(", "'danceschool.financial'", ")", ":", "'''\n If the financial app is installed, then...
When viewing individual event registrations, there are a large number of potential issues that can arise that may warrant scrutiny. This property just checks all of these conditions and indicates if anything is amiss so that the template need not check each of these conditions individually repea...
[ "When", "viewing", "individual", "event", "registrations", "there", "are", "a", "large", "number", "of", "potential", "issues", "that", "can", "arise", "that", "may", "warrant", "scrutiny", ".", "This", "property", "just", "checks", "all", "of", "these", "cond...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2340-L2359
django-danceschool/django-danceschool
danceschool/core/models.py
EventRegistration.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' includeName = kwargs.pop('includeName',True) context = super(EventRegistration,self).get_email_context(**kwargs) context.update({ 'title': self.event.name, 'start': self.event.firstOccurre...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' includeName = kwargs.pop('includeName',True) context = super(EventRegistration,self).get_email_context(**kwargs) context.update({ 'title': self.event.name, 'start': self.event.firstOccurre...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "includeName", "=", "kwargs", ".", "pop", "(", "'includeName'", ",", "True", ")", "context", "=", "super", "(", "EventRegistration", ",", "self", ")", ".", "get_email_context", "("...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2377-L2392
django-danceschool/django-danceschool
danceschool/core/models.py
TemporaryEventRegistration.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' includeName = kwargs.pop('includeName',True) context = super(TemporaryEventRegistration,self).get_email_context(**kwargs) context.update({ 'title': self.event.name, 'start': self.event.f...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' includeName = kwargs.pop('includeName',True) context = super(TemporaryEventRegistration,self).get_email_context(**kwargs) context.update({ 'title': self.event.name, 'start': self.event.f...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "includeName", "=", "kwargs", ".", "pop", "(", "'includeName'", ",", "True", ")", "context", "=", "super", "(", "TemporaryEventRegistration", ",", "self", ")", ".", "get_email_contex...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2421-L2438
django-danceschool/django-danceschool
danceschool/core/models.py
EmailTemplate.save
def save(self, *args, **kwargs): ''' If this is an HTML template, then set the non-HTML content to be the stripped version of the HTML. If this is a plain text template, then set the HTML content to be null. ''' if self.send_html: self.content = get_text_for_html(self...
python
def save(self, *args, **kwargs): ''' If this is an HTML template, then set the non-HTML content to be the stripped version of the HTML. If this is a plain text template, then set the HTML content to be null. ''' if self.send_html: self.content = get_text_for_html(self...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "send_html", ":", "self", ".", "content", "=", "get_text_for_html", "(", "self", ".", "html_content", ")", "else", ":", "self", ".", "html_content", "...
If this is an HTML template, then set the non-HTML content to be the stripped version of the HTML. If this is a plain text template, then set the HTML content to be null.
[ "If", "this", "is", "an", "HTML", "template", "then", "set", "the", "non", "-", "HTML", "content", "to", "be", "the", "stripped", "version", "of", "the", "HTML", ".", "If", "this", "is", "a", "plain", "text", "template", "then", "set", "the", "HTML", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2469-L2479
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.create_from_item
def create_from_item(cls, amount, item_description, **kwargs): ''' Creates an Invoice as well as a single associated InvoiceItem with the passed description (for things like gift certificates) ''' submissionUser = kwargs.pop('submissionUser', None) collectedByUser = kwarg...
python
def create_from_item(cls, amount, item_description, **kwargs): ''' Creates an Invoice as well as a single associated InvoiceItem with the passed description (for things like gift certificates) ''' submissionUser = kwargs.pop('submissionUser', None) collectedByUser = kwarg...
[ "def", "create_from_item", "(", "cls", ",", "amount", ",", "item_description", ",", "*", "*", "kwargs", ")", ":", "submissionUser", "=", "kwargs", ".", "pop", "(", "'submissionUser'", ",", "None", ")", "collectedByUser", "=", "kwargs", ".", "pop", "(", "'c...
Creates an Invoice as well as a single associated InvoiceItem with the passed description (for things like gift certificates)
[ "Creates", "an", "Invoice", "as", "well", "as", "a", "single", "associated", "InvoiceItem", "with", "the", "passed", "description", "(", "for", "things", "like", "gift", "certificates", ")" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2547-L2578
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.create_from_registration
def create_from_registration(cls, reg, **kwargs): ''' Handles the creation of an Invoice as well as one InvoiceItem per assodciated TemporaryEventRegistration or registration. Also handles taxes appropriately. ''' submissionUser = kwargs.pop('submissionUser', None) ...
python
def create_from_registration(cls, reg, **kwargs): ''' Handles the creation of an Invoice as well as one InvoiceItem per assodciated TemporaryEventRegistration or registration. Also handles taxes appropriately. ''' submissionUser = kwargs.pop('submissionUser', None) ...
[ "def", "create_from_registration", "(", "cls", ",", "reg", ",", "*", "*", "kwargs", ")", ":", "submissionUser", "=", "kwargs", ".", "pop", "(", "'submissionUser'", ",", "None", ")", "collectedByUser", "=", "kwargs", ".", "pop", "(", "'collectedByUser'", ",",...
Handles the creation of an Invoice as well as one InvoiceItem per assodciated TemporaryEventRegistration or registration. Also handles taxes appropriately.
[ "Handles", "the", "creation", "of", "an", "Invoice", "as", "well", "as", "one", "InvoiceItem", "per", "assodciated", "TemporaryEventRegistration", "or", "registration", ".", "Also", "handles", "taxes", "appropriately", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2591-L2656
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.url
def url(self): ''' Because invoice URLs are generally emailed, this includes the default site URL and the protocol specified in settings. ''' if self.id: return '%s://%s%s' % ( getConstant('email__linkProtocol'), Site.objects.ge...
python
def url(self): ''' Because invoice URLs are generally emailed, this includes the default site URL and the protocol specified in settings. ''' if self.id: return '%s://%s%s' % ( getConstant('email__linkProtocol'), Site.objects.ge...
[ "def", "url", "(", "self", ")", ":", "if", "self", ".", "id", ":", "return", "'%s://%s%s'", "%", "(", "getConstant", "(", "'email__linkProtocol'", ")", ",", "Site", ".", "objects", ".", "get_current", "(", ")", ".", "domain", ",", "reverse", "(", "'vie...
Because invoice URLs are generally emailed, this includes the default site URL and the protocol specified in settings.
[ "Because", "invoice", "URLs", "are", "generally", "emailed", "this", "includes", "the", "default", "site", "URL", "and", "the", "protocol", "specified", "in", "settings", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2710-L2721
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.get_default_recipients
def get_default_recipients(self): ''' Overrides EmailRecipientMixin ''' if self.email: return [self.email,] if self.finalRegistration: return [self.finalRegistration.customer.email,] elif self.temporaryRegistration: return [self.temporaryRegistration.e...
python
def get_default_recipients(self): ''' Overrides EmailRecipientMixin ''' if self.email: return [self.email,] if self.finalRegistration: return [self.finalRegistration.customer.email,] elif self.temporaryRegistration: return [self.temporaryRegistration.e...
[ "def", "get_default_recipients", "(", "self", ")", ":", "if", "self", ".", "email", ":", "return", "[", "self", ".", "email", ",", "]", "if", "self", ".", "finalRegistration", ":", "return", "[", "self", ".", "finalRegistration", ".", "customer", ".", "e...
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2730-L2738
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.get_email_context
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Invoice,self).get_email_context(**kwargs) context.update({ 'id': self.id, 'url': '%s?v=%s' % (self.url, self.validationString), 'amountPaid': self.amountPaid, ...
python
def get_email_context(self,**kwargs): ''' Overrides EmailRecipientMixin ''' context = super(Invoice,self).get_email_context(**kwargs) context.update({ 'id': self.id, 'url': '%s?v=%s' % (self.url, self.validationString), 'amountPaid': self.amountPaid, ...
[ "def", "get_email_context", "(", "self", ",", "*", "*", "kwargs", ")", ":", "context", "=", "super", "(", "Invoice", ",", "self", ")", ".", "get_email_context", "(", "*", "*", "kwargs", ")", "context", ".", "update", "(", "{", "'id'", ":", "self", "....
Overrides EmailRecipientMixin
[ "Overrides", "EmailRecipientMixin" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2740-L2759
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.calculateTaxes
def calculateTaxes(self): ''' Updates the tax field to reflect the amount of taxes depending on the local rate as well as whether the buyer or seller pays sales tax. ''' tax_rate = (getConstant('registration__salesTaxRate') or 0) / 100 if tax_rate > 0: if se...
python
def calculateTaxes(self): ''' Updates the tax field to reflect the amount of taxes depending on the local rate as well as whether the buyer or seller pays sales tax. ''' tax_rate = (getConstant('registration__salesTaxRate') or 0) / 100 if tax_rate > 0: if se...
[ "def", "calculateTaxes", "(", "self", ")", ":", "tax_rate", "=", "(", "getConstant", "(", "'registration__salesTaxRate'", ")", "or", "0", ")", "/", "100", "if", "tax_rate", ">", "0", ":", "if", "self", ".", "buyerPaysSalesTax", ":", "# If the buyer pays taxes,...
Updates the tax field to reflect the amount of taxes depending on the local rate as well as whether the buyer or seller pays sales tax.
[ "Updates", "the", "tax", "field", "to", "reflect", "the", "amount", "of", "taxes", "depending", "on", "the", "local", "rate", "as", "well", "as", "whether", "the", "buyer", "or", "seller", "pays", "sales", "tax", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2777-L2793
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.processPayment
def processPayment(self, amount, fees, paidOnline=True, methodName=None, methodTxn=None, submissionUser=None, collectedByUser=None, forceFinalize=False, status=None, notify=None): ''' When a payment processor makes a successful payment against an invoice, it can call this method which handles st...
python
def processPayment(self, amount, fees, paidOnline=True, methodName=None, methodTxn=None, submissionUser=None, collectedByUser=None, forceFinalize=False, status=None, notify=None): ''' When a payment processor makes a successful payment against an invoice, it can call this method which handles st...
[ "def", "processPayment", "(", "self", ",", "amount", ",", "fees", ",", "paidOnline", "=", "True", ",", "methodName", "=", "None", ",", "methodTxn", "=", "None", ",", "submissionUser", "=", "None", ",", "collectedByUser", "=", "None", ",", "forceFinalize", ...
When a payment processor makes a successful payment against an invoice, it can call this method which handles status updates, the creation of a final registration object (if applicable), and the firing of appropriate registration-related signals.
[ "When", "a", "payment", "processor", "makes", "a", "successful", "payment", "against", "an", "invoice", "it", "can", "call", "this", "method", "which", "handles", "status", "updates", "the", "creation", "of", "a", "final", "registration", "object", "(", "if", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2795-L2863
django-danceschool/django-danceschool
danceschool/core/models.py
Invoice.allocateFees
def allocateFees(self): ''' Fees are allocated across invoice items based on their discounted total price net of adjustments as a proportion of the overall invoice's total price ''' items = list(self.invoiceitem_set.all()) # Check that totals and adjusments match...
python
def allocateFees(self): ''' Fees are allocated across invoice items based on their discounted total price net of adjustments as a proportion of the overall invoice's total price ''' items = list(self.invoiceitem_set.all()) # Check that totals and adjusments match...
[ "def", "allocateFees", "(", "self", ")", ":", "items", "=", "list", "(", "self", ".", "invoiceitem_set", ".", "all", "(", ")", ")", "# Check that totals and adjusments match. If they do not, raise an error.", "if", "self", ".", "total", "!=", "sum", "(", "[", "...
Fees are allocated across invoice items based on their discounted total price net of adjustments as a proportion of the overall invoice's total price
[ "Fees", "are", "allocated", "across", "invoice", "items", "based", "on", "their", "discounted", "total", "price", "net", "of", "adjustments", "as", "a", "proportion", "of", "the", "overall", "invoice", "s", "total", "price" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/models.py#L2865-L2903
django-danceschool/django-danceschool
danceschool/payments/paypal/views.py
createPaypalPayment
def createPaypalPayment(request): ''' This view handles the creation of Paypal Express Checkout Payment objects. All Express Checkout payments must either be associated with a pre-existing Invoice or a registration, or they must have an amount and type passed in the post data (such as gift certific...
python
def createPaypalPayment(request): ''' This view handles the creation of Paypal Express Checkout Payment objects. All Express Checkout payments must either be associated with a pre-existing Invoice or a registration, or they must have an amount and type passed in the post data (such as gift certific...
[ "def", "createPaypalPayment", "(", "request", ")", ":", "logger", ".", "info", "(", "'Received request for Paypal Express Checkout payment.'", ")", "invoice_id", "=", "request", ".", "POST", ".", "get", "(", "'invoice_id'", ")", "tr_id", "=", "request", ".", "POST...
This view handles the creation of Paypal Express Checkout Payment objects. All Express Checkout payments must either be associated with a pre-existing Invoice or a registration, or they must have an amount and type passed in the post data (such as gift certificate payment requests).
[ "This", "view", "handles", "the", "creation", "of", "Paypal", "Express", "Checkout", "Payment", "objects", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/payments/paypal/views.py#L24-L198
django-danceschool/django-danceschool
danceschool/discounts/models.py
DiscountCombo.applyAndAllocate
def applyAndAllocate(self,allocatedPrices,tieredTuples,payAtDoor=False): ''' This method takes an initial allocation of prices across events, and an identical length list of allocation tuples. It applies the rule specified by this discount, allocates the discount across the listed ...
python
def applyAndAllocate(self,allocatedPrices,tieredTuples,payAtDoor=False): ''' This method takes an initial allocation of prices across events, and an identical length list of allocation tuples. It applies the rule specified by this discount, allocates the discount across the listed ...
[ "def", "applyAndAllocate", "(", "self", ",", "allocatedPrices", ",", "tieredTuples", ",", "payAtDoor", "=", "False", ")", ":", "initial_net_price", "=", "sum", "(", "[", "x", "for", "x", "in", "allocatedPrices", "]", ")", "if", "self", ".", "discountType", ...
This method takes an initial allocation of prices across events, and an identical length list of allocation tuples. It applies the rule specified by this discount, allocates the discount across the listed items, and returns both the price and the allocation
[ "This", "method", "takes", "an", "initial", "allocation", "of", "prices", "across", "events", "and", "an", "identical", "length", "list", "of", "allocation", "tuples", ".", "It", "applies", "the", "rule", "specified", "by", "this", "discount", "allocates", "th...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L146-L201
django-danceschool/django-danceschool
danceschool/discounts/models.py
DiscountCombo.getFlatPrice
def getFlatPrice(self,payAtDoor=False): ''' Rather than embedding logic re: door pricing, other code can call this method. ''' if self.discountType is not DiscountCombo.DiscountType.flatPrice: return None if payAtDoor: return self.doorPrice ...
python
def getFlatPrice(self,payAtDoor=False): ''' Rather than embedding logic re: door pricing, other code can call this method. ''' if self.discountType is not DiscountCombo.DiscountType.flatPrice: return None if payAtDoor: return self.doorPrice ...
[ "def", "getFlatPrice", "(", "self", ",", "payAtDoor", "=", "False", ")", ":", "if", "self", ".", "discountType", "is", "not", "DiscountCombo", ".", "DiscountType", ".", "flatPrice", ":", "return", "None", "if", "payAtDoor", ":", "return", "self", ".", "doo...
Rather than embedding logic re: door pricing, other code can call this method.
[ "Rather", "than", "embedding", "logic", "re", ":", "door", "pricing", "other", "code", "can", "call", "this", "method", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L203-L213
django-danceschool/django-danceschool
danceschool/discounts/models.py
DiscountCombo.getComponentList
def getComponentList(self): ''' This function just returns a list with items that are supposed to be present in the the list multiple times as multiple elements of the list. It simplifies checking whether a discount's conditions are satisfied. ''' component_list...
python
def getComponentList(self): ''' This function just returns a list with items that are supposed to be present in the the list multiple times as multiple elements of the list. It simplifies checking whether a discount's conditions are satisfied. ''' component_list...
[ "def", "getComponentList", "(", "self", ")", ":", "component_list", "=", "[", "]", "for", "x", "in", "self", ".", "discountcombocomponent_set", ".", "all", "(", ")", ":", "for", "y", "in", "range", "(", "0", ",", "x", ".", "quantity", ")", ":", "comp...
This function just returns a list with items that are supposed to be present in the the list multiple times as multiple elements of the list. It simplifies checking whether a discount's conditions are satisfied.
[ "This", "function", "just", "returns", "a", "list", "with", "items", "that", "are", "supposed", "to", "be", "present", "in", "the", "the", "list", "multiple", "times", "as", "multiple", "elements", "of", "the", "list", ".", "It", "simplifies", "checking", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L215-L230
django-danceschool/django-danceschool
danceschool/discounts/models.py
DiscountCombo.save
def save(self, *args, **kwargs): ''' Don't save any passed values related to a type of discount that is not the specified type ''' if self.discountType != self.DiscountType.flatPrice: self.onlinePrice = None self.doorPrice = None if self.discount...
python
def save(self, *args, **kwargs): ''' Don't save any passed values related to a type of discount that is not the specified type ''' if self.discountType != self.DiscountType.flatPrice: self.onlinePrice = None self.doorPrice = None if self.discount...
[ "def", "save", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "discountType", "!=", "self", ".", "DiscountType", ".", "flatPrice", ":", "self", ".", "onlinePrice", "=", "None", "self", ".", "doorPrice", "=", "Non...
Don't save any passed values related to a type of discount that is not the specified type
[ "Don", "t", "save", "any", "passed", "values", "related", "to", "a", "type", "of", "discount", "that", "is", "not", "the", "specified", "type" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/models.py#L232-L249
django-danceschool/django-danceschool
danceschool/discounts/handlers.py
getBestDiscount
def getBestDiscount(sender,**kwargs): ''' When a customer registers for events, discounts may need to be automatically applied. A given shopping cart may, in fact, be eligible for multiple different types of discounts (e.g. hours-based discounts for increasing numbers of class hours), but typically...
python
def getBestDiscount(sender,**kwargs): ''' When a customer registers for events, discounts may need to be automatically applied. A given shopping cart may, in fact, be eligible for multiple different types of discounts (e.g. hours-based discounts for increasing numbers of class hours), but typically...
[ "def", "getBestDiscount", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "if", "not", "getConstant", "(", "'general__discountsEnabled'", ")", ":", "return", "logger", ".", "debug", "(", "'Signal fired to request discounts.'", ")", "reg", "=", "kwargs", ".", ...
When a customer registers for events, discounts may need to be automatically applied. A given shopping cart may, in fact, be eligible for multiple different types of discounts (e.g. hours-based discounts for increasing numbers of class hours), but typically, only one discount should be applied. Theref...
[ "When", "a", "customer", "registers", "for", "events", "discounts", "may", "need", "to", "be", "automatically", "applied", ".", "A", "given", "shopping", "cart", "may", "in", "fact", "be", "eligible", "for", "multiple", "different", "types", "of", "discounts",...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/discounts/handlers.py#L22-L163
django-danceschool/django-danceschool
danceschool/payments/square/cms_plugins.py
SquareCheckoutFormPlugin.render
def render(self, context, instance, placeholder): ''' Add the cart-specific context to this form ''' context = super(SquareCheckoutFormPlugin, self).render(context, instance, placeholder) context.update({ 'squareApplicationId': getattr(settings,'SQUARE_APPLICATION_ID',''), ...
python
def render(self, context, instance, placeholder): ''' Add the cart-specific context to this form ''' context = super(SquareCheckoutFormPlugin, self).render(context, instance, placeholder) context.update({ 'squareApplicationId': getattr(settings,'SQUARE_APPLICATION_ID',''), ...
[ "def", "render", "(", "self", ",", "context", ",", "instance", ",", "placeholder", ")", ":", "context", "=", "super", "(", "SquareCheckoutFormPlugin", ",", "self", ")", ".", "render", "(", "context", ",", "instance", ",", "placeholder", ")", "context", "."...
Add the cart-specific context to this form
[ "Add", "the", "cart", "-", "specific", "context", "to", "this", "form" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/payments/square/cms_plugins.py#L18-L26
django-danceschool/django-danceschool
danceschool/vouchers/handlers.py
checkVoucherCode
def checkVoucherCode(sender,**kwargs): ''' Check that the given voucher code is valid ''' logger.debug('Signal to check RegistrationContactForm handled by vouchers app.') formData = kwargs.get('formData',{}) request = kwargs.get('request',{}) registration = kwargs.get('registration'...
python
def checkVoucherCode(sender,**kwargs): ''' Check that the given voucher code is valid ''' logger.debug('Signal to check RegistrationContactForm handled by vouchers app.') formData = kwargs.get('formData',{}) request = kwargs.get('request',{}) registration = kwargs.get('registration'...
[ "def", "checkVoucherCode", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Signal to check RegistrationContactForm handled by vouchers app.'", ")", "formData", "=", "kwargs", ".", "get", "(", "'formData'", ",", "{", "}", ")", "re...
Check that the given voucher code is valid
[ "Check", "that", "the", "given", "voucher", "code", "is", "valid" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L20-L71
django-danceschool/django-danceschool
danceschool/vouchers/handlers.py
applyVoucherCodeTemporarily
def applyVoucherCodeTemporarily(sender,**kwargs): ''' When the core registration system creates a temporary registration with a voucher code, the voucher app looks for vouchers that match that code and creates TemporaryVoucherUse objects to keep track of the fact that the voucher may be used. '...
python
def applyVoucherCodeTemporarily(sender,**kwargs): ''' When the core registration system creates a temporary registration with a voucher code, the voucher app looks for vouchers that match that code and creates TemporaryVoucherUse objects to keep track of the fact that the voucher may be used. '...
[ "def", "applyVoucherCodeTemporarily", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Signal fired to apply temporary vouchers.'", ")", "reg", "=", "kwargs", ".", "pop", "(", "'registration'", ")", "voucherId", "=", "reg", ".", ...
When the core registration system creates a temporary registration with a voucher code, the voucher app looks for vouchers that match that code and creates TemporaryVoucherUse objects to keep track of the fact that the voucher may be used.
[ "When", "the", "core", "registration", "system", "creates", "a", "temporary", "registration", "with", "a", "voucher", "code", "the", "voucher", "app", "looks", "for", "vouchers", "that", "match", "that", "code", "and", "creates", "TemporaryVoucherUse", "objects", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L75-L94
django-danceschool/django-danceschool
danceschool/vouchers/handlers.py
applyReferrerVouchersTemporarily
def applyReferrerVouchersTemporarily(sender,**kwargs): ''' Unlike voucher codes which have to be manually supplied, referrer discounts are automatically applied here, assuming that the referral program is enabled. ''' # Only continue if the referral program is enabled if not getConstant(...
python
def applyReferrerVouchersTemporarily(sender,**kwargs): ''' Unlike voucher codes which have to be manually supplied, referrer discounts are automatically applied here, assuming that the referral program is enabled. ''' # Only continue if the referral program is enabled if not getConstant(...
[ "def", "applyReferrerVouchersTemporarily", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "# Only continue if the referral program is enabled\r", "if", "not", "getConstant", "(", "'referrals__enableReferralProgram'", ")", ":", "return", "logger", ".", "debug", "(", "...
Unlike voucher codes which have to be manually supplied, referrer discounts are automatically applied here, assuming that the referral program is enabled.
[ "Unlike", "voucher", "codes", "which", "have", "to", "be", "manually", "supplied", "referrer", "discounts", "are", "automatically", "applied", "here", "assuming", "that", "the", "referral", "program", "is", "enabled", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L98-L124
django-danceschool/django-danceschool
danceschool/vouchers/handlers.py
applyVoucherCodesFinal
def applyVoucherCodesFinal(sender,**kwargs): ''' Once a registration has been completed, vouchers are used and referrers are awarded ''' logger.debug('Signal fired to mark voucher codes as applied.') finalReg = kwargs.pop('registration') tr = finalReg.temporaryRegistration tvus = ...
python
def applyVoucherCodesFinal(sender,**kwargs): ''' Once a registration has been completed, vouchers are used and referrers are awarded ''' logger.debug('Signal fired to mark voucher codes as applied.') finalReg = kwargs.pop('registration') tr = finalReg.temporaryRegistration tvus = ...
[ "def", "applyVoucherCodesFinal", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Signal fired to mark voucher codes as applied.'", ")", "finalReg", "=", "kwargs", ".", "pop", "(", "'registration'", ")", "tr", "=", "finalReg", "."...
Once a registration has been completed, vouchers are used and referrers are awarded
[ "Once", "a", "registration", "has", "been", "completed", "vouchers", "are", "used", "and", "referrers", "are", "awarded" ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L170-L185
django-danceschool/django-danceschool
danceschool/vouchers/handlers.py
provideCustomerReferralCode
def provideCustomerReferralCode(sender,**kwargs): ''' If the vouchers app is installed and referrals are enabled, then the customer's profile page can show their voucher referral code. ''' customer = kwargs.pop('customer') if getConstant('vouchers__enableVouchers') and getConstant('referrals__e...
python
def provideCustomerReferralCode(sender,**kwargs): ''' If the vouchers app is installed and referrals are enabled, then the customer's profile page can show their voucher referral code. ''' customer = kwargs.pop('customer') if getConstant('vouchers__enableVouchers') and getConstant('referrals__e...
[ "def", "provideCustomerReferralCode", "(", "sender", ",", "*", "*", "kwargs", ")", ":", "customer", "=", "kwargs", ".", "pop", "(", "'customer'", ")", "if", "getConstant", "(", "'vouchers__enableVouchers'", ")", "and", "getConstant", "(", "'referrals__enableReferr...
If the vouchers app is installed and referrals are enabled, then the customer's profile page can show their voucher referral code.
[ "If", "the", "vouchers", "app", "is", "installed", "and", "referrals", "are", "enabled", "then", "the", "customer", "s", "profile", "page", "can", "show", "their", "voucher", "referral", "code", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/vouchers/handlers.py#L189-L199
django-danceschool/django-danceschool
danceschool/core/constants.py
getConstant
def getConstant(name): ''' This is a convenience function that makes it easy to access the value of a preference/constant without needing to check if the django_dynamic_preferences app has been set up and without needing to load from that model directly. ''' # We instantiate a manager for our g...
python
def getConstant(name): ''' This is a convenience function that makes it easy to access the value of a preference/constant without needing to check if the django_dynamic_preferences app has been set up and without needing to load from that model directly. ''' # We instantiate a manager for our g...
[ "def", "getConstant", "(", "name", ")", ":", "# We instantiate a manager for our global preferences", "if", "'dynamic_preferences_globalpreferencemodel'", "in", "connection", ".", "introspection", ".", "table_names", "(", ")", "and", "not", "isPreliminaryRun", "(", ")", "...
This is a convenience function that makes it easy to access the value of a preference/constant without needing to check if the django_dynamic_preferences app has been set up and without needing to load from that model directly.
[ "This", "is", "a", "convenience", "function", "that", "makes", "it", "easy", "to", "access", "the", "value", "of", "a", "preference", "/", "constant", "without", "needing", "to", "check", "if", "the", "django_dynamic_preferences", "app", "has", "been", "set", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/constants.py#L15-L29
django-danceschool/django-danceschool
danceschool/core/constants.py
updateConstant
def updateConstant(name,value,fail_silently=False): ''' This is a convenience function that makes it easy to update the value of a preference/constant without needing to check if the django_dynamic_preferences app has been set up, without needing to load from that model directly, and with the option to ...
python
def updateConstant(name,value,fail_silently=False): ''' This is a convenience function that makes it easy to update the value of a preference/constant without needing to check if the django_dynamic_preferences app has been set up, without needing to load from that model directly, and with the option to ...
[ "def", "updateConstant", "(", "name", ",", "value", ",", "fail_silently", "=", "False", ")", ":", "# We instantiate a manager for our global preferences", "if", "'dynamic_preferences_globalpreferencemodel'", "in", "connection", ".", "introspection", ".", "table_names", "(",...
This is a convenience function that makes it easy to update the value of a preference/constant without needing to check if the django_dynamic_preferences app has been set up, without needing to load from that model directly, and with the option to suppress any errors (e.g. KeyErrors resulting from the order...
[ "This", "is", "a", "convenience", "function", "that", "makes", "it", "easy", "to", "update", "the", "value", "of", "a", "preference", "/", "constant", "without", "needing", "to", "check", "if", "the", "django_dynamic_preferences", "app", "has", "been", "set", ...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/core/constants.py#L32-L50
django-danceschool/django-danceschool
danceschool/payments/square/views.py
processSquarePayment
def processSquarePayment(request): ''' This view handles the charging of approved Square Checkout payments. All Checkout payments must either be associated with a pre-existing Invoice or a registration, or they must have an amount and type passed in the post data (such as gift certificate payment r...
python
def processSquarePayment(request): ''' This view handles the charging of approved Square Checkout payments. All Checkout payments must either be associated with a pre-existing Invoice or a registration, or they must have an amount and type passed in the post data (such as gift certificate payment r...
[ "def", "processSquarePayment", "(", "request", ")", ":", "logger", ".", "info", "(", "'Received request for Square Checkout payment.'", ")", "nonce_id", "=", "request", ".", "POST", ".", "get", "(", "'nonce'", ")", "invoice_id", "=", "request", ".", "POST", ".",...
This view handles the charging of approved Square Checkout payments. All Checkout payments must either be associated with a pre-existing Invoice or a registration, or they must have an amount and type passed in the post data (such as gift certificate payment requests).
[ "This", "view", "handles", "the", "charging", "of", "approved", "Square", "Checkout", "payments", "." ]
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/payments/square/views.py#L33-L205
django-danceschool/django-danceschool
danceschool/payments/square/views.py
processPointOfSalePayment
def processPointOfSalePayment(request): ''' This view handles the callbacks from point-of-sale transactions. Please note that this will only work if you have set up your callback URL in Square to point to this view. ''' print('Request data is: %s' % request.GET) # iOS transactions put all r...
python
def processPointOfSalePayment(request): ''' This view handles the callbacks from point-of-sale transactions. Please note that this will only work if you have set up your callback URL in Square to point to this view. ''' print('Request data is: %s' % request.GET) # iOS transactions put all r...
[ "def", "processPointOfSalePayment", "(", "request", ")", ":", "print", "(", "'Request data is: %s'", "%", "request", ".", "GET", ")", "# iOS transactions put all response information in the data key:", "data", "=", "json", ".", "loads", "(", "request", ".", "GET", "."...
This view handles the callbacks from point-of-sale transactions. Please note that this will only work if you have set up your callback URL in Square to point to this view.
[ "This", "view", "handles", "the", "callbacks", "from", "point", "-", "of", "-", "sale", "transactions", ".", "Please", "note", "that", "this", "will", "only", "work", "if", "you", "have", "set", "up", "your", "callback", "URL", "in", "Square", "to", "poi...
train
https://github.com/django-danceschool/django-danceschool/blob/bb08cbf39017a812a5a94bdb4ea34170bf1a30ba/danceschool/payments/square/views.py#L208-L424
orcasgit/django-fernet-fields
fernet_fields/fields.py
get_prep_lookup
def get_prep_lookup(self): """Raise errors for unsupported lookups""" raise FieldError("{} '{}' does not support lookups".format( self.lhs.field.__class__.__name__, self.lookup_name))
python
def get_prep_lookup(self): """Raise errors for unsupported lookups""" raise FieldError("{} '{}' does not support lookups".format( self.lhs.field.__class__.__name__, self.lookup_name))
[ "def", "get_prep_lookup", "(", "self", ")", ":", "raise", "FieldError", "(", "\"{} '{}' does not support lookups\"", ".", "format", "(", "self", ".", "lhs", ".", "field", ".", "__class__", ".", "__name__", ",", "self", ".", "lookup_name", ")", ")" ]
Raise errors for unsupported lookups
[ "Raise", "errors", "for", "unsupported", "lookups" ]
train
https://github.com/orcasgit/django-fernet-fields/blob/888777e5bdb93c72339663e7464f6ceaf4f5e7dd/fernet_fields/fields.py#L93-L96
orcasgit/django-fernet-fields
fernet_fields/hkdf.py
derive_fernet_key
def derive_fernet_key(input_key): """Derive a 32-bit b64-encoded Fernet key from arbitrary input key.""" hkdf = HKDF( algorithm=hashes.SHA256(), length=32, salt=salt, info=info, backend=backend, ) return base64.urlsafe_b64encode(hkdf.derive(force_bytes(input_key))...
python
def derive_fernet_key(input_key): """Derive a 32-bit b64-encoded Fernet key from arbitrary input key.""" hkdf = HKDF( algorithm=hashes.SHA256(), length=32, salt=salt, info=info, backend=backend, ) return base64.urlsafe_b64encode(hkdf.derive(force_bytes(input_key))...
[ "def", "derive_fernet_key", "(", "input_key", ")", ":", "hkdf", "=", "HKDF", "(", "algorithm", "=", "hashes", ".", "SHA256", "(", ")", ",", "length", "=", "32", ",", "salt", "=", "salt", ",", "info", "=", "info", ",", "backend", "=", "backend", ",", ...
Derive a 32-bit b64-encoded Fernet key from arbitrary input key.
[ "Derive", "a", "32", "-", "bit", "b64", "-", "encoded", "Fernet", "key", "from", "arbitrary", "input", "key", "." ]
train
https://github.com/orcasgit/django-fernet-fields/blob/888777e5bdb93c72339663e7464f6ceaf4f5e7dd/fernet_fields/hkdf.py#L14-L23
xnd-project/gumath
python/gumath/__init__.py
reduce_cpu
def reduce_cpu(f, x, axes, dtype): """NumPy's reduce in terms of fold.""" axes = _get_axes(axes, x.ndim) if not axes: return x permute = [n for n in range(x.ndim) if n not in axes] permute = axes + permute T = x.transpose(permute=permute) N = len(axes) t = T.type.at(N, dtype=d...
python
def reduce_cpu(f, x, axes, dtype): """NumPy's reduce in terms of fold.""" axes = _get_axes(axes, x.ndim) if not axes: return x permute = [n for n in range(x.ndim) if n not in axes] permute = axes + permute T = x.transpose(permute=permute) N = len(axes) t = T.type.at(N, dtype=d...
[ "def", "reduce_cpu", "(", "f", ",", "x", ",", "axes", ",", "dtype", ")", ":", "axes", "=", "_get_axes", "(", "axes", ",", "x", ".", "ndim", ")", "if", "not", "axes", ":", "return", "x", "permute", "=", "[", "n", "for", "n", "in", "range", "(", ...
NumPy's reduce in terms of fold.
[ "NumPy", "s", "reduce", "in", "terms", "of", "fold", "." ]
train
https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath/__init__.py#L93-L118
xnd-project/gumath
python/gumath/__init__.py
reduce_cuda
def reduce_cuda(g, x, axes, dtype): """Reductions in CUDA use the thrust library for speed and have limited functionality.""" if axes != 0: raise NotImplementedError("'axes' keyword is not implemented for CUDA") return g(x, dtype=dtype)
python
def reduce_cuda(g, x, axes, dtype): """Reductions in CUDA use the thrust library for speed and have limited functionality.""" if axes != 0: raise NotImplementedError("'axes' keyword is not implemented for CUDA") return g(x, dtype=dtype)
[ "def", "reduce_cuda", "(", "g", ",", "x", ",", "axes", ",", "dtype", ")", ":", "if", "axes", "!=", "0", ":", "raise", "NotImplementedError", "(", "\"'axes' keyword is not implemented for CUDA\"", ")", "return", "g", "(", "x", ",", "dtype", "=", "dtype", ")...
Reductions in CUDA use the thrust library for speed and have limited functionality.
[ "Reductions", "in", "CUDA", "use", "the", "thrust", "library", "for", "speed", "and", "have", "limited", "functionality", "." ]
train
https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath/__init__.py#L120-L126
xnd-project/gumath
python/gumath_aux.py
maxlevel
def maxlevel(lst): """Return maximum nesting depth""" maxlev = 0 def f(lst, level): nonlocal maxlev if isinstance(lst, list): level += 1 maxlev = max(level, maxlev) for item in lst: f(item, level) f(lst, 0) return maxlev
python
def maxlevel(lst): """Return maximum nesting depth""" maxlev = 0 def f(lst, level): nonlocal maxlev if isinstance(lst, list): level += 1 maxlev = max(level, maxlev) for item in lst: f(item, level) f(lst, 0) return maxlev
[ "def", "maxlevel", "(", "lst", ")", ":", "maxlev", "=", "0", "def", "f", "(", "lst", ",", "level", ")", ":", "nonlocal", "maxlev", "if", "isinstance", "(", "lst", ",", "list", ")", ":", "level", "+=", "1", "maxlev", "=", "max", "(", "level", ",",...
Return maximum nesting depth
[ "Return", "maximum", "nesting", "depth" ]
train
https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L101-L112
xnd-project/gumath
python/gumath_aux.py
getitem
def getitem(lst, indices): """Definition for multidimensional slicing and indexing on arbitrarily shaped nested lists. """ if not indices: return lst i, indices = indices[0], indices[1:] item = list.__getitem__(lst, i) if isinstance(i, int): return getitem(item, indices)...
python
def getitem(lst, indices): """Definition for multidimensional slicing and indexing on arbitrarily shaped nested lists. """ if not indices: return lst i, indices = indices[0], indices[1:] item = list.__getitem__(lst, i) if isinstance(i, int): return getitem(item, indices)...
[ "def", "getitem", "(", "lst", ",", "indices", ")", ":", "if", "not", "indices", ":", "return", "lst", "i", ",", "indices", "=", "indices", "[", "0", "]", ",", "indices", "[", "1", ":", "]", "item", "=", "list", ".", "__getitem__", "(", "lst", ","...
Definition for multidimensional slicing and indexing on arbitrarily shaped nested lists.
[ "Definition", "for", "multidimensional", "slicing", "and", "indexing", "on", "arbitrarily", "shaped", "nested", "lists", "." ]
train
https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L114-L136
xnd-project/gumath
python/gumath_aux.py
genslices
def genslices(n): """Generate all possible slices for a single dimension.""" def range_with_none(): yield None yield from range(-n, n+1) for t in product(range_with_none(), range_with_none(), range_with_none()): s = slice(*t) if s.step != 0: yield s
python
def genslices(n): """Generate all possible slices for a single dimension.""" def range_with_none(): yield None yield from range(-n, n+1) for t in product(range_with_none(), range_with_none(), range_with_none()): s = slice(*t) if s.step != 0: yield s
[ "def", "genslices", "(", "n", ")", ":", "def", "range_with_none", "(", ")", ":", "yield", "None", "yield", "from", "range", "(", "-", "n", ",", "n", "+", "1", ")", "for", "t", "in", "product", "(", "range_with_none", "(", ")", ",", "range_with_none",...
Generate all possible slices for a single dimension.
[ "Generate", "all", "possible", "slices", "for", "a", "single", "dimension", "." ]
train
https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L276-L285
xnd-project/gumath
python/gumath_aux.py
genslices_ndim
def genslices_ndim(ndim, shape): """Generate all possible slice tuples for 'shape'.""" iterables = [genslices(shape[n]) for n in range(ndim)] yield from product(*iterables)
python
def genslices_ndim(ndim, shape): """Generate all possible slice tuples for 'shape'.""" iterables = [genslices(shape[n]) for n in range(ndim)] yield from product(*iterables)
[ "def", "genslices_ndim", "(", "ndim", ",", "shape", ")", ":", "iterables", "=", "[", "genslices", "(", "shape", "[", "n", "]", ")", "for", "n", "in", "range", "(", "ndim", ")", "]", "yield", "from", "product", "(", "*", "iterables", ")" ]
Generate all possible slice tuples for 'shape'.
[ "Generate", "all", "possible", "slice", "tuples", "for", "shape", "." ]
train
https://github.com/xnd-project/gumath/blob/a20ed5621db566ef805b8fb27ba4d8487f48c6b5/python/gumath_aux.py#L287-L290
aarongarrett/inspyred
inspyred/ec/variators/mutators.py
mutator
def mutator(mutate): """Return an inspyred mutator function based on the given function. This function generator takes a function that operates on only one candidate to produce a single mutated candidate. The generator handles the iteration over each candidate in the set to be mutated. The gi...
python
def mutator(mutate): """Return an inspyred mutator function based on the given function. This function generator takes a function that operates on only one candidate to produce a single mutated candidate. The generator handles the iteration over each candidate in the set to be mutated. The gi...
[ "def", "mutator", "(", "mutate", ")", ":", "@", "functools", ".", "wraps", "(", "mutate", ")", "def", "inspyred_mutator", "(", "random", ",", "candidates", ",", "args", ")", ":", "mutants", "=", "[", "]", "for", "i", ",", "cs", "in", "enumerate", "("...
Return an inspyred mutator function based on the given function. This function generator takes a function that operates on only one candidate to produce a single mutated candidate. The generator handles the iteration over each candidate in the set to be mutated. The given function ``mutate`` must...
[ "Return", "an", "inspyred", "mutator", "function", "based", "on", "the", "given", "function", ".", "This", "function", "generator", "takes", "a", "function", "that", "operates", "on", "only", "one", "candidate", "to", "produce", "a", "single", "mutated", "cand...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L33-L65
aarongarrett/inspyred
inspyred/ec/variators/mutators.py
bit_flip_mutation
def bit_flip_mutation(random, candidate, args): """Return the mutants produced by bit-flip mutation on the candidates. This function performs bit-flip mutation. If a candidate solution contains non-binary values, this function leaves it unchanged. .. Arguments: random -- the random number gener...
python
def bit_flip_mutation(random, candidate, args): """Return the mutants produced by bit-flip mutation on the candidates. This function performs bit-flip mutation. If a candidate solution contains non-binary values, this function leaves it unchanged. .. Arguments: random -- the random number gener...
[ "def", "bit_flip_mutation", "(", "random", ",", "candidate", ",", "args", ")", ":", "rate", "=", "args", ".", "setdefault", "(", "'mutation_rate'", ",", "0.1", ")", "mutant", "=", "copy", ".", "copy", "(", "candidate", ")", "if", "len", "(", "mutant", ...
Return the mutants produced by bit-flip mutation on the candidates. This function performs bit-flip mutation. If a candidate solution contains non-binary values, this function leaves it unchanged. .. Arguments: random -- the random number generator object candidate -- the candidate solution ...
[ "Return", "the", "mutants", "produced", "by", "bit", "-", "flip", "mutation", "on", "the", "candidates", "." ]
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L69-L93
aarongarrett/inspyred
inspyred/ec/variators/mutators.py
random_reset_mutation
def random_reset_mutation(random, candidate, args): """Return the mutants produced by randomly choosing new values. This function performs random-reset mutation. It assumes that candidate solutions are composed of discrete values. This function makes use of the bounder function as specified in the EC'...
python
def random_reset_mutation(random, candidate, args): """Return the mutants produced by randomly choosing new values. This function performs random-reset mutation. It assumes that candidate solutions are composed of discrete values. This function makes use of the bounder function as specified in the EC'...
[ "def", "random_reset_mutation", "(", "random", ",", "candidate", ",", "args", ")", ":", "bounder", "=", "args", "[", "'_ec'", "]", ".", "bounder", "try", ":", "values", "=", "bounder", ".", "values", "except", "AttributeError", ":", "values", "=", "None", ...
Return the mutants produced by randomly choosing new values. This function performs random-reset mutation. It assumes that candidate solutions are composed of discrete values. This function makes use of the bounder function as specified in the EC's ``evolve`` method, and it assumes that the bounder c...
[ "Return", "the", "mutants", "produced", "by", "randomly", "choosing", "new", "values", "." ]
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L97-L137
aarongarrett/inspyred
inspyred/ec/variators/mutators.py
scramble_mutation
def scramble_mutation(random, candidate, args): """Return the mutants created by scramble mutation on the candidates. This function performs scramble mutation. It randomly chooses two locations along the candidate and scrambles the values within that slice. .. Arguments: random -- the rand...
python
def scramble_mutation(random, candidate, args): """Return the mutants created by scramble mutation on the candidates. This function performs scramble mutation. It randomly chooses two locations along the candidate and scrambles the values within that slice. .. Arguments: random -- the rand...
[ "def", "scramble_mutation", "(", "random", ",", "candidate", ",", "args", ")", ":", "rate", "=", "args", ".", "setdefault", "(", "'mutation_rate'", ",", "0.1", ")", "if", "random", ".", "random", "(", ")", "<", "rate", ":", "size", "=", "len", "(", "...
Return the mutants created by scramble mutation on the candidates. This function performs scramble mutation. It randomly chooses two locations along the candidate and scrambles the values within that slice. .. Arguments: random -- the random number generator object candidate -- the cand...
[ "Return", "the", "mutants", "created", "by", "scramble", "mutation", "on", "the", "candidates", "." ]
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L141-L171
aarongarrett/inspyred
inspyred/ec/variators/mutators.py
gaussian_mutation
def gaussian_mutation(random, candidate, args): """Return the mutants created by Gaussian mutation on the candidates. This function performs Gaussian mutation. This function makes use of the bounder function as specified in the EC's ``evolve`` method. .. Arguments: random -- the random n...
python
def gaussian_mutation(random, candidate, args): """Return the mutants created by Gaussian mutation on the candidates. This function performs Gaussian mutation. This function makes use of the bounder function as specified in the EC's ``evolve`` method. .. Arguments: random -- the random n...
[ "def", "gaussian_mutation", "(", "random", ",", "candidate", ",", "args", ")", ":", "mut_rate", "=", "args", ".", "setdefault", "(", "'mutation_rate'", ",", "0.1", ")", "mean", "=", "args", ".", "setdefault", "(", "'gaussian_mean'", ",", "0.0", ")", "stdev...
Return the mutants created by Gaussian mutation on the candidates. This function performs Gaussian mutation. This function makes use of the bounder function as specified in the EC's ``evolve`` method. .. Arguments: random -- the random number generator object candidate -- the candidat...
[ "Return", "the", "mutants", "created", "by", "Gaussian", "mutation", "on", "the", "candidates", "." ]
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L208-L239
aarongarrett/inspyred
inspyred/ec/variators/mutators.py
nonuniform_mutation
def nonuniform_mutation(random, candidate, args): """Return the mutants produced by nonuniform mutation on the candidates. The function performs nonuniform mutation as specified in (Michalewicz, "Genetic Algorithms + Data Structures = Evolution Programs," Springer, 1996). This function also makes use o...
python
def nonuniform_mutation(random, candidate, args): """Return the mutants produced by nonuniform mutation on the candidates. The function performs nonuniform mutation as specified in (Michalewicz, "Genetic Algorithms + Data Structures = Evolution Programs," Springer, 1996). This function also makes use o...
[ "def", "nonuniform_mutation", "(", "random", ",", "candidate", ",", "args", ")", ":", "bounder", "=", "args", "[", "'_ec'", "]", ".", "bounder", "num_gens", "=", "args", "[", "'_ec'", "]", ".", "num_generations", "max_gens", "=", "args", "[", "'max_generat...
Return the mutants produced by nonuniform mutation on the candidates. The function performs nonuniform mutation as specified in (Michalewicz, "Genetic Algorithms + Data Structures = Evolution Programs," Springer, 1996). This function also makes use of the bounder function as specified in the EC's ``ev...
[ "Return", "the", "mutants", "produced", "by", "nonuniform", "mutation", "on", "the", "candidates", "." ]
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/variators/mutators.py#L243-L285
aarongarrett/inspyred
inspyred/ec/archivers.py
population_archiver
def population_archiver(random, population, archive, args): """Archive the current population. This function replaces the archive with the individuals of the current population. .. Arguments: random -- the random number generator object population -- the population of individual...
python
def population_archiver(random, population, archive, args): """Archive the current population. This function replaces the archive with the individuals of the current population. .. Arguments: random -- the random number generator object population -- the population of individual...
[ "def", "population_archiver", "(", "random", ",", "population", ",", "archive", ",", "args", ")", ":", "new_archive", "=", "[", "]", "for", "ind", "in", "population", ":", "new_archive", ".", "append", "(", "ind", ")", "return", "new_archive" ]
Archive the current population. This function replaces the archive with the individuals of the current population. .. Arguments: random -- the random number generator object population -- the population of individuals archive -- the current archive of individuals args ...
[ "Archive", "the", "current", "population", ".", "This", "function", "replaces", "the", "archive", "with", "the", "individuals", "of", "the", "current", "population", ".", "..", "Arguments", ":", "random", "--", "the", "random", "number", "generator", "object", ...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/archivers.py#L65-L81
aarongarrett/inspyred
inspyred/ec/archivers.py
best_archiver
def best_archiver(random, population, archive, args): """Archive only the best individual(s). This function archives the best solutions and removes inferior ones. If the comparison operators have been overloaded to define Pareto preference (as in the ``Pareto`` class), then this archiver will form ...
python
def best_archiver(random, population, archive, args): """Archive only the best individual(s). This function archives the best solutions and removes inferior ones. If the comparison operators have been overloaded to define Pareto preference (as in the ``Pareto`` class), then this archiver will form ...
[ "def", "best_archiver", "(", "random", ",", "population", ",", "archive", ",", "args", ")", ":", "new_archive", "=", "archive", "for", "ind", "in", "population", ":", "if", "len", "(", "new_archive", ")", "==", "0", ":", "new_archive", ".", "append", "("...
Archive only the best individual(s). This function archives the best solutions and removes inferior ones. If the comparison operators have been overloaded to define Pareto preference (as in the ``Pareto`` class), then this archiver will form a Pareto archive. .. Arguments: random -...
[ "Archive", "only", "the", "best", "individual", "(", "s", ")", ".", "This", "function", "archives", "the", "best", "solutions", "and", "removes", "inferior", "ones", ".", "If", "the", "comparison", "operators", "have", "been", "overloaded", "to", "define", "...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/archivers.py#L84-L118
aarongarrett/inspyred
inspyred/ec/archivers.py
adaptive_grid_archiver
def adaptive_grid_archiver(random, population, archive, args): """Archive only the best individual(s) using a fixed size grid. This function archives the best solutions by using a fixed-size grid to determine which existing solutions should be removed in order to make room for new ones. This archiv...
python
def adaptive_grid_archiver(random, population, archive, args): """Archive only the best individual(s) using a fixed size grid. This function archives the best solutions by using a fixed-size grid to determine which existing solutions should be removed in order to make room for new ones. This archiv...
[ "def", "adaptive_grid_archiver", "(", "random", ",", "population", ",", "archive", ",", "args", ")", ":", "def", "get_grid_location", "(", "fitness", ",", "num_grid_divisions", ",", "global_smallest", ",", "global_largest", ")", ":", "loc", "=", "0", "n", "=",...
Archive only the best individual(s) using a fixed size grid. This function archives the best solutions by using a fixed-size grid to determine which existing solutions should be removed in order to make room for new ones. This archiver is designed specifically for use with the Pareto Archived Evolu...
[ "Archive", "only", "the", "best", "individual", "(", "s", ")", "using", "a", "fixed", "size", "grid", ".", "This", "function", "archives", "the", "best", "solutions", "by", "using", "a", "fixed", "-", "size", "grid", "to", "determine", "which", "existing",...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/archivers.py#L121-L256
aarongarrett/inspyred
inspyred/swarm/topologies.py
ring_topology
def ring_topology(random, population, args): """Returns the neighbors using a ring topology. This function sets all particles in a specified sized neighborhood as neighbors for a given particle. This is known as a ring topology. The resulting list of lists of neighbors is returned. .. Arg...
python
def ring_topology(random, population, args): """Returns the neighbors using a ring topology. This function sets all particles in a specified sized neighborhood as neighbors for a given particle. This is known as a ring topology. The resulting list of lists of neighbors is returned. .. Arg...
[ "def", "ring_topology", "(", "random", ",", "population", ",", "args", ")", ":", "neighborhood_size", "=", "args", ".", "setdefault", "(", "'neighborhood_size'", ",", "3", ")", "half_hood", "=", "neighborhood_size", "//", "2", "neighbor_index_start", "=", "[", ...
Returns the neighbors using a ring topology. This function sets all particles in a specified sized neighborhood as neighbors for a given particle. This is known as a ring topology. The resulting list of lists of neighbors is returned. .. Arguments: random -- the random number generator...
[ "Returns", "the", "neighbors", "using", "a", "ring", "topology", ".", "This", "function", "sets", "all", "particles", "in", "a", "specified", "sized", "neighborhood", "as", "neighbors", "for", "a", "given", "particle", ".", "This", "is", "known", "as", "a", ...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/swarm/topologies.py#L69-L101
aarongarrett/inspyred
inspyred/ec/ec.py
EvolutionaryComputation.evolve
def evolve(self, generator, evaluator, pop_size=100, seeds=None, maximize=True, bounder=None, **args): """Perform the evolution. This function creates a population and then runs it through a series of evolutionary epochs until the terminator is satisfied. The general outline of ...
python
def evolve(self, generator, evaluator, pop_size=100, seeds=None, maximize=True, bounder=None, **args): """Perform the evolution. This function creates a population and then runs it through a series of evolutionary epochs until the terminator is satisfied. The general outline of ...
[ "def", "evolve", "(", "self", ",", "generator", ",", "evaluator", ",", "pop_size", "=", "100", ",", "seeds", "=", "None", ",", "maximize", "=", "True", ",", "bounder", "=", "None", ",", "*", "*", "args", ")", ":", "self", ".", "_kwargs", "=", "args...
Perform the evolution. This function creates a population and then runs it through a series of evolutionary epochs until the terminator is satisfied. The general outline of an epoch is selection, variation, evaluation, replacement, migration, archival, and observation. The funct...
[ "Perform", "the", "evolution", ".", "This", "function", "creates", "a", "population", "and", "then", "runs", "it", "through", "a", "series", "of", "evolutionary", "epochs", "until", "the", "terminator", "is", "satisfied", ".", "The", "general", "outline", "of"...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/ec.py#L381-L518
aarongarrett/inspyred
inspyred/ec/selectors.py
truncation_selection
def truncation_selection(random, population, args): """Selects the best individuals from the population. This function performs truncation selection, which means that only the best individuals from the current population are selected. This is a completely deterministic selection mechanism. ...
python
def truncation_selection(random, population, args): """Selects the best individuals from the population. This function performs truncation selection, which means that only the best individuals from the current population are selected. This is a completely deterministic selection mechanism. ...
[ "def", "truncation_selection", "(", "random", ",", "population", ",", "args", ")", ":", "num_selected", "=", "args", ".", "setdefault", "(", "'num_selected'", ",", "len", "(", "population", ")", ")", "population", ".", "sort", "(", "reverse", "=", "True", ...
Selects the best individuals from the population. This function performs truncation selection, which means that only the best individuals from the current population are selected. This is a completely deterministic selection mechanism. .. Arguments: random -- the random number generator...
[ "Selects", "the", "best", "individuals", "from", "the", "population", ".", "This", "function", "performs", "truncation", "selection", "which", "means", "that", "only", "the", "best", "individuals", "from", "the", "current", "population", "are", "selected", ".", ...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/selectors.py#L63-L83
aarongarrett/inspyred
inspyred/ec/selectors.py
uniform_selection
def uniform_selection(random, population, args): """Return a uniform sampling of individuals from the population. This function performs uniform selection by randomly choosing members of the population with replacement. .. Arguments: random -- the random number generator object p...
python
def uniform_selection(random, population, args): """Return a uniform sampling of individuals from the population. This function performs uniform selection by randomly choosing members of the population with replacement. .. Arguments: random -- the random number generator object p...
[ "def", "uniform_selection", "(", "random", ",", "population", ",", "args", ")", ":", "num_selected", "=", "args", ".", "setdefault", "(", "'num_selected'", ",", "1", ")", "selected", "=", "[", "]", "for", "_", "in", "range", "(", "num_selected", ")", ":"...
Return a uniform sampling of individuals from the population. This function performs uniform selection by randomly choosing members of the population with replacement. .. Arguments: random -- the random number generator object population -- the population of individuals args -...
[ "Return", "a", "uniform", "sampling", "of", "individuals", "from", "the", "population", ".", "This", "function", "performs", "uniform", "selection", "by", "randomly", "choosing", "members", "of", "the", "population", "with", "replacement", ".", "..", "Arguments", ...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/selectors.py#L86-L107
aarongarrett/inspyred
inspyred/ec/selectors.py
fitness_proportionate_selection
def fitness_proportionate_selection(random, population, args): """Return fitness proportionate sampling of individuals from the population. This function stochastically chooses individuals from the population with probability proportional to their fitness. This is often referred to as "roulette wh...
python
def fitness_proportionate_selection(random, population, args): """Return fitness proportionate sampling of individuals from the population. This function stochastically chooses individuals from the population with probability proportional to their fitness. This is often referred to as "roulette wh...
[ "def", "fitness_proportionate_selection", "(", "random", ",", "population", ",", "args", ")", ":", "num_selected", "=", "args", ".", "setdefault", "(", "'num_selected'", ",", "1", ")", "len_pop", "=", "len", "(", "population", ")", "psum", "=", "[", "i", "...
Return fitness proportionate sampling of individuals from the population. This function stochastically chooses individuals from the population with probability proportional to their fitness. This is often referred to as "roulette wheel" selection. Note that this selection is not valid for minimiza...
[ "Return", "fitness", "proportionate", "sampling", "of", "individuals", "from", "the", "population", ".", "This", "function", "stochastically", "chooses", "individuals", "from", "the", "population", "with", "probability", "proportional", "to", "their", "fitness", ".", ...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/selectors.py#L110-L164
aarongarrett/inspyred
inspyred/ec/selectors.py
rank_selection
def rank_selection(random, population, args): """Return a rank-based sampling of individuals from the population. This function behaves similarly to fitness proportionate selection, except that it uses the individual's rank in the population, rather than its raw fitness value, to determine its prob...
python
def rank_selection(random, population, args): """Return a rank-based sampling of individuals from the population. This function behaves similarly to fitness proportionate selection, except that it uses the individual's rank in the population, rather than its raw fitness value, to determine its prob...
[ "def", "rank_selection", "(", "random", ",", "population", ",", "args", ")", ":", "num_selected", "=", "args", ".", "setdefault", "(", "'num_selected'", ",", "1", ")", "# Set up the roulette wheel", "len_pop", "=", "len", "(", "population", ")", "population", ...
Return a rank-based sampling of individuals from the population. This function behaves similarly to fitness proportionate selection, except that it uses the individual's rank in the population, rather than its raw fitness value, to determine its probability. This means that it can be used for both ...
[ "Return", "a", "rank", "-", "based", "sampling", "of", "individuals", "from", "the", "population", ".", "This", "function", "behaves", "similarly", "to", "fitness", "proportionate", "selection", "except", "that", "it", "uses", "the", "individual", "s", "rank", ...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/selectors.py#L167-L212
aarongarrett/inspyred
inspyred/ec/selectors.py
tournament_selection
def tournament_selection(random, population, args): """Return a tournament sampling of individuals from the population. This function selects ``num_selected`` individuals from the population. It selects each one by using random sampling without replacement to pull ``tournament_size`` individuals a...
python
def tournament_selection(random, population, args): """Return a tournament sampling of individuals from the population. This function selects ``num_selected`` individuals from the population. It selects each one by using random sampling without replacement to pull ``tournament_size`` individuals a...
[ "def", "tournament_selection", "(", "random", ",", "population", ",", "args", ")", ":", "num_selected", "=", "args", ".", "setdefault", "(", "'num_selected'", ",", "1", ")", "tournament_size", "=", "args", ".", "setdefault", "(", "'tournament_size'", ",", "2",...
Return a tournament sampling of individuals from the population. This function selects ``num_selected`` individuals from the population. It selects each one by using random sampling without replacement to pull ``tournament_size`` individuals and adds the best of the tournament as its selection. If...
[ "Return", "a", "tournament", "sampling", "of", "individuals", "from", "the", "population", ".", "This", "function", "selects", "num_selected", "individuals", "from", "the", "population", ".", "It", "selects", "each", "one", "by", "using", "random", "sampling", "...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/selectors.py#L215-L244
aarongarrett/inspyred
inspyred/ec/observers.py
best_observer
def best_observer(population, num_generations, num_evaluations, args): """Print the best individual in the population to the screen. This function displays the best individual in the population to the screen. .. Arguments: population -- the population of Individuals num_generat...
python
def best_observer(population, num_generations, num_evaluations, args): """Print the best individual in the population to the screen. This function displays the best individual in the population to the screen. .. Arguments: population -- the population of Individuals num_generat...
[ "def", "best_observer", "(", "population", ",", "num_generations", ",", "num_evaluations", ",", "args", ")", ":", "print", "(", "\"Best Individual: {0}\\n\"", ".", "format", "(", "str", "(", "max", "(", "population", ")", ")", ")", ")" ]
Print the best individual in the population to the screen. This function displays the best individual in the population to the screen. .. Arguments: population -- the population of Individuals num_generations -- the number of elapsed generations num_evaluations -- the number...
[ "Print", "the", "best", "individual", "in", "the", "population", "to", "the", "screen", ".", "This", "function", "displays", "the", "best", "individual", "in", "the", "population", "to", "the", "screen", ".", "..", "Arguments", ":", "population", "--", "the"...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/observers.py#L59-L72
aarongarrett/inspyred
inspyred/ec/observers.py
stats_observer
def stats_observer(population, num_generations, num_evaluations, args): """Print the statistics of the evolutionary computation to the screen. This function displays the statistics of the evolutionary computation to the screen. The output includes the generation number, the current number of evalua...
python
def stats_observer(population, num_generations, num_evaluations, args): """Print the statistics of the evolutionary computation to the screen. This function displays the statistics of the evolutionary computation to the screen. The output includes the generation number, the current number of evalua...
[ "def", "stats_observer", "(", "population", ",", "num_generations", ",", "num_evaluations", ",", "args", ")", ":", "stats", "=", "inspyred", ".", "ec", ".", "analysis", ".", "fitness_statistics", "(", "population", ")", "worst_fit", "=", "'{0:>10}'", ".", "for...
Print the statistics of the evolutionary computation to the screen. This function displays the statistics of the evolutionary computation to the screen. The output includes the generation number, the current number of evaluations, the maximum fitness, the minimum fitness, the average fitness, and ...
[ "Print", "the", "statistics", "of", "the", "evolutionary", "computation", "to", "the", "screen", ".", "This", "function", "displays", "the", "statistics", "of", "the", "evolutionary", "computation", "to", "the", "screen", ".", "The", "output", "includes", "the",...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/observers.py#L75-L110
aarongarrett/inspyred
inspyred/ec/observers.py
population_observer
def population_observer(population, num_generations, num_evaluations, args): """Print the current population of the evolutionary computation to the screen. This function displays the current population of the evolutionary computation to the screen in fitness-sorted order. .. Arguments: ...
python
def population_observer(population, num_generations, num_evaluations, args): """Print the current population of the evolutionary computation to the screen. This function displays the current population of the evolutionary computation to the screen in fitness-sorted order. .. Arguments: ...
[ "def", "population_observer", "(", "population", ",", "num_generations", ",", "num_evaluations", ",", "args", ")", ":", "population", ".", "sort", "(", "reverse", "=", "True", ")", "print", "(", "'---------------------------------------------------------------------------...
Print the current population of the evolutionary computation to the screen. This function displays the current population of the evolutionary computation to the screen in fitness-sorted order. .. Arguments: population -- the population of Individuals num_generations -- the number o...
[ "Print", "the", "current", "population", "of", "the", "evolutionary", "computation", "to", "the", "screen", ".", "This", "function", "displays", "the", "current", "population", "of", "the", "evolutionary", "computation", "to", "the", "screen", "in", "fitness", "...
train
https://github.com/aarongarrett/inspyred/blob/d5976ab503cc9d51c6f586cbb7bb601a38c01128/inspyred/ec/observers.py#L113-L132