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
train
MembershipRequest.is_ready
Return ``True`` if the results are ready. If you pass ``check=False``, no attempt is made to check again for results. :param bool check: whether to query for the results :return: ``True`` if the results are ready :rtype: bool
groupy/api/memberships.py
def is_ready(self, check=True): """Return ``True`` if the results are ready. If you pass ``check=False``, no attempt is made to check again for results. :param bool check: whether to query for the results :return: ``True`` if the results are ready :rtype: bool "...
def is_ready(self, check=True): """Return ``True`` if the results are ready. If you pass ``check=False``, no attempt is made to check again for results. :param bool check: whether to query for the results :return: ``True`` if the results are ready :rtype: bool "...
[ "Return", "True", "if", "the", "results", "are", "ready", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L274-L286
[ "def", "is_ready", "(", "self", ",", "check", "=", "True", ")", ":", "if", "not", "self", ".", "_is_ready", "and", "check", ":", "self", ".", "check_if_ready", "(", ")", "return", "self", ".", "_is_ready" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
MembershipRequest.poll
Return the results when they become ready. :param int timeout: the maximum time to wait for the results :param float interval: the number of seconds between checks :return: the membership request result :rtype: :class:`~groupy.api.memberships.MembershipResult.Results`
groupy/api/memberships.py
def poll(self, timeout=30, interval=2): """Return the results when they become ready. :param int timeout: the maximum time to wait for the results :param float interval: the number of seconds between checks :return: the membership request result :rtype: :class:`~groupy.api.membe...
def poll(self, timeout=30, interval=2): """Return the results when they become ready. :param int timeout: the maximum time to wait for the results :param float interval: the number of seconds between checks :return: the membership request result :rtype: :class:`~groupy.api.membe...
[ "Return", "the", "results", "when", "they", "become", "ready", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L288-L300
[ "def", "poll", "(", "self", ",", "timeout", "=", "30", ",", "interval", "=", "2", ")", ":", "time", ".", "sleep", "(", "interval", ")", "start", "=", "time", ".", "time", "(", ")", "while", "time", ".", "time", "(", ")", "-", "start", "<", "tim...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
MembershipRequest.get
Return the results now. :return: the membership request results :rtype: :class:`~groupy.api.memberships.MembershipResult.Results` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if the results have expired
groupy/api/memberships.py
def get(self): """Return the results now. :return: the membership request results :rtype: :class:`~groupy.api.memberships.MembershipResult.Results` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if the results ha...
def get(self): """Return the results now. :return: the membership request results :rtype: :class:`~groupy.api.memberships.MembershipResult.Results` :raises groupy.exceptions.ResultsNotReady: if the results are not ready :raises groupy.exceptions.ResultsExpired: if the results ha...
[ "Return", "the", "results", "now", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/memberships.py#L302-L314
[ "def", "get", "(", "self", ")", ":", "if", "self", ".", "_expired_exception", ":", "raise", "self", ".", "_expired_exception", "if", "self", ".", "_not_ready_exception", ":", "raise", "self", ".", "_not_ready_exception", "return", "self", ".", "results" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.list
List groups by page. The API allows certain fields to be excluded from the results so that very large groups can be fetched without exceeding the maximum response size. At the time of this writing, only 'memberships' is supported. :param int page: page number :param int...
groupy/api/groups.py
def list(self, page=1, per_page=10, omit=None): """List groups by page. The API allows certain fields to be excluded from the results so that very large groups can be fetched without exceeding the maximum response size. At the time of this writing, only 'memberships' is supporte...
def list(self, page=1, per_page=10, omit=None): """List groups by page. The API allows certain fields to be excluded from the results so that very large groups can be fetched without exceeding the maximum response size. At the time of this writing, only 'memberships' is supporte...
[ "List", "groups", "by", "page", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L23-L38
[ "def", "list", "(", "self", ",", "page", "=", "1", ",", "per_page", "=", "10", ",", "omit", "=", "None", ")", ":", "return", "pagers", ".", "GroupList", "(", "self", ",", "self", ".", "_raw_list", ",", "page", "=", "page", ",", "per_page", "=", "...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.list_all
List all groups. Since the order of groups is determined by recent activity, this is the recommended way to obtain a list of all groups. See :func:`~groupy.api.groups.Groups.list` for details about ``omit``. :param int per_page: number of groups per page :param int omit: a comm...
groupy/api/groups.py
def list_all(self, per_page=10, omit=None): """List all groups. Since the order of groups is determined by recent activity, this is the recommended way to obtain a list of all groups. See :func:`~groupy.api.groups.Groups.list` for details about ``omit``. :param int per_page: nu...
def list_all(self, per_page=10, omit=None): """List all groups. Since the order of groups is determined by recent activity, this is the recommended way to obtain a list of all groups. See :func:`~groupy.api.groups.Groups.list` for details about ``omit``. :param int per_page: nu...
[ "List", "all", "groups", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L40-L52
[ "def", "list_all", "(", "self", ",", "per_page", "=", "10", ",", "omit", "=", "None", ")", ":", "return", "self", ".", "list", "(", "per_page", "=", "per_page", ",", "omit", "=", "omit", ")", ".", "autopage", "(", ")" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.list_former
List all former groups. :return: a list of groups :rtype: :class:`list`
groupy/api/groups.py
def list_former(self): """List all former groups. :return: a list of groups :rtype: :class:`list` """ url = utils.urljoin(self.url, 'former') response = self.session.get(url) return [Group(self, **group) for group in response.data]
def list_former(self): """List all former groups. :return: a list of groups :rtype: :class:`list` """ url = utils.urljoin(self.url, 'former') response = self.session.get(url) return [Group(self, **group) for group in response.data]
[ "List", "all", "former", "groups", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L54-L62
[ "def", "list_former", "(", "self", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'former'", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", ")", "return", "[", "Group", "(", "self", ",", "*", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.get
Get a single group by ID. :param str id: a group ID :return: a group :rtype: :class:`~groupy.api.groups.Group`
groupy/api/groups.py
def get(self, id): """Get a single group by ID. :param str id: a group ID :return: a group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, id) response = self.session.get(url) return Group(self, **response.data)
def get(self, id): """Get a single group by ID. :param str id: a group ID :return: a group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, id) response = self.session.get(url) return Group(self, **response.data)
[ "Get", "a", "single", "group", "by", "ID", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L64-L73
[ "def", "get", "(", "self", ",", "id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "id", ")", "response", "=", "self", ".", "session", ".", "get", "(", "url", ")", "return", "Group", "(", "self", ",", "*", "*", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.create
Create a new group. Note that, although possible, there may be issues when not using an image URL from GroupMe's image service. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str image_url: GroupMe ...
groupy/api/groups.py
def create(self, name, description=None, image_url=None, share=None, **kwargs): """Create a new group. Note that, although possible, there may be issues when not using an image URL from GroupMe's image service. :param str name: group name (140 characters maximum) :param str des...
def create(self, name, description=None, image_url=None, share=None, **kwargs): """Create a new group. Note that, although possible, there may be issues when not using an image URL from GroupMe's image service. :param str name: group name (140 characters maximum) :param str des...
[ "Create", "a", "new", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L75-L96
[ "def", "create", "(", "self", ",", "name", ",", "description", "=", "None", ",", "image_url", "=", "None", ",", "share", "=", "None", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'name'", ":", "name", ",", "'description'", ":", "descripti...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.update
Update the details of a group. .. note:: There are significant bugs in this endpoint! 1. not providing ``name`` produces 400: "Topic can't be blank" 2. not providing ``office_mode`` produces 500: "sql: Scan error on column index 14: sql/driver: couldn't convert ...
groupy/api/groups.py
def update(self, id, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of a group. .. note:: There are significant bugs in this endpoint! 1. not providing ``name`` produces 400: "Topic can't be blank" ...
def update(self, id, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of a group. .. note:: There are significant bugs in this endpoint! 1. not providing ``name`` produces 400: "Topic can't be blank" ...
[ "Update", "the", "details", "of", "a", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L98-L133
[ "def", "update", "(", "self", ",", "id", ",", "name", "=", "None", ",", "description", "=", "None", ",", "image_url", "=", "None", ",", "office_mode", "=", "None", ",", "share", "=", "None", ",", "*", "*", "kwargs", ")", ":", "path", "=", "'{}/upda...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.destroy
Destroy a group. :param str id: a group ID :return: ``True`` if successful :rtype: bool
groupy/api/groups.py
def destroy(self, id): """Destroy a group. :param str id: a group ID :return: ``True`` if successful :rtype: bool """ path = '{}/destroy'.format(id) url = utils.urljoin(self.url, path) response = self.session.post(url) return response.ok
def destroy(self, id): """Destroy a group. :param str id: a group ID :return: ``True`` if successful :rtype: bool """ path = '{}/destroy'.format(id) url = utils.urljoin(self.url, path) response = self.session.post(url) return response.ok
[ "Destroy", "a", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L135-L145
[ "def", "destroy", "(", "self", ",", "id", ")", ":", "path", "=", "'{}/destroy'", ".", "format", "(", "id", ")", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "path", ")", "response", "=", "self", ".", "session", ".", "post", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.join
Join a group using a share token. :param str group_id: the group_id of a group :param str share_token: the share token :return: the group :rtype: :class:`~groupy.api.groups.Group`
groupy/api/groups.py
def join(self, group_id, share_token): """Join a group using a share token. :param str group_id: the group_id of a group :param str share_token: the share token :return: the group :rtype: :class:`~groupy.api.groups.Group` """ path = '{}/join/{}'.format(group_id, ...
def join(self, group_id, share_token): """Join a group using a share token. :param str group_id: the group_id of a group :param str share_token: the share token :return: the group :rtype: :class:`~groupy.api.groups.Group` """ path = '{}/join/{}'.format(group_id, ...
[ "Join", "a", "group", "using", "a", "share", "token", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L147-L159
[ "def", "join", "(", "self", ",", "group_id", ",", "share_token", ")", ":", "path", "=", "'{}/join/{}'", ".", "format", "(", "group_id", ",", "share_token", ")", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "path", ")", "response",...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.rejoin
Rejoin a former group. :param str group_id: the group_id of a group :return: the group :rtype: :class:`~groupy.api.groups.Group`
groupy/api/groups.py
def rejoin(self, group_id): """Rejoin a former group. :param str group_id: the group_id of a group :return: the group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, 'join') payload = {'group_id': group_id} response = self.sess...
def rejoin(self, group_id): """Rejoin a former group. :param str group_id: the group_id of a group :return: the group :rtype: :class:`~groupy.api.groups.Group` """ url = utils.urljoin(self.url, 'join') payload = {'group_id': group_id} response = self.sess...
[ "Rejoin", "a", "former", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L161-L171
[ "def", "rejoin", "(", "self", ",", "group_id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'join'", ")", "payload", "=", "{", "'group_id'", ":", "group_id", "}", "response", "=", "self", ".", "session", ".", "post", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Groups.change_owners
Change the owner of a group. .. note:: you must be the owner to change owners :param str group_id: the group_id of a group :param str owner_id: the ID of the new owner :return: the result :rtype: :class:`~groupy.api.groups.ChangeOwnersResult`
groupy/api/groups.py
def change_owners(self, group_id, owner_id): """Change the owner of a group. .. note:: you must be the owner to change owners :param str group_id: the group_id of a group :param str owner_id: the ID of the new owner :return: the result :rtype: :class:`~groupy.api.groups...
def change_owners(self, group_id, owner_id): """Change the owner of a group. .. note:: you must be the owner to change owners :param str group_id: the group_id of a group :param str owner_id: the ID of the new owner :return: the result :rtype: :class:`~groupy.api.groups...
[ "Change", "the", "owner", "of", "a", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L173-L192
[ "def", "change_owners", "(", "self", ",", "group_id", ",", "owner_id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'change_owners'", ")", "payload", "=", "{", "'requests'", ":", "[", "{", "'group_id'", ":", "group_id", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Group.update
Update the details of the group. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str image_url: GroupMe image service URL :param bool office_mode: (undocumented) :param bool share: whether to generate...
groupy/api/groups.py
def update(self, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of the group. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str im...
def update(self, name=None, description=None, image_url=None, office_mode=None, share=None, **kwargs): """Update the details of the group. :param str name: group name (140 characters maximum) :param str description: short description (255 characters maximum) :param str im...
[ "Update", "the", "details", "of", "the", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L272-L292
[ "def", "update", "(", "self", ",", "name", "=", "None", ",", "description", "=", "None", ",", "image_url", "=", "None", ",", "office_mode", "=", "None", ",", "share", "=", "None", ",", "*", "*", "kwargs", ")", ":", "# note we default to the current values ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Group.refresh_from_server
Refresh the group from the server in place.
groupy/api/groups.py
def refresh_from_server(self): """Refresh the group from the server in place.""" group = self.manager.get(id=self.id) self.__init__(self.manager, **group.data)
def refresh_from_server(self): """Refresh the group from the server in place.""" group = self.manager.get(id=self.id) self.__init__(self.manager, **group.data)
[ "Refresh", "the", "group", "from", "the", "server", "in", "place", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L314-L317
[ "def", "refresh_from_server", "(", "self", ")", ":", "group", "=", "self", ".", "manager", ".", "get", "(", "id", "=", "self", ".", "id", ")", "self", ".", "__init__", "(", "self", ".", "manager", ",", "*", "*", "group", ".", "data", ")" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Group.create_bot
Create a new bot in a particular group. :param str name: bot name :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL for each new message :param bool dm_notification: whether to POST-back for direct messages? :return: the new ...
groupy/api/groups.py
def create_bot(self, name, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL...
def create_bot(self, name, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL...
[ "Create", "a", "new", "bot", "in", "a", "particular", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L319-L332
[ "def", "create_bot", "(", "self", ",", "name", ",", "avatar_url", "=", "None", ",", "callback_url", "=", "None", ",", "dm_notification", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_bots", ".", "create", "(", "name", "=", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Group.get_membership
Get your membership. Note that your membership may not exist. For example, you do not have a membership in a former group. Also, the group returned by the API when rejoining a former group does not contain your membership. You must call :func:`refresh_from_server` to update the list of ...
groupy/api/groups.py
def get_membership(self): """Get your membership. Note that your membership may not exist. For example, you do not have a membership in a former group. Also, the group returned by the API when rejoining a former group does not contain your membership. You must call :func:`refres...
def get_membership(self): """Get your membership. Note that your membership may not exist. For example, you do not have a membership in a former group. Also, the group returned by the API when rejoining a former group does not contain your membership. You must call :func:`refres...
[ "Get", "your", "membership", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L345-L362
[ "def", "get_membership", "(", "self", ")", ":", "user_id", "=", "self", ".", "_user", ".", "me", "[", "'user_id'", "]", "for", "member", "in", "self", ".", "members", ":", "if", "member", ".", "user_id", "==", "user_id", ":", "return", "member", "raise...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Group.update_membership
Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.members.Member`
groupy/api/groups.py
def update_membership(self, nickname=None, **kwargs): """Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.members.Member` """ return self.memberships.upda...
def update_membership(self, nickname=None, **kwargs): """Update your own membership. Note that this fails on former groups. :param str nickname: new nickname :return: updated membership :rtype: :class:`~groupy.api.members.Member` """ return self.memberships.upda...
[ "Update", "your", "own", "membership", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/groups.py#L364-L373
[ "def", "update_membership", "(", "self", ",", "nickname", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "memberships", ".", "update", "(", "nickname", "=", "nickname", ",", "*", "*", "kwargs", ")" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
urljoin
Join a base url with a relative path.
groupy/utils.py
def urljoin(base, path=None): """Join a base url with a relative path.""" # /foo/bar + baz makes /foo/bar/baz instead of /foo/baz if path is None: url = base else: if not base.endswith('/'): base += '/' url = urllib.parse.urljoin(base, str(path)) return url
def urljoin(base, path=None): """Join a base url with a relative path.""" # /foo/bar + baz makes /foo/bar/baz instead of /foo/baz if path is None: url = base else: if not base.endswith('/'): base += '/' url = urllib.parse.urljoin(base, str(path)) return url
[ "Join", "a", "base", "url", "with", "a", "relative", "path", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L8-L17
[ "def", "urljoin", "(", "base", ",", "path", "=", "None", ")", ":", "# /foo/bar + baz makes /foo/bar/baz instead of /foo/baz", "if", "path", "is", "None", ":", "url", "=", "base", "else", ":", "if", "not", "base", ".", "endswith", "(", "'/'", ")", ":", "bas...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
parse_share_url
Return the group_id and share_token in a group's share url. :param str share_url: the share url of a group
groupy/utils.py
def parse_share_url(share_url): """Return the group_id and share_token in a group's share url. :param str share_url: the share url of a group """ *__, group_id, share_token = share_url.rstrip('/').split('/') return group_id, share_token
def parse_share_url(share_url): """Return the group_id and share_token in a group's share url. :param str share_url: the share url of a group """ *__, group_id, share_token = share_url.rstrip('/').split('/') return group_id, share_token
[ "Return", "the", "group_id", "and", "share_token", "in", "a", "group", "s", "share", "url", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L20-L26
[ "def", "parse_share_url", "(", "share_url", ")", ":", "*", "__", ",", "group_id", ",", "share_token", "=", "share_url", ".", "rstrip", "(", "'/'", ")", ".", "split", "(", "'/'", ")", "return", "group_id", ",", "share_token" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
get_rfc3339
Return an RFC 3339 timestamp. :param datetime.datetime when: a datetime in UTC :return: RFC 3339 timestamp :rtype: str
groupy/utils.py
def get_rfc3339(when): """Return an RFC 3339 timestamp. :param datetime.datetime when: a datetime in UTC :return: RFC 3339 timestamp :rtype: str """ microseconds = format(when.microsecond, '04d')[:4] rfc3339 = '%Y-%m-%dT%H:%M:%S.{}Z' return when.strftime(rfc3339.format(microseconds))
def get_rfc3339(when): """Return an RFC 3339 timestamp. :param datetime.datetime when: a datetime in UTC :return: RFC 3339 timestamp :rtype: str """ microseconds = format(when.microsecond, '04d')[:4] rfc3339 = '%Y-%m-%dT%H:%M:%S.{}Z' return when.strftime(rfc3339.format(microseconds))
[ "Return", "an", "RFC", "3339", "timestamp", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L29-L38
[ "def", "get_rfc3339", "(", "when", ")", ":", "microseconds", "=", "format", "(", "when", ".", "microsecond", ",", "'04d'", ")", "[", ":", "4", "]", "rfc3339", "=", "'%Y-%m-%dT%H:%M:%S.{}Z'", "return", "when", ".", "strftime", "(", "rfc3339", ".", "format",...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
make_filter
Create a filter from keyword arguments.
groupy/utils.py
def make_filter(**tests): """Create a filter from keyword arguments.""" tests = [AttrTest(k, v) for k, v in tests.items()] return Filter(tests)
def make_filter(**tests): """Create a filter from keyword arguments.""" tests = [AttrTest(k, v) for k, v in tests.items()] return Filter(tests)
[ "Create", "a", "filter", "from", "keyword", "arguments", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L116-L119
[ "def", "make_filter", "(", "*", "*", "tests", ")", ":", "tests", "=", "[", "AttrTest", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "tests", ".", "items", "(", ")", "]", "return", "Filter", "(", "tests", ")" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Filter.find
Find exactly one match in the list of objects. :param objects: objects to filter :type objects: :class:`list` :return: the one matching object :raises groupy.exceptions.NoMatchesError: if no objects match :raises groupy.exceptions.MultipleMatchesError: if multiple objects match
groupy/utils.py
def find(self, objects): """Find exactly one match in the list of objects. :param objects: objects to filter :type objects: :class:`list` :return: the one matching object :raises groupy.exceptions.NoMatchesError: if no objects match :raises groupy.exceptions.MultipleMatc...
def find(self, objects): """Find exactly one match in the list of objects. :param objects: objects to filter :type objects: :class:`list` :return: the one matching object :raises groupy.exceptions.NoMatchesError: if no objects match :raises groupy.exceptions.MultipleMatc...
[ "Find", "exactly", "one", "match", "in", "the", "list", "of", "objects", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/utils.py#L89-L104
[ "def", "find", "(", "self", ",", "objects", ")", ":", "matches", "=", "list", "(", "self", ".", "__call__", "(", "objects", ")", ")", "if", "not", "matches", ":", "raise", "exceptions", ".", "NoMatchesError", "(", "objects", ",", "self", ".", "tests", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Bots.list
Return a list of bots. :return: all of your bots :rtype: :class:`list`
groupy/api/bots.py
def list(self): """Return a list of bots. :return: all of your bots :rtype: :class:`list` """ response = self.session.get(self.url) return [Bot(self, **bot) for bot in response.data]
def list(self): """Return a list of bots. :return: all of your bots :rtype: :class:`list` """ response = self.session.get(self.url) return [Bot(self, **bot) for bot in response.data]
[ "Return", "a", "list", "of", "bots", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L11-L18
[ "def", "list", "(", "self", ")", ":", "response", "=", "self", ".", "session", ".", "get", "(", "self", ".", "url", ")", "return", "[", "Bot", "(", "self", ",", "*", "*", "bot", ")", "for", "bot", "in", "response", ".", "data", "]" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Bots.create
Create a new bot in a particular group. :param str name: bot name :param str group_id: the group_id of a group :param str avatar_url: the URL of an image to use as an avatar :param str callback_url: a POST-back URL for each new message :param bool dm_notification: whether to POS...
groupy/api/bots.py
def create(self, name, group_id, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str group_id: the group_id of a group :param str avatar_url: the URL of an image to use as an ...
def create(self, name, group_id, avatar_url=None, callback_url=None, dm_notification=None, **kwargs): """Create a new bot in a particular group. :param str name: bot name :param str group_id: the group_id of a group :param str avatar_url: the URL of an image to use as an ...
[ "Create", "a", "new", "bot", "in", "a", "particular", "group", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L20-L44
[ "def", "create", "(", "self", ",", "name", ",", "group_id", ",", "avatar_url", "=", "None", ",", "callback_url", "=", "None", ",", "dm_notification", "=", "None", ",", "*", "*", "kwargs", ")", ":", "payload", "=", "{", "'bot'", ":", "{", "'name'", ":...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Bots.post
Post a new message as a bot to its room. :param str bot_id: the ID of the bot :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool
groupy/api/bots.py
def post(self, bot_id, text, attachments=None): """Post a new message as a bot to its room. :param str bot_id: the ID of the bot :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if succe...
def post(self, bot_id, text, attachments=None): """Post a new message as a bot to its room. :param str bot_id: the ID of the bot :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if succe...
[ "Post", "a", "new", "message", "as", "a", "bot", "to", "its", "room", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L46-L63
[ "def", "post", "(", "self", ",", "bot_id", ",", "text", ",", "attachments", "=", "None", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'post'", ")", "payload", "=", "dict", "(", "bot_id", "=", "bot_id", ",", "text", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Bots.destroy
Destroy a bot. :param str bot_id: the ID of the bot to destroy :return: ``True`` if successful :rtype: bool
groupy/api/bots.py
def destroy(self, bot_id): """Destroy a bot. :param str bot_id: the ID of the bot to destroy :return: ``True`` if successful :rtype: bool """ url = utils.urljoin(self.url, 'destroy') payload = {'bot_id': bot_id} response = self.session.post(url, json=payl...
def destroy(self, bot_id): """Destroy a bot. :param str bot_id: the ID of the bot to destroy :return: ``True`` if successful :rtype: bool """ url = utils.urljoin(self.url, 'destroy') payload = {'bot_id': bot_id} response = self.session.post(url, json=payl...
[ "Destroy", "a", "bot", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L65-L75
[ "def", "destroy", "(", "self", ",", "bot_id", ")", ":", "url", "=", "utils", ".", "urljoin", "(", "self", ".", "url", ",", "'destroy'", ")", "payload", "=", "{", "'bot_id'", ":", "bot_id", "}", "response", "=", "self", ".", "session", ".", "post", ...
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
Bot.post
Post a message as the bot. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool
groupy/api/bots.py
def post(self, text, attachments=None): """Post a message as the bot. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool """ return self.manager....
def post(self, text, attachments=None): """Post a message as the bot. :param str text: the text of the message :param attachments: a list of attachments :type attachments: :class:`list` :return: ``True`` if successful :rtype: bool """ return self.manager....
[ "Post", "a", "message", "as", "the", "bot", "." ]
rhgrant10/Groupy
python
https://github.com/rhgrant10/Groupy/blob/ffd8cac57586fa1c218e3b4bfaa531142c3be766/groupy/api/bots.py#L88-L97
[ "def", "post", "(", "self", ",", "text", ",", "attachments", "=", "None", ")", ":", "return", "self", ".", "manager", ".", "post", "(", "self", ".", "bot_id", ",", "text", ",", "attachments", ")" ]
ffd8cac57586fa1c218e3b4bfaa531142c3be766
train
flatten_until
Flatten a nested sequence. A sequence could be a nested list of lists or tuples or a combination of both :param is_leaf: Predicate. Predicate to determine whether an item in the iterable `xs` is a leaf node or not. :param xs: Iterable. Nested lists or tuples :return: list.
pyramda/iterable/flatten.py
def flatten_until(is_leaf, xs): """ Flatten a nested sequence. A sequence could be a nested list of lists or tuples or a combination of both :param is_leaf: Predicate. Predicate to determine whether an item in the iterable `xs` is a leaf node or not. :param xs: Iterable. Neste...
def flatten_until(is_leaf, xs): """ Flatten a nested sequence. A sequence could be a nested list of lists or tuples or a combination of both :param is_leaf: Predicate. Predicate to determine whether an item in the iterable `xs` is a leaf node or not. :param xs: Iterable. Neste...
[ "Flatten", "a", "nested", "sequence", ".", "A", "sequence", "could", "be", "a", "nested", "list", "of", "lists", "or", "tuples", "or", "a", "combination", "of", "both" ]
jackfirth/pyramda
python
https://github.com/jackfirth/pyramda/blob/85ab1c2f456085c9e31e3831459ee1a850ab559c/pyramda/iterable/flatten.py#L9-L28
[ "def", "flatten_until", "(", "is_leaf", ",", "xs", ")", ":", "def", "_flatten_until", "(", "items", ")", ":", "if", "isinstance", "(", "Iterable", ",", "items", ")", "and", "not", "is_leaf", "(", "items", ")", ":", "for", "item", "in", "items", ":", ...
85ab1c2f456085c9e31e3831459ee1a850ab559c
train
flip
Calls the function f by flipping the first two positional arguments
pyramda/function/flip.py
def flip(f): """ Calls the function f by flipping the first two positional arguments """ def wrapped(*args, **kwargs): return f(*flip_first_two(args), **kwargs) f_spec = make_func_curry_spec(f) return curry_by_spec(f_spec, wrapped)
def flip(f): """ Calls the function f by flipping the first two positional arguments """ def wrapped(*args, **kwargs): return f(*flip_first_two(args), **kwargs) f_spec = make_func_curry_spec(f) return curry_by_spec(f_spec, wrapped)
[ "Calls", "the", "function", "f", "by", "flipping", "the", "first", "two", "positional", "arguments" ]
jackfirth/pyramda
python
https://github.com/jackfirth/pyramda/blob/85ab1c2f456085c9e31e3831459ee1a850ab559c/pyramda/function/flip.py#L10-L21
[ "def", "flip", "(", "f", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "f", "(", "*", "flip_first_two", "(", "args", ")", ",", "*", "*", "kwargs", ")", "f_spec", "=", "make_func_curry_spec", "(", "f", ...
85ab1c2f456085c9e31e3831459ee1a850ab559c
train
cachier
A persistent, stale-free memoization decorator. The positional and keyword arguments to the wrapped function must be hashable (i.e. Python's immutable built-in objects, not mutable containers). Also, notice that since objects which are instances of user-defined classes are hashable but all compare uneq...
cachier/core.py
def cachier(stale_after=None, next_time=False, pickle_reload=True, mongetter=None): """A persistent, stale-free memoization decorator. The positional and keyword arguments to the wrapped function must be hashable (i.e. Python's immutable built-in objects, not mutable containers). Also, noti...
def cachier(stale_after=None, next_time=False, pickle_reload=True, mongetter=None): """A persistent, stale-free memoization decorator. The positional and keyword arguments to the wrapped function must be hashable (i.e. Python's immutable built-in objects, not mutable containers). Also, noti...
[ "A", "persistent", "stale", "-", "free", "memoization", "decorator", "." ]
shaypal5/cachier
python
https://github.com/shaypal5/cachier/blob/998233b97b9d905292e9d33413677f98d131f17d/cachier/core.py#L74-L185
[ "def", "cachier", "(", "stale_after", "=", "None", ",", "next_time", "=", "False", ",", "pickle_reload", "=", "True", ",", "mongetter", "=", "None", ")", ":", "# print('Inside the wrapper maker')", "# print('mongetter={}'.format(mongetter))", "# print('stale_after={}'.for...
998233b97b9d905292e9d33413677f98d131f17d
train
defineID
Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str)
urbandictionary.py
def defineID(defid): """Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str) """ json = _get_urban_json(UD_DEFID_URL + urlquote(str(defid))) return _parse_urban_json(json)
def defineID(defid): """Search for UD's definition ID and return list of UrbanDefinition objects. Keyword arguments: defid -- definition ID to search for (int or str) """ json = _get_urban_json(UD_DEFID_URL + urlquote(str(defid))) return _parse_urban_json(json)
[ "Search", "for", "UD", "s", "definition", "ID", "and", "return", "list", "of", "UrbanDefinition", "objects", "." ]
bocong/urbandictionary-py
python
https://github.com/bocong/urbandictionary-py/blob/aa919cd2c28563ca7f09ff80a3125de2dc7576ba/urbandictionary.py#L63-L70
[ "def", "defineID", "(", "defid", ")", ":", "json", "=", "_get_urban_json", "(", "UD_DEFID_URL", "+", "urlquote", "(", "str", "(", "defid", ")", ")", ")", "return", "_parse_urban_json", "(", "json", ")" ]
aa919cd2c28563ca7f09ff80a3125de2dc7576ba
train
has_external_dependency
Check that a non-Python dependency is installed.
setup.py
def has_external_dependency(name): 'Check that a non-Python dependency is installed.' for directory in os.environ['PATH'].split(':'): if os.path.exists(os.path.join(directory, name)): return True return False
def has_external_dependency(name): 'Check that a non-Python dependency is installed.' for directory in os.environ['PATH'].split(':'): if os.path.exists(os.path.join(directory, name)): return True return False
[ "Check", "that", "a", "non", "-", "Python", "dependency", "is", "installed", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/setup.py#L11-L16
[ "def", "has_external_dependency", "(", "name", ")", ":", "for", "directory", "in", "os", ".", "environ", "[", "'PATH'", "]", ".", "split", "(", "':'", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "os", ".", "path", ".", "join", "(", "dire...
75f77e27071ba667df93e740b61bbb0383ba0843
train
with_vtk
Tests VTK interface and mesh repair of Stanford Bunny Mesh
pymeshfix/examples/fix.py
def with_vtk(plot=True): """ Tests VTK interface and mesh repair of Stanford Bunny Mesh """ mesh = vtki.PolyData(bunny_scan) meshfix = pymeshfix.MeshFix(mesh) if plot: print('Plotting input mesh') meshfix.plot() meshfix.repair() if plot: print('Plotting repaired mesh') ...
def with_vtk(plot=True): """ Tests VTK interface and mesh repair of Stanford Bunny Mesh """ mesh = vtki.PolyData(bunny_scan) meshfix = pymeshfix.MeshFix(mesh) if plot: print('Plotting input mesh') meshfix.plot() meshfix.repair() if plot: print('Plotting repaired mesh') ...
[ "Tests", "VTK", "interface", "and", "mesh", "repair", "of", "Stanford", "Bunny", "Mesh" ]
akaszynski/pymeshfix
python
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/examples/fix.py#L15-L27
[ "def", "with_vtk", "(", "plot", "=", "True", ")", ":", "mesh", "=", "vtki", ".", "PolyData", "(", "bunny_scan", ")", "meshfix", "=", "pymeshfix", ".", "MeshFix", "(", "mesh", ")", "if", "plot", ":", "print", "(", "'Plotting input mesh'", ")", "meshfix", ...
51873b25d8d46168479989a528db8456af6748f4
train
MeshFix.load_arrays
Loads triangular mesh from vertex and face numpy arrays. Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points. Parameters ---------- v : np.ndarray n x 3 vertex array. f : np.ndar...
pymeshfix/meshfix.py
def load_arrays(self, v, f): """Loads triangular mesh from vertex and face numpy arrays. Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points. Parameters ---------- v : np.ndarray ...
def load_arrays(self, v, f): """Loads triangular mesh from vertex and face numpy arrays. Both vertex and face arrays should be 2D arrays with each vertex containing XYZ data and each face containing three points. Parameters ---------- v : np.ndarray ...
[ "Loads", "triangular", "mesh", "from", "vertex", "and", "face", "numpy", "arrays", "." ]
akaszynski/pymeshfix
python
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L37-L74
[ "def", "load_arrays", "(", "self", ",", "v", ",", "f", ")", ":", "# Check inputs", "if", "not", "isinstance", "(", "v", ",", "np", ".", "ndarray", ")", ":", "try", ":", "v", "=", "np", ".", "asarray", "(", "v", ",", "np", ".", "float", ")", "if...
51873b25d8d46168479989a528db8456af6748f4
train
MeshFix.mesh
Return the surface mesh
pymeshfix/meshfix.py
def mesh(self): """Return the surface mesh""" triangles = np.empty((self.f.shape[0], 4)) triangles[:, -3:] = self.f triangles[:, 0] = 3 return vtki.PolyData(self.v, triangles, deep=False)
def mesh(self): """Return the surface mesh""" triangles = np.empty((self.f.shape[0], 4)) triangles[:, -3:] = self.f triangles[:, 0] = 3 return vtki.PolyData(self.v, triangles, deep=False)
[ "Return", "the", "surface", "mesh" ]
akaszynski/pymeshfix
python
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L77-L82
[ "def", "mesh", "(", "self", ")", ":", "triangles", "=", "np", ".", "empty", "(", "(", "self", ".", "f", ".", "shape", "[", "0", "]", ",", "4", ")", ")", "triangles", "[", ":", ",", "-", "3", ":", "]", "=", "self", ".", "f", "triangles", "["...
51873b25d8d46168479989a528db8456af6748f4
train
MeshFix.plot
Plot the mesh. Parameters ---------- show_holes : bool, optional Shows boundaries. Default True
pymeshfix/meshfix.py
def plot(self, show_holes=True): """ Plot the mesh. Parameters ---------- show_holes : bool, optional Shows boundaries. Default True """ if show_holes: edges = self.mesh.extract_edges(boundary_edges=True, ...
def plot(self, show_holes=True): """ Plot the mesh. Parameters ---------- show_holes : bool, optional Shows boundaries. Default True """ if show_holes: edges = self.mesh.extract_edges(boundary_edges=True, ...
[ "Plot", "the", "mesh", "." ]
akaszynski/pymeshfix
python
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L84-L104
[ "def", "plot", "(", "self", ",", "show_holes", "=", "True", ")", ":", "if", "show_holes", ":", "edges", "=", "self", ".", "mesh", ".", "extract_edges", "(", "boundary_edges", "=", "True", ",", "feature_edges", "=", "False", ",", "manifold_edges", "=", "F...
51873b25d8d46168479989a528db8456af6748f4
train
MeshFix.repair
Performs mesh repair using MeshFix's default repair process. Parameters ---------- verbose : bool, optional Enables or disables debug printing. Disabled by default. joincomp : bool, optional Attempts to join nearby open components. remove_small...
pymeshfix/meshfix.py
def repair(self, verbose=False, joincomp=False, remove_smallest_components=True): """Performs mesh repair using MeshFix's default repair process. Parameters ---------- verbose : bool, optional Enables or disables debug printing. Disabled by default. ...
def repair(self, verbose=False, joincomp=False, remove_smallest_components=True): """Performs mesh repair using MeshFix's default repair process. Parameters ---------- verbose : bool, optional Enables or disables debug printing. Disabled by default. ...
[ "Performs", "mesh", "repair", "using", "MeshFix", "s", "default", "repair", "process", "." ]
akaszynski/pymeshfix
python
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L106-L133
[ "def", "repair", "(", "self", ",", "verbose", "=", "False", ",", "joincomp", "=", "False", ",", "remove_smallest_components", "=", "True", ")", ":", "assert", "self", ".", "f", ".", "shape", "[", "1", "]", "==", "3", ",", "'Face array must contain three co...
51873b25d8d46168479989a528db8456af6748f4
train
MeshFix.write
Writes a surface mesh to disk. Written file may be an ASCII or binary ply, stl, or vtk mesh file. Parameters ---------- filename : str Filename of mesh to be written. Filetype is inferred from the extension of the filename unless overridden with ...
pymeshfix/meshfix.py
def write(self, filename, binary=True): """Writes a surface mesh to disk. Written file may be an ASCII or binary ply, stl, or vtk mesh file. Parameters ---------- filename : str Filename of mesh to be written. Filetype is inferred from the exten...
def write(self, filename, binary=True): """Writes a surface mesh to disk. Written file may be an ASCII or binary ply, stl, or vtk mesh file. Parameters ---------- filename : str Filename of mesh to be written. Filetype is inferred from the exten...
[ "Writes", "a", "surface", "mesh", "to", "disk", "." ]
akaszynski/pymeshfix
python
https://github.com/akaszynski/pymeshfix/blob/51873b25d8d46168479989a528db8456af6748f4/pymeshfix/meshfix.py#L135-L158
[ "def", "write", "(", "self", ",", "filename", ",", "binary", "=", "True", ")", ":", "self", ".", "mesh", ".", "write", "(", "filename", ",", "binary", ")" ]
51873b25d8d46168479989a528db8456af6748f4
train
scrape
Scrape a URL optionally with parameters. This is effectively a wrapper around urllib2.urlopen.
scraperwiki/utils.py
def scrape(url, params=None, user_agent=None): ''' Scrape a URL optionally with parameters. This is effectively a wrapper around urllib2.urlopen. ''' headers = {} if user_agent: headers['User-Agent'] = user_agent data = params and six.moves.urllib.parse.urlencode(params) or None ...
def scrape(url, params=None, user_agent=None): ''' Scrape a URL optionally with parameters. This is effectively a wrapper around urllib2.urlopen. ''' headers = {} if user_agent: headers['User-Agent'] = user_agent data = params and six.moves.urllib.parse.urlencode(params) or None ...
[ "Scrape", "a", "URL", "optionally", "with", "parameters", ".", "This", "is", "effectively", "a", "wrapper", "around", "urllib2", ".", "urlopen", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/utils.py#L21-L39
[ "def", "scrape", "(", "url", ",", "params", "=", "None", ",", "user_agent", "=", "None", ")", ":", "headers", "=", "{", "}", "if", "user_agent", ":", "headers", "[", "'User-Agent'", "]", "=", "user_agent", "data", "=", "params", "and", "six", ".", "m...
75f77e27071ba667df93e740b61bbb0383ba0843
train
pdftoxml
converts pdf file to xml file
scraperwiki/utils.py
def pdftoxml(pdfdata, options=""): """converts pdf file to xml file""" pdffout = tempfile.NamedTemporaryFile(suffix='.pdf') pdffout.write(pdfdata) pdffout.flush() xmlin = tempfile.NamedTemporaryFile(mode='r', suffix='.xml') tmpxml = xmlin.name # "temph.xml" cmd = 'pdftohtml -xml -nodrm -zo...
def pdftoxml(pdfdata, options=""): """converts pdf file to xml file""" pdffout = tempfile.NamedTemporaryFile(suffix='.pdf') pdffout.write(pdfdata) pdffout.flush() xmlin = tempfile.NamedTemporaryFile(mode='r', suffix='.xml') tmpxml = xmlin.name # "temph.xml" cmd = 'pdftohtml -xml -nodrm -zo...
[ "converts", "pdf", "file", "to", "xml", "file" ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/utils.py#L42-L60
[ "def", "pdftoxml", "(", "pdfdata", ",", "options", "=", "\"\"", ")", ":", "pdffout", "=", "tempfile", ".", "NamedTemporaryFile", "(", "suffix", "=", "'.pdf'", ")", "pdffout", ".", "write", "(", "pdfdata", ")", "pdffout", ".", "flush", "(", ")", "xmlin", ...
75f77e27071ba667df93e740b61bbb0383ba0843
train
execute
Execute an arbitrary SQL query given by query, returning any results as a list of OrderedDicts. A list of values can be supplied as an, additional argument, which will be substituted into question marks in the query.
scraperwiki/sql.py
def execute(query, data=None): """ Execute an arbitrary SQL query given by query, returning any results as a list of OrderedDicts. A list of values can be supplied as an, additional argument, which will be substituted into question marks in the query. """ connection = _State.connection() ...
def execute(query, data=None): """ Execute an arbitrary SQL query given by query, returning any results as a list of OrderedDicts. A list of values can be supplied as an, additional argument, which will be substituted into question marks in the query. """ connection = _State.connection() ...
[ "Execute", "an", "arbitrary", "SQL", "query", "given", "by", "query", "returning", "any", "results", "as", "a", "list", "of", "OrderedDicts", ".", "A", "list", "of", "values", "can", "be", "supplied", "as", "an", "additional", "argument", "which", "will", ...
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L134-L159
[ "def", "execute", "(", "query", ",", "data", "=", "None", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "new_transaction", "(", ")", "if", "data", "is", "None", ":", "data", "=", "[", "]", "result", "=", "connecti...
75f77e27071ba667df93e740b61bbb0383ba0843
train
select
Perform a sql select statement with the given query (without 'select') and return any results as a list of OrderedDicts.
scraperwiki/sql.py
def select(query, data=None): """ Perform a sql select statement with the given query (without 'select') and return any results as a list of OrderedDicts. """ connection = _State.connection() _State.new_transaction() if data is None: data = [] result = connection.execute('select...
def select(query, data=None): """ Perform a sql select statement with the given query (without 'select') and return any results as a list of OrderedDicts. """ connection = _State.connection() _State.new_transaction() if data is None: data = [] result = connection.execute('select...
[ "Perform", "a", "sql", "select", "statement", "with", "the", "given", "query", "(", "without", "select", ")", "and", "return", "any", "results", "as", "a", "list", "of", "OrderedDicts", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L162-L178
[ "def", "select", "(", "query", ",", "data", "=", "None", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "new_transaction", "(", ")", "if", "data", "is", "None", ":", "data", "=", "[", "]", "result", "=", "connectio...
75f77e27071ba667df93e740b61bbb0383ba0843
train
save
Save the given data to the table specified by `table_name` (which defaults to 'swdata'). The data must be a mapping or an iterable of mappings. Unique keys is a list of keys that exist for all rows and for which a unique index will be created.
scraperwiki/sql.py
def save(unique_keys, data, table_name='swdata'): """ Save the given data to the table specified by `table_name` (which defaults to 'swdata'). The data must be a mapping or an iterable of mappings. Unique keys is a list of keys that exist for all rows and for which a unique index will be created. ...
def save(unique_keys, data, table_name='swdata'): """ Save the given data to the table specified by `table_name` (which defaults to 'swdata'). The data must be a mapping or an iterable of mappings. Unique keys is a list of keys that exist for all rows and for which a unique index will be created. ...
[ "Save", "the", "given", "data", "to", "the", "table", "specified", "by", "table_name", "(", "which", "defaults", "to", "swdata", ")", ".", "The", "data", "must", "be", "a", "mapping", "or", "an", "iterable", "of", "mappings", ".", "Unique", "keys", "is",...
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L181-L207
[ "def", "save", "(", "unique_keys", ",", "data", ",", "table_name", "=", "'swdata'", ")", ":", "_set_table", "(", "table_name", ")", "connection", "=", "_State", ".", "connection", "(", ")", "if", "isinstance", "(", "data", ",", "Mapping", ")", ":", "# Is...
75f77e27071ba667df93e740b61bbb0383ba0843
train
_set_table
Specify the table to work on.
scraperwiki/sql.py
def _set_table(table_name): """ Specify the table to work on. """ _State.connection() _State.reflect_metadata() _State.table = sqlalchemy.Table(table_name, _State.metadata, extend_existing=True) if list(_State.table.columns.keys()) == []: _State.t...
def _set_table(table_name): """ Specify the table to work on. """ _State.connection() _State.reflect_metadata() _State.table = sqlalchemy.Table(table_name, _State.metadata, extend_existing=True) if list(_State.table.columns.keys()) == []: _State.t...
[ "Specify", "the", "table", "to", "work", "on", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L210-L222
[ "def", "_set_table", "(", "table_name", ")", ":", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "_State", ".", "table", "=", "sqlalchemy", ".", "Table", "(", "table_name", ",", "_State", ".", "metadata", ",", "extend_e...
75f77e27071ba667df93e740b61bbb0383ba0843
train
show_tables
Return the names of the tables currently in the database.
scraperwiki/sql.py
def show_tables(): """ Return the names of the tables currently in the database. """ _State.connection() _State.reflect_metadata() metadata = _State.metadata response = select('name, sql from sqlite_master where type="table"') return {row['name']: row['sql'] for row in response}
def show_tables(): """ Return the names of the tables currently in the database. """ _State.connection() _State.reflect_metadata() metadata = _State.metadata response = select('name, sql from sqlite_master where type="table"') return {row['name']: row['sql'] for row in response}
[ "Return", "the", "names", "of", "the", "tables", "currently", "in", "the", "database", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L225-L235
[ "def", "show_tables", "(", ")", ":", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "metadata", "=", "_State", ".", "metadata", "response", "=", "select", "(", "'name, sql from sqlite_master where type=\"table\"'", ")", "return...
75f77e27071ba667df93e740b61bbb0383ba0843
train
save_var
Save a variable to the table specified by _State.vars_table_name. Key is the name of the variable, and value is the value.
scraperwiki/sql.py
def save_var(name, value): """ Save a variable to the table specified by _State.vars_table_name. Key is the name of the variable, and value is the value. """ connection = _State.connection() _State.reflect_metadata() vars_table = sqlalchemy.Table( _State.vars_table_name, _State.meta...
def save_var(name, value): """ Save a variable to the table specified by _State.vars_table_name. Key is the name of the variable, and value is the value. """ connection = _State.connection() _State.reflect_metadata() vars_table = sqlalchemy.Table( _State.vars_table_name, _State.meta...
[ "Save", "a", "variable", "to", "the", "table", "specified", "by", "_State", ".", "vars_table_name", ".", "Key", "is", "the", "name", "of", "the", "variable", "and", "value", "is", "the", "value", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L238-L268
[ "def", "save_var", "(", "name", ",", "value", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "vars_table", "=", "sqlalchemy", ".", "Table", "(", "_State", ".", "vars_table_name", ",", "_Stat...
75f77e27071ba667df93e740b61bbb0383ba0843
train
get_var
Returns the variable with the provided key from the table specified by _State.vars_table_name.
scraperwiki/sql.py
def get_var(name, default=None): """ Returns the variable with the provided key from the table specified by _State.vars_table_name. """ alchemytypes = {"text": lambda x: x.decode('utf-8'), "big_integer": lambda x: int(x), "date": lambda x: x.decode('utf-8'), ...
def get_var(name, default=None): """ Returns the variable with the provided key from the table specified by _State.vars_table_name. """ alchemytypes = {"text": lambda x: x.decode('utf-8'), "big_integer": lambda x: int(x), "date": lambda x: x.decode('utf-8'), ...
[ "Returns", "the", "variable", "with", "the", "provided", "key", "from", "the", "table", "specified", "by", "_State", ".", "vars_table_name", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L271-L306
[ "def", "get_var", "(", "name", ",", "default", "=", "None", ")", ":", "alchemytypes", "=", "{", "\"text\"", ":", "lambda", "x", ":", "x", ".", "decode", "(", "'utf-8'", ")", ",", "\"big_integer\"", ":", "lambda", "x", ":", "int", "(", "x", ")", ","...
75f77e27071ba667df93e740b61bbb0383ba0843
train
create_index
Create a new index of the columns in column_names, where column_names is a list of strings. If unique is True, it will be a unique index.
scraperwiki/sql.py
def create_index(column_names, unique=False): """ Create a new index of the columns in column_names, where column_names is a list of strings. If unique is True, it will be a unique index. """ connection = _State.connection() _State.reflect_metadata() table_name = _State.table.name t...
def create_index(column_names, unique=False): """ Create a new index of the columns in column_names, where column_names is a list of strings. If unique is True, it will be a unique index. """ connection = _State.connection() _State.reflect_metadata() table_name = _State.table.name t...
[ "Create", "a", "new", "index", "of", "the", "columns", "in", "column_names", "where", "column_names", "is", "a", "list", "of", "strings", ".", "If", "unique", "is", "True", "it", "will", "be", "a", "unique", "index", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L309-L335
[ "def", "create_index", "(", "column_names", ",", "unique", "=", "False", ")", ":", "connection", "=", "_State", ".", "connection", "(", ")", "_State", ".", "reflect_metadata", "(", ")", "table_name", "=", "_State", ".", "table", ".", "name", "table", "=", ...
75f77e27071ba667df93e740b61bbb0383ba0843
train
fit_row
Takes a row and checks to make sure it fits in the columns of the current table. If it does not fit, adds the required columns.
scraperwiki/sql.py
def fit_row(connection, row, unique_keys): """ Takes a row and checks to make sure it fits in the columns of the current table. If it does not fit, adds the required columns. """ new_columns = [] for column_name, column_value in list(row.items()): new_column = sqlalchemy.Column(column_na...
def fit_row(connection, row, unique_keys): """ Takes a row and checks to make sure it fits in the columns of the current table. If it does not fit, adds the required columns. """ new_columns = [] for column_name, column_value in list(row.items()): new_column = sqlalchemy.Column(column_na...
[ "Takes", "a", "row", "and", "checks", "to", "make", "sure", "it", "fits", "in", "the", "columns", "of", "the", "current", "table", ".", "If", "it", "does", "not", "fit", "adds", "the", "required", "columns", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L338-L357
[ "def", "fit_row", "(", "connection", ",", "row", ",", "unique_keys", ")", ":", "new_columns", "=", "[", "]", "for", "column_name", ",", "column_value", "in", "list", "(", "row", ".", "items", "(", ")", ")", ":", "new_column", "=", "sqlalchemy", ".", "C...
75f77e27071ba667df93e740b61bbb0383ba0843
train
create_table
Save the table currently waiting to be created.
scraperwiki/sql.py
def create_table(unique_keys): """ Save the table currently waiting to be created. """ _State.new_transaction() _State.table.create(bind=_State.engine, checkfirst=True) if unique_keys != []: create_index(unique_keys, unique=True) _State.table_pending = False _State.reflect_metada...
def create_table(unique_keys): """ Save the table currently waiting to be created. """ _State.new_transaction() _State.table.create(bind=_State.engine, checkfirst=True) if unique_keys != []: create_index(unique_keys, unique=True) _State.table_pending = False _State.reflect_metada...
[ "Save", "the", "table", "currently", "waiting", "to", "be", "created", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L360-L369
[ "def", "create_table", "(", "unique_keys", ")", ":", "_State", ".", "new_transaction", "(", ")", "_State", ".", "table", ".", "create", "(", "bind", "=", "_State", ".", "engine", ",", "checkfirst", "=", "True", ")", "if", "unique_keys", "!=", "[", "]", ...
75f77e27071ba667df93e740b61bbb0383ba0843
train
add_column
Add a column to the current table.
scraperwiki/sql.py
def add_column(connection, column): """ Add a column to the current table. """ stmt = alembic.ddl.base.AddColumn(_State.table.name, column) connection.execute(stmt) _State.reflect_metadata()
def add_column(connection, column): """ Add a column to the current table. """ stmt = alembic.ddl.base.AddColumn(_State.table.name, column) connection.execute(stmt) _State.reflect_metadata()
[ "Add", "a", "column", "to", "the", "current", "table", "." ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L372-L378
[ "def", "add_column", "(", "connection", ",", "column", ")", ":", "stmt", "=", "alembic", ".", "ddl", ".", "base", ".", "AddColumn", "(", "_State", ".", "table", ".", "name", ",", "column", ")", "connection", ".", "execute", "(", "stmt", ")", "_State", ...
75f77e27071ba667df93e740b61bbb0383ba0843
train
drop
Drop the current table if it exists
scraperwiki/sql.py
def drop(): """ Drop the current table if it exists """ # Ensure the connection is up _State.connection() _State.table.drop(checkfirst=True) _State.metadata.remove(_State.table) _State.table = None _State.new_transaction()
def drop(): """ Drop the current table if it exists """ # Ensure the connection is up _State.connection() _State.table.drop(checkfirst=True) _State.metadata.remove(_State.table) _State.table = None _State.new_transaction()
[ "Drop", "the", "current", "table", "if", "it", "exists" ]
scraperwiki/scraperwiki-python
python
https://github.com/scraperwiki/scraperwiki-python/blob/75f77e27071ba667df93e740b61bbb0383ba0843/scraperwiki/sql.py#L394-L403
[ "def", "drop", "(", ")", ":", "# Ensure the connection is up", "_State", ".", "connection", "(", ")", "_State", ".", "table", ".", "drop", "(", "checkfirst", "=", "True", ")", "_State", ".", "metadata", ".", "remove", "(", "_State", ".", "table", ")", "_...
75f77e27071ba667df93e740b61bbb0383ba0843
train
attach_attrs_table
Extracts attributes and attaches them to element.
pandoc_tablenos.py
def attach_attrs_table(key, value, fmt, meta): """Extracts attributes and attaches them to element.""" # We can't use attach_attrs_factory() because Table is a block-level element if key in ['Table']: assert len(value) == 5 caption = value[0] # caption, align, x, head, body # Set ...
def attach_attrs_table(key, value, fmt, meta): """Extracts attributes and attaches them to element.""" # We can't use attach_attrs_factory() because Table is a block-level element if key in ['Table']: assert len(value) == 5 caption = value[0] # caption, align, x, head, body # Set ...
[ "Extracts", "attributes", "and", "attaches", "them", "to", "element", "." ]
tomduck/pandoc-tablenos
python
https://github.com/tomduck/pandoc-tablenos/blob/b3c7b6a259eec5fb7c8420033d05b32640f1f266/pandoc_tablenos.py#L89-L107
[ "def", "attach_attrs_table", "(", "key", ",", "value", ",", "fmt", ",", "meta", ")", ":", "# We can't use attach_attrs_factory() because Table is a block-level element", "if", "key", "in", "[", "'Table'", "]", ":", "assert", "len", "(", "value", ")", "==", "5", ...
b3c7b6a259eec5fb7c8420033d05b32640f1f266
train
process_tables
Processes the attributed tables.
pandoc_tablenos.py
def process_tables(key, value, fmt, meta): """Processes the attributed tables.""" global has_unnumbered_tables # pylint: disable=global-statement # Process block-level Table elements if key == 'Table': # Inspect the table if len(value) == 5: # Unattributed, bail out has_...
def process_tables(key, value, fmt, meta): """Processes the attributed tables.""" global has_unnumbered_tables # pylint: disable=global-statement # Process block-level Table elements if key == 'Table': # Inspect the table if len(value) == 5: # Unattributed, bail out has_...
[ "Processes", "the", "attributed", "tables", "." ]
tomduck/pandoc-tablenos
python
https://github.com/tomduck/pandoc-tablenos/blob/b3c7b6a259eec5fb7c8420033d05b32640f1f266/pandoc_tablenos.py#L195-L249
[ "def", "process_tables", "(", "key", ",", "value", ",", "fmt", ",", "meta", ")", ":", "global", "has_unnumbered_tables", "# pylint: disable=global-statement", "# Process block-level Table elements", "if", "key", "==", "'Table'", ":", "# Inspect the table", "if", "len", ...
b3c7b6a259eec5fb7c8420033d05b32640f1f266
train
main
Filters the document AST.
pandoc_tablenos.py
def main(): """Filters the document AST.""" # pylint: disable=global-statement global PANDOCVERSION global AttrTable # Get the output format and document fmt = args.fmt doc = json.loads(STDIN.read()) # Initialize pandocxnos # pylint: disable=too-many-function-args PANDOCVERSIO...
def main(): """Filters the document AST.""" # pylint: disable=global-statement global PANDOCVERSION global AttrTable # Get the output format and document fmt = args.fmt doc = json.loads(STDIN.read()) # Initialize pandocxnos # pylint: disable=too-many-function-args PANDOCVERSIO...
[ "Filters", "the", "document", "AST", "." ]
tomduck/pandoc-tablenos
python
https://github.com/tomduck/pandoc-tablenos/blob/b3c7b6a259eec5fb7c8420033d05b32640f1f266/pandoc_tablenos.py#L368-L441
[ "def", "main", "(", ")", ":", "# pylint: disable=global-statement", "global", "PANDOCVERSION", "global", "AttrTable", "# Get the output format and document", "fmt", "=", "args", ".", "fmt", "doc", "=", "json", ".", "loads", "(", "STDIN", ".", "read", "(", ")", "...
b3c7b6a259eec5fb7c8420033d05b32640f1f266
train
request
Make a http request to clockwork, using the XML provided Sets sensible headers for the request. If there is a problem with the http connection a clockwork_exceptions.HttpException is raised
clockwork/clockwork_http.py
def request(url, xml): """Make a http request to clockwork, using the XML provided Sets sensible headers for the request. If there is a problem with the http connection a clockwork_exceptions.HttpException is raised """ r = _urllib.Request(url, xml) r.add_header('Content-Type'...
def request(url, xml): """Make a http request to clockwork, using the XML provided Sets sensible headers for the request. If there is a problem with the http connection a clockwork_exceptions.HttpException is raised """ r = _urllib.Request(url, xml) r.add_header('Content-Type'...
[ "Make", "a", "http", "request", "to", "clockwork", "using", "the", "XML", "provided", "Sets", "sensible", "headers", "for", "the", "request", ".", "If", "there", "is", "a", "problem", "with", "the", "http", "connection", "a", "clockwork_exceptions", ".", "Ht...
mediaburst/clockwork-python
python
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork_http.py#L11-L44
[ "def", "request", "(", "url", ",", "xml", ")", ":", "r", "=", "_urllib", ".", "Request", "(", "url", ",", "xml", ")", "r", ".", "add_header", "(", "'Content-Type'", ",", "'application/xml'", ")", "r", ".", "add_header", "(", "'User-Agent'", ",", "'Cloc...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
train
API.get_balance
Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set
clockwork/clockwork.py
def get_balance(self): """Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set""" xml_root ...
def get_balance(self): """Check the balance fot this account. Returns a dictionary containing: account_type: The account type balance: The balance remaining on the account currency: The currency used for the account balance. Assume GBP in not set""" xml_root ...
[ "Check", "the", "balance", "fot", "this", "account", ".", "Returns", "a", "dictionary", "containing", ":", "account_type", ":", "The", "account", "type", "balance", ":", "The", "balance", "remaining", "on", "the", "account", "currency", ":", "The", "currency",...
mediaburst/clockwork-python
python
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L47-L67
[ "def", "get_balance", "(", "self", ")", ":", "xml_root", "=", "self", ".", "__init_xml", "(", "'Balance'", ")", "response", "=", "clockwork_http", ".", "request", "(", "BALANCE_URL", ",", "etree", ".", "tostring", "(", "xml_root", ",", "encoding", "=", "'u...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
train
API.send
Send a SMS message, or an array of SMS messages
clockwork/clockwork.py
def send(self, messages): """Send a SMS message, or an array of SMS messages""" tmpSms = SMS(to='', message='') if str(type(messages)) == str(type(tmpSms)): messages = [messages] xml_root = self.__init_xml('Message') wrapper_id = 0 for m in messages: ...
def send(self, messages): """Send a SMS message, or an array of SMS messages""" tmpSms = SMS(to='', message='') if str(type(messages)) == str(type(tmpSms)): messages = [messages] xml_root = self.__init_xml('Message') wrapper_id = 0 for m in messages: ...
[ "Send", "a", "SMS", "message", "or", "an", "array", "of", "SMS", "messages" ]
mediaburst/clockwork-python
python
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L69-L115
[ "def", "send", "(", "self", ",", "messages", ")", ":", "tmpSms", "=", "SMS", "(", "to", "=", "''", ",", "message", "=", "''", ")", "if", "str", "(", "type", "(", "messages", ")", ")", "==", "str", "(", "type", "(", "tmpSms", ")", ")", ":", "m...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
train
API.__init_xml
Init a etree element and pop a key in there
clockwork/clockwork.py
def __init_xml(self, rootElementTag): """Init a etree element and pop a key in there""" xml_root = etree.Element(rootElementTag) key = etree.SubElement(xml_root, "Key") key.text = self.apikey return xml_root
def __init_xml(self, rootElementTag): """Init a etree element and pop a key in there""" xml_root = etree.Element(rootElementTag) key = etree.SubElement(xml_root, "Key") key.text = self.apikey return xml_root
[ "Init", "a", "etree", "element", "and", "pop", "a", "key", "in", "there" ]
mediaburst/clockwork-python
python
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L117-L122
[ "def", "__init_xml", "(", "self", ",", "rootElementTag", ")", ":", "xml_root", "=", "etree", ".", "Element", "(", "rootElementTag", ")", "key", "=", "etree", ".", "SubElement", "(", "xml_root", ",", "\"Key\"", ")", "key", ".", "text", "=", "self", ".", ...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
train
API.__build_sms_data
Build a dictionary of SMS message elements
clockwork/clockwork.py
def __build_sms_data(self, message): """Build a dictionary of SMS message elements""" attributes = {} attributes_to_translate = { 'to' : 'To', 'message' : 'Content', 'client_id' : 'ClientID', 'concat' : 'Concat', 'from_name': 'From', ...
def __build_sms_data(self, message): """Build a dictionary of SMS message elements""" attributes = {} attributes_to_translate = { 'to' : 'To', 'message' : 'Content', 'client_id' : 'ClientID', 'concat' : 'Concat', 'from_name': 'From', ...
[ "Build", "a", "dictionary", "of", "SMS", "message", "elements" ]
mediaburst/clockwork-python
python
https://github.com/mediaburst/clockwork-python/blob/7f8368bbed1fcb5218584fbc5094d93c6aa365d1/clockwork/clockwork.py#L125-L150
[ "def", "__build_sms_data", "(", "self", ",", "message", ")", ":", "attributes", "=", "{", "}", "attributes_to_translate", "=", "{", "'to'", ":", "'To'", ",", "'message'", ":", "'Content'", ",", "'client_id'", ":", "'ClientID'", ",", "'concat'", ":", "'Concat...
7f8368bbed1fcb5218584fbc5094d93c6aa365d1
train
pstats2entries
Helper to convert serialized pstats back to a list of raw entries. Converse operation of cProfile.Profile.snapshot_stats()
pyprof2calltree.py
def pstats2entries(data): """Helper to convert serialized pstats back to a list of raw entries. Converse operation of cProfile.Profile.snapshot_stats() """ # Each entry's key is a tuple of (filename, line number, function name) entries = {} allcallers = {} # first pass over stats to build ...
def pstats2entries(data): """Helper to convert serialized pstats back to a list of raw entries. Converse operation of cProfile.Profile.snapshot_stats() """ # Each entry's key is a tuple of (filename, line number, function name) entries = {} allcallers = {} # first pass over stats to build ...
[ "Helper", "to", "convert", "serialized", "pstats", "back", "to", "a", "list", "of", "raw", "entries", "." ]
pwaller/pyprof2calltree
python
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L106-L141
[ "def", "pstats2entries", "(", "data", ")", ":", "# Each entry's key is a tuple of (filename, line number, function name)", "entries", "=", "{", "}", "allcallers", "=", "{", "}", "# first pass over stats to build the list of entry instances", "for", "code_info", ",", "call_info"...
62b99c7b366ad317d3d5e21fb73466c8baea670e
train
is_installed
Return whether or not a given executable is installed on the machine.
pyprof2calltree.py
def is_installed(prog): """Return whether or not a given executable is installed on the machine.""" with open(os.devnull, 'w') as devnull: try: if os.name == 'nt': retcode = subprocess.call(['where', prog], stdout=devnull) else: retcode = subproces...
def is_installed(prog): """Return whether or not a given executable is installed on the machine.""" with open(os.devnull, 'w') as devnull: try: if os.name == 'nt': retcode = subprocess.call(['where', prog], stdout=devnull) else: retcode = subproces...
[ "Return", "whether", "or", "not", "a", "given", "executable", "is", "installed", "on", "the", "machine", "." ]
pwaller/pyprof2calltree
python
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L144-L159
[ "def", "is_installed", "(", "prog", ")", ":", "with", "open", "(", "os", ".", "devnull", ",", "'w'", ")", "as", "devnull", ":", "try", ":", "if", "os", ".", "name", "==", "'nt'", ":", "retcode", "=", "subprocess", ".", "call", "(", "[", "'where'", ...
62b99c7b366ad317d3d5e21fb73466c8baea670e
train
main
Execute the converter using parameters provided on the command line
pyprof2calltree.py
def main(): """Execute the converter using parameters provided on the command line""" parser = argparse.ArgumentParser() parser.add_argument('-o', '--outfile', metavar='output_file_path', help="Save calltree stats to <outfile>") parser.add_argument('-i', '--infile', metavar='inp...
def main(): """Execute the converter using parameters provided on the command line""" parser = argparse.ArgumentParser() parser.add_argument('-o', '--outfile', metavar='output_file_path', help="Save calltree stats to <outfile>") parser.add_argument('-i', '--infile', metavar='inp...
[ "Execute", "the", "converter", "using", "parameters", "provided", "on", "the", "command", "line" ]
pwaller/pyprof2calltree
python
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L289-L355
[ "def", "main", "(", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'-o'", ",", "'--outfile'", ",", "metavar", "=", "'output_file_path'", ",", "help", "=", "\"Save calltree stats to <outfile>\"", ")", ...
62b99c7b366ad317d3d5e21fb73466c8baea670e
train
convert
convert `profiling_data` to calltree format and dump it to `outputfile` `profiling_data` can either be: - a pstats.Stats instance - the filename of a pstats.Stats dump - the result of a call to cProfile.Profile.getstats() `outputfile` can either be: - a file() instance open in ...
pyprof2calltree.py
def convert(profiling_data, outputfile): """convert `profiling_data` to calltree format and dump it to `outputfile` `profiling_data` can either be: - a pstats.Stats instance - the filename of a pstats.Stats dump - the result of a call to cProfile.Profile.getstats() `outputfile` can...
def convert(profiling_data, outputfile): """convert `profiling_data` to calltree format and dump it to `outputfile` `profiling_data` can either be: - a pstats.Stats instance - the filename of a pstats.Stats dump - the result of a call to cProfile.Profile.getstats() `outputfile` can...
[ "convert", "profiling_data", "to", "calltree", "format", "and", "dump", "it", "to", "outputfile" ]
pwaller/pyprof2calltree
python
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L370-L387
[ "def", "convert", "(", "profiling_data", ",", "outputfile", ")", ":", "converter", "=", "CalltreeConverter", "(", "profiling_data", ")", "if", "is_basestring", "(", "outputfile", ")", ":", "with", "open", "(", "outputfile", ",", "\"w\"", ")", "as", "f", ":",...
62b99c7b366ad317d3d5e21fb73466c8baea670e
train
CalltreeConverter.output
Write the converted entries to out_file
pyprof2calltree.py
def output(self, out_file): """Write the converted entries to out_file""" self.out_file = out_file out_file.write('event: ns : Nanoseconds\n') out_file.write('events: ns\n') self._output_summary() for entry in sorted(self.entries, key=_entry_sort_key): self._o...
def output(self, out_file): """Write the converted entries to out_file""" self.out_file = out_file out_file.write('event: ns : Nanoseconds\n') out_file.write('events: ns\n') self._output_summary() for entry in sorted(self.entries, key=_entry_sort_key): self._o...
[ "Write", "the", "converted", "entries", "to", "out_file" ]
pwaller/pyprof2calltree
python
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L204-L211
[ "def", "output", "(", "self", ",", "out_file", ")", ":", "self", ".", "out_file", "=", "out_file", "out_file", ".", "write", "(", "'event: ns : Nanoseconds\\n'", ")", "out_file", ".", "write", "(", "'events: ns\\n'", ")", "self", ".", "_output_summary", "(", ...
62b99c7b366ad317d3d5e21fb73466c8baea670e
train
CalltreeConverter.visualize
Launch kcachegrind on the converted entries. One of the executables listed in KCACHEGRIND_EXECUTABLES must be present in the system path.
pyprof2calltree.py
def visualize(self): """Launch kcachegrind on the converted entries. One of the executables listed in KCACHEGRIND_EXECUTABLES must be present in the system path. """ available_cmd = None for cmd in KCACHEGRIND_EXECUTABLES: if is_installed(cmd): ...
def visualize(self): """Launch kcachegrind on the converted entries. One of the executables listed in KCACHEGRIND_EXECUTABLES must be present in the system path. """ available_cmd = None for cmd in KCACHEGRIND_EXECUTABLES: if is_installed(cmd): ...
[ "Launch", "kcachegrind", "on", "the", "converted", "entries", "." ]
pwaller/pyprof2calltree
python
https://github.com/pwaller/pyprof2calltree/blob/62b99c7b366ad317d3d5e21fb73466c8baea670e/pyprof2calltree.py#L213-L247
[ "def", "visualize", "(", "self", ")", ":", "available_cmd", "=", "None", "for", "cmd", "in", "KCACHEGRIND_EXECUTABLES", ":", "if", "is_installed", "(", "cmd", ")", ":", "available_cmd", "=", "cmd", "break", "if", "available_cmd", "is", "None", ":", "sys", ...
62b99c7b366ad317d3d5e21fb73466c8baea670e
train
Bouncer.get_app
Helper method that implements the logic to look up an application.
flask_bouncer.py
def get_app(self, reference_app=None): """Helper method that implements the logic to look up an application.""" if reference_app is not None: return reference_app if self.app is not None: return self.app ctx = stack.top if ctx is not None: ...
def get_app(self, reference_app=None): """Helper method that implements the logic to look up an application.""" if reference_app is not None: return reference_app if self.app is not None: return self.app ctx = stack.top if ctx is not None: ...
[ "Helper", "method", "that", "implements", "the", "logic", "to", "look", "up", "an", "application", "." ]
bouncer-app/flask-bouncer
python
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L80-L96
[ "def", "get_app", "(", "self", ",", "reference_app", "=", "None", ")", ":", "if", "reference_app", "is", "not", "None", ":", "return", "reference_app", "if", "self", ".", "app", "is", "not", "None", ":", "return", "self", ".", "app", "ctx", "=", "stack...
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
train
Bouncer.init_app
Initializes the Flask-Bouncer extension for the specified application. :param app: The application.
flask_bouncer.py
def init_app(self, app, **kwargs): """ Initializes the Flask-Bouncer extension for the specified application. :param app: The application. """ self.app = app self._init_extension() self.app.before_request(self.check_implicit_rules) if kwargs.get('ensure_author...
def init_app(self, app, **kwargs): """ Initializes the Flask-Bouncer extension for the specified application. :param app: The application. """ self.app = app self._init_extension() self.app.before_request(self.check_implicit_rules) if kwargs.get('ensure_author...
[ "Initializes", "the", "Flask", "-", "Bouncer", "extension", "for", "the", "specified", "application", "." ]
bouncer-app/flask-bouncer
python
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L98-L110
[ "def", "init_app", "(", "self", ",", "app", ",", "*", "*", "kwargs", ")", ":", "self", ".", "app", "=", "app", "self", ".", "_init_extension", "(", ")", "self", ".", "app", ".", "before_request", "(", "self", ".", "check_implicit_rules", ")", "if", "...
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
train
Bouncer.check_authorization
checks that an authorization call has been made during the request
flask_bouncer.py
def check_authorization(self, response): """checks that an authorization call has been made during the request""" if not hasattr(request, '_authorized'): raise Unauthorized elif not request._authorized: raise Unauthorized return response
def check_authorization(self, response): """checks that an authorization call has been made during the request""" if not hasattr(request, '_authorized'): raise Unauthorized elif not request._authorized: raise Unauthorized return response
[ "checks", "that", "an", "authorization", "call", "has", "been", "made", "during", "the", "request" ]
bouncer-app/flask-bouncer
python
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L118-L124
[ "def", "check_authorization", "(", "self", ",", "response", ")", ":", "if", "not", "hasattr", "(", "request", ",", "'_authorized'", ")", ":", "raise", "Unauthorized", "elif", "not", "request", ".", "_authorized", ":", "raise", "Unauthorized", "return", "respon...
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
train
Bouncer.check_implicit_rules
if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will automatically check the permissions for you
flask_bouncer.py
def check_implicit_rules(self): """ if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will automatically check the permissions for you """ if not self.request_is_managed_by_flask_classy(): return if self.method_is_ex...
def check_implicit_rules(self): """ if you are using flask classy are using the standard index,new,put,post, etc ... type routes, we will automatically check the permissions for you """ if not self.request_is_managed_by_flask_classy(): return if self.method_is_ex...
[ "if", "you", "are", "using", "flask", "classy", "are", "using", "the", "standard", "index", "new", "put", "post", "etc", "...", "type", "routes", "we", "will", "automatically", "check", "the", "permissions", "for", "you" ]
bouncer-app/flask-bouncer
python
https://github.com/bouncer-app/flask-bouncer/blob/41a8763520cca7d7ff1b247ab6eb3383281f5ab7/flask_bouncer.py#L126-L138
[ "def", "check_implicit_rules", "(", "self", ")", ":", "if", "not", "self", ".", "request_is_managed_by_flask_classy", "(", ")", ":", "return", "if", "self", ".", "method_is_explictly_overwritten", "(", ")", ":", "return", "class_name", ",", "action", "=", "reque...
41a8763520cca7d7ff1b247ab6eb3383281f5ab7
train
rotate_texture
Rotates the given texture by a given angle. Args: texture (texture): the texture to rotate rotation (float): the angle of rotation in degrees x_offset (float): the x component of the center of rotation (optional) y_offset (float): the y component of the center of rotation (optional)...
penkit/textures/util.py
def rotate_texture(texture, rotation, x_offset=0.5, y_offset=0.5): """Rotates the given texture by a given angle. Args: texture (texture): the texture to rotate rotation (float): the angle of rotation in degrees x_offset (float): the x component of the center of rotation (optional) ...
def rotate_texture(texture, rotation, x_offset=0.5, y_offset=0.5): """Rotates the given texture by a given angle. Args: texture (texture): the texture to rotate rotation (float): the angle of rotation in degrees x_offset (float): the x component of the center of rotation (optional) ...
[ "Rotates", "the", "given", "texture", "by", "a", "given", "angle", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/util.py#L6-L24
[ "def", "rotate_texture", "(", "texture", ",", "rotation", ",", "x_offset", "=", "0.5", ",", "y_offset", "=", "0.5", ")", ":", "x", ",", "y", "=", "texture", "x", "=", "x", ".", "copy", "(", ")", "-", "x_offset", "y", "=", "y", ".", "copy", "(", ...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
fit_texture
Fits a layer into a texture by scaling each axis to (0, 1). Does not preserve aspect ratio (TODO: make this an option). Args: layer (layer): the layer to scale Returns: texture: A texture.
penkit/textures/util.py
def fit_texture(layer): """Fits a layer into a texture by scaling each axis to (0, 1). Does not preserve aspect ratio (TODO: make this an option). Args: layer (layer): the layer to scale Returns: texture: A texture. """ x, y = layer x = (x - np.nanmin(x)) / (np.nanmax(x) -...
def fit_texture(layer): """Fits a layer into a texture by scaling each axis to (0, 1). Does not preserve aspect ratio (TODO: make this an option). Args: layer (layer): the layer to scale Returns: texture: A texture. """ x, y = layer x = (x - np.nanmin(x)) / (np.nanmax(x) -...
[ "Fits", "a", "layer", "into", "a", "texture", "by", "scaling", "each", "axis", "to", "(", "0", "1", ")", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/util.py#L27-L41
[ "def", "fit_texture", "(", "layer", ")", ":", "x", ",", "y", "=", "layer", "x", "=", "(", "x", "-", "np", ".", "nanmin", "(", "x", ")", ")", "/", "(", "np", ".", "nanmax", "(", "x", ")", "-", "np", ".", "nanmin", "(", "x", ")", ")", "y", ...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
check_valid_solution
Check that the solution is valid: every path is visited exactly once.
optimizer/penkit_optimize/route_util.py
def check_valid_solution(solution, graph): """Check that the solution is valid: every path is visited exactly once.""" expected = Counter( i for (i, _) in graph.iter_starts_with_index() if i < graph.get_disjoint(i) ) actual = Counter( min(i, graph.get_disjoint(i)) for i i...
def check_valid_solution(solution, graph): """Check that the solution is valid: every path is visited exactly once.""" expected = Counter( i for (i, _) in graph.iter_starts_with_index() if i < graph.get_disjoint(i) ) actual = Counter( min(i, graph.get_disjoint(i)) for i i...
[ "Check", "that", "the", "solution", "is", "valid", ":", "every", "path", "is", "visited", "exactly", "once", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/route_util.py#L5-L23
[ "def", "check_valid_solution", "(", "solution", ",", "graph", ")", ":", "expected", "=", "Counter", "(", "i", "for", "(", "i", ",", "_", ")", "in", "graph", ".", "iter_starts_with_index", "(", ")", "if", "i", "<", "graph", ".", "get_disjoint", "(", "i"...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
get_route_from_solution
Converts a solution (a list of node indices) into a list of paths suitable for rendering.
optimizer/penkit_optimize/route_util.py
def get_route_from_solution(solution, graph): """Converts a solution (a list of node indices) into a list of paths suitable for rendering.""" # As a guard against comparing invalid "solutions", # ensure that this solution is valid. assert check_valid_solution(solution, graph) return [graph.get...
def get_route_from_solution(solution, graph): """Converts a solution (a list of node indices) into a list of paths suitable for rendering.""" # As a guard against comparing invalid "solutions", # ensure that this solution is valid. assert check_valid_solution(solution, graph) return [graph.get...
[ "Converts", "a", "solution", "(", "a", "list", "of", "node", "indices", ")", "into", "a", "list", "of", "paths", "suitable", "for", "rendering", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/route_util.py#L26-L34
[ "def", "get_route_from_solution", "(", "solution", ",", "graph", ")", ":", "# As a guard against comparing invalid \"solutions\",", "# ensure that this solution is valid.", "assert", "check_valid_solution", "(", "solution", ",", "graph", ")", "return", "[", "graph", ".", "g...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
branching_turtle_generator
Given a turtle program, creates a generator of turtle positions. The state of the turtle consists of its position and angle. The turtle starts at the position ``(0, 0)`` facing up. Each character in the turtle program is processed in order and causes an update to the state. The position component o...
penkit/turtle.py
def branching_turtle_generator(turtle_program, turn_amount=DEFAULT_TURN, initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1): """Given a turtle program, creates a generator of turtle positions. The state of the turtle consists of its position and angle. The turtle starts a...
def branching_turtle_generator(turtle_program, turn_amount=DEFAULT_TURN, initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1): """Given a turtle program, creates a generator of turtle positions. The state of the turtle consists of its position and angle. The turtle starts a...
[ "Given", "a", "turtle", "program", "creates", "a", "generator", "of", "turtle", "positions", ".", "The", "state", "of", "the", "turtle", "consists", "of", "its", "position", "and", "angle", ".", "The", "turtle", "starts", "at", "the", "position", "(", "0",...
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/turtle.py#L23-L89
[ "def", "branching_turtle_generator", "(", "turtle_program", ",", "turn_amount", "=", "DEFAULT_TURN", ",", "initial_angle", "=", "DEFAULT_INITIAL_ANGLE", ",", "resolution", "=", "1", ")", ":", "saved_states", "=", "list", "(", ")", "state", "=", "(", "0", ",", ...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
turtle_to_texture
Makes a texture from a turtle program. Args: turtle_program (str): a string representing the turtle program; see the docstring of `branching_turtle_generator` for more details turn_amount (float): amount to turn in degrees initial_angle (float): initial orientation of the turtle...
penkit/turtle.py
def turtle_to_texture(turtle_program, turn_amount=DEFAULT_TURN, initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1): """Makes a texture from a turtle program. Args: turtle_program (str): a string representing the turtle program; see the docstring of `branching_turtle_ge...
def turtle_to_texture(turtle_program, turn_amount=DEFAULT_TURN, initial_angle=DEFAULT_INITIAL_ANGLE, resolution=1): """Makes a texture from a turtle program. Args: turtle_program (str): a string representing the turtle program; see the docstring of `branching_turtle_ge...
[ "Makes", "a", "texture", "from", "a", "turtle", "program", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/turtle.py#L104-L120
[ "def", "turtle_to_texture", "(", "turtle_program", ",", "turn_amount", "=", "DEFAULT_TURN", ",", "initial_angle", "=", "DEFAULT_INITIAL_ANGLE", ",", "resolution", "=", "1", ")", ":", "generator", "=", "branching_turtle_generator", "(", "turtle_program", ",", "turn_amo...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
transform_sequence
Applies a given set of substitution rules to the given string or generator. For more background see: https://en.wikipedia.org/wiki/L-system Args: sequence (str): a string or generator onto which transformations are applied transformations (dict): a dictionary mapping each char to the strin...
penkit/fractal/l_systems.py
def transform_sequence(sequence, transformations): """Applies a given set of substitution rules to the given string or generator. For more background see: https://en.wikipedia.org/wiki/L-system Args: sequence (str): a string or generator onto which transformations are applied transform...
def transform_sequence(sequence, transformations): """Applies a given set of substitution rules to the given string or generator. For more background see: https://en.wikipedia.org/wiki/L-system Args: sequence (str): a string or generator onto which transformations are applied transform...
[ "Applies", "a", "given", "set", "of", "substitution", "rules", "to", "the", "given", "string", "or", "generator", ".", "For", "more", "background", "see", ":", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "L", "-", "system"...
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/fractal/l_systems.py#L10-L31
[ "def", "transform_sequence", "(", "sequence", ",", "transformations", ")", ":", "for", "c", "in", "sequence", ":", "for", "k", "in", "transformations", ".", "get", "(", "c", ",", "c", ")", ":", "yield", "k" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
transform_multiple
Chains a transformation a given number of times. Args: sequence (str): a string or generator onto which transformations are applied transformations (dict): a dictionary mapping each char to the string that is substituted for it when the rule is applied iterations (int): how many...
penkit/fractal/l_systems.py
def transform_multiple(sequence, transformations, iterations): """Chains a transformation a given number of times. Args: sequence (str): a string or generator onto which transformations are applied transformations (dict): a dictionary mapping each char to the string that is substitu...
def transform_multiple(sequence, transformations, iterations): """Chains a transformation a given number of times. Args: sequence (str): a string or generator onto which transformations are applied transformations (dict): a dictionary mapping each char to the string that is substitu...
[ "Chains", "a", "transformation", "a", "given", "number", "of", "times", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/fractal/l_systems.py#L34-L48
[ "def", "transform_multiple", "(", "sequence", ",", "transformations", ",", "iterations", ")", ":", "for", "_", "in", "range", "(", "iterations", ")", ":", "sequence", "=", "transform_sequence", "(", "sequence", ",", "transformations", ")", "return", "sequence" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
l_system
Generates a texture by running transformations on a turtle program. First, the given transformations are applied to the axiom. This is repeated `iterations` times. Then, the output is run as a turtle program to get a texture, which is returned. For more background see: https://en.wikipedia.org/wiki/L-...
penkit/fractal/l_systems.py
def l_system(axiom, transformations, iterations=1, angle=45, resolution=1): """Generates a texture by running transformations on a turtle program. First, the given transformations are applied to the axiom. This is repeated `iterations` times. Then, the output is run as a turtle program to get a texture...
def l_system(axiom, transformations, iterations=1, angle=45, resolution=1): """Generates a texture by running transformations on a turtle program. First, the given transformations are applied to the axiom. This is repeated `iterations` times. Then, the output is run as a turtle program to get a texture...
[ "Generates", "a", "texture", "by", "running", "transformations", "on", "a", "turtle", "program", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/fractal/l_systems.py#L51-L73
[ "def", "l_system", "(", "axiom", ",", "transformations", ",", "iterations", "=", "1", ",", "angle", "=", "45", ",", "resolution", "=", "1", ")", ":", "turtle_program", "=", "transform_multiple", "(", "axiom", ",", "transformations", ",", "iterations", ")", ...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
PathGraph.get_path
Returns the path corresponding to the node i.
optimizer/penkit_optimize/path_graph.py
def get_path(self, i): """Returns the path corresponding to the node i.""" index = (i - 1) // 2 reverse = (i - 1) % 2 path = self.paths[index] if reverse: return path.reversed() else: return path
def get_path(self, i): """Returns the path corresponding to the node i.""" index = (i - 1) // 2 reverse = (i - 1) % 2 path = self.paths[index] if reverse: return path.reversed() else: return path
[ "Returns", "the", "path", "corresponding", "to", "the", "node", "i", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/path_graph.py#L22-L30
[ "def", "get_path", "(", "self", ",", "i", ")", ":", "index", "=", "(", "i", "-", "1", ")", "//", "2", "reverse", "=", "(", "i", "-", "1", ")", "%", "2", "path", "=", "self", ".", "paths", "[", "index", "]", "if", "reverse", ":", "return", "...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
PathGraph.cost
Returns the distance between the end of path i and the start of path j.
optimizer/penkit_optimize/path_graph.py
def cost(self, i, j): """Returns the distance between the end of path i and the start of path j.""" return dist(self.endpoints[i][1], self.endpoints[j][0])
def cost(self, i, j): """Returns the distance between the end of path i and the start of path j.""" return dist(self.endpoints[i][1], self.endpoints[j][0])
[ "Returns", "the", "distance", "between", "the", "end", "of", "path", "i", "and", "the", "start", "of", "path", "j", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/path_graph.py#L32-L35
[ "def", "cost", "(", "self", ",", "i", ",", "j", ")", ":", "return", "dist", "(", "self", ".", "endpoints", "[", "i", "]", "[", "1", "]", ",", "self", ".", "endpoints", "[", "j", "]", "[", "0", "]", ")" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
PathGraph.get_coordinates
Returns the starting coordinates of node i as a pair, or the end coordinates iff end is True.
optimizer/penkit_optimize/path_graph.py
def get_coordinates(self, i, end=False): """Returns the starting coordinates of node i as a pair, or the end coordinates iff end is True.""" if end: endpoint = self.endpoints[i][1] else: endpoint = self.endpoints[i][0] return (endpoint.real, endpoint.imag)
def get_coordinates(self, i, end=False): """Returns the starting coordinates of node i as a pair, or the end coordinates iff end is True.""" if end: endpoint = self.endpoints[i][1] else: endpoint = self.endpoints[i][0] return (endpoint.real, endpoint.imag)
[ "Returns", "the", "starting", "coordinates", "of", "node", "i", "as", "a", "pair", "or", "the", "end", "coordinates", "iff", "end", "is", "True", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/path_graph.py#L37-L44
[ "def", "get_coordinates", "(", "self", ",", "i", ",", "end", "=", "False", ")", ":", "if", "end", ":", "endpoint", "=", "self", ".", "endpoints", "[", "i", "]", "[", "1", "]", "else", ":", "endpoint", "=", "self", ".", "endpoints", "[", "i", "]",...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
PathGraph.iter_starts_with_index
Returns a generator over (index, start coordinate) pairs, excluding the origin.
optimizer/penkit_optimize/path_graph.py
def iter_starts_with_index(self): """Returns a generator over (index, start coordinate) pairs, excluding the origin.""" for i in range(1, len(self.endpoints)): yield i, self.get_coordinates(i)
def iter_starts_with_index(self): """Returns a generator over (index, start coordinate) pairs, excluding the origin.""" for i in range(1, len(self.endpoints)): yield i, self.get_coordinates(i)
[ "Returns", "a", "generator", "over", "(", "index", "start", "coordinate", ")", "pairs", "excluding", "the", "origin", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/path_graph.py#L46-L50
[ "def", "iter_starts_with_index", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "endpoints", ")", ")", ":", "yield", "i", ",", "self", ".", "get_coordinates", "(", "i", ")" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
PathGraph.iter_disjunctions
Returns a generator over 2-element lists of indexes which must be mutually exclusive in a solution (i.e. pairs of nodes which represent the same path in opposite directions.)
optimizer/penkit_optimize/path_graph.py
def iter_disjunctions(self): """Returns a generator over 2-element lists of indexes which must be mutually exclusive in a solution (i.e. pairs of nodes which represent the same path in opposite directions.)""" for i in range(1, len(self.endpoints), 2): yield [i, self.get_disj...
def iter_disjunctions(self): """Returns a generator over 2-element lists of indexes which must be mutually exclusive in a solution (i.e. pairs of nodes which represent the same path in opposite directions.)""" for i in range(1, len(self.endpoints), 2): yield [i, self.get_disj...
[ "Returns", "a", "generator", "over", "2", "-", "element", "lists", "of", "indexes", "which", "must", "be", "mutually", "exclusive", "in", "a", "solution", "(", "i", ".", "e", ".", "pairs", "of", "nodes", "which", "represent", "the", "same", "path", "in",...
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/optimizer/penkit_optimize/path_graph.py#L57-L62
[ "def", "iter_disjunctions", "(", "self", ")", ":", "for", "i", "in", "range", "(", "1", ",", "len", "(", "self", ".", "endpoints", ")", ",", "2", ")", ":", "yield", "[", "i", ",", "self", ".", "get_disjoint", "(", "i", ")", "]" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
show_plot
Preview a plot in a jupyter notebook. Args: plot (list): the plot to display (list of layers) width (int): the width of the preview height (int): the height of the preview Returns: An object that renders in Jupyter as the provided plot
penkit/preview.py
def show_plot(plot, width=PREVIEW_WIDTH, height=PREVIEW_HEIGHT): """Preview a plot in a jupyter notebook. Args: plot (list): the plot to display (list of layers) width (int): the width of the preview height (int): the height of the preview Returns: An object that render...
def show_plot(plot, width=PREVIEW_WIDTH, height=PREVIEW_HEIGHT): """Preview a plot in a jupyter notebook. Args: plot (list): the plot to display (list of layers) width (int): the width of the preview height (int): the height of the preview Returns: An object that render...
[ "Preview", "a", "plot", "in", "a", "jupyter", "notebook", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/preview.py#L28-L39
[ "def", "show_plot", "(", "plot", ",", "width", "=", "PREVIEW_WIDTH", ",", "height", "=", "PREVIEW_HEIGHT", ")", ":", "return", "SVG", "(", "data", "=", "plot_to_svg", "(", "plot", ",", "width", ",", "height", ")", ")" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
calculate_view_box
Calculates the size of the SVG viewBox to use. Args: layers (list): the layers in the image aspect_ratio (float): the height of the output divided by the width margin (float): minimum amount of buffer to add around the image, relative to the total dimensions Returns: ...
penkit/write.py
def calculate_view_box(layers, aspect_ratio, margin=DEFAULT_VIEW_BOX_MARGIN): """Calculates the size of the SVG viewBox to use. Args: layers (list): the layers in the image aspect_ratio (float): the height of the output divided by the width margin (float): minimum amount of buffer to ad...
def calculate_view_box(layers, aspect_ratio, margin=DEFAULT_VIEW_BOX_MARGIN): """Calculates the size of the SVG viewBox to use. Args: layers (list): the layers in the image aspect_ratio (float): the height of the output divided by the width margin (float): minimum amount of buffer to ad...
[ "Calculates", "the", "size", "of", "the", "SVG", "viewBox", "to", "use", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/write.py#L15-L50
[ "def", "calculate_view_box", "(", "layers", ",", "aspect_ratio", ",", "margin", "=", "DEFAULT_VIEW_BOX_MARGIN", ")", ":", "min_x", "=", "min", "(", "np", ".", "nanmin", "(", "x", ")", "for", "x", ",", "y", "in", "layers", ")", "max_x", "=", "max", "(",...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
_layer_to_path_gen
Generates an SVG path from a given layer. Args: layer (layer): the layer to convert Yields: str: the next component of the path
penkit/write.py
def _layer_to_path_gen(layer): """Generates an SVG path from a given layer. Args: layer (layer): the layer to convert Yields: str: the next component of the path """ draw = False for x, y in zip(*layer): if np.isnan(x) or np.isnan(y): draw = False el...
def _layer_to_path_gen(layer): """Generates an SVG path from a given layer. Args: layer (layer): the layer to convert Yields: str: the next component of the path """ draw = False for x, y in zip(*layer): if np.isnan(x) or np.isnan(y): draw = False el...
[ "Generates", "an", "SVG", "path", "from", "a", "given", "layer", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/write.py#L53-L70
[ "def", "_layer_to_path_gen", "(", "layer", ")", ":", "draw", "=", "False", "for", "x", ",", "y", "in", "zip", "(", "*", "layer", ")", ":", "if", "np", ".", "isnan", "(", "x", ")", "or", "np", ".", "isnan", "(", "y", ")", ":", "draw", "=", "Fa...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
plot_to_svg
Converts a plot (list of layers) into an SVG document. Args: plot (list): list of layers that make up the plot width (float): the width of the resulting image height (float): the height of the resulting image unit (str): the units of the resulting image if not pixels Returns: ...
penkit/write.py
def plot_to_svg(plot, width, height, unit=''): """Converts a plot (list of layers) into an SVG document. Args: plot (list): list of layers that make up the plot width (float): the width of the resulting image height (float): the height of the resulting image unit (str): the unit...
def plot_to_svg(plot, width, height, unit=''): """Converts a plot (list of layers) into an SVG document. Args: plot (list): list of layers that make up the plot width (float): the width of the resulting image height (float): the height of the resulting image unit (str): the unit...
[ "Converts", "a", "plot", "(", "list", "of", "layers", ")", "into", "an", "SVG", "document", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/write.py#L85-L127
[ "def", "plot_to_svg", "(", "plot", ",", "width", ",", "height", ",", "unit", "=", "''", ")", ":", "flipped_plot", "=", "[", "(", "x", ",", "-", "y", ")", "for", "x", ",", "y", "in", "plot", "]", "aspect_ratio", "=", "height", "/", "width", "view_...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
write_plot
Writes a plot SVG to a file. Args: plot (list): a list of layers to plot filename (str): the name of the file to write width (float): the width of the output SVG height (float): the height of the output SVG unit (str): the unit of the height and width
penkit/write.py
def write_plot(plot, filename, width=DEFAULT_PAGE_WIDTH, height=DEFAULT_PAGE_HEIGHT, unit=DEFAULT_PAGE_UNIT): """Writes a plot SVG to a file. Args: plot (list): a list of layers to plot filename (str): the name of the file to write width (float): the width of the output SVG heig...
def write_plot(plot, filename, width=DEFAULT_PAGE_WIDTH, height=DEFAULT_PAGE_HEIGHT, unit=DEFAULT_PAGE_UNIT): """Writes a plot SVG to a file. Args: plot (list): a list of layers to plot filename (str): the name of the file to write width (float): the width of the output SVG heig...
[ "Writes", "a", "plot", "SVG", "to", "a", "file", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/write.py#L147-L159
[ "def", "write_plot", "(", "plot", ",", "filename", ",", "width", "=", "DEFAULT_PAGE_WIDTH", ",", "height", "=", "DEFAULT_PAGE_HEIGHT", ",", "unit", "=", "DEFAULT_PAGE_UNIT", ")", ":", "svg", "=", "plot_to_svg", "(", "plot", ",", "width", ",", "height", ",", ...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
draw_layer
Draws a layer on the given matplotlib axis. Args: ax (axis): the matplotlib axis to draw on layer (layer): the layers to plot
penkit/mpl_preview.py
def draw_layer(ax, layer): """Draws a layer on the given matplotlib axis. Args: ax (axis): the matplotlib axis to draw on layer (layer): the layers to plot """ ax.set_aspect('equal', 'datalim') ax.plot(*layer) ax.axis('off')
def draw_layer(ax, layer): """Draws a layer on the given matplotlib axis. Args: ax (axis): the matplotlib axis to draw on layer (layer): the layers to plot """ ax.set_aspect('equal', 'datalim') ax.plot(*layer) ax.axis('off')
[ "Draws", "a", "layer", "on", "the", "given", "matplotlib", "axis", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/mpl_preview.py#L9-L18
[ "def", "draw_layer", "(", "ax", ",", "layer", ")", ":", "ax", ".", "set_aspect", "(", "'equal'", ",", "'datalim'", ")", "ax", ".", "plot", "(", "*", "layer", ")", "ax", ".", "axis", "(", "'off'", ")" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
map_texture_to_surface
Returns values on a surface for points on a texture. Args: texture (texture): the texture to trace over the surface surface (surface): the surface to trace along Returns: an array of surface heights for each point in the texture. Line separators (i.e. values that are ``nan`` in...
penkit/projection.py
def map_texture_to_surface(texture, surface): """Returns values on a surface for points on a texture. Args: texture (texture): the texture to trace over the surface surface (surface): the surface to trace along Returns: an array of surface heights for each point in the text...
def map_texture_to_surface(texture, surface): """Returns values on a surface for points on a texture. Args: texture (texture): the texture to trace over the surface surface (surface): the surface to trace along Returns: an array of surface heights for each point in the text...
[ "Returns", "values", "on", "a", "surface", "for", "points", "on", "a", "texture", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/projection.py#L10-L33
[ "def", "map_texture_to_surface", "(", "texture", ",", "surface", ")", ":", "texture_x", ",", "texture_y", "=", "texture", "surface_h", ",", "surface_w", "=", "surface", ".", "shape", "surface_x", "=", "np", ".", "clip", "(", "np", ".", "int32", "(", "surfa...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
project_texture
Creates a texture by adding z-values to an existing texture and projecting. When working with surfaces there are two ways to accomplish the same thing: 1. project the surface and map a texture to the projected surface 2. map a texture to the surface, and then project the result The first method, whic...
penkit/projection.py
def project_texture(texture_xy, texture_z, angle=DEFAULT_ANGLE): """Creates a texture by adding z-values to an existing texture and projecting. When working with surfaces there are two ways to accomplish the same thing: 1. project the surface and map a texture to the projected surface 2. map a texture...
def project_texture(texture_xy, texture_z, angle=DEFAULT_ANGLE): """Creates a texture by adding z-values to an existing texture and projecting. When working with surfaces there are two ways to accomplish the same thing: 1. project the surface and map a texture to the projected surface 2. map a texture...
[ "Creates", "a", "texture", "by", "adding", "z", "-", "values", "to", "an", "existing", "texture", "and", "projecting", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/projection.py#L36-L60
[ "def", "project_texture", "(", "texture_xy", ",", "texture_z", ",", "angle", "=", "DEFAULT_ANGLE", ")", ":", "z_coef", "=", "np", ".", "sin", "(", "np", ".", "radians", "(", "angle", ")", ")", "y_coef", "=", "np", ".", "cos", "(", "np", ".", "radians...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
project_surface
Returns the height of the surface when projected at the given angle. Args: surface (surface): the surface to project angle (float): the angle at which to project the surface Returns: surface: A projected surface.
penkit/projection.py
def project_surface(surface, angle=DEFAULT_ANGLE): """Returns the height of the surface when projected at the given angle. Args: surface (surface): the surface to project angle (float): the angle at which to project the surface Returns: surface: A projected surface. """ z_c...
def project_surface(surface, angle=DEFAULT_ANGLE): """Returns the height of the surface when projected at the given angle. Args: surface (surface): the surface to project angle (float): the angle at which to project the surface Returns: surface: A projected surface. """ z_c...
[ "Returns", "the", "height", "of", "the", "surface", "when", "projected", "at", "the", "given", "angle", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/projection.py#L63-L79
[ "def", "project_surface", "(", "surface", ",", "angle", "=", "DEFAULT_ANGLE", ")", ":", "z_coef", "=", "np", ".", "sin", "(", "np", ".", "radians", "(", "angle", ")", ")", "y_coef", "=", "np", ".", "cos", "(", "np", ".", "radians", "(", "angle", ")...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
project_texture_on_surface
Maps a texture onto a surface, then projects to 2D and returns a layer. Args: texture (texture): the texture to project surface (surface): the surface to project onto angle (float): the projection angle in degrees (0 = top-down, 90 = side view) Returns: layer: A layer.
penkit/projection.py
def project_texture_on_surface(texture, surface, angle=DEFAULT_ANGLE): """Maps a texture onto a surface, then projects to 2D and returns a layer. Args: texture (texture): the texture to project surface (surface): the surface to project onto angle (float): the projection angle in degrees...
def project_texture_on_surface(texture, surface, angle=DEFAULT_ANGLE): """Maps a texture onto a surface, then projects to 2D and returns a layer. Args: texture (texture): the texture to project surface (surface): the surface to project onto angle (float): the projection angle in degrees...
[ "Maps", "a", "texture", "onto", "a", "surface", "then", "projects", "to", "2D", "and", "returns", "a", "layer", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/projection.py#L82-L96
[ "def", "project_texture_on_surface", "(", "texture", ",", "surface", ",", "angle", "=", "DEFAULT_ANGLE", ")", ":", "projected_surface", "=", "project_surface", "(", "surface", ",", "angle", ")", "texture_x", ",", "_", "=", "texture", "texture_y", "=", "map_textu...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
_remove_hidden_parts
Removes parts of a projected surface that are not visible. Args: projected_surface (surface): the surface to use Returns: surface: A projected surface.
penkit/projection.py
def _remove_hidden_parts(projected_surface): """Removes parts of a projected surface that are not visible. Args: projected_surface (surface): the surface to use Returns: surface: A projected surface. """ surface = np.copy(projected_surface) surface[~_make_occlusion_mask(project...
def _remove_hidden_parts(projected_surface): """Removes parts of a projected surface that are not visible. Args: projected_surface (surface): the surface to use Returns: surface: A projected surface. """ surface = np.copy(projected_surface) surface[~_make_occlusion_mask(project...
[ "Removes", "parts", "of", "a", "projected", "surface", "that", "are", "not", "visible", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/projection.py#L114-L125
[ "def", "_remove_hidden_parts", "(", "projected_surface", ")", ":", "surface", "=", "np", ".", "copy", "(", "projected_surface", ")", "surface", "[", "~", "_make_occlusion_mask", "(", "projected_surface", ")", "]", "=", "np", ".", "nan", "return", "surface" ]
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
project_and_occlude_texture
Projects a texture onto a surface with occluded areas removed. Args: texture (texture): the texture to map to the projected surface surface (surface): the surface to project angle (float): the angle to project at, in degrees (0 = overhead, 90 = side view) Returns: layer: A laye...
penkit/projection.py
def project_and_occlude_texture(texture, surface, angle=DEFAULT_ANGLE): """Projects a texture onto a surface with occluded areas removed. Args: texture (texture): the texture to map to the projected surface surface (surface): the surface to project angle (float): the angle to project at...
def project_and_occlude_texture(texture, surface, angle=DEFAULT_ANGLE): """Projects a texture onto a surface with occluded areas removed. Args: texture (texture): the texture to map to the projected surface surface (surface): the surface to project angle (float): the angle to project at...
[ "Projects", "a", "texture", "onto", "a", "surface", "with", "occluded", "areas", "removed", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/projection.py#L128-L143
[ "def", "project_and_occlude_texture", "(", "texture", ",", "surface", ",", "angle", "=", "DEFAULT_ANGLE", ")", ":", "projected_surface", "=", "project_surface", "(", "surface", ",", "angle", ")", "projected_surface", "=", "_remove_hidden_parts", "(", "projected_surfac...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
make_lines_texture
Makes a texture consisting of a given number of horizontal lines. Args: num_lines (int): the number of lines to draw resolution (int): the number of midpoints on each line Returns: A texture.
penkit/textures/__init__.py
def make_lines_texture(num_lines=10, resolution=50): """Makes a texture consisting of a given number of horizontal lines. Args: num_lines (int): the number of lines to draw resolution (int): the number of midpoints on each line Returns: A texture. """ x, y = np.meshgrid( ...
def make_lines_texture(num_lines=10, resolution=50): """Makes a texture consisting of a given number of horizontal lines. Args: num_lines (int): the number of lines to draw resolution (int): the number of midpoints on each line Returns: A texture. """ x, y = np.meshgrid( ...
[ "Makes", "a", "texture", "consisting", "of", "a", "given", "number", "of", "horizontal", "lines", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/__init__.py#L9-L25
[ "def", "make_lines_texture", "(", "num_lines", "=", "10", ",", "resolution", "=", "50", ")", ":", "x", ",", "y", "=", "np", ".", "meshgrid", "(", "np", ".", "hstack", "(", "[", "np", ".", "linspace", "(", "0", ",", "1", ",", "resolution", ")", ",...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
make_grid_texture
Makes a texture consisting of a grid of vertical and horizontal lines. Args: num_h_lines (int): the number of horizontal lines to draw num_v_lines (int): the number of vertical lines to draw resolution (int): the number of midpoints to draw on each line Returns: A texture.
penkit/textures/__init__.py
def make_grid_texture(num_h_lines=10, num_v_lines=10, resolution=50): """Makes a texture consisting of a grid of vertical and horizontal lines. Args: num_h_lines (int): the number of horizontal lines to draw num_v_lines (int): the number of vertical lines to draw resolution (int): the n...
def make_grid_texture(num_h_lines=10, num_v_lines=10, resolution=50): """Makes a texture consisting of a grid of vertical and horizontal lines. Args: num_h_lines (int): the number of horizontal lines to draw num_v_lines (int): the number of vertical lines to draw resolution (int): the n...
[ "Makes", "a", "texture", "consisting", "of", "a", "grid", "of", "vertical", "and", "horizontal", "lines", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/__init__.py#L28-L41
[ "def", "make_grid_texture", "(", "num_h_lines", "=", "10", ",", "num_v_lines", "=", "10", ",", "resolution", "=", "50", ")", ":", "x_h", ",", "y_h", "=", "make_lines_texture", "(", "num_h_lines", ",", "resolution", ")", "y_v", ",", "x_v", "=", "make_lines_...
da451a30f62cfefbab285b9d6979b8dec3ac4957
train
make_spiral_texture
Makes a texture consisting of a spiral from the origin. Args: spirals (float): the number of rotations to make ccw (bool): make spirals counter-clockwise (default is clockwise) offset (float): if non-zero, spirals start offset by this amount resolution (int): number of midpoints alo...
penkit/textures/__init__.py
def make_spiral_texture(spirals=6.0, ccw=False, offset=0.0, resolution=1000): """Makes a texture consisting of a spiral from the origin. Args: spirals (float): the number of rotations to make ccw (bool): make spirals counter-clockwise (default is clockwise) offset (float): if non-zero, ...
def make_spiral_texture(spirals=6.0, ccw=False, offset=0.0, resolution=1000): """Makes a texture consisting of a spiral from the origin. Args: spirals (float): the number of rotations to make ccw (bool): make spirals counter-clockwise (default is clockwise) offset (float): if non-zero, ...
[ "Makes", "a", "texture", "consisting", "of", "a", "spiral", "from", "the", "origin", "." ]
paulgb/penkit
python
https://github.com/paulgb/penkit/blob/da451a30f62cfefbab285b9d6979b8dec3ac4957/penkit/textures/__init__.py#L44-L66
[ "def", "make_spiral_texture", "(", "spirals", "=", "6.0", ",", "ccw", "=", "False", ",", "offset", "=", "0.0", ",", "resolution", "=", "1000", ")", ":", "dist", "=", "np", ".", "sqrt", "(", "np", ".", "linspace", "(", "0.", ",", "1.", ",", "resolut...
da451a30f62cfefbab285b9d6979b8dec3ac4957