partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
valid
EnterpriseCustomerManageLearnersView.post
Handle POST request - handle form submissions. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpResponse: HttpResponse
enterprise/admin/views.py
def post(self, request, customer_uuid): """ Handle POST request - handle form submissions. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpResponse...
def post(self, request, customer_uuid): """ Handle POST request - handle form submissions. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpResponse...
[ "Handle", "POST", "request", "-", "handle", "form", "submissions", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/views.py#L816-L889
[ "def", "post", "(", "self", ",", "request", ",", "customer_uuid", ")", ":", "enterprise_customer", "=", "EnterpriseCustomer", ".", "objects", ".", "get", "(", "uuid", "=", "customer_uuid", ")", "# pylint: disable=no-member", "manage_learners_form", "=", "ManageLearn...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerManageLearnersView.delete
Handle DELETE request - handle unlinking learner. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpResponse: HttpResponse
enterprise/admin/views.py
def delete(self, request, customer_uuid): """ Handle DELETE request - handle unlinking learner. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpRes...
def delete(self, request, customer_uuid): """ Handle DELETE request - handle unlinking learner. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpRes...
[ "Handle", "DELETE", "request", "-", "handle", "unlinking", "learner", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/views.py#L891-L918
[ "def", "delete", "(", "self", ",", "request", ",", "customer_uuid", ")", ":", "# TODO: pylint acts stupid - find a way around it without suppressing", "enterprise_customer", "=", "EnterpriseCustomer", ".", "objects", ".", "get", "(", "uuid", "=", "customer_uuid", ")", "...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
DataSharingConsentQuerySet.proxied_get
Perform the query and returns a single object matching the given keyword arguments. This customizes the queryset to return an instance of ``ProxyDataSharingConsent`` when the searched-for ``DataSharingConsent`` instance does not exist.
consent/models.py
def proxied_get(self, *args, **kwargs): """ Perform the query and returns a single object matching the given keyword arguments. This customizes the queryset to return an instance of ``ProxyDataSharingConsent`` when the searched-for ``DataSharingConsent`` instance does not exist. ...
def proxied_get(self, *args, **kwargs): """ Perform the query and returns a single object matching the given keyword arguments. This customizes the queryset to return an instance of ``ProxyDataSharingConsent`` when the searched-for ``DataSharingConsent`` instance does not exist. ...
[ "Perform", "the", "query", "and", "returns", "a", "single", "object", "matching", "the", "given", "keyword", "arguments", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/consent/models.py#L38-L66
[ "def", "proxied_get", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "original_kwargs", "=", "kwargs", ".", "copy", "(", ")", "if", "'course_id'", "in", "kwargs", ":", "try", ":", "# Check if we have a course ID or a course run ID", "course_...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ProxyDataSharingConsent.from_children
Build a ProxyDataSharingConsent using the details of the received consent records.
consent/models.py
def from_children(cls, program_uuid, *children): """ Build a ProxyDataSharingConsent using the details of the received consent records. """ if not children or any(child is None for child in children): return None granted = all((child.granted for child in children)) ...
def from_children(cls, program_uuid, *children): """ Build a ProxyDataSharingConsent using the details of the received consent records. """ if not children or any(child is None for child in children): return None granted = all((child.granted for child in children)) ...
[ "Build", "a", "ProxyDataSharingConsent", "using", "the", "details", "of", "the", "received", "consent", "records", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/consent/models.py#L127-L151
[ "def", "from_children", "(", "cls", ",", "program_uuid", ",", "*", "children", ")", ":", "if", "not", "children", "or", "any", "(", "child", "is", "None", "for", "child", "in", "children", ")", ":", "return", "None", "granted", "=", "all", "(", "(", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ProxyDataSharingConsent.commit
Commit a real ``DataSharingConsent`` object to the database, mirroring current field settings. :return: A ``DataSharingConsent`` object if validation is successful, otherwise ``None``.
consent/models.py
def commit(self): """ Commit a real ``DataSharingConsent`` object to the database, mirroring current field settings. :return: A ``DataSharingConsent`` object if validation is successful, otherwise ``None``. """ if self._child_consents: consents = [] for ...
def commit(self): """ Commit a real ``DataSharingConsent`` object to the database, mirroring current field settings. :return: A ``DataSharingConsent`` object if validation is successful, otherwise ``None``. """ if self._child_consents: consents = [] for ...
[ "Commit", "a", "real", "DataSharingConsent", "object", "to", "the", "database", "mirroring", "current", "field", "settings", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/consent/models.py#L153-L177
[ "def", "commit", "(", "self", ")", ":", "if", "self", ".", "_child_consents", ":", "consents", "=", "[", "]", "for", "consent", "in", "self", ".", "_child_consents", ":", "consent", ".", "granted", "=", "self", ".", "granted", "consents", ".", "append", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
Command.send_xapi_statements
Send xAPI analytics data of the enterprise learners to the given LRS. Arguments: lrs_configuration (XAPILRSConfiguration): Configuration object containing LRS configurations of the LRS where to send xAPI learner analytics. days (int): Include course enrollment of this n...
integrated_channels/xapi/management/commands/send_course_completions.py
def send_xapi_statements(self, lrs_configuration, days): """ Send xAPI analytics data of the enterprise learners to the given LRS. Arguments: lrs_configuration (XAPILRSConfiguration): Configuration object containing LRS configurations of the LRS where to send xAPI l...
def send_xapi_statements(self, lrs_configuration, days): """ Send xAPI analytics data of the enterprise learners to the given LRS. Arguments: lrs_configuration (XAPILRSConfiguration): Configuration object containing LRS configurations of the LRS where to send xAPI l...
[ "Send", "xAPI", "analytics", "data", "of", "the", "enterprise", "learners", "to", "the", "given", "LRS", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/management/commands/send_course_completions.py#L122-L147
[ "def", "send_xapi_statements", "(", "self", ",", "lrs_configuration", ",", "days", ")", ":", "persistent_course_grades", "=", "self", ".", "get_course_completions", "(", "lrs_configuration", ".", "enterprise_customer", ",", "days", ")", "users", "=", "self", ".", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
Command.get_course_completions
Get course completions via PersistentCourseGrade for all the learners of given enterprise customer. Arguments: enterprise_customer (EnterpriseCustomer): Include Course enrollments for learners of this enterprise customer. days (int): Include course enrollment of this num...
integrated_channels/xapi/management/commands/send_course_completions.py
def get_course_completions(self, enterprise_customer, days): """ Get course completions via PersistentCourseGrade for all the learners of given enterprise customer. Arguments: enterprise_customer (EnterpriseCustomer): Include Course enrollments for learners of this e...
def get_course_completions(self, enterprise_customer, days): """ Get course completions via PersistentCourseGrade for all the learners of given enterprise customer. Arguments: enterprise_customer (EnterpriseCustomer): Include Course enrollments for learners of this e...
[ "Get", "course", "completions", "via", "PersistentCourseGrade", "for", "all", "the", "learners", "of", "given", "enterprise", "customer", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/management/commands/send_course_completions.py#L149-L165
[ "def", "get_course_completions", "(", "self", ",", "enterprise_customer", ",", "days", ")", ":", "return", "PersistentCourseGrade", ".", "objects", ".", "filter", "(", "passed_timestamp__gt", "=", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "datetime...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
Command.prefetch_users
Prefetch Users from the list of user_ids present in the persistent_course_grades. Arguments: persistent_course_grades (list): A list of PersistentCourseGrade. Returns: (dict): A dictionary containing user_id to user mapping.
integrated_channels/xapi/management/commands/send_course_completions.py
def prefetch_users(persistent_course_grades): """ Prefetch Users from the list of user_ids present in the persistent_course_grades. Arguments: persistent_course_grades (list): A list of PersistentCourseGrade. Returns: (dict): A dictionary containing user_id to u...
def prefetch_users(persistent_course_grades): """ Prefetch Users from the list of user_ids present in the persistent_course_grades. Arguments: persistent_course_grades (list): A list of PersistentCourseGrade. Returns: (dict): A dictionary containing user_id to u...
[ "Prefetch", "Users", "from", "the", "list", "of", "user_ids", "present", "in", "the", "persistent_course_grades", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/management/commands/send_course_completions.py#L168-L183
[ "def", "prefetch_users", "(", "persistent_course_grades", ")", ":", "users", "=", "User", ".", "objects", ".", "filter", "(", "id__in", "=", "[", "grade", ".", "user_id", "for", "grade", "in", "persistent_course_grades", "]", ")", "return", "{", "user", ".",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
create_roles
Create the enterprise roles if they do not already exist.
enterprise/migrations/0065_add_enterprise_feature_roles.py
def create_roles(apps, schema_editor): """Create the enterprise roles if they do not already exist.""" EnterpriseFeatureRole = apps.get_model('enterprise', 'EnterpriseFeatureRole') EnterpriseFeatureRole.objects.update_or_create(name=ENTERPRISE_CATALOG_ADMIN_ROLE) EnterpriseFeatureRole.objects.update_or_...
def create_roles(apps, schema_editor): """Create the enterprise roles if they do not already exist.""" EnterpriseFeatureRole = apps.get_model('enterprise', 'EnterpriseFeatureRole') EnterpriseFeatureRole.objects.update_or_create(name=ENTERPRISE_CATALOG_ADMIN_ROLE) EnterpriseFeatureRole.objects.update_or_...
[ "Create", "the", "enterprise", "roles", "if", "they", "do", "not", "already", "exist", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0065_add_enterprise_feature_roles.py#L13-L18
[ "def", "create_roles", "(", "apps", ",", "schema_editor", ")", ":", "EnterpriseFeatureRole", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'EnterpriseFeatureRole'", ")", "EnterpriseFeatureRole", ".", "objects", ".", "update_or_create", "(", "name", "=", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
delete_roles
Delete the enterprise roles.
enterprise/migrations/0065_add_enterprise_feature_roles.py
def delete_roles(apps, schema_editor): """Delete the enterprise roles.""" EnterpriseFeatureRole = apps.get_model('enterprise', 'EnterpriseFeatureRole') EnterpriseFeatureRole.objects.filter( name__in=[ENTERPRISE_CATALOG_ADMIN_ROLE, ENTERPRISE_DASHBOARD_ADMIN_ROLE, ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE...
def delete_roles(apps, schema_editor): """Delete the enterprise roles.""" EnterpriseFeatureRole = apps.get_model('enterprise', 'EnterpriseFeatureRole') EnterpriseFeatureRole.objects.filter( name__in=[ENTERPRISE_CATALOG_ADMIN_ROLE, ENTERPRISE_DASHBOARD_ADMIN_ROLE, ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE...
[ "Delete", "the", "enterprise", "roles", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0065_add_enterprise_feature_roles.py#L21-L26
[ "def", "delete_roles", "(", "apps", ",", "schema_editor", ")", ":", "EnterpriseFeatureRole", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'EnterpriseFeatureRole'", ")", "EnterpriseFeatureRole", ".", "objects", ".", "filter", "(", "name__in", "=", "[",...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_identity_provider
Get Identity Provider with given id. Return: Instance of ProviderConfig or None.
enterprise/utils.py
def get_identity_provider(provider_id): """ Get Identity Provider with given id. Return: Instance of ProviderConfig or None. """ try: from third_party_auth.provider import Registry # pylint: disable=redefined-outer-name except ImportError as exception: LOGGER.warning("...
def get_identity_provider(provider_id): """ Get Identity Provider with given id. Return: Instance of ProviderConfig or None. """ try: from third_party_auth.provider import Registry # pylint: disable=redefined-outer-name except ImportError as exception: LOGGER.warning("...
[ "Get", "Identity", "Provider", "with", "given", "id", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L114-L131
[ "def", "get_identity_provider", "(", "provider_id", ")", ":", "try", ":", "from", "third_party_auth", ".", "provider", "import", "Registry", "# pylint: disable=redefined-outer-name", "except", "ImportError", "as", "exception", ":", "LOGGER", ".", "warning", "(", "\"Co...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_idp_choices
Get a list of identity providers choices for enterprise customer. Return: A list of choices of all identity providers, None if it can not get any available identity provider.
enterprise/utils.py
def get_idp_choices(): """ Get a list of identity providers choices for enterprise customer. Return: A list of choices of all identity providers, None if it can not get any available identity provider. """ try: from third_party_auth.provider import Registry # pylint: disable=redef...
def get_idp_choices(): """ Get a list of identity providers choices for enterprise customer. Return: A list of choices of all identity providers, None if it can not get any available identity provider. """ try: from third_party_auth.provider import Registry # pylint: disable=redef...
[ "Get", "a", "list", "of", "identity", "providers", "choices", "for", "enterprise", "customer", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L134-L151
[ "def", "get_idp_choices", "(", ")", ":", "try", ":", "from", "third_party_auth", ".", "provider", "import", "Registry", "# pylint: disable=redefined-outer-name", "except", "ImportError", "as", "exception", ":", "LOGGER", ".", "warning", "(", "\"Could not import Registry...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_catalog_admin_url_template
Get template of catalog admin url. URL template will contain a placeholder '{catalog_id}' for catalog id. Arguments: mode e.g. change/add. Returns: A string containing template for catalog url. Example: >>> get_catalog_admin_url_template('change') "http://localhost:183...
enterprise/utils.py
def get_catalog_admin_url_template(mode='change'): """ Get template of catalog admin url. URL template will contain a placeholder '{catalog_id}' for catalog id. Arguments: mode e.g. change/add. Returns: A string containing template for catalog url. Example: >>> get_cat...
def get_catalog_admin_url_template(mode='change'): """ Get template of catalog admin url. URL template will contain a placeholder '{catalog_id}' for catalog id. Arguments: mode e.g. change/add. Returns: A string containing template for catalog url. Example: >>> get_cat...
[ "Get", "template", "of", "catalog", "admin", "url", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L185-L213
[ "def", "get_catalog_admin_url_template", "(", "mode", "=", "'change'", ")", ":", "api_base_url", "=", "getattr", "(", "settings", ",", "\"COURSE_CATALOG_API_URL\"", ",", "\"\"", ")", "# Extract FQDN (Fully Qualified Domain Name) from API URL.", "match", "=", "re", ".", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
build_notification_message
Create HTML and plaintext message bodies for a notification. We receive a context with data we can use to render, as well as an optional site template configration - if we don't get a template configuration, we'll use the standard, built-in template. Arguments: template_context (dict): A set o...
enterprise/utils.py
def build_notification_message(template_context, template_configuration=None): """ Create HTML and plaintext message bodies for a notification. We receive a context with data we can use to render, as well as an optional site template configration - if we don't get a template configuration, we'll use th...
def build_notification_message(template_context, template_configuration=None): """ Create HTML and plaintext message bodies for a notification. We receive a context with data we can use to render, as well as an optional site template configration - if we don't get a template configuration, we'll use th...
[ "Create", "HTML", "and", "plaintext", "message", "bodies", "for", "a", "notification", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L216-L246
[ "def", "build_notification_message", "(", "template_context", ",", "template_configuration", "=", "None", ")", ":", "if", "(", "template_configuration", "is", "not", "None", "and", "template_configuration", ".", "html_template", "and", "template_configuration", ".", "pl...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_notification_subject_line
Get a subject line for a notification email. The method is designed to fail in a "smart" way; if we can't render a database-backed subject line template, then we'll fall back to a template saved in the Django settings; if we can't render _that_ one, then we'll fall through to a friendly string written ...
enterprise/utils.py
def get_notification_subject_line(course_name, template_configuration=None): """ Get a subject line for a notification email. The method is designed to fail in a "smart" way; if we can't render a database-backed subject line template, then we'll fall back to a template saved in the Django settings;...
def get_notification_subject_line(course_name, template_configuration=None): """ Get a subject line for a notification email. The method is designed to fail in a "smart" way; if we can't render a database-backed subject line template, then we'll fall back to a template saved in the Django settings;...
[ "Get", "a", "subject", "line", "for", "a", "notification", "email", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L249-L286
[ "def", "get_notification_subject_line", "(", "course_name", ",", "template_configuration", "=", "None", ")", ":", "stock_subject_template", "=", "_", "(", "'You\\'ve been enrolled in {course_name}!'", ")", "default_subject_template", "=", "getattr", "(", "settings", ",", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
send_email_notification_message
Send an email notifying a user about their enrollment in a course. Arguments: user: Either a User object or a PendingEnterpriseCustomerUser that we can use to get details for the email enrolled_in (dict): The dictionary contains details of the enrollable object (either cours...
enterprise/utils.py
def send_email_notification_message(user, enrolled_in, enterprise_customer, email_connection=None): """ Send an email notifying a user about their enrollment in a course. Arguments: user: Either a User object or a PendingEnterpriseCustomerUser that we can use to get details for the emai...
def send_email_notification_message(user, enrolled_in, enterprise_customer, email_connection=None): """ Send an email notifying a user about their enrollment in a course. Arguments: user: Either a User object or a PendingEnterpriseCustomerUser that we can use to get details for the emai...
[ "Send", "an", "email", "notifying", "a", "user", "about", "their", "enrollment", "in", "a", "course", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L289-L353
[ "def", "send_email_notification_message", "(", "user", ",", "enrolled_in", ",", "enterprise_customer", ",", "email_connection", "=", "None", ")", ":", "if", "hasattr", "(", "user", ",", "'first_name'", ")", "and", "hasattr", "(", "user", ",", "'username'", ")", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_enterprise_customer
Get the ``EnterpriseCustomer`` instance associated with ``uuid``. :param uuid: The universally unique ID of the enterprise customer. :return: The ``EnterpriseCustomer`` instance, or ``None`` if it doesn't exist.
enterprise/utils.py
def get_enterprise_customer(uuid): """ Get the ``EnterpriseCustomer`` instance associated with ``uuid``. :param uuid: The universally unique ID of the enterprise customer. :return: The ``EnterpriseCustomer`` instance, or ``None`` if it doesn't exist. """ EnterpriseCustomer = apps.get_model('ent...
def get_enterprise_customer(uuid): """ Get the ``EnterpriseCustomer`` instance associated with ``uuid``. :param uuid: The universally unique ID of the enterprise customer. :return: The ``EnterpriseCustomer`` instance, or ``None`` if it doesn't exist. """ EnterpriseCustomer = apps.get_model('ent...
[ "Get", "the", "EnterpriseCustomer", "instance", "associated", "with", "uuid", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L356-L367
[ "def", "get_enterprise_customer", "(", "uuid", ")", ":", "EnterpriseCustomer", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'EnterpriseCustomer'", ")", "# pylint: disable=invalid-name", "try", ":", "return", "EnterpriseCustomer", ".", "objects", ".", "get...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_enterprise_customer_for_user
Return enterprise customer instance for given user. Some users are associated with an enterprise customer via `EnterpriseCustomerUser` model, 1. if given user is associated with any enterprise customer, return enterprise customer. 2. otherwise return `None`. Arguments: auth_user (contr...
enterprise/utils.py
def get_enterprise_customer_for_user(auth_user): """ Return enterprise customer instance for given user. Some users are associated with an enterprise customer via `EnterpriseCustomerUser` model, 1. if given user is associated with any enterprise customer, return enterprise customer. 2. othe...
def get_enterprise_customer_for_user(auth_user): """ Return enterprise customer instance for given user. Some users are associated with an enterprise customer via `EnterpriseCustomerUser` model, 1. if given user is associated with any enterprise customer, return enterprise customer. 2. othe...
[ "Return", "enterprise", "customer", "instance", "for", "given", "user", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L370-L389
[ "def", "get_enterprise_customer_for_user", "(", "auth_user", ")", ":", "EnterpriseCustomerUser", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'EnterpriseCustomerUser'", ")", "# pylint: disable=invalid-name", "try", ":", "return", "EnterpriseCustomerUser", ".", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_enterprise_customer_user
Return the object for EnterpriseCustomerUser. Arguments: user_id (str): user identifier enterprise_uuid (UUID): Universally unique identifier for the enterprise customer. Returns: (EnterpriseCustomerUser): enterprise customer user record
enterprise/utils.py
def get_enterprise_customer_user(user_id, enterprise_uuid): """ Return the object for EnterpriseCustomerUser. Arguments: user_id (str): user identifier enterprise_uuid (UUID): Universally unique identifier for the enterprise customer. Returns: (EnterpriseCustomerUser): enterpri...
def get_enterprise_customer_user(user_id, enterprise_uuid): """ Return the object for EnterpriseCustomerUser. Arguments: user_id (str): user identifier enterprise_uuid (UUID): Universally unique identifier for the enterprise customer. Returns: (EnterpriseCustomerUser): enterpri...
[ "Return", "the", "object", "for", "EnterpriseCustomerUser", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L392-L411
[ "def", "get_enterprise_customer_user", "(", "user_id", ",", "enterprise_uuid", ")", ":", "EnterpriseCustomerUser", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'EnterpriseCustomerUser'", ")", "# pylint: disable=invalid-name", "try", ":", "return", "Enterprise...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_course_track_selection_url
Return track selection url for the given course. Arguments: course_run (dict): A dictionary containing course run metadata. query_parameters (dict): A dictionary containing query parameters to be added to course selection url. Raises: (KeyError): Raised when course run dict does not ha...
enterprise/utils.py
def get_course_track_selection_url(course_run, query_parameters): """ Return track selection url for the given course. Arguments: course_run (dict): A dictionary containing course run metadata. query_parameters (dict): A dictionary containing query parameters to be added to course selection...
def get_course_track_selection_url(course_run, query_parameters): """ Return track selection url for the given course. Arguments: course_run (dict): A dictionary containing course run metadata. query_parameters (dict): A dictionary containing query parameters to be added to course selection...
[ "Return", "track", "selection", "url", "for", "the", "given", "course", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L414-L443
[ "def", "get_course_track_selection_url", "(", "course_run", ",", "query_parameters", ")", ":", "try", ":", "course_root", "=", "reverse", "(", "'course_modes_choose'", ",", "kwargs", "=", "{", "'course_id'", ":", "course_run", "[", "'key'", "]", "}", ")", "excep...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
update_query_parameters
Return url with updated query parameters. Arguments: url (str): Original url whose query parameters need to be updated. query_parameters (dict): A dictionary containing query parameters to be added to course selection url. Returns: (slug): slug identifier for the identity provider that...
enterprise/utils.py
def update_query_parameters(url, query_parameters): """ Return url with updated query parameters. Arguments: url (str): Original url whose query parameters need to be updated. query_parameters (dict): A dictionary containing query parameters to be added to course selection url. Returns...
def update_query_parameters(url, query_parameters): """ Return url with updated query parameters. Arguments: url (str): Original url whose query parameters need to be updated. query_parameters (dict): A dictionary containing query parameters to be added to course selection url. Returns...
[ "Return", "url", "with", "updated", "query", "parameters", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L446-L467
[ "def", "update_query_parameters", "(", "url", ",", "query_parameters", ")", ":", "scheme", ",", "netloc", ",", "path", ",", "query_string", ",", "fragment", "=", "urlsplit", "(", "url", ")", "url_params", "=", "parse_qs", "(", "query_string", ")", "# Update ur...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
filter_audit_course_modes
Filter audit course modes out if the enterprise customer has not enabled the 'Enable audit enrollment' flag. Arguments: enterprise_customer: The EnterpriseCustomer that the enrollment was created using. course_modes: iterable with dictionaries containing a required 'mode' key
enterprise/utils.py
def filter_audit_course_modes(enterprise_customer, course_modes): """ Filter audit course modes out if the enterprise customer has not enabled the 'Enable audit enrollment' flag. Arguments: enterprise_customer: The EnterpriseCustomer that the enrollment was created using. course_modes: iter...
def filter_audit_course_modes(enterprise_customer, course_modes): """ Filter audit course modes out if the enterprise customer has not enabled the 'Enable audit enrollment' flag. Arguments: enterprise_customer: The EnterpriseCustomer that the enrollment was created using. course_modes: iter...
[ "Filter", "audit", "course", "modes", "out", "if", "the", "enterprise", "customer", "has", "not", "enabled", "the", "Enable", "audit", "enrollment", "flag", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L470-L482
[ "def", "filter_audit_course_modes", "(", "enterprise_customer", ",", "course_modes", ")", ":", "audit_modes", "=", "getattr", "(", "settings", ",", "'ENTERPRISE_COURSE_ENROLLMENT_AUDIT_MODES'", ",", "[", "'audit'", "]", ")", "if", "not", "enterprise_customer", ".", "e...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_enterprise_customer_or_404
Given an EnterpriseCustomer UUID, return the corresponding EnterpriseCustomer or raise a 404. Arguments: enterprise_uuid (str): The UUID (in string form) of the EnterpriseCustomer to fetch. Returns: (EnterpriseCustomer): The EnterpriseCustomer given the UUID.
enterprise/utils.py
def get_enterprise_customer_or_404(enterprise_uuid): """ Given an EnterpriseCustomer UUID, return the corresponding EnterpriseCustomer or raise a 404. Arguments: enterprise_uuid (str): The UUID (in string form) of the EnterpriseCustomer to fetch. Returns: (EnterpriseCustomer): The Ente...
def get_enterprise_customer_or_404(enterprise_uuid): """ Given an EnterpriseCustomer UUID, return the corresponding EnterpriseCustomer or raise a 404. Arguments: enterprise_uuid (str): The UUID (in string form) of the EnterpriseCustomer to fetch. Returns: (EnterpriseCustomer): The Ente...
[ "Given", "an", "EnterpriseCustomer", "UUID", "return", "the", "corresponding", "EnterpriseCustomer", "or", "raise", "a", "404", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L485-L502
[ "def", "get_enterprise_customer_or_404", "(", "enterprise_uuid", ")", ":", "EnterpriseCustomer", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'EnterpriseCustomer'", ")", "# pylint: disable=invalid-name", "try", ":", "enterprise_uuid", "=", "UUID", "(", "ent...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_cache_key
Get MD5 encoded cache key for given arguments. Here is the format of key before MD5 encryption. key1:value1__key2:value2 ... Example: >>> get_cache_key(site_domain="example.com", resource="enterprise") # Here is key format for above call # "site_domain:example.com__resource:ent...
enterprise/utils.py
def get_cache_key(**kwargs): """ Get MD5 encoded cache key for given arguments. Here is the format of key before MD5 encryption. key1:value1__key2:value2 ... Example: >>> get_cache_key(site_domain="example.com", resource="enterprise") # Here is key format for above call ...
def get_cache_key(**kwargs): """ Get MD5 encoded cache key for given arguments. Here is the format of key before MD5 encryption. key1:value1__key2:value2 ... Example: >>> get_cache_key(site_domain="example.com", resource="enterprise") # Here is key format for above call ...
[ "Get", "MD5", "encoded", "cache", "key", "for", "given", "arguments", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L519-L540
[ "def", "get_cache_key", "(", "*", "*", "kwargs", ")", ":", "key", "=", "'__'", ".", "join", "(", "[", "'{}:{}'", ".", "format", "(", "item", ",", "value", ")", "for", "item", ",", "value", "in", "iteritems", "(", "kwargs", ")", "]", ")", "return", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
traverse_pagination
Traverse a paginated API response. Extracts and concatenates "results" (list of dict) returned by DRF-powered APIs. Arguments: response (Dict): Current response dict from service API endpoint (slumber Resource object): slumber Resource object from edx-rest-api-client Returns: ...
enterprise/utils.py
def traverse_pagination(response, endpoint): """ Traverse a paginated API response. Extracts and concatenates "results" (list of dict) returned by DRF-powered APIs. Arguments: response (Dict): Current response dict from service API endpoint (slumber Resource object): slumber Resour...
def traverse_pagination(response, endpoint): """ Traverse a paginated API response. Extracts and concatenates "results" (list of dict) returned by DRF-powered APIs. Arguments: response (Dict): Current response dict from service API endpoint (slumber Resource object): slumber Resour...
[ "Traverse", "a", "paginated", "API", "response", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L543-L567
[ "def", "traverse_pagination", "(", "response", ",", "endpoint", ")", ":", "results", "=", "response", ".", "get", "(", "'results'", ",", "[", "]", ")", "next_page", "=", "response", ".", "get", "(", "'next'", ")", "while", "next_page", ":", "querystring", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
ungettext_min_max
Return grammatically correct, translated text based off of a minimum and maximum value. Example: min = 1, max = 1, singular = '{} hour required for this course', plural = '{} hours required for this course' output = '1 hour required for this course' min = 2, max = 2, singular = '{} hour re...
enterprise/utils.py
def ungettext_min_max(singular, plural, range_text, min_val, max_val): """ Return grammatically correct, translated text based off of a minimum and maximum value. Example: min = 1, max = 1, singular = '{} hour required for this course', plural = '{} hours required for this course' output = ...
def ungettext_min_max(singular, plural, range_text, min_val, max_val): """ Return grammatically correct, translated text based off of a minimum and maximum value. Example: min = 1, max = 1, singular = '{} hour required for this course', plural = '{} hours required for this course' output = ...
[ "Return", "grammatically", "correct", "translated", "text", "based", "off", "of", "a", "minimum", "and", "maximum", "value", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L570-L600
[ "def", "ungettext_min_max", "(", "singular", ",", "plural", ",", "range_text", ",", "min_val", ",", "max_val", ")", ":", "if", "min_val", "is", "None", "and", "max_val", "is", "None", ":", "return", "None", "if", "min_val", "==", "max_val", "or", "min_val"...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
format_price
Format the price to have the appropriate currency and digits.. :param price: The price amount. :param currency: The currency for the price. :return: A formatted price string, i.e. '$10', '$10.52'.
enterprise/utils.py
def format_price(price, currency='$'): """ Format the price to have the appropriate currency and digits.. :param price: The price amount. :param currency: The currency for the price. :return: A formatted price string, i.e. '$10', '$10.52'. """ if int(price) == price: return '{}{}'.f...
def format_price(price, currency='$'): """ Format the price to have the appropriate currency and digits.. :param price: The price amount. :param currency: The currency for the price. :return: A formatted price string, i.e. '$10', '$10.52'. """ if int(price) == price: return '{}{}'.f...
[ "Format", "the", "price", "to", "have", "the", "appropriate", "currency", "and", "digits", ".." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L603-L613
[ "def", "format_price", "(", "price", ",", "currency", "=", "'$'", ")", ":", "if", "int", "(", "price", ")", "==", "price", ":", "return", "'{}{}'", ".", "format", "(", "currency", ",", "int", "(", "price", ")", ")", "return", "'{}{:0.2f}'", ".", "for...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_configuration_value_for_site
Get the site configuration value for a key, unless a site configuration does not exist for that site. Useful for testing when no Site Configuration exists in edx-enterprise or if a site in LMS doesn't have a configuration tied to it. :param site: A Site model object :param key: The name of the value t...
enterprise/utils.py
def get_configuration_value_for_site(site, key, default=None): """ Get the site configuration value for a key, unless a site configuration does not exist for that site. Useful for testing when no Site Configuration exists in edx-enterprise or if a site in LMS doesn't have a configuration tied to it. ...
def get_configuration_value_for_site(site, key, default=None): """ Get the site configuration value for a key, unless a site configuration does not exist for that site. Useful for testing when no Site Configuration exists in edx-enterprise or if a site in LMS doesn't have a configuration tied to it. ...
[ "Get", "the", "site", "configuration", "value", "for", "a", "key", "unless", "a", "site", "configuration", "does", "not", "exist", "for", "that", "site", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L616-L630
[ "def", "get_configuration_value_for_site", "(", "site", ",", "key", ",", "default", "=", "None", ")", ":", "if", "hasattr", "(", "site", ",", "'configuration'", ")", ":", "return", "site", ".", "configuration", ".", "get_value", "(", "key", ",", "default", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_configuration_value
Get a configuration value, or fall back to ``default`` if it doesn't exist. Also takes a `type` argument to guide which particular upstream method to use when trying to retrieve a value. Current types include: - `url` to specifically get a URL.
enterprise/utils.py
def get_configuration_value(val_name, default=None, **kwargs): """ Get a configuration value, or fall back to ``default`` if it doesn't exist. Also takes a `type` argument to guide which particular upstream method to use when trying to retrieve a value. Current types include: - `url` to specifi...
def get_configuration_value(val_name, default=None, **kwargs): """ Get a configuration value, or fall back to ``default`` if it doesn't exist. Also takes a `type` argument to guide which particular upstream method to use when trying to retrieve a value. Current types include: - `url` to specifi...
[ "Get", "a", "configuration", "value", "or", "fall", "back", "to", "default", "if", "it", "doesn", "t", "exist", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L633-L643
[ "def", "get_configuration_value", "(", "val_name", ",", "default", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ".", "get", "(", "'type'", ")", "==", "'url'", ":", "return", "get_url", "(", "val_name", ")", "or", "default", "if", "ca...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_request_value
Get the value in the request, either through query parameters or posted data, from a key. :param request: The request from which the value should be gotten. :param key: The key to use to get the desired value. :param default: The backup value to use in case the input key cannot help us get the value. :...
enterprise/utils.py
def get_request_value(request, key, default=None): """ Get the value in the request, either through query parameters or posted data, from a key. :param request: The request from which the value should be gotten. :param key: The key to use to get the desired value. :param default: The backup value t...
def get_request_value(request, key, default=None): """ Get the value in the request, either through query parameters or posted data, from a key. :param request: The request from which the value should be gotten. :param key: The key to use to get the desired value. :param default: The backup value t...
[ "Get", "the", "value", "in", "the", "request", "either", "through", "query", "parameters", "or", "posted", "data", "from", "a", "key", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L646-L657
[ "def", "get_request_value", "(", "request", ",", "key", ",", "default", "=", "None", ")", ":", "if", "request", ".", "method", "in", "[", "'GET'", ",", "'DELETE'", "]", ":", "return", "request", ".", "query_params", ".", "get", "(", "key", ",", "reques...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
track_event
Emit a track event to segment (and forwarded to GA) for some parts of the Enterprise workflows.
enterprise/utils.py
def track_event(user_id, event_name, properties): """ Emit a track event to segment (and forwarded to GA) for some parts of the Enterprise workflows. """ # Only call the endpoint if the import was successful. if segment: segment.track(user_id, event_name, properties)
def track_event(user_id, event_name, properties): """ Emit a track event to segment (and forwarded to GA) for some parts of the Enterprise workflows. """ # Only call the endpoint if the import was successful. if segment: segment.track(user_id, event_name, properties)
[ "Emit", "a", "track", "event", "to", "segment", "(", "and", "forwarded", "to", "GA", ")", "for", "some", "parts", "of", "the", "Enterprise", "workflows", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L685-L691
[ "def", "track_event", "(", "user_id", ",", "event_name", ",", "properties", ")", ":", "# Only call the endpoint if the import was successful.", "if", "segment", ":", "segment", ".", "track", "(", "user_id", ",", "event_name", ",", "properties", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
track_enrollment
Emit a track event for enterprise course enrollment.
enterprise/utils.py
def track_enrollment(pathway, user_id, course_run_id, url_path=None): """ Emit a track event for enterprise course enrollment. """ track_event(user_id, 'edx.bi.user.enterprise.onboarding', { 'pathway': pathway, 'url_path': url_path, 'course_run_id': course_run_id, })
def track_enrollment(pathway, user_id, course_run_id, url_path=None): """ Emit a track event for enterprise course enrollment. """ track_event(user_id, 'edx.bi.user.enterprise.onboarding', { 'pathway': pathway, 'url_path': url_path, 'course_run_id': course_run_id, })
[ "Emit", "a", "track", "event", "for", "enterprise", "course", "enrollment", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L694-L702
[ "def", "track_enrollment", "(", "pathway", ",", "user_id", ",", "course_run_id", ",", "url_path", "=", "None", ")", ":", "track_event", "(", "user_id", ",", "'edx.bi.user.enterprise.onboarding'", ",", "{", "'pathway'", ":", "pathway", ",", "'url_path'", ":", "ur...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
is_course_run_enrollable
Return true if the course run is enrollable, false otherwise. We look for the following criteria: - end is greater than now OR null - enrollment_start is less than now OR null - enrollment_end is greater than now OR null
enterprise/utils.py
def is_course_run_enrollable(course_run): """ Return true if the course run is enrollable, false otherwise. We look for the following criteria: - end is greater than now OR null - enrollment_start is less than now OR null - enrollment_end is greater than now OR null """ now = datetime.d...
def is_course_run_enrollable(course_run): """ Return true if the course run is enrollable, false otherwise. We look for the following criteria: - end is greater than now OR null - enrollment_start is less than now OR null - enrollment_end is greater than now OR null """ now = datetime.d...
[ "Return", "true", "if", "the", "course", "run", "is", "enrollable", "false", "otherwise", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L715-L730
[ "def", "is_course_run_enrollable", "(", "course_run", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", "pytz", ".", "UTC", ")", "end", "=", "parse_datetime_handle_invalid", "(", "course_run", ".", "get", "(", "'end'", ")", ")", "enrollment...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
is_course_run_upgradeable
Return true if the course run has a verified seat with an unexpired upgrade deadline, false otherwise.
enterprise/utils.py
def is_course_run_upgradeable(course_run): """ Return true if the course run has a verified seat with an unexpired upgrade deadline, false otherwise. """ now = datetime.datetime.now(pytz.UTC) for seat in course_run.get('seats', []): if seat.get('type') == 'verified': upgrade_dead...
def is_course_run_upgradeable(course_run): """ Return true if the course run has a verified seat with an unexpired upgrade deadline, false otherwise. """ now = datetime.datetime.now(pytz.UTC) for seat in course_run.get('seats', []): if seat.get('type') == 'verified': upgrade_dead...
[ "Return", "true", "if", "the", "course", "run", "has", "a", "verified", "seat", "with", "an", "unexpired", "upgrade", "deadline", "false", "otherwise", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L733-L742
[ "def", "is_course_run_upgradeable", "(", "course_run", ")", ":", "now", "=", "datetime", ".", "datetime", ".", "now", "(", "pytz", ".", "UTC", ")", "for", "seat", "in", "course_run", ".", "get", "(", "'seats'", ",", "[", "]", ")", ":", "if", "seat", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_closest_course_run
Return course run with start date closest to now.
enterprise/utils.py
def get_closest_course_run(course_runs): """ Return course run with start date closest to now. """ if len(course_runs) == 1: return course_runs[0] now = datetime.datetime.now(pytz.UTC) # course runs with no start date should be considered last. never = now - datetime.timedelta(days=...
def get_closest_course_run(course_runs): """ Return course run with start date closest to now. """ if len(course_runs) == 1: return course_runs[0] now = datetime.datetime.now(pytz.UTC) # course runs with no start date should be considered last. never = now - datetime.timedelta(days=...
[ "Return", "course", "run", "with", "start", "date", "closest", "to", "now", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L752-L762
[ "def", "get_closest_course_run", "(", "course_runs", ")", ":", "if", "len", "(", "course_runs", ")", "==", "1", ":", "return", "course_runs", "[", "0", "]", "now", "=", "datetime", ".", "datetime", ".", "now", "(", "pytz", ".", "UTC", ")", "# course runs...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_active_course_runs
Return active course runs (user is enrolled in) of the given course. This function will return the course_runs of 'course' which have active enrollment by looking into 'users_all_enrolled_courses'
enterprise/utils.py
def get_active_course_runs(course, users_all_enrolled_courses): """ Return active course runs (user is enrolled in) of the given course. This function will return the course_runs of 'course' which have active enrollment by looking into 'users_all_enrolled_courses' """ # User's all course_run id...
def get_active_course_runs(course, users_all_enrolled_courses): """ Return active course runs (user is enrolled in) of the given course. This function will return the course_runs of 'course' which have active enrollment by looking into 'users_all_enrolled_courses' """ # User's all course_run id...
[ "Return", "active", "course", "runs", "(", "user", "is", "enrolled", "in", ")", "of", "the", "given", "course", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L765-L777
[ "def", "get_active_course_runs", "(", "course", ",", "users_all_enrolled_courses", ")", ":", "# User's all course_run ids in which he has enrolled.", "enrolled_course_run_ids", "=", "[", "enrolled_course_run", "[", "'course_details'", "]", "[", "'course_id'", "]", "for", "enr...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_current_course_run
Return the current course run on the following conditions. - If user has active course runs (already enrolled) then return course run with closest start date Otherwise it will check the following logic: - Course run is enrollable (see is_course_run_enrollable) - Course run has a verified seat and the u...
enterprise/utils.py
def get_current_course_run(course, users_active_course_runs): """ Return the current course run on the following conditions. - If user has active course runs (already enrolled) then return course run with closest start date Otherwise it will check the following logic: - Course run is enrollable (se...
def get_current_course_run(course, users_active_course_runs): """ Return the current course run on the following conditions. - If user has active course runs (already enrolled) then return course run with closest start date Otherwise it will check the following logic: - Course run is enrollable (se...
[ "Return", "the", "current", "course", "run", "on", "the", "following", "conditions", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L780-L808
[ "def", "get_current_course_run", "(", "course", ",", "users_active_course_runs", ")", ":", "current_course_run", "=", "None", "filtered_course_runs", "=", "[", "]", "all_course_runs", "=", "course", "[", "'course_runs'", "]", "if", "users_active_course_runs", ":", "cu...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
strip_html_tags
Strip all tags from a string except those tags provided in `allowed_tags` parameter. Args: text (str): string to strip html tags from allowed_tags (list): allowed list of html tags Returns: a string without html tags
enterprise/utils.py
def strip_html_tags(text, allowed_tags=None): """ Strip all tags from a string except those tags provided in `allowed_tags` parameter. Args: text (str): string to strip html tags from allowed_tags (list): allowed list of html tags Returns: a string without html tags """ if text...
def strip_html_tags(text, allowed_tags=None): """ Strip all tags from a string except those tags provided in `allowed_tags` parameter. Args: text (str): string to strip html tags from allowed_tags (list): allowed list of html tags Returns: a string without html tags """ if text...
[ "Strip", "all", "tags", "from", "a", "string", "except", "those", "tags", "provided", "in", "allowed_tags", "parameter", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L811-L825
[ "def", "strip_html_tags", "(", "text", ",", "allowed_tags", "=", "None", ")", ":", "if", "text", "is", "None", ":", "return", "if", "allowed_tags", "is", "None", ":", "allowed_tags", "=", "ALLOWED_TAGS", "return", "bleach", ".", "clean", "(", "text", ",", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
parse_course_key
Return the serialized course key given either a course run ID or course key.
enterprise/utils.py
def parse_course_key(course_identifier): """ Return the serialized course key given either a course run ID or course key. """ try: course_run_key = CourseKey.from_string(course_identifier) except InvalidKeyError: # Assume we already have a course key. return course_identifier...
def parse_course_key(course_identifier): """ Return the serialized course key given either a course run ID or course key. """ try: course_run_key = CourseKey.from_string(course_identifier) except InvalidKeyError: # Assume we already have a course key. return course_identifier...
[ "Return", "the", "serialized", "course", "key", "given", "either", "a", "course", "run", "ID", "or", "course", "key", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/utils.py#L828-L838
[ "def", "parse_course_key", "(", "course_identifier", ")", ":", "try", ":", "course_run_key", "=", "CourseKey", ".", "from_string", "(", "course_identifier", ")", "except", "InvalidKeyError", ":", "# Assume we already have a course key.", "return", "course_identifier", "re...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
create_roles
Create the enterprise roles if they do not already exist.
enterprise/migrations/0066_add_system_wide_enterprise_operator_role.py
def create_roles(apps, schema_editor): """Create the enterprise roles if they do not already exist.""" SystemWideEnterpriseRole = apps.get_model('enterprise', 'SystemWideEnterpriseRole') SystemWideEnterpriseRole.objects.update_or_create(name=ENTERPRISE_OPERATOR_ROLE)
def create_roles(apps, schema_editor): """Create the enterprise roles if they do not already exist.""" SystemWideEnterpriseRole = apps.get_model('enterprise', 'SystemWideEnterpriseRole') SystemWideEnterpriseRole.objects.update_or_create(name=ENTERPRISE_OPERATOR_ROLE)
[ "Create", "the", "enterprise", "roles", "if", "they", "do", "not", "already", "exist", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0066_add_system_wide_enterprise_operator_role.py#L10-L13
[ "def", "create_roles", "(", "apps", ",", "schema_editor", ")", ":", "SystemWideEnterpriseRole", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'SystemWideEnterpriseRole'", ")", "SystemWideEnterpriseRole", ".", "objects", ".", "update_or_create", "(", "name"...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
delete_roles
Delete the enterprise roles.
enterprise/migrations/0066_add_system_wide_enterprise_operator_role.py
def delete_roles(apps, schema_editor): """Delete the enterprise roles.""" SystemWideEnterpriseRole = apps.get_model('enterprise', 'SystemWideEnterpriseRole') SystemWideEnterpriseRole.objects.filter( name__in=[ENTERPRISE_OPERATOR_ROLE] ).delete()
def delete_roles(apps, schema_editor): """Delete the enterprise roles.""" SystemWideEnterpriseRole = apps.get_model('enterprise', 'SystemWideEnterpriseRole') SystemWideEnterpriseRole.objects.filter( name__in=[ENTERPRISE_OPERATOR_ROLE] ).delete()
[ "Delete", "the", "enterprise", "roles", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/migrations/0066_add_system_wide_enterprise_operator_role.py#L16-L21
[ "def", "delete_roles", "(", "apps", ",", "schema_editor", ")", ":", "SystemWideEnterpriseRole", "=", "apps", ".", "get_model", "(", "'enterprise'", ",", "'SystemWideEnterpriseRole'", ")", "SystemWideEnterpriseRole", ".", "objects", ".", "filter", "(", "name__in", "=...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseXAPIClient.lrs
LRS client instance to be used for sending statements.
integrated_channels/xapi/client.py
def lrs(self): """ LRS client instance to be used for sending statements. """ return RemoteLRS( version=self.lrs_configuration.version, endpoint=self.lrs_configuration.endpoint, auth=self.lrs_configuration.authorization_header, )
def lrs(self): """ LRS client instance to be used for sending statements. """ return RemoteLRS( version=self.lrs_configuration.version, endpoint=self.lrs_configuration.endpoint, auth=self.lrs_configuration.authorization_header, )
[ "LRS", "client", "instance", "to", "be", "used", "for", "sending", "statements", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/client.py#L32-L40
[ "def", "lrs", "(", "self", ")", ":", "return", "RemoteLRS", "(", "version", "=", "self", ".", "lrs_configuration", ".", "version", ",", "endpoint", "=", "self", ".", "lrs_configuration", ".", "endpoint", ",", "auth", "=", "self", ".", "lrs_configuration", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseXAPIClient.save_statement
Save xAPI statement. Arguments: statement (EnterpriseStatement): xAPI Statement to send to the LRS. Raises: ClientError: If xAPI statement fails to save.
integrated_channels/xapi/client.py
def save_statement(self, statement): """ Save xAPI statement. Arguments: statement (EnterpriseStatement): xAPI Statement to send to the LRS. Raises: ClientError: If xAPI statement fails to save. """ response = self.lrs.save_statement(statement) ...
def save_statement(self, statement): """ Save xAPI statement. Arguments: statement (EnterpriseStatement): xAPI Statement to send to the LRS. Raises: ClientError: If xAPI statement fails to save. """ response = self.lrs.save_statement(statement) ...
[ "Save", "xAPI", "statement", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/xapi/client.py#L42-L55
[ "def", "save_statement", "(", "self", ",", "statement", ")", ":", "response", "=", "self", ".", "lrs", ".", "save_statement", "(", "statement", ")", "if", "not", "response", ":", "raise", "ClientError", "(", "'EnterpriseXAPIClient request failed.'", ")" ]
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
SapSuccessFactorsLearnerExporter.get_learner_data_records
Return a SapSuccessFactorsLearnerDataTransmissionAudit with the given enrollment and course completion data. If completed_date is None and the learner isn't passing, then course completion has not been met. If no remote ID can be found, return None.
integrated_channels/sap_success_factors/exporters/learner_data.py
def get_learner_data_records(self, enterprise_enrollment, completed_date=None, grade=None, is_passing=False): """ Return a SapSuccessFactorsLearnerDataTransmissionAudit with the given enrollment and course completion data. If completed_date is None and the learner isn't passing, then course com...
def get_learner_data_records(self, enterprise_enrollment, completed_date=None, grade=None, is_passing=False): """ Return a SapSuccessFactorsLearnerDataTransmissionAudit with the given enrollment and course completion data. If completed_date is None and the learner isn't passing, then course com...
[ "Return", "a", "SapSuccessFactorsLearnerDataTransmissionAudit", "with", "the", "given", "enrollment", "and", "course", "completion", "data", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/exporters/learner_data.py#L28-L73
[ "def", "get_learner_data_records", "(", "self", ",", "enterprise_enrollment", ",", "completed_date", "=", "None", ",", "grade", "=", "None", ",", "is_passing", "=", "False", ")", ":", "completed_timestamp", "=", "None", "course_completed", "=", "False", "if", "c...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
SapSuccessFactorsLearnerManger.unlink_learners
Iterate over each learner and unlink inactive SAP channel learners. This method iterates over each enterprise learner and unlink learner from the enterprise if the learner is marked inactive in the related integrated channel.
integrated_channels/sap_success_factors/exporters/learner_data.py
def unlink_learners(self): """ Iterate over each learner and unlink inactive SAP channel learners. This method iterates over each enterprise learner and unlink learner from the enterprise if the learner is marked inactive in the related integrated channel. """ sa...
def unlink_learners(self): """ Iterate over each learner and unlink inactive SAP channel learners. This method iterates over each enterprise learner and unlink learner from the enterprise if the learner is marked inactive in the related integrated channel. """ sa...
[ "Iterate", "over", "each", "learner", "and", "unlink", "inactive", "SAP", "channel", "learners", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/exporters/learner_data.py#L92-L134
[ "def", "unlink_learners", "(", "self", ")", ":", "sap_inactive_learners", "=", "self", ".", "client", ".", "get_inactive_sap_learners", "(", ")", "enterprise_customer", "=", "self", ".", "enterprise_configuration", ".", "enterprise_customer", "if", "not", "sap_inactiv...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
has_implicit_access_to_dashboard
Check that if request user has implicit access to `ENTERPRISE_DASHBOARD_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not
enterprise/rules.py
def has_implicit_access_to_dashboard(user, obj): # pylint: disable=unused-argument """ Check that if request user has implicit access to `ENTERPRISE_DASHBOARD_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not """ request = get_request_or_stub() deco...
def has_implicit_access_to_dashboard(user, obj): # pylint: disable=unused-argument """ Check that if request user has implicit access to `ENTERPRISE_DASHBOARD_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not """ request = get_request_or_stub() deco...
[ "Check", "that", "if", "request", "user", "has", "implicit", "access", "to", "ENTERPRISE_DASHBOARD_ADMIN_ROLE", "feature", "role", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/rules.py#L25-L34
[ "def", "has_implicit_access_to_dashboard", "(", "user", ",", "obj", ")", ":", "# pylint: disable=unused-argument", "request", "=", "get_request_or_stub", "(", ")", "decoded_jwt", "=", "get_decoded_jwt_from_request", "(", "request", ")", "return", "request_user_has_implicit_...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
has_implicit_access_to_catalog
Check that if request user has implicit access to `ENTERPRISE_CATALOG_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not
enterprise/rules.py
def has_implicit_access_to_catalog(user, obj): # pylint: disable=unused-argument """ Check that if request user has implicit access to `ENTERPRISE_CATALOG_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not """ request = get_request_or_stub() decoded_...
def has_implicit_access_to_catalog(user, obj): # pylint: disable=unused-argument """ Check that if request user has implicit access to `ENTERPRISE_CATALOG_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not """ request = get_request_or_stub() decoded_...
[ "Check", "that", "if", "request", "user", "has", "implicit", "access", "to", "ENTERPRISE_CATALOG_ADMIN_ROLE", "feature", "role", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/rules.py#L53-L62
[ "def", "has_implicit_access_to_catalog", "(", "user", ",", "obj", ")", ":", "# pylint: disable=unused-argument", "request", "=", "get_request_or_stub", "(", ")", "decoded_jwt", "=", "get_decoded_jwt_from_request", "(", "request", ")", "return", "request_user_has_implicit_ac...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
has_implicit_access_to_enrollment_api
Check that if request user has implicit access to `ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not
enterprise/rules.py
def has_implicit_access_to_enrollment_api(user, obj): # pylint: disable=unused-argument """ Check that if request user has implicit access to `ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not """ request = get_request_or_stub(...
def has_implicit_access_to_enrollment_api(user, obj): # pylint: disable=unused-argument """ Check that if request user has implicit access to `ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE` feature role. Returns: boolean: whether the request user has access or not """ request = get_request_or_stub(...
[ "Check", "that", "if", "request", "user", "has", "implicit", "access", "to", "ENTERPRISE_ENROLLMENT_API_ADMIN_ROLE", "feature", "role", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/rules.py#L82-L91
[ "def", "has_implicit_access_to_enrollment_api", "(", "user", ",", "obj", ")", ":", "# pylint: disable=unused-argument", "request", "=", "get_request_or_stub", "(", ")", "decoded_jwt", "=", "get_decoded_jwt_from_request", "(", "request", ")", "return", "request_user_has_impl...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
transform_language_code
Transform ISO language code (e.g. en-us) to the language name expected by SAPSF.
integrated_channels/sap_success_factors/exporters/utils.py
def transform_language_code(code): """ Transform ISO language code (e.g. en-us) to the language name expected by SAPSF. """ if code is None: return 'English' components = code.split('-', 2) language_code = components[0] try: country_code = components[1] except IndexError...
def transform_language_code(code): """ Transform ISO language code (e.g. en-us) to the language name expected by SAPSF. """ if code is None: return 'English' components = code.split('-', 2) language_code = components[0] try: country_code = components[1] except IndexError...
[ "Transform", "ISO", "language", "code", "(", "e", ".", "g", ".", "en", "-", "us", ")", "to", "the", "language", "name", "expected", "by", "SAPSF", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/exporters/utils.py#L29-L47
[ "def", "transform_language_code", "(", "code", ")", ":", "if", "code", "is", "None", ":", "return", "'English'", "components", "=", "code", ".", "split", "(", "'-'", ",", "2", ")", "language_code", "=", "components", "[", "0", "]", "try", ":", "country_c...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
EnterpriseCustomerEntitlementInline.ecommerce_coupon_url
Instance is EnterpriseCustomer. Return e-commerce coupon urls.
enterprise/admin/__init__.py
def ecommerce_coupon_url(self, instance): """ Instance is EnterpriseCustomer. Return e-commerce coupon urls. """ if not instance.entitlement_id: return "N/A" return format_html( '<a href="{base_url}/coupons/{id}" target="_blank">View coupon "{id}" details...
def ecommerce_coupon_url(self, instance): """ Instance is EnterpriseCustomer. Return e-commerce coupon urls. """ if not instance.entitlement_id: return "N/A" return format_html( '<a href="{base_url}/coupons/{id}" target="_blank">View coupon "{id}" details...
[ "Instance", "is", "EnterpriseCustomer", ".", "Return", "e", "-", "commerce", "coupon", "urls", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/__init__.py#L100-L110
[ "def", "ecommerce_coupon_url", "(", "self", ",", "instance", ")", ":", "if", "not", "instance", ".", "entitlement_id", ":", "return", "\"N/A\"", "return", "format_html", "(", "'<a href=\"{base_url}/coupons/{id}\" target=\"_blank\">View coupon \"{id}\" details</a>'", ",", "b...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
dropHistoricalTable
Drops the historical sap_success_factors table named herein.
integrated_channels/sap_success_factors/migrations/0014_drop_historical_table.py
def dropHistoricalTable(apps, schema_editor): """ Drops the historical sap_success_factors table named herein. """ table_name = 'sap_success_factors_historicalsapsuccessfactorsenterprisecus80ad' if table_name in connection.introspection.table_names(): migrations.DeleteModel( name...
def dropHistoricalTable(apps, schema_editor): """ Drops the historical sap_success_factors table named herein. """ table_name = 'sap_success_factors_historicalsapsuccessfactorsenterprisecus80ad' if table_name in connection.introspection.table_names(): migrations.DeleteModel( name...
[ "Drops", "the", "historical", "sap_success_factors", "table", "named", "herein", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/sap_success_factors/migrations/0014_drop_historical_table.py#L7-L15
[ "def", "dropHistoricalTable", "(", "apps", ",", "schema_editor", ")", ":", "table_name", "=", "'sap_success_factors_historicalsapsuccessfactorsenterprisecus80ad'", "if", "table_name", "in", "connection", ".", "introspection", ".", "table_names", "(", ")", ":", "migrations...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
Command.handle
Transmit the learner data for the EnterpriseCustomer(s) to the active integration channels.
integrated_channels/integrated_channel/management/commands/transmit_learner_data.py
def handle(self, *args, **options): """ Transmit the learner data for the EnterpriseCustomer(s) to the active integration channels. """ # Ensure that we were given an api_user name, and that User exists. api_username = options['api_user'] try: User.objects.get...
def handle(self, *args, **options): """ Transmit the learner data for the EnterpriseCustomer(s) to the active integration channels. """ # Ensure that we were given an api_user name, and that User exists. api_username = options['api_user'] try: User.objects.get...
[ "Transmit", "the", "learner", "data", "for", "the", "EnterpriseCustomer", "(", "s", ")", "to", "the", "active", "integration", "channels", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/integrated_channels/integrated_channel/management/commands/transmit_learner_data.py#L40-L53
[ "def", "handle", "(", "self", ",", "*", "args", ",", "*", "*", "options", ")", ":", "# Ensure that we were given an api_user name, and that User exists.", "api_username", "=", "options", "[", "'api_user'", "]", "try", ":", "User", ".", "objects", ".", "get", "("...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
export_as_csv_action
Return an export csv action. Arguments: description (string): action description fields ([string]): list of model fields to include header (bool): whether or not to output the column names as the first row
enterprise/admin/actions.py
def export_as_csv_action(description="Export selected objects as CSV file", fields=None, header=True): """ Return an export csv action. Arguments: description (string): action description fields ([string]): list of model fields to include header (bool): whether or not to output the ...
def export_as_csv_action(description="Export selected objects as CSV file", fields=None, header=True): """ Return an export csv action. Arguments: description (string): action description fields ([string]): list of model fields to include header (bool): whether or not to output the ...
[ "Return", "an", "export", "csv", "action", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/actions.py#L16-L63
[ "def", "export_as_csv_action", "(", "description", "=", "\"Export selected objects as CSV file\"", ",", "fields", "=", "None", ",", "header", "=", "True", ")", ":", "# adapted from https://gist.github.com/mgerring/3645889", "def", "export_as_csv", "(", "modeladmin", ",", ...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
get_clear_catalog_id_action
Return the action method to clear the catalog ID for a EnterpriseCustomer.
enterprise/admin/actions.py
def get_clear_catalog_id_action(description=None): """ Return the action method to clear the catalog ID for a EnterpriseCustomer. """ description = description or _("Unlink selected objects from existing course catalogs") def clear_catalog_id(modeladmin, request, queryset): # pylint: disable=unuse...
def get_clear_catalog_id_action(description=None): """ Return the action method to clear the catalog ID for a EnterpriseCustomer. """ description = description or _("Unlink selected objects from existing course catalogs") def clear_catalog_id(modeladmin, request, queryset): # pylint: disable=unuse...
[ "Return", "the", "action", "method", "to", "clear", "the", "catalog", "ID", "for", "a", "EnterpriseCustomer", "." ]
edx/edx-enterprise
python
https://github.com/edx/edx-enterprise/blob/aea91379ab0a87cd3bc798961fce28b60ee49a80/enterprise/admin/actions.py#L66-L78
[ "def", "get_clear_catalog_id_action", "(", "description", "=", "None", ")", ":", "description", "=", "description", "or", "_", "(", "\"Unlink selected objects from existing course catalogs\"", ")", "def", "clear_catalog_id", "(", "modeladmin", ",", "request", ",", "quer...
aea91379ab0a87cd3bc798961fce28b60ee49a80
valid
Account._login
Login to pybotvac account using provided email and password. :param email: email for pybotvac account :param password: Password for pybotvac account :return:
pybotvac/account.py
def _login(self, email, password): """ Login to pybotvac account using provided email and password. :param email: email for pybotvac account :param password: Password for pybotvac account :return: """ response = requests.post(urljoin(self.ENDPOINT, 'sessions'), ...
def _login(self, email, password): """ Login to pybotvac account using provided email and password. :param email: email for pybotvac account :param password: Password for pybotvac account :return: """ response = requests.post(urljoin(self.ENDPOINT, 'sessions'), ...
[ "Login", "to", "pybotvac", "account", "using", "provided", "email", "and", "password", "." ]
stianaske/pybotvac
python
https://github.com/stianaske/pybotvac/blob/e3f655e81070ff209aaa4efb7880016cf2599e6d/pybotvac/account.py#L36-L54
[ "def", "_login", "(", "self", ",", "email", ",", "password", ")", ":", "response", "=", "requests", ".", "post", "(", "urljoin", "(", "self", ".", "ENDPOINT", ",", "'sessions'", ")", ",", "json", "=", "{", "'email'", ":", "email", ",", "'password'", ...
e3f655e81070ff209aaa4efb7880016cf2599e6d
valid
Account.refresh_maps
Get information about maps of the robots. :return:
pybotvac/account.py
def refresh_maps(self): """ Get information about maps of the robots. :return: """ for robot in self.robots: resp2 = ( requests.get(urljoin(self.ENDPOINT, 'users/me/robots/{}/maps'.format(robot.serial)), headers=self._head...
def refresh_maps(self): """ Get information about maps of the robots. :return: """ for robot in self.robots: resp2 = ( requests.get(urljoin(self.ENDPOINT, 'users/me/robots/{}/maps'.format(robot.serial)), headers=self._head...
[ "Get", "information", "about", "maps", "of", "the", "robots", "." ]
stianaske/pybotvac
python
https://github.com/stianaske/pybotvac/blob/e3f655e81070ff209aaa4efb7880016cf2599e6d/pybotvac/account.py#L79-L90
[ "def", "refresh_maps", "(", "self", ")", ":", "for", "robot", "in", "self", ".", "robots", ":", "resp2", "=", "(", "requests", ".", "get", "(", "urljoin", "(", "self", ".", "ENDPOINT", ",", "'users/me/robots/{}/maps'", ".", "format", "(", "robot", ".", ...
e3f655e81070ff209aaa4efb7880016cf2599e6d
valid
Account.refresh_robots
Get information about robots connected to account. :return:
pybotvac/account.py
def refresh_robots(self): """ Get information about robots connected to account. :return: """ resp = requests.get(urljoin(self.ENDPOINT, 'dashboard'), headers=self._headers) resp.raise_for_status() for robot in resp.json()['robots']: ...
def refresh_robots(self): """ Get information about robots connected to account. :return: """ resp = requests.get(urljoin(self.ENDPOINT, 'dashboard'), headers=self._headers) resp.raise_for_status() for robot in resp.json()['robots']: ...
[ "Get", "information", "about", "robots", "connected", "to", "account", "." ]
stianaske/pybotvac
python
https://github.com/stianaske/pybotvac/blob/e3f655e81070ff209aaa4efb7880016cf2599e6d/pybotvac/account.py#L92-L118
[ "def", "refresh_robots", "(", "self", ")", ":", "resp", "=", "requests", ".", "get", "(", "urljoin", "(", "self", ".", "ENDPOINT", ",", "'dashboard'", ")", ",", "headers", "=", "self", ".", "_headers", ")", "resp", ".", "raise_for_status", "(", ")", "f...
e3f655e81070ff209aaa4efb7880016cf2599e6d
valid
Account.get_map_image
Return a requested map from a robot. :return:
pybotvac/account.py
def get_map_image(url, dest_path=None): """ Return a requested map from a robot. :return: """ image = requests.get(url, stream=True, timeout=10) if dest_path: image_url = url.rsplit('/', 2)[1] + '-' + url.rsplit('/', 1)[1] image_filename = image_...
def get_map_image(url, dest_path=None): """ Return a requested map from a robot. :return: """ image = requests.get(url, stream=True, timeout=10) if dest_path: image_url = url.rsplit('/', 2)[1] + '-' + url.rsplit('/', 1)[1] image_filename = image_...
[ "Return", "a", "requested", "map", "from", "a", "robot", "." ]
stianaske/pybotvac
python
https://github.com/stianaske/pybotvac/blob/e3f655e81070ff209aaa4efb7880016cf2599e6d/pybotvac/account.py#L121-L138
[ "def", "get_map_image", "(", "url", ",", "dest_path", "=", "None", ")", ":", "image", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ",", "timeout", "=", "10", ")", "if", "dest_path", ":", "image_url", "=", "url", ".", "rsplit",...
e3f655e81070ff209aaa4efb7880016cf2599e6d
valid
Account.refresh_persistent_maps
Get information about persistent maps of the robots. :return:
pybotvac/account.py
def refresh_persistent_maps(self): """ Get information about persistent maps of the robots. :return: """ for robot in self._robots: resp2 = (requests.get(urljoin( self.ENDPOINT, 'users/me/robots/{}/persistent_maps'.format(robot.serial)...
def refresh_persistent_maps(self): """ Get information about persistent maps of the robots. :return: """ for robot in self._robots: resp2 = (requests.get(urljoin( self.ENDPOINT, 'users/me/robots/{}/persistent_maps'.format(robot.serial)...
[ "Get", "information", "about", "persistent", "maps", "of", "the", "robots", "." ]
stianaske/pybotvac
python
https://github.com/stianaske/pybotvac/blob/e3f655e81070ff209aaa4efb7880016cf2599e6d/pybotvac/account.py#L151-L163
[ "def", "refresh_persistent_maps", "(", "self", ")", ":", "for", "robot", "in", "self", ".", "_robots", ":", "resp2", "=", "(", "requests", ".", "get", "(", "urljoin", "(", "self", ".", "ENDPOINT", ",", "'users/me/robots/{}/persistent_maps'", ".", "format", "...
e3f655e81070ff209aaa4efb7880016cf2599e6d
valid
Robot._message
Sends message to robot with data from parameter 'json' :param json: dict containing data to send :return: server response
pybotvac/robot.py
def _message(self, json): """ Sends message to robot with data from parameter 'json' :param json: dict containing data to send :return: server response """ cert_path = os.path.join(os.path.dirname(__file__), 'cert', 'neatocloud.com.crt') response = requests.post(...
def _message(self, json): """ Sends message to robot with data from parameter 'json' :param json: dict containing data to send :return: server response """ cert_path = os.path.join(os.path.dirname(__file__), 'cert', 'neatocloud.com.crt') response = requests.post(...
[ "Sends", "message", "to", "robot", "with", "data", "from", "parameter", "json", ":", "param", "json", ":", "dict", "containing", "data", "to", "send", ":", "return", ":", "server", "response" ]
stianaske/pybotvac
python
https://github.com/stianaske/pybotvac/blob/e3f655e81070ff209aaa4efb7880016cf2599e6d/pybotvac/robot.py#L49-L63
[ "def", "_message", "(", "self", ",", "json", ")", ":", "cert_path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ",", "'cert'", ",", "'neatocloud.com.crt'", ")", "response", "=", "requests", ".", ...
e3f655e81070ff209aaa4efb7880016cf2599e6d
valid
add_edge_lengths
Add add the edge lengths as a :any:`DiGraph<networkx.DiGraph>` for the graph. Uses the ``pos`` vertex property to get the location of each vertex. These are then used to calculate the length of an edge between two vertices. Parameters ---------- g : :any:`networkx.DiGraph`, :class:`numpy.n...
queueing_tool/graph/graph_preparation.py
def add_edge_lengths(g): """Add add the edge lengths as a :any:`DiGraph<networkx.DiGraph>` for the graph. Uses the ``pos`` vertex property to get the location of each vertex. These are then used to calculate the length of an edge between two vertices. Parameters ---------- g : :any:`ne...
def add_edge_lengths(g): """Add add the edge lengths as a :any:`DiGraph<networkx.DiGraph>` for the graph. Uses the ``pos`` vertex property to get the location of each vertex. These are then used to calculate the length of an edge between two vertices. Parameters ---------- g : :any:`ne...
[ "Add", "add", "the", "edge", "lengths", "as", "a", ":", "any", ":", "DiGraph<networkx", ".", "DiGraph", ">", "for", "the", "graph", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_preparation.py#L11-L46
[ "def", "add_edge_lengths", "(", "g", ")", ":", "g", "=", "_test_graph", "(", "g", ")", "g", ".", "new_edge_property", "(", "'edge_length'", ")", "for", "e", "in", "g", ".", "edges", "(", ")", ":", "latlon1", "=", "g", ".", "vp", "(", "e", "[", "1...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
_prepare_graph
Prepares a graph for use in :class:`.QueueNetwork`. This function is called by ``__init__`` in the :class:`.QueueNetwork` class. It creates the :class:`.QueueServer` instances that sit on the edges, and sets various edge and node properties that are used when drawing the graph. Parameters ----...
queueing_tool/graph/graph_preparation.py
def _prepare_graph(g, g_colors, q_cls, q_arg, adjust_graph): """Prepares a graph for use in :class:`.QueueNetwork`. This function is called by ``__init__`` in the :class:`.QueueNetwork` class. It creates the :class:`.QueueServer` instances that sit on the edges, and sets various edge and node prope...
def _prepare_graph(g, g_colors, q_cls, q_arg, adjust_graph): """Prepares a graph for use in :class:`.QueueNetwork`. This function is called by ``__init__`` in the :class:`.QueueNetwork` class. It creates the :class:`.QueueServer` instances that sit on the edges, and sets various edge and node prope...
[ "Prepares", "a", "graph", "for", "use", "in", ":", "class", ":", ".", "QueueNetwork", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_preparation.py#L49-L156
[ "def", "_prepare_graph", "(", "g", ",", "g_colors", ",", "q_cls", ",", "q_arg", ",", "adjust_graph", ")", ":", "g", "=", "_test_graph", "(", "g", ")", "if", "adjust_graph", ":", "pos", "=", "nx", ".", "get_node_attributes", "(", "g", ",", "'pos'", ")",...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
Agent.desired_destination
Returns the agents next destination given their current location on the network. An ``Agent`` chooses one of the out edges at random. The probability that the ``Agent`` will travel along a specific edge is specified in the :class:`QueueNetwork's<.QueueNetwork>` transition matrix...
queueing_tool/queues/agents.py
def desired_destination(self, network, edge): """Returns the agents next destination given their current location on the network. An ``Agent`` chooses one of the out edges at random. The probability that the ``Agent`` will travel along a specific edge is specified in the :class:...
def desired_destination(self, network, edge): """Returns the agents next destination given their current location on the network. An ``Agent`` chooses one of the out edges at random. The probability that the ``Agent`` will travel along a specific edge is specified in the :class:...
[ "Returns", "the", "agents", "next", "destination", "given", "their", "current", "location", "on", "the", "network", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/agents.py#L67-L109
[ "def", "desired_destination", "(", "self", ",", "network", ",", "edge", ")", ":", "n", "=", "len", "(", "network", ".", "out_edges", "[", "edge", "[", "1", "]", "]", ")", "if", "n", "<=", "1", ":", "return", "network", ".", "out_edges", "[", "edge"...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
GreedyAgent.desired_destination
Returns the agents next destination given their current location on the network. ``GreedyAgents`` choose their next destination with-in the network by picking the adjacent queue with the fewest number of :class:`Agents<.Agent>` in the queue. Parameters ---------- ...
queueing_tool/queues/agents.py
def desired_destination(self, network, edge): """Returns the agents next destination given their current location on the network. ``GreedyAgents`` choose their next destination with-in the network by picking the adjacent queue with the fewest number of :class:`Agents<.Agent>` in...
def desired_destination(self, network, edge): """Returns the agents next destination given their current location on the network. ``GreedyAgents`` choose their next destination with-in the network by picking the adjacent queue with the fewest number of :class:`Agents<.Agent>` in...
[ "Returns", "the", "agents", "next", "destination", "given", "their", "current", "location", "on", "the", "network", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/agents.py#L140-L167
[ "def", "desired_destination", "(", "self", ",", "network", ",", "edge", ")", ":", "adjacent_edges", "=", "network", ".", "out_edges", "[", "edge", "[", "1", "]", "]", "d", "=", "_argmin", "(", "[", "network", ".", "edge2queue", "[", "d", "]", ".", "n...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
_calculate_distance
Calculates the distance between two points on earth.
queueing_tool/graph/graph_functions.py
def _calculate_distance(latlon1, latlon2): """Calculates the distance between two points on earth. """ lat1, lon1 = latlon1 lat2, lon2 = latlon2 dlon = lon2 - lon1 dlat = lat2 - lat1 R = 6371 # radius of the earth in kilometers a = np.sin(dlat / 2)**2 + np.cos(lat1) * np.cos(lat2) * (np...
def _calculate_distance(latlon1, latlon2): """Calculates the distance between two points on earth. """ lat1, lon1 = latlon1 lat2, lon2 = latlon2 dlon = lon2 - lon1 dlat = lat2 - lat1 R = 6371 # radius of the earth in kilometers a = np.sin(dlat / 2)**2 + np.cos(lat1) * np.cos(lat2) * (np...
[ "Calculates", "the", "distance", "between", "two", "points", "on", "earth", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_functions.py#L7-L17
[ "def", "_calculate_distance", "(", "latlon1", ",", "latlon2", ")", ":", "lat1", ",", "lon1", "=", "latlon1", "lat2", ",", "lon2", "=", "latlon2", "dlon", "=", "lon2", "-", "lon1", "dlat", "=", "lat2", "-", "lat1", "R", "=", "6371", "# radius of the earth...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
graph2dict
Takes a graph and returns an adjacency list. Parameters ---------- g : :any:`networkx.DiGraph`, :any:`networkx.Graph`, etc. Any object that networkx can turn into a :any:`DiGraph<networkx.DiGraph>`. return_dict_of_dict : bool (optional, default: ``True``) Specifies whether this ...
queueing_tool/graph/graph_functions.py
def graph2dict(g, return_dict_of_dict=True): """Takes a graph and returns an adjacency list. Parameters ---------- g : :any:`networkx.DiGraph`, :any:`networkx.Graph`, etc. Any object that networkx can turn into a :any:`DiGraph<networkx.DiGraph>`. return_dict_of_dict : bool (optional...
def graph2dict(g, return_dict_of_dict=True): """Takes a graph and returns an adjacency list. Parameters ---------- g : :any:`networkx.DiGraph`, :any:`networkx.Graph`, etc. Any object that networkx can turn into a :any:`DiGraph<networkx.DiGraph>`. return_dict_of_dict : bool (optional...
[ "Takes", "a", "graph", "and", "returns", "an", "adjacency", "list", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_functions.py#L46-L88
[ "def", "graph2dict", "(", "g", ",", "return_dict_of_dict", "=", "True", ")", ":", "if", "not", "isinstance", "(", "g", ",", "nx", ".", "DiGraph", ")", ":", "g", "=", "QueueNetworkDiGraph", "(", "g", ")", "dict_of_dicts", "=", "nx", ".", "to_dict_of_dicts...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
_matrix2dict
Takes an adjacency matrix and returns an adjacency list.
queueing_tool/graph/graph_wrapper.py
def _matrix2dict(matrix, etype=False): """Takes an adjacency matrix and returns an adjacency list.""" n = len(matrix) adj = {k: {} for k in range(n)} for k in range(n): for j in range(n): if matrix[k, j] != 0: adj[k][j] = {} if not etype else matrix[k, j] return ...
def _matrix2dict(matrix, etype=False): """Takes an adjacency matrix and returns an adjacency list.""" n = len(matrix) adj = {k: {} for k in range(n)} for k in range(n): for j in range(n): if matrix[k, j] != 0: adj[k][j] = {} if not etype else matrix[k, j] return ...
[ "Takes", "an", "adjacency", "matrix", "and", "returns", "an", "adjacency", "list", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L15-L24
[ "def", "_matrix2dict", "(", "matrix", ",", "etype", "=", "False", ")", ":", "n", "=", "len", "(", "matrix", ")", "adj", "=", "{", "k", ":", "{", "}", "for", "k", "in", "range", "(", "n", ")", "}", "for", "k", "in", "range", "(", "n", ")", "...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
_dict2dict
Takes a dictionary based representation of an adjacency list and returns a dict of dicts based representation.
queueing_tool/graph/graph_wrapper.py
def _dict2dict(adj_dict): """Takes a dictionary based representation of an adjacency list and returns a dict of dicts based representation. """ item = adj_dict.popitem() adj_dict[item[0]] = item[1] if not isinstance(item[1], dict): new_dict = {} for key, value in adj_dict.items()...
def _dict2dict(adj_dict): """Takes a dictionary based representation of an adjacency list and returns a dict of dicts based representation. """ item = adj_dict.popitem() adj_dict[item[0]] = item[1] if not isinstance(item[1], dict): new_dict = {} for key, value in adj_dict.items()...
[ "Takes", "a", "dictionary", "based", "representation", "of", "an", "adjacency", "list", "and", "returns", "a", "dict", "of", "dicts", "based", "representation", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L27-L39
[ "def", "_dict2dict", "(", "adj_dict", ")", ":", "item", "=", "adj_dict", ".", "popitem", "(", ")", "adj_dict", "[", "item", "[", "0", "]", "]", "=", "item", "[", "1", "]", "if", "not", "isinstance", "(", "item", "[", "1", "]", ",", "dict", ")", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
_adjacency_adjust
Takes an adjacency list and returns a (possibly) modified adjacency list.
queueing_tool/graph/graph_wrapper.py
def _adjacency_adjust(adjacency, adjust, is_directed): """Takes an adjacency list and returns a (possibly) modified adjacency list. """ for v, adj in adjacency.items(): for properties in adj.values(): if properties.get('edge_type') is None: properties['edge_type'] = ...
def _adjacency_adjust(adjacency, adjust, is_directed): """Takes an adjacency list and returns a (possibly) modified adjacency list. """ for v, adj in adjacency.items(): for properties in adj.values(): if properties.get('edge_type') is None: properties['edge_type'] = ...
[ "Takes", "an", "adjacency", "list", "and", "returns", "a", "(", "possibly", ")", "modified", "adjacency", "list", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L42-L70
[ "def", "_adjacency_adjust", "(", "adjacency", ",", "adjust", ",", "is_directed", ")", ":", "for", "v", ",", "adj", "in", "adjacency", ".", "items", "(", ")", ":", "for", "properties", "in", "adj", ".", "values", "(", ")", ":", "if", "properties", ".", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
adjacency2graph
Takes an adjacency list, dict, or matrix and returns a graph. The purpose of this function is take an adjacency list (or matrix) and return a :class:`.QueueNetworkDiGraph` that can be used with a :class:`.QueueNetwork` instance. The Graph returned has the ``edge_type`` edge property set for each edge. ...
queueing_tool/graph/graph_wrapper.py
def adjacency2graph(adjacency, edge_type=None, adjust=1, **kwargs): """Takes an adjacency list, dict, or matrix and returns a graph. The purpose of this function is take an adjacency list (or matrix) and return a :class:`.QueueNetworkDiGraph` that can be used with a :class:`.QueueNetwork` instance. The...
def adjacency2graph(adjacency, edge_type=None, adjust=1, **kwargs): """Takes an adjacency list, dict, or matrix and returns a graph. The purpose of this function is take an adjacency list (or matrix) and return a :class:`.QueueNetworkDiGraph` that can be used with a :class:`.QueueNetwork` instance. The...
[ "Takes", "an", "adjacency", "list", "dict", "or", "matrix", "and", "returns", "a", "graph", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L73-L181
[ "def", "adjacency2graph", "(", "adjacency", ",", "edge_type", "=", "None", ",", "adjust", "=", "1", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "adjacency", ",", "np", ".", "ndarray", ")", ":", "adjacency", "=", "_matrix2dict", "(", "ad...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetworkDiGraph.get_edge_type
Returns all edges with the specified edge type. Parameters ---------- edge_type : int An integer specifying what type of edges to return. Returns ------- out : list of 2-tuples A list of 2-tuples representing the edges in the graph wi...
queueing_tool/graph/graph_wrapper.py
def get_edge_type(self, edge_type): """Returns all edges with the specified edge type. Parameters ---------- edge_type : int An integer specifying what type of edges to return. Returns ------- out : list of 2-tuples A list of 2-tuples rep...
def get_edge_type(self, edge_type): """Returns all edges with the specified edge type. Parameters ---------- edge_type : int An integer specifying what type of edges to return. Returns ------- out : list of 2-tuples A list of 2-tuples rep...
[ "Returns", "all", "edges", "with", "the", "specified", "edge", "type", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L318-L354
[ "def", "get_edge_type", "(", "self", ",", "edge_type", ")", ":", "edges", "=", "[", "]", "for", "e", "in", "self", ".", "edges", "(", ")", ":", "if", "self", ".", "adj", "[", "e", "[", "0", "]", "]", "[", "e", "[", "1", "]", "]", ".", "get"...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetworkDiGraph.draw_graph
Draws the graph. Uses matplotlib, specifically :class:`~matplotlib.collections.LineCollection` and :meth:`~matplotlib.axes.Axes.scatter`. Gets the default keyword arguments for both methods by calling :meth:`~.QueueNetworkDiGraph.lines_scatter_args` first. Parameters ...
queueing_tool/graph/graph_wrapper.py
def draw_graph(self, line_kwargs=None, scatter_kwargs=None, **kwargs): """Draws the graph. Uses matplotlib, specifically :class:`~matplotlib.collections.LineCollection` and :meth:`~matplotlib.axes.Axes.scatter`. Gets the default keyword arguments for both methods by calling ...
def draw_graph(self, line_kwargs=None, scatter_kwargs=None, **kwargs): """Draws the graph. Uses matplotlib, specifically :class:`~matplotlib.collections.LineCollection` and :meth:`~matplotlib.axes.Axes.scatter`. Gets the default keyword arguments for both methods by calling ...
[ "Draws", "the", "graph", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L356-L425
[ "def", "draw_graph", "(", "self", ",", "line_kwargs", "=", "None", ",", "scatter_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "HAS_MATPLOTLIB", ":", "raise", "ImportError", "(", "\"Matplotlib is required to draw the graph.\"", ")", "fig"...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetworkDiGraph.lines_scatter_args
Returns the arguments used when plotting. Takes any keyword arguments for :class:`~matplotlib.collections.LineCollection` and :meth:`~matplotlib.axes.Axes.scatter` and returns two dictionaries with all the defaults set. Parameters ---------- line_kwargs : dict (...
queueing_tool/graph/graph_wrapper.py
def lines_scatter_args(self, line_kwargs=None, scatter_kwargs=None, pos=None): """Returns the arguments used when plotting. Takes any keyword arguments for :class:`~matplotlib.collections.LineCollection` and :meth:`~matplotlib.axes.Axes.scatter` and returns two dictionaries with...
def lines_scatter_args(self, line_kwargs=None, scatter_kwargs=None, pos=None): """Returns the arguments used when plotting. Takes any keyword arguments for :class:`~matplotlib.collections.LineCollection` and :meth:`~matplotlib.axes.Axes.scatter` and returns two dictionaries with...
[ "Returns", "the", "arguments", "used", "when", "plotting", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/graph/graph_wrapper.py#L427-L515
[ "def", "lines_scatter_args", "(", "self", ",", "line_kwargs", "=", "None", ",", "scatter_kwargs", "=", "None", ",", "pos", "=", "None", ")", ":", "if", "pos", "is", "not", "None", ":", "self", ".", "set_pos", "(", "pos", ")", "elif", "self", ".", "po...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
poisson_random_measure
A function that returns the arrival time of the next arrival for a Poisson random measure. Parameters ---------- t : float The start time from which to simulate the next arrival time. rate : function The *intensity function* for the measure, where ``rate(t)`` is the expected...
queueing_tool/queues/queue_servers.py
def poisson_random_measure(t, rate, rate_max): """A function that returns the arrival time of the next arrival for a Poisson random measure. Parameters ---------- t : float The start time from which to simulate the next arrival time. rate : function The *intensity function* for ...
def poisson_random_measure(t, rate, rate_max): """A function that returns the arrival time of the next arrival for a Poisson random measure. Parameters ---------- t : float The start time from which to simulate the next arrival time. rate : function The *intensity function* for ...
[ "A", "function", "that", "returns", "the", "arrival", "time", "of", "the", "next", "arrival", "for", "a", "Poisson", "random", "measure", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L13-L79
[ "def", "poisson_random_measure", "(", "t", ",", "rate", ",", "rate_max", ")", ":", "scale", "=", "1.0", "/", "rate_max", "t", "=", "t", "+", "exponential", "(", "scale", ")", "while", "rate_max", "*", "uniform", "(", ")", ">", "rate", "(", "t", ")", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.clear
Clears out the queue. Removes all arrivals, departures, and queued agents from the :class:`.QueueServer`, resets ``num_arrivals``, ``num_departures``, ``num_system``, and the clock to zero. It also clears any stored ``data`` and the server is then set to inactive.
queueing_tool/queues/queue_servers.py
def clear(self): """Clears out the queue. Removes all arrivals, departures, and queued agents from the :class:`.QueueServer`, resets ``num_arrivals``, ``num_departures``, ``num_system``, and the clock to zero. It also clears any stored ``data`` and the server is then set to inact...
def clear(self): """Clears out the queue. Removes all arrivals, departures, and queued agents from the :class:`.QueueServer`, resets ``num_arrivals``, ``num_departures``, ``num_system``, and the clock to zero. It also clears any stored ``data`` and the server is then set to inact...
[ "Clears", "out", "the", "queue", ".", "Removes", "all", "arrivals", "departures", "and", "queued", "agents", "from", "the", ":", "class", ":", ".", "QueueServer", "resets", "num_arrivals", "num_departures", "num_system", "and", "the", "clock", "to", "zero", "....
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L392-L412
[ "def", "clear", "(", "self", ")", ":", "self", ".", "data", "=", "{", "}", "self", ".", "_num_arrivals", "=", "0", "self", ".", "_oArrivals", "=", "0", "self", ".", "num_departures", "=", "0", "self", ".", "num_system", "=", "0", "self", ".", "_num...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer._current_color
Returns a color for the queue. Parameters ---------- which : int (optional, default: ``0``) Specifies the type of color to return. Returns ------- color : list Returns a RGBA color that is represented as a list with 4 entries where ea...
queueing_tool/queues/queue_servers.py
def _current_color(self, which=0): """Returns a color for the queue. Parameters ---------- which : int (optional, default: ``0``) Specifies the type of color to return. Returns ------- color : list Returns a RGBA color that is represented...
def _current_color(self, which=0): """Returns a color for the queue. Parameters ---------- which : int (optional, default: ``0``) Specifies the type of color to return. Returns ------- color : list Returns a RGBA color that is represented...
[ "Returns", "a", "color", "for", "the", "queue", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L418-L465
[ "def", "_current_color", "(", "self", ",", "which", "=", "0", ")", ":", "if", "which", "==", "1", ":", "color", "=", "self", ".", "colors", "[", "'edge_loop_color'", "]", "elif", "which", "==", "2", ":", "color", "=", "self", ".", "colors", "[", "'...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.delay_service
Adds an extra service time to the next departing :class:`Agent's<.Agent>` service time. Parameters ---------- t : float (optional) Specifies the departing time for the agent scheduled to depart next. If ``t`` is not given, then an additional service t...
queueing_tool/queues/queue_servers.py
def delay_service(self, t=None): """Adds an extra service time to the next departing :class:`Agent's<.Agent>` service time. Parameters ---------- t : float (optional) Specifies the departing time for the agent scheduled to depart next. If ``t`` is not giv...
def delay_service(self, t=None): """Adds an extra service time to the next departing :class:`Agent's<.Agent>` service time. Parameters ---------- t : float (optional) Specifies the departing time for the agent scheduled to depart next. If ``t`` is not giv...
[ "Adds", "an", "extra", "service", "time", "to", "the", "next", "departing", ":", "class", ":", "Agent", "s<", ".", "Agent", ">", "service", "time", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L467-L487
[ "def", "delay_service", "(", "self", ",", "t", "=", "None", ")", ":", "if", "len", "(", "self", ".", "_departures", ")", ">", "1", ":", "agent", "=", "heappop", "(", "self", ".", "_departures", ")", "if", "t", "is", "None", ":", "agent", ".", "_t...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.fetch_data
Fetches data from the queue. Parameters ---------- return_header : bool (optonal, default: ``False``) Determines whether the column headers are returned. Returns ------- data : :class:`~numpy.ndarray` A six column :class:`~numpy.ndarray` of all t...
queueing_tool/queues/queue_servers.py
def fetch_data(self, return_header=False): """Fetches data from the queue. Parameters ---------- return_header : bool (optonal, default: ``False``) Determines whether the column headers are returned. Returns ------- data : :class:`~numpy.ndarray` ...
def fetch_data(self, return_header=False): """Fetches data from the queue. Parameters ---------- return_header : bool (optonal, default: ``False``) Determines whether the column headers are returned. Returns ------- data : :class:`~numpy.ndarray` ...
[ "Fetches", "data", "from", "the", "queue", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L489-L540
[ "def", "fetch_data", "(", "self", ",", "return_header", "=", "False", ")", ":", "qdata", "=", "[", "]", "for", "d", "in", "self", ".", "data", ".", "values", "(", ")", ":", "qdata", ".", "extend", "(", "d", ")", "dat", "=", "np", ".", "zeros", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.next_event
Simulates the queue forward one event. Use :meth:`.simulate` instead. Returns ------- out : :class:`.Agent` (sometimes) If the next event is a departure then the departing agent is returned, otherwise nothing is returned. See Also -------- ...
queueing_tool/queues/queue_servers.py
def next_event(self): """Simulates the queue forward one event. Use :meth:`.simulate` instead. Returns ------- out : :class:`.Agent` (sometimes) If the next event is a departure then the departing agent is returned, otherwise nothing is returned. ...
def next_event(self): """Simulates the queue forward one event. Use :meth:`.simulate` instead. Returns ------- out : :class:`.Agent` (sometimes) If the next event is a departure then the departing agent is returned, otherwise nothing is returned. ...
[ "Simulates", "the", "queue", "forward", "one", "event", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L555-L624
[ "def", "next_event", "(", "self", ")", ":", "if", "self", ".", "_departures", "[", "0", "]", ".", "_time", "<", "self", ".", "_arrivals", "[", "0", "]", ".", "_time", ":", "new_depart", "=", "heappop", "(", "self", ".", "_departures", ")", "self", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.next_event_description
Returns an integer representing whether the next event is an arrival, a departure, or nothing. Returns ------- out : int An integer representing whether the next event is an arrival or a departure: ``1`` corresponds to an arrival, ``2`` corresponds to...
queueing_tool/queues/queue_servers.py
def next_event_description(self): """Returns an integer representing whether the next event is an arrival, a departure, or nothing. Returns ------- out : int An integer representing whether the next event is an arrival or a departure: ``1`` corresponds to...
def next_event_description(self): """Returns an integer representing whether the next event is an arrival, a departure, or nothing. Returns ------- out : int An integer representing whether the next event is an arrival or a departure: ``1`` corresponds to...
[ "Returns", "an", "integer", "representing", "whether", "the", "next", "event", "is", "an", "arrival", "a", "departure", "or", "nothing", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L626-L643
[ "def", "next_event_description", "(", "self", ")", ":", "if", "self", ".", "_departures", "[", "0", "]", ".", "_time", "<", "self", ".", "_arrivals", "[", "0", "]", ".", "_time", ":", "return", "2", "elif", "self", ".", "_arrivals", "[", "0", "]", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.set_num_servers
Change the number of servers in the queue to ``n``. Parameters ---------- n : int or :const:`numpy.infty` A positive integer (or ``numpy.infty``) to set the number of queues in the system to. Raises ------ TypeError If ``n`` is not an...
queueing_tool/queues/queue_servers.py
def set_num_servers(self, n): """Change the number of servers in the queue to ``n``. Parameters ---------- n : int or :const:`numpy.infty` A positive integer (or ``numpy.infty``) to set the number of queues in the system to. Raises ------ ...
def set_num_servers(self, n): """Change the number of servers in the queue to ``n``. Parameters ---------- n : int or :const:`numpy.infty` A positive integer (or ``numpy.infty``) to set the number of queues in the system to. Raises ------ ...
[ "Change", "the", "number", "of", "servers", "in", "the", "queue", "to", "n", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L657-L681
[ "def", "set_num_servers", "(", "self", ",", "n", ")", ":", "if", "not", "isinstance", "(", "n", ",", "numbers", ".", "Integral", ")", "and", "n", "is", "not", "infty", ":", "the_str", "=", "\"n must be an integer or infinity.\\n{0}\"", "raise", "TypeError", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueServer.simulate
This method simulates the queue forward for a specified amount of simulation time, or for a specific number of events. Parameters ---------- n : int (optional, default: ``1``) The number of events to simulate. If ``t``, ``nA``, and ``nD`` are not given th...
queueing_tool/queues/queue_servers.py
def simulate(self, n=1, t=None, nA=None, nD=None): """This method simulates the queue forward for a specified amount of simulation time, or for a specific number of events. Parameters ---------- n : int (optional, default: ``1``) The number of events to simul...
def simulate(self, n=1, t=None, nA=None, nD=None): """This method simulates the queue forward for a specified amount of simulation time, or for a specific number of events. Parameters ---------- n : int (optional, default: ``1``) The number of events to simul...
[ "This", "method", "simulates", "the", "queue", "forward", "for", "a", "specified", "amount", "of", "simulation", "time", "or", "for", "a", "specific", "number", "of", "events", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/queues/queue_servers.py#L683-L757
[ "def", "simulate", "(", "self", ",", "n", "=", "1", ",", "t", "=", "None", ",", "nA", "=", "None", ",", "nD", "=", "None", ")", ":", "if", "t", "is", "None", "and", "nD", "is", "None", "and", "nA", "is", "None", ":", "for", "dummy", "in", "...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
_get_queues
Used to specify edge indices from different types of arguments.
queueing_tool/network/queue_network.py
def _get_queues(g, queues, edge, edge_type): """Used to specify edge indices from different types of arguments.""" INT = numbers.Integral if isinstance(queues, INT): queues = [queues] elif queues is None: if edge is not None: if isinstance(edge, tuple): if is...
def _get_queues(g, queues, edge, edge_type): """Used to specify edge indices from different types of arguments.""" INT = numbers.Integral if isinstance(queues, INT): queues = [queues] elif queues is None: if edge is not None: if isinstance(edge, tuple): if is...
[ "Used", "to", "specify", "edge", "indices", "from", "different", "types", "of", "arguments", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1605-L1636
[ "def", "_get_queues", "(", "g", ",", "queues", ",", "edge", ",", "edge_type", ")", ":", "INT", "=", "numbers", ".", "Integral", "if", "isinstance", "(", "queues", ",", "INT", ")", ":", "queues", "=", "[", "queues", "]", "elif", "queues", "is", "None"...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.animate
Animates the network as it's simulating. The animations can be saved to disk or viewed in interactive mode. Closing the window ends the animation if viewed in interactive mode. This method calls :meth:`~matplotlib.axes.scatter`, and :class:`~matplotlib.collections.LineCollection...
queueing_tool/network/queue_network.py
def animate(self, out=None, t=None, line_kwargs=None, scatter_kwargs=None, **kwargs): """Animates the network as it's simulating. The animations can be saved to disk or viewed in interactive mode. Closing the window ends the animation if viewed in interactive mode. This ...
def animate(self, out=None, t=None, line_kwargs=None, scatter_kwargs=None, **kwargs): """Animates the network as it's simulating. The animations can be saved to disk or viewed in interactive mode. Closing the window ends the animation if viewed in interactive mode. This ...
[ "Animates", "the", "network", "as", "it", "s", "simulating", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L411-L587
[ "def", "animate", "(", "self", ",", "out", "=", "None", ",", "t", "=", "None", ",", "line_kwargs", "=", "None", ",", "scatter_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "_initialized", ":", "msg", "=", "(", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.clear
Resets the queue to its initial state. The attributes ``t``, ``num_events``, ``num_agents`` are set to zero, :meth:`.reset_colors` is called, and the :meth:`.QueueServer.clear` method is called for each queue in the network. Notes ----- ``QueueNetwork`` must be ...
queueing_tool/network/queue_network.py
def clear(self): """Resets the queue to its initial state. The attributes ``t``, ``num_events``, ``num_agents`` are set to zero, :meth:`.reset_colors` is called, and the :meth:`.QueueServer.clear` method is called for each queue in the network. Notes ----- ...
def clear(self): """Resets the queue to its initial state. The attributes ``t``, ``num_events``, ``num_agents`` are set to zero, :meth:`.reset_colors` is called, and the :meth:`.QueueServer.clear` method is called for each queue in the network. Notes ----- ...
[ "Resets", "the", "queue", "to", "its", "initial", "state", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L589-L610
[ "def", "clear", "(", "self", ")", ":", "self", ".", "_t", "=", "0", "self", ".", "num_events", "=", "0", "self", ".", "num_agents", "=", "np", ".", "zeros", "(", "self", ".", "nE", ",", "int", ")", "self", ".", "_fancy_heap", "=", "PriorityQueue", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.clear_data
Clears data from all queues. If none of the parameters are given then every queue's data is cleared. Parameters ---------- queues : int or an iterable of int (optional) The edge index (or an iterable of edge indices) identifying the :class:`QueueServer(s...
queueing_tool/network/queue_network.py
def clear_data(self, queues=None, edge=None, edge_type=None): """Clears data from all queues. If none of the parameters are given then every queue's data is cleared. Parameters ---------- queues : int or an iterable of int (optional) The edge index (or an it...
def clear_data(self, queues=None, edge=None, edge_type=None): """Clears data from all queues. If none of the parameters are given then every queue's data is cleared. Parameters ---------- queues : int or an iterable of int (optional) The edge index (or an it...
[ "Clears", "data", "from", "all", "queues", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L612-L640
[ "def", "clear_data", "(", "self", ",", "queues", "=", "None", ",", "edge", "=", "None", ",", "edge_type", "=", "None", ")", ":", "queues", "=", "_get_queues", "(", "self", ".", "g", ",", "queues", ",", "edge", ",", "edge_type", ")", "for", "k", "in...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.copy
Returns a deep copy of itself.
queueing_tool/network/queue_network.py
def copy(self): """Returns a deep copy of itself.""" net = QueueNetwork(None) net.g = self.g.copy() net.max_agents = copy.deepcopy(self.max_agents) net.nV = copy.deepcopy(self.nV) net.nE = copy.deepcopy(self.nE) net.num_agents = copy.deepcopy(self.num_agents) ...
def copy(self): """Returns a deep copy of itself.""" net = QueueNetwork(None) net.g = self.g.copy() net.max_agents = copy.deepcopy(self.max_agents) net.nV = copy.deepcopy(self.nV) net.nE = copy.deepcopy(self.nE) net.num_agents = copy.deepcopy(self.num_agents) ...
[ "Returns", "a", "deep", "copy", "of", "itself", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L642-L665
[ "def", "copy", "(", "self", ")", ":", "net", "=", "QueueNetwork", "(", "None", ")", "net", ".", "g", "=", "self", ".", "g", ".", "copy", "(", ")", "net", ".", "max_agents", "=", "copy", ".", "deepcopy", "(", "self", ".", "max_agents", ")", "net",...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.draw
Draws the network. The coloring of the network corresponds to the number of agents at each queue. Parameters ---------- update_colors : ``bool`` (optional, default: ``True``). Specifies whether all the colors are updated. line_kwargs : dict (optional, default: None) ...
queueing_tool/network/queue_network.py
def draw(self, update_colors=True, line_kwargs=None, scatter_kwargs=None, **kwargs): """Draws the network. The coloring of the network corresponds to the number of agents at each queue. Parameters ---------- update_colors : ``bool`` (optional, default: ``True``). ...
def draw(self, update_colors=True, line_kwargs=None, scatter_kwargs=None, **kwargs): """Draws the network. The coloring of the network corresponds to the number of agents at each queue. Parameters ---------- update_colors : ``bool`` (optional, default: ``True``). ...
[ "Draws", "the", "network", ".", "The", "coloring", "of", "the", "network", "corresponds", "to", "the", "number", "of", "agents", "at", "each", "queue", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L667-L741
[ "def", "draw", "(", "self", ",", "update_colors", "=", "True", ",", "line_kwargs", "=", "None", ",", "scatter_kwargs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "not", "HAS_MATPLOTLIB", ":", "raise", "ImportError", "(", "\"matplotlib is necessary...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.get_agent_data
Gets data from queues and organizes it by agent. If none of the parameters are given then data from every :class:`.QueueServer` is retrieved. Parameters ---------- queues : int or *array_like* (optional) The edge index (or an iterable of edge indices) identifying ...
queueing_tool/network/queue_network.py
def get_agent_data(self, queues=None, edge=None, edge_type=None, return_header=False): """Gets data from queues and organizes it by agent. If none of the parameters are given then data from every :class:`.QueueServer` is retrieved. Parameters ---------- queues : int or ...
def get_agent_data(self, queues=None, edge=None, edge_type=None, return_header=False): """Gets data from queues and organizes it by agent. If none of the parameters are given then data from every :class:`.QueueServer` is retrieved. Parameters ---------- queues : int or ...
[ "Gets", "data", "from", "queues", "and", "organizes", "it", "by", "agent", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L743-L821
[ "def", "get_agent_data", "(", "self", ",", "queues", "=", "None", ",", "edge", "=", "None", ",", "edge_type", "=", "None", ",", "return_header", "=", "False", ")", ":", "queues", "=", "_get_queues", "(", "self", ".", "g", ",", "queues", ",", "edge", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.get_queue_data
Gets data from all the queues. If none of the parameters are given then data from every :class:`.QueueServer` is retrieved. Parameters ---------- queues : int or an *array_like* of int, (optional) The edge index (or an iterable of edge indices) identifying ...
queueing_tool/network/queue_network.py
def get_queue_data(self, queues=None, edge=None, edge_type=None, return_header=False): """Gets data from all the queues. If none of the parameters are given then data from every :class:`.QueueServer` is retrieved. Parameters ---------- queues : int or an *array_like* of...
def get_queue_data(self, queues=None, edge=None, edge_type=None, return_header=False): """Gets data from all the queues. If none of the parameters are given then data from every :class:`.QueueServer` is retrieved. Parameters ---------- queues : int or an *array_like* of...
[ "Gets", "data", "from", "all", "the", "queues", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L823-L904
[ "def", "get_queue_data", "(", "self", ",", "queues", "=", "None", ",", "edge", "=", "None", ",", "edge_type", "=", "None", ",", "return_header", "=", "False", ")", ":", "queues", "=", "_get_queues", "(", "self", ".", "g", ",", "queues", ",", "edge", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.initialize
Prepares the ``QueueNetwork`` for simulation. Each :class:`.QueueServer` in the network starts inactive, which means they do not accept arrivals from outside the network, and they have no agents in their system. This method sets queues to active, which then allows agents to arrive from ...
queueing_tool/network/queue_network.py
def initialize(self, nActive=1, queues=None, edges=None, edge_type=None): """Prepares the ``QueueNetwork`` for simulation. Each :class:`.QueueServer` in the network starts inactive, which means they do not accept arrivals from outside the network, and they have no agents in their system...
def initialize(self, nActive=1, queues=None, edges=None, edge_type=None): """Prepares the ``QueueNetwork`` for simulation. Each :class:`.QueueServer` in the network starts inactive, which means they do not accept arrivals from outside the network, and they have no agents in their system...
[ "Prepares", "the", "QueueNetwork", "for", "simulation", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L906-L985
[ "def", "initialize", "(", "self", ",", "nActive", "=", "1", ",", "queues", "=", "None", ",", "edges", "=", "None", ",", "edge_type", "=", "None", ")", ":", "if", "queues", "is", "None", "and", "edges", "is", "None", "and", "edge_type", "is", "None", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.next_event_description
Returns whether the next event is an arrival or a departure and the queue the event is accuring at. Returns ------- des : str Indicates whether the next event is an arrival, a departure, or nothing; returns ``'Arrival'``, ``'Departure'``, or ``'Nothin...
queueing_tool/network/queue_network.py
def next_event_description(self): """Returns whether the next event is an arrival or a departure and the queue the event is accuring at. Returns ------- des : str Indicates whether the next event is an arrival, a departure, or nothing; returns ``'Arrival'...
def next_event_description(self): """Returns whether the next event is an arrival or a departure and the queue the event is accuring at. Returns ------- des : str Indicates whether the next event is an arrival, a departure, or nothing; returns ``'Arrival'...
[ "Returns", "whether", "the", "next", "event", "is", "an", "arrival", "or", "a", "departure", "and", "the", "queue", "the", "event", "is", "accuring", "at", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L987-L1012
[ "def", "next_event_description", "(", "self", ")", ":", "if", "self", ".", "_fancy_heap", ".", "size", "==", "0", ":", "event_type", "=", "'Nothing'", "edge_index", "=", "None", "else", ":", "s", "=", "[", "q", ".", "_key", "(", ")", "for", "q", "in"...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.reset_colors
Resets all edge and vertex colors to their default values.
queueing_tool/network/queue_network.py
def reset_colors(self): """Resets all edge and vertex colors to their default values.""" for k, e in enumerate(self.g.edges()): self.g.set_ep(e, 'edge_color', self.edge2queue[k].colors['edge_color']) for v in self.g.nodes(): self.g.set_vp(v, 'vertex_fill_color', self.colo...
def reset_colors(self): """Resets all edge and vertex colors to their default values.""" for k, e in enumerate(self.g.edges()): self.g.set_ep(e, 'edge_color', self.edge2queue[k].colors['edge_color']) for v in self.g.nodes(): self.g.set_vp(v, 'vertex_fill_color', self.colo...
[ "Resets", "all", "edge", "and", "vertex", "colors", "to", "their", "default", "values", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1014-L1019
[ "def", "reset_colors", "(", "self", ")", ":", "for", "k", ",", "e", "in", "enumerate", "(", "self", ".", "g", ".", "edges", "(", ")", ")", ":", "self", ".", "g", ".", "set_ep", "(", "e", ",", "'edge_color'", ",", "self", ".", "edge2queue", "[", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.set_transitions
Change the routing transitions probabilities for the network. Parameters ---------- mat : dict or :class:`~numpy.ndarray` A transition routing matrix or transition dictionary. If passed a dictionary, the keys are source vertex indices and the values a...
queueing_tool/network/queue_network.py
def set_transitions(self, mat): """Change the routing transitions probabilities for the network. Parameters ---------- mat : dict or :class:`~numpy.ndarray` A transition routing matrix or transition dictionary. If passed a dictionary, the keys are source ...
def set_transitions(self, mat): """Change the routing transitions probabilities for the network. Parameters ---------- mat : dict or :class:`~numpy.ndarray` A transition routing matrix or transition dictionary. If passed a dictionary, the keys are source ...
[ "Change", "the", "routing", "transitions", "probabilities", "for", "the", "network", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1021-L1136
[ "def", "set_transitions", "(", "self", ",", "mat", ")", ":", "if", "isinstance", "(", "mat", ",", "dict", ")", ":", "for", "key", ",", "value", "in", "mat", ".", "items", "(", ")", ":", "probs", "=", "list", "(", "value", ".", "values", "(", ")",...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.show_active
Draws the network, highlighting active queues. The colored vertices represent vertices that have at least one queue on an in-edge that is active. Dark edges represent queues that are active, light edges represent queues that are inactive. Parameters ---------- *...
queueing_tool/network/queue_network.py
def show_active(self, **kwargs): """Draws the network, highlighting active queues. The colored vertices represent vertices that have at least one queue on an in-edge that is active. Dark edges represent queues that are active, light edges represent queues that are inactive. ...
def show_active(self, **kwargs): """Draws the network, highlighting active queues. The colored vertices represent vertices that have at least one queue on an in-edge that is active. Dark edges represent queues that are active, light edges represent queues that are inactive. ...
[ "Draws", "the", "network", "highlighting", "active", "queues", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1138-L1183
[ "def", "show_active", "(", "self", ",", "*", "*", "kwargs", ")", ":", "g", "=", "self", ".", "g", "for", "v", "in", "g", ".", "nodes", "(", ")", ":", "self", ".", "g", ".", "set_vp", "(", "v", ",", "'vertex_color'", ",", "[", "0", ",", "0", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.show_type
Draws the network, highlighting queues of a certain type. The colored vertices represent self loops of type ``edge_type``. Dark edges represent queues of type ``edge_type``. Parameters ---------- edge_type : int The type of vertices and edges to be shown. **...
queueing_tool/network/queue_network.py
def show_type(self, edge_type, **kwargs): """Draws the network, highlighting queues of a certain type. The colored vertices represent self loops of type ``edge_type``. Dark edges represent queues of type ``edge_type``. Parameters ---------- edge_type : int T...
def show_type(self, edge_type, **kwargs): """Draws the network, highlighting queues of a certain type. The colored vertices represent self loops of type ``edge_type``. Dark edges represent queues of type ``edge_type``. Parameters ---------- edge_type : int T...
[ "Draws", "the", "network", "highlighting", "queues", "of", "a", "certain", "type", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1185-L1237
[ "def", "show_type", "(", "self", ",", "edge_type", ",", "*", "*", "kwargs", ")", ":", "for", "v", "in", "self", ".", "g", ".", "nodes", "(", ")", ":", "e", "=", "(", "v", ",", "v", ")", "if", "self", ".", "g", ".", "is_edge", "(", "e", ")",...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.simulate
Simulates the network forward. Simulates either a specific number of events or for a specified amount of simulation time. Parameters ---------- n : int (optional, default: 1) The number of events to simulate. If ``t`` is not given then this parameter is ...
queueing_tool/network/queue_network.py
def simulate(self, n=1, t=None): """Simulates the network forward. Simulates either a specific number of events or for a specified amount of simulation time. Parameters ---------- n : int (optional, default: 1) The number of events to simulate. If ``t`` is n...
def simulate(self, n=1, t=None): """Simulates the network forward. Simulates either a specific number of events or for a specified amount of simulation time. Parameters ---------- n : int (optional, default: 1) The number of events to simulate. If ``t`` is n...
[ "Simulates", "the", "network", "forward", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1239-L1300
[ "def", "simulate", "(", "self", ",", "n", "=", "1", ",", "t", "=", "None", ")", ":", "if", "not", "self", ".", "_initialized", ":", "msg", "=", "(", "\"Network has not been initialized. \"", "\"Call '.initialize()' first.\"", ")", "raise", "QueueingToolError", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.start_collecting_data
Tells the queues to collect data on agents' arrival, service start, and departure times. If none of the parameters are given then every :class:`.QueueServer` will start collecting data. Parameters ---------- queues : :any:`int`, *array_like* (optional) The e...
queueing_tool/network/queue_network.py
def start_collecting_data(self, queues=None, edge=None, edge_type=None): """Tells the queues to collect data on agents' arrival, service start, and departure times. If none of the parameters are given then every :class:`.QueueServer` will start collecting data. Parameters ...
def start_collecting_data(self, queues=None, edge=None, edge_type=None): """Tells the queues to collect data on agents' arrival, service start, and departure times. If none of the parameters are given then every :class:`.QueueServer` will start collecting data. Parameters ...
[ "Tells", "the", "queues", "to", "collect", "data", "on", "agents", "arrival", "service", "start", "and", "departure", "times", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1381-L1410
[ "def", "start_collecting_data", "(", "self", ",", "queues", "=", "None", ",", "edge", "=", "None", ",", "edge_type", "=", "None", ")", ":", "queues", "=", "_get_queues", "(", "self", ".", "g", ",", "queues", ",", "edge", ",", "edge_type", ")", "for", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.stop_collecting_data
Tells the queues to stop collecting data on agents. If none of the parameters are given then every :class:`.QueueServer` will stop collecting data. Parameters ---------- queues : int, *array_like* (optional) The edge index (or an iterable of edge indices) identifyin...
queueing_tool/network/queue_network.py
def stop_collecting_data(self, queues=None, edge=None, edge_type=None): """Tells the queues to stop collecting data on agents. If none of the parameters are given then every :class:`.QueueServer` will stop collecting data. Parameters ---------- queues : int, *array_like...
def stop_collecting_data(self, queues=None, edge=None, edge_type=None): """Tells the queues to stop collecting data on agents. If none of the parameters are given then every :class:`.QueueServer` will stop collecting data. Parameters ---------- queues : int, *array_like...
[ "Tells", "the", "queues", "to", "stop", "collecting", "data", "on", "agents", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1412-L1440
[ "def", "stop_collecting_data", "(", "self", ",", "queues", "=", "None", ",", "edge", "=", "None", ",", "edge_type", "=", "None", ")", ":", "queues", "=", "_get_queues", "(", "self", ".", "g", ",", "queues", ",", "edge", ",", "edge_type", ")", "for", ...
ccd418cf647ac03a54f78ba5e3725903f541b808
valid
QueueNetwork.transitions
Returns the routing probabilities for each vertex in the graph. Parameters ---------- return_matrix : bool (optional, the default is ``True``) Specifies whether an :class:`~numpy.ndarray` is returned. If ``False``, a dict is returned instead. Returns ...
queueing_tool/network/queue_network.py
def transitions(self, return_matrix=True): """Returns the routing probabilities for each vertex in the graph. Parameters ---------- return_matrix : bool (optional, the default is ``True``) Specifies whether an :class:`~numpy.ndarray` is returned. If ``Fal...
def transitions(self, return_matrix=True): """Returns the routing probabilities for each vertex in the graph. Parameters ---------- return_matrix : bool (optional, the default is ``True``) Specifies whether an :class:`~numpy.ndarray` is returned. If ``Fal...
[ "Returns", "the", "routing", "probabilities", "for", "each", "vertex", "in", "the", "graph", "." ]
djordon/queueing-tool
python
https://github.com/djordon/queueing-tool/blob/ccd418cf647ac03a54f78ba5e3725903f541b808/queueing_tool/network/queue_network.py#L1442-L1532
[ "def", "transitions", "(", "self", ",", "return_matrix", "=", "True", ")", ":", "if", "return_matrix", ":", "mat", "=", "np", ".", "zeros", "(", "(", "self", ".", "nV", ",", "self", ".", "nV", ")", ")", "for", "v", "in", "self", ".", "g", ".", ...
ccd418cf647ac03a54f78ba5e3725903f541b808