Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class Users:
def __init__(self, client):
self.client = client
self.keys = UsersKeys(self.client)
self.emails = UsersEmails(self.client)
self.followers = UsersFollowers(self.client)
def get(self, user=None):
url = 'user'
if (user is not None and user != self.client._username):
url = 'users/%s' % user
return self.client.get(url, msg_type=UserResponse)
def update(self, name=None, email=None, blog=None, company=None,
location=None, hireable=False, bio=None):
<|code_end|>
with the help of current file imports:
from userskeys import UsersKeys
from usersemails import UsersEmails
from usersfollowers import UsersFollowers
from ..messages import User
from ..requests import UserResponse
and context from other files:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
, which may contain function names, class names, or code. Output only the next line. | msg = User(
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class Users:
def __init__(self, client):
self.client = client
self.keys = UsersKeys(self.client)
self.emails = UsersEmails(self.client)
self.followers = UsersFollowers(self.client)
def get(self, user=None):
url = 'user'
if (user is not None and user != self.client._username):
url = 'users/%s' % user
<|code_end|>
. Write the next line using the current file imports:
from userskeys import UsersKeys
from usersemails import UsersEmails
from usersfollowers import UsersFollowers
from ..messages import User
from ..requests import UserResponse
and context from other files:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
, which may include functions, classes, or code. Output only the next line. | return self.client.get(url, msg_type=UserResponse)
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class ReposKeys:
def __init__(self, client):
self.client = client
def list(self, repo, user=None):
return self.client.get(
'repos/%s/%s/keys' % (
self.client.user(user), repo), msg_type=KeyListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/keys/%s' % (
self.client.user(user), repo, id), msg_type=KeyResponse)
def create(self, repo, title, key, user=None):
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Key(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# key = msgs.StringField(2)
# title = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
# response = msgs.MessageField('Key', 1)
#
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
# response = msgs.MessageField('Key', 1, repeated=True)
. Output only the next line. | msg = Key(
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class ReposKeys:
def __init__(self, client):
self.client = client
def list(self, repo, user=None):
return self.client.get(
'repos/%s/%s/keys' % (
self.client.user(user), repo), msg_type=KeyListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/keys/%s' % (
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Key(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# key = msgs.StringField(2)
# title = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
# response = msgs.MessageField('Key', 1)
#
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
# response = msgs.MessageField('Key', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, id), msg_type=KeyResponse)
|
Next line prediction: <|code_start|>from __future__ import unicode_literals
class ReposKeys:
def __init__(self, client):
self.client = client
def list(self, repo, user=None):
return self.client.get(
'repos/%s/%s/keys' % (
<|code_end|>
. Use current file imports:
(from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse
)
and context including class names, function names, or small code snippets from other files:
# Path: flask_github/client/messages.py
# class Key(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# key = msgs.StringField(2)
# title = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
# response = msgs.MessageField('Key', 1)
#
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
# response = msgs.MessageField('Key', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo), msg_type=KeyListResponse)
|
Given snippet: <|code_start|>from __future__ import unicode_literals
class OrgMembers:
def __init__(self, client):
self.client = client
def list(self, org, public_only=False):
url = 'orgs/%s/members' % org
if public_only:
url = 'orgs/%s/public_members' % org
return self.client.get(url, msg_type=UserListResponse)
def get(self, org, user=None, public_only=False):
url = 'orgs/%s/members/%s' % (org, self.client.user(user))
if public_only:
url = 'orgs/%s/public_members/%s' % (
org, self.client.user(user))
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ..requests import UserResponse
from ..requests import UserListResponse
and context:
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
which might include code, classes, or functions. Output only the next line. | return self.client.get(url, msg_type=UserResponse)
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class OrgMembers:
def __init__(self, client):
self.client = client
def list(self, org, public_only=False):
url = 'orgs/%s/members' % org
if public_only:
url = 'orgs/%s/public_members' % org
<|code_end|>
. Write the next line using the current file imports:
from ..requests import UserResponse
from ..requests import UserListResponse
and context from other files:
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | return self.client.get(url, msg_type=UserListResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class OrgTeams:
def __init__(self, client):
self.client = client
def list(self, org):
return self.client.get('orgs/%s/teams' % org, msg_type=TeamListResponse)
def get(self, id):
return self.client.get('teams/%s' % id, msg_type=TeamResponse)
def create(self, org, name, repo_names=None, permission=None):
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
. Output only the next line. | msg = Team(
|
Given snippet: <|code_start|>from __future__ import unicode_literals
class OrgTeams:
def __init__(self, client):
self.client = client
def list(self, org):
return self.client.get('orgs/%s/teams' % org, msg_type=TeamListResponse)
def get(self, id):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
which might include code, classes, or functions. Output only the next line. | return self.client.get('teams/%s' % id, msg_type=TeamResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class OrgTeams:
def __init__(self, client):
self.client = client
def list(self, org):
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
. Output only the next line. | return self.client.get('orgs/%s/teams' % org, msg_type=TeamListResponse)
|
Using the snippet: <|code_start|> 'teams/%s' % id)
# members..
def list_members(self, id):
return self.client.get(
'teams/%s/members' % id, msg_type=UserListResponse)
def get_member(self, id, user=None):
return self.client.get(
'teams/%s/members/%s' % (
id, self.client.user(user)), msg_type=UserResponse)
def add_member(self, id, user):
return self.client.put(
'teams/%s/members/%s' % (id, self.client.user(user)))
def delete_member(self, id, user):
return self.client.delete(
'teams/%s/members/%s' % (id, self.client.user(user)))
# repos..
def list_repos(self, id):
return self.client.get(
'teams/%s/repos' % id, msg_type=RepoListResponse)
def get_repo(self, id, user, repo):
return self.client.get(
'teams/%s/repos/%s/%s' % (
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
. Output only the next line. | id, self.client.user(user), repo), msg_type=RepoResponse)
|
Predict the next line for this snippet: <|code_start|> def _edit(self, id, msg):
return self.client.patch('teams/%s' % id, data=msg)
def delete(self, id):
return self.client.delete(
'teams/%s' % id)
# members..
def list_members(self, id):
return self.client.get(
'teams/%s/members' % id, msg_type=UserListResponse)
def get_member(self, id, user=None):
return self.client.get(
'teams/%s/members/%s' % (
id, self.client.user(user)), msg_type=UserResponse)
def add_member(self, id, user):
return self.client.put(
'teams/%s/members/%s' % (id, self.client.user(user)))
def delete_member(self, id, user):
return self.client.delete(
'teams/%s/members/%s' % (id, self.client.user(user)))
# repos..
def list_repos(self, id):
return self.client.get(
<|code_end|>
with the help of current file imports:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | 'teams/%s/repos' % id, msg_type=RepoListResponse)
|
Predict the next line for this snippet: <|code_start|> name=name,
repo_names=repo_names,
permission=permission)
return self._create(org=org, msg=msg)
def _create(self, org, msg):
return self.client.post('orgs/%s/teams' % org, data=msg)
def edit(self, id, name, permission=None):
msg = Team(
name=name,
permission=permission)
return self._edit(id=id, msg=msg)
def _edit(self, id, msg):
return self.client.patch('teams/%s' % id, data=msg)
def delete(self, id):
return self.client.delete(
'teams/%s' % id)
# members..
def list_members(self, id):
return self.client.get(
'teams/%s/members' % id, msg_type=UserListResponse)
def get_member(self, id, user=None):
return self.client.get(
'teams/%s/members/%s' % (
<|code_end|>
with the help of current file imports:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | id, self.client.user(user)), msg_type=UserResponse)
|
Based on the snippet: <|code_start|> def get(self, id):
return self.client.get('teams/%s' % id, msg_type=TeamResponse)
def create(self, org, name, repo_names=None, permission=None):
msg = Team(
name=name,
repo_names=repo_names,
permission=permission)
return self._create(org=org, msg=msg)
def _create(self, org, msg):
return self.client.post('orgs/%s/teams' % org, data=msg)
def edit(self, id, name, permission=None):
msg = Team(
name=name,
permission=permission)
return self._edit(id=id, msg=msg)
def _edit(self, id, msg):
return self.client.patch('teams/%s' % id, data=msg)
def delete(self, id):
return self.client.delete(
'teams/%s' % id)
# members..
def list_members(self, id):
return self.client.get(
<|code_end|>
, predict the immediate next line with the help of imports:
from ..messages import Team
from ..requests import TeamResponse
from ..requests import TeamListResponse
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import UserResponse
from ..requests import UserListResponse
and context (classes, functions, sometimes code) from other files:
# Path: flask_github/client/messages.py
# class Team(msgs.Message):
# name = msgs.StringField(1)
# repo_names = msgs.StringField(2, repeated=True)
# permission = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class TeamResponse(msgs.Message):
# response = msgs.MessageField('Team', 1)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
. Output only the next line. | 'teams/%s/members' % id, msg_type=UserListResponse)
|
Next line prediction: <|code_start|>from __future__ import unicode_literals
class UsersKeys:
def __init__(self, client):
self.client = client
def list(self):
return self.client.get(
'user/keys', msg_type=KeyListResponse)
def get(self, id):
return self.client.get(
'user/keys/%s' % id, msg_type=KeyResponse)
def create(self, title, key):
<|code_end|>
. Use current file imports:
(from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse
)
and context including class names, function names, or small code snippets from other files:
# Path: flask_github/client/messages.py
# class Key(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# key = msgs.StringField(2)
# title = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
# response = msgs.MessageField('Key', 1)
#
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
# response = msgs.MessageField('Key', 1, repeated=True)
. Output only the next line. | msg = Key(
|
Continue the code snippet: <|code_start|>from __future__ import unicode_literals
class UsersKeys:
def __init__(self, client):
self.client = client
def list(self):
return self.client.get(
'user/keys', msg_type=KeyListResponse)
def get(self, id):
return self.client.get(
<|code_end|>
. Use current file imports:
from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse
and context (classes, functions, or code) from other files:
# Path: flask_github/client/messages.py
# class Key(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# key = msgs.StringField(2)
# title = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
# response = msgs.MessageField('Key', 1)
#
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
# response = msgs.MessageField('Key', 1, repeated=True)
. Output only the next line. | 'user/keys/%s' % id, msg_type=KeyResponse)
|
Next line prediction: <|code_start|>from __future__ import unicode_literals
class UsersKeys:
def __init__(self, client):
self.client = client
def list(self):
return self.client.get(
<|code_end|>
. Use current file imports:
(from ..messages import Key
from ..requests import KeyResponse
from ..requests import KeyListResponse
)
and context including class names, function names, or small code snippets from other files:
# Path: flask_github/client/messages.py
# class Key(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# key = msgs.StringField(2)
# title = msgs.StringField(3)
#
# Path: flask_github/client/requests.py
# class KeyResponse(msgs.Message):
# response = msgs.MessageField('Key', 1)
#
# Path: flask_github/client/requests.py
# class KeyListResponse(msgs.Message):
# response = msgs.MessageField('Key', 1, repeated=True)
. Output only the next line. | 'user/keys', msg_type=KeyListResponse)
|
Given snippet: <|code_start|>from __future__ import unicode_literals
class GitDataTrees:
def __init__(self, client):
self.client = client
def get(self, repo, sha, recursive=False, user=None):
query = None
if recursive:
query = {'recursive': '1'}
return self.client.get('repos/%s/%s/git/trees/%s' % (
self.client.user(user), repo, sha), query=query, msg_type=TreeListResponse)
def create(self, repo, tree, base_tree=None, user=None):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ..messages import Tree
from ..requests import TreeResponse
from ..requests import TreeListResponse
and context:
# Path: flask_github/client/messages.py
# class Tree(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# message = msgs.StringField(3)
# tree = msgs.MessageField('Tree', 4, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(5)
# mode = msgs.StringField(6)
# type = msgs.StringField(7)
# size = msgs.IntegerField(8, default=0)
# content = msgs.StringField(9)
# # String of the SHA1 of the tree you want to update with new data
# base_tree = msgs.StringField(10)
#
# Path: flask_github/client/requests.py
# class TreeResponse(msgs.Message):
# response = msgs.MessageField('Tree', 1)
#
# Path: flask_github/client/requests.py
# class TreeListResponse(msgs.Message):
# response = msgs.MessageField('Tree', 1, repeated=True)
which might include code, classes, or functions. Output only the next line. | msg = Tree(
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class GitDataTrees:
def __init__(self, client):
self.client = client
def get(self, repo, sha, recursive=False, user=None):
query = None
if recursive:
query = {'recursive': '1'}
return self.client.get('repos/%s/%s/git/trees/%s' % (
self.client.user(user), repo, sha), query=query, msg_type=TreeListResponse)
def create(self, repo, tree, base_tree=None, user=None):
msg = Tree(
base_tree=base_tree,
tree=tree)
return self._create(repo=repo, msg=msg, user=user)
def _create(self, repo, msg, user=None):
return self.client.post(
'repos/%s/%s/git/trees' % (
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import Tree
from ..requests import TreeResponse
from ..requests import TreeListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Tree(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# message = msgs.StringField(3)
# tree = msgs.MessageField('Tree', 4, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(5)
# mode = msgs.StringField(6)
# type = msgs.StringField(7)
# size = msgs.IntegerField(8, default=0)
# content = msgs.StringField(9)
# # String of the SHA1 of the tree you want to update with new data
# base_tree = msgs.StringField(10)
#
# Path: flask_github/client/requests.py
# class TreeResponse(msgs.Message):
# response = msgs.MessageField('Tree', 1)
#
# Path: flask_github/client/requests.py
# class TreeListResponse(msgs.Message):
# response = msgs.MessageField('Tree', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo), data=msg, msg_type=TreeResponse)
|
Next line prediction: <|code_start|>from __future__ import unicode_literals
class GitDataTrees:
def __init__(self, client):
self.client = client
def get(self, repo, sha, recursive=False, user=None):
query = None
if recursive:
query = {'recursive': '1'}
return self.client.get('repos/%s/%s/git/trees/%s' % (
<|code_end|>
. Use current file imports:
(from ..messages import Tree
from ..requests import TreeResponse
from ..requests import TreeListResponse
)
and context including class names, function names, or small code snippets from other files:
# Path: flask_github/client/messages.py
# class Tree(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# message = msgs.StringField(3)
# tree = msgs.MessageField('Tree', 4, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(5)
# mode = msgs.StringField(6)
# type = msgs.StringField(7)
# size = msgs.IntegerField(8, default=0)
# content = msgs.StringField(9)
# # String of the SHA1 of the tree you want to update with new data
# base_tree = msgs.StringField(10)
#
# Path: flask_github/client/requests.py
# class TreeResponse(msgs.Message):
# response = msgs.MessageField('Tree', 1)
#
# Path: flask_github/client/requests.py
# class TreeListResponse(msgs.Message):
# response = msgs.MessageField('Tree', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, sha), query=query, msg_type=TreeListResponse)
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class Orgs:
def __init__(self, client):
self.client = client
self.teams = OrgTeams(self.client)
self.members = OrgMembers(self.client)
def list(self, user=None):
url = 'user/orgs'
if user and user != self.client._username:
url = 'users/%s/orgs' % self.client.user(user)
return self.client.get(url, msg_type=OrgListResponse)
def get(self, org):
return self.client.get('orgs/%s' % org, msg_type=UserResponse)
def edit(self, org, billing_email=None, company=None, email=None,
location=None, name=None):
<|code_end|>
. Write the next line using the current file imports:
from orgteams import OrgTeams
from orgmembers import OrgMembers
from ..messages import Org
from ..requests import UserResponse
from ..requests import OrgListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Org(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# login = msgs.StringField(2)
# company = msgs.StringField(3)
# billing_email = msgs.StringField(4)
# email = msgs.StringField(5)
# location = msgs.StringField(6)
# name = msgs.StringField(7)
# members = msgs.MessageField('User', 8, repeated=True)
# url = msgs.StringField(9)
# repos_url = msgs.StringField(10)
# events_url = msgs.StringField(11)
# avatar_url = msgs.StringField(12)
# members_url = msgs.StringField(13)
# public_members_url = msgs.StringField(14)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class OrgListResponse(msgs.Message):
# response = msgs.MessageField('Org', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | msg = Org(
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class Orgs:
def __init__(self, client):
self.client = client
self.teams = OrgTeams(self.client)
self.members = OrgMembers(self.client)
def list(self, user=None):
url = 'user/orgs'
if user and user != self.client._username:
url = 'users/%s/orgs' % self.client.user(user)
return self.client.get(url, msg_type=OrgListResponse)
def get(self, org):
<|code_end|>
, generate the next line using the imports in this file:
from orgteams import OrgTeams
from orgmembers import OrgMembers
from ..messages import Org
from ..requests import UserResponse
from ..requests import OrgListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Org(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# login = msgs.StringField(2)
# company = msgs.StringField(3)
# billing_email = msgs.StringField(4)
# email = msgs.StringField(5)
# location = msgs.StringField(6)
# name = msgs.StringField(7)
# members = msgs.MessageField('User', 8, repeated=True)
# url = msgs.StringField(9)
# repos_url = msgs.StringField(10)
# events_url = msgs.StringField(11)
# avatar_url = msgs.StringField(12)
# members_url = msgs.StringField(13)
# public_members_url = msgs.StringField(14)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class OrgListResponse(msgs.Message):
# response = msgs.MessageField('Org', 1, repeated=True)
. Output only the next line. | return self.client.get('orgs/%s' % org, msg_type=UserResponse)
|
Continue the code snippet: <|code_start|>from __future__ import unicode_literals
class Orgs:
def __init__(self, client):
self.client = client
self.teams = OrgTeams(self.client)
self.members = OrgMembers(self.client)
def list(self, user=None):
url = 'user/orgs'
if user and user != self.client._username:
url = 'users/%s/orgs' % self.client.user(user)
<|code_end|>
. Use current file imports:
from orgteams import OrgTeams
from orgmembers import OrgMembers
from ..messages import Org
from ..requests import UserResponse
from ..requests import OrgListResponse
and context (classes, functions, or code) from other files:
# Path: flask_github/client/messages.py
# class Org(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# login = msgs.StringField(2)
# company = msgs.StringField(3)
# billing_email = msgs.StringField(4)
# email = msgs.StringField(5)
# location = msgs.StringField(6)
# name = msgs.StringField(7)
# members = msgs.MessageField('User', 8, repeated=True)
# url = msgs.StringField(9)
# repos_url = msgs.StringField(10)
# events_url = msgs.StringField(11)
# avatar_url = msgs.StringField(12)
# members_url = msgs.StringField(13)
# public_members_url = msgs.StringField(14)
#
# Path: flask_github/client/requests.py
# class UserResponse(msgs.Message):
# response = msgs.MessageField('User', 1)
#
# Path: flask_github/client/requests.py
# class OrgListResponse(msgs.Message):
# response = msgs.MessageField('Org', 1, repeated=True)
. Output only the next line. | return self.client.get(url, msg_type=OrgListResponse)
|
Given the code snippet: <|code_start|> 'labels': labels,
'sort': sort,
'direction': direction,
'since': since
}
return self.client.get('issues', query=query, msg_type=IssueListResponse)
def list_repo_issues(self, repo, milestone=None, assignee=None,
mentioned=None, state='open', labels=None, sort='created', direction='desc',
since=None, user=None):
query = {
'state': state,
'assignee': assignee,
'mentioned': mentioned,
'labels': labels,
'sort': sort,
'direction': direction,
'since': since,
'milestone': milestone
}
return self.client.get('repos/%s/%s/issues' % (
self.client.user(user), repo), query=query, msg_type=IssueListResponse)
def get(self, repo, number, user=None):
return self.client.get(
'repos/%s/%s/issues/%s' % (
self.client.user(user), repo, number), msg_type=IssueResponse)
def create(self, repo, title, body=None, assignee=None,
milestone=None, labels=None, user=None):
<|code_end|>
, generate the next line using the imports in this file:
from issuesevents import IssuesEvents
from issueslabels import IssuesLabels
from issuescomments import IssuesComments
from issuesmilestones import IssuesMilestones
from ..messages import Issue
from ..requests import IssueResponse
from ..requests import IssueListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Issue(msgs.Message):
# title = msgs.StringField(1)
# body = msgs.StringField(2)
# state = msgs.StringField(3)
# labels = msgs.StringField(4, repeated=True)
# assignee = msgs.StringField(5)
# milestone = msgs.StringField(6)
#
# Path: flask_github/client/requests.py
# class IssueResponse(msgs.Message):
# response = msgs.MessageField('Issue', 1)
#
# Path: flask_github/client/requests.py
# class IssueListResponse(msgs.Message):
# response = msgs.MessageField('Issue', 1, repeated=True)
. Output only the next line. | msg = Issue(
|
Here is a snippet: <|code_start|> sort='created', direction='desc', since=None):
query = {
'filter': filter,
'state': state,
'labels': labels,
'sort': sort,
'direction': direction,
'since': since
}
return self.client.get('issues', query=query, msg_type=IssueListResponse)
def list_repo_issues(self, repo, milestone=None, assignee=None,
mentioned=None, state='open', labels=None, sort='created', direction='desc',
since=None, user=None):
query = {
'state': state,
'assignee': assignee,
'mentioned': mentioned,
'labels': labels,
'sort': sort,
'direction': direction,
'since': since,
'milestone': milestone
}
return self.client.get('repos/%s/%s/issues' % (
self.client.user(user), repo), query=query, msg_type=IssueListResponse)
def get(self, repo, number, user=None):
return self.client.get(
'repos/%s/%s/issues/%s' % (
<|code_end|>
. Write the next line using the current file imports:
from issuesevents import IssuesEvents
from issueslabels import IssuesLabels
from issuescomments import IssuesComments
from issuesmilestones import IssuesMilestones
from ..messages import Issue
from ..requests import IssueResponse
from ..requests import IssueListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Issue(msgs.Message):
# title = msgs.StringField(1)
# body = msgs.StringField(2)
# state = msgs.StringField(3)
# labels = msgs.StringField(4, repeated=True)
# assignee = msgs.StringField(5)
# milestone = msgs.StringField(6)
#
# Path: flask_github/client/requests.py
# class IssueResponse(msgs.Message):
# response = msgs.MessageField('Issue', 1)
#
# Path: flask_github/client/requests.py
# class IssueListResponse(msgs.Message):
# response = msgs.MessageField('Issue', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | self.client.user(user), repo, number), msg_type=IssueResponse)
|
Predict the next line after this snippet: <|code_start|>from __future__ import unicode_literals
class Issues:
def __init__(self, client):
self.client = client
self.comments = IssuesComments(self.client)
self.events = IssuesEvents(self.client)
self.labels = IssuesLabels(self.client)
self.milestones = IssuesMilestones(self.client)
def list_issues(self, filter='assigned', state='open', labels=None,
sort='created', direction='desc', since=None):
query = {
'filter': filter,
'state': state,
'labels': labels,
'sort': sort,
'direction': direction,
'since': since
}
<|code_end|>
using the current file's imports:
from issuesevents import IssuesEvents
from issueslabels import IssuesLabels
from issuescomments import IssuesComments
from issuesmilestones import IssuesMilestones
from ..messages import Issue
from ..requests import IssueResponse
from ..requests import IssueListResponse
and any relevant context from other files:
# Path: flask_github/client/messages.py
# class Issue(msgs.Message):
# title = msgs.StringField(1)
# body = msgs.StringField(2)
# state = msgs.StringField(3)
# labels = msgs.StringField(4, repeated=True)
# assignee = msgs.StringField(5)
# milestone = msgs.StringField(6)
#
# Path: flask_github/client/requests.py
# class IssueResponse(msgs.Message):
# response = msgs.MessageField('Issue', 1)
#
# Path: flask_github/client/requests.py
# class IssueListResponse(msgs.Message):
# response = msgs.MessageField('Issue', 1, repeated=True)
. Output only the next line. | return self.client.get('issues', query=query, msg_type=IssueListResponse)
|
Continue the code snippet: <|code_start|>from __future__ import unicode_literals
class Gists:
def __init__(self, client):
self.client = client
def list(self, user=None):
url = 'users/%s/gists' % user if user else 'gists'
return self.client.get(url, msg_type=GistListResponse)
def list_public(self):
return self.client.get('gists/public', msg_type=GistListResponse)
def list_starred(self):
return self.client.get('gists/starred', msg_type=GistListResponse)
def get(self, id):
return self.client.get('gists/%s' % id, msg_type=GistResponse)
def create(self, public, files, description=None):
<|code_end|>
. Use current file imports:
from ..messages import Gist
from ..requests import GistResponse
from ..requests import GistListResponse
and context (classes, functions, or code) from other files:
# Path: flask_github/client/messages.py
# class Gist(msgs.Message):
# '''
# {
# "files": {
# "ring.erl": {
# "size": 932,
# "filename": "ring.erl",
# "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
# }
# }
# "history": [
# {
# "url": "https://api.github.com/gists/14a2302d4083e5331759",
# "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
# "user": {
# "login": "octocat",
# "id": 1,
# "avatar_url": "https://github.com/images/error/octocat_happy.gif",
# "gravatar_id": "somehexcode",
# "url": "https://api.github.com/users/octocat"
# },
# "change_status": {
# "deletions": 0,
# "additions": 180,
# "total": 180
# },
# "committed_at": "2010-04-14T02:15:15Z"
# }
# ]
# '''
# id = msgs.IntegerField(1, default=0)
# url = msgs.StringField(2)
# description = msgs.StringField(3)
# public = msgs.BooleanField(4, default=True)
# user = msgs.MessageField('User', 5)
# comments = msgs.IntegerField(6, default=0)
# comments_url = msgs.StringField(7)
# html_url = msgs.StringField(8)
# git_pull_url = msgs.StringField(9)
# git_push_url = msgs.StringField(10)
# created_at = msgs.StringField(11)
# forks = msgs.MessageField('Gist', 12, repeated=True)
#
# Path: flask_github/client/requests.py
# class GistResponse(msgs.Message):
# response = msgs.MessageField('Gist', 1)
#
# Path: flask_github/client/requests.py
# class GistListResponse(msgs.Message):
# response = msgs.MessageField('Gist', 1, repeated=True)
. Output only the next line. | msg = Gist(
|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class Gists:
def __init__(self, client):
self.client = client
def list(self, user=None):
url = 'users/%s/gists' % user if user else 'gists'
return self.client.get(url, msg_type=GistListResponse)
def list_public(self):
return self.client.get('gists/public', msg_type=GistListResponse)
def list_starred(self):
return self.client.get('gists/starred', msg_type=GistListResponse)
def get(self, id):
<|code_end|>
with the help of current file imports:
from ..messages import Gist
from ..requests import GistResponse
from ..requests import GistListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Gist(msgs.Message):
# '''
# {
# "files": {
# "ring.erl": {
# "size": 932,
# "filename": "ring.erl",
# "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
# }
# }
# "history": [
# {
# "url": "https://api.github.com/gists/14a2302d4083e5331759",
# "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
# "user": {
# "login": "octocat",
# "id": 1,
# "avatar_url": "https://github.com/images/error/octocat_happy.gif",
# "gravatar_id": "somehexcode",
# "url": "https://api.github.com/users/octocat"
# },
# "change_status": {
# "deletions": 0,
# "additions": 180,
# "total": 180
# },
# "committed_at": "2010-04-14T02:15:15Z"
# }
# ]
# '''
# id = msgs.IntegerField(1, default=0)
# url = msgs.StringField(2)
# description = msgs.StringField(3)
# public = msgs.BooleanField(4, default=True)
# user = msgs.MessageField('User', 5)
# comments = msgs.IntegerField(6, default=0)
# comments_url = msgs.StringField(7)
# html_url = msgs.StringField(8)
# git_pull_url = msgs.StringField(9)
# git_push_url = msgs.StringField(10)
# created_at = msgs.StringField(11)
# forks = msgs.MessageField('Gist', 12, repeated=True)
#
# Path: flask_github/client/requests.py
# class GistResponse(msgs.Message):
# response = msgs.MessageField('Gist', 1)
#
# Path: flask_github/client/requests.py
# class GistListResponse(msgs.Message):
# response = msgs.MessageField('Gist', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | return self.client.get('gists/%s' % id, msg_type=GistResponse)
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class Gists:
def __init__(self, client):
self.client = client
def list(self, user=None):
url = 'users/%s/gists' % user if user else 'gists'
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import Gist
from ..requests import GistResponse
from ..requests import GistListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Gist(msgs.Message):
# '''
# {
# "files": {
# "ring.erl": {
# "size": 932,
# "filename": "ring.erl",
# "raw_url": "https://gist.github.com/raw/365370/8c4d2d43d178df44f4c03a7f2ac0ff512853564e/ring.erl"
# }
# }
# "history": [
# {
# "url": "https://api.github.com/gists/14a2302d4083e5331759",
# "version": "57a7f021a713b1c5a6a199b54cc514735d2d462f",
# "user": {
# "login": "octocat",
# "id": 1,
# "avatar_url": "https://github.com/images/error/octocat_happy.gif",
# "gravatar_id": "somehexcode",
# "url": "https://api.github.com/users/octocat"
# },
# "change_status": {
# "deletions": 0,
# "additions": 180,
# "total": 180
# },
# "committed_at": "2010-04-14T02:15:15Z"
# }
# ]
# '''
# id = msgs.IntegerField(1, default=0)
# url = msgs.StringField(2)
# description = msgs.StringField(3)
# public = msgs.BooleanField(4, default=True)
# user = msgs.MessageField('User', 5)
# comments = msgs.IntegerField(6, default=0)
# comments_url = msgs.StringField(7)
# html_url = msgs.StringField(8)
# git_pull_url = msgs.StringField(9)
# git_push_url = msgs.StringField(10)
# created_at = msgs.StringField(11)
# forks = msgs.MessageField('Gist', 12, repeated=True)
#
# Path: flask_github/client/requests.py
# class GistResponse(msgs.Message):
# response = msgs.MessageField('Gist', 1)
#
# Path: flask_github/client/requests.py
# class GistListResponse(msgs.Message):
# response = msgs.MessageField('Gist', 1, repeated=True)
. Output only the next line. | return self.client.get(url, msg_type=GistListResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class Events:
def __init__(self, client):
# TODO: Research http://developer.github.com/v3/events/types/
self.client = client
def list_public_events(self):
'''List public events.'''
<|code_end|>
, determine the next line of code. You have imports:
from ..requests import EventListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/requests.py
# class EventListResponse(msgs.Message):
# response = msgs.MessageField('Event', 1, repeated=True)
. Output only the next line. | return self.client.get('events', msg_type=EventListResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class UsersFollowers:
def __init__(self, client):
self.client = client
def list_followers(self, user=None):
url = 'users/%s/followers' % user if (
user is not None and user != self.client._username) else 'user/followers'
<|code_end|>
, predict the next line using imports from the current file:
from ..requests import UserListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
. Output only the next line. | return self.client.get(url, msg_type=UserListResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class IssuesEvents:
def __init__(self, client):
self.client = client
def list(self, repo, issue_id=None, user=None):
'repos/%s/%s/issues/events' % (self.client.user(user), repo)
if issue_id:
url = 'repos/%s/%s/issues/%s/events' % (
self.client.user(user), repo, issue_id)
return self.client.get(url, msg_type=IssueEventListResponse)
def get(self, repo, id, user=None):
return self.client.get('repos/%s/%s/issues/events/%s' % (
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import IssueEvent
from ..requests import IssueEventResponse
from ..requests import IssueEventListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class IssueEvent(msgs.Message):
# pass
#
# Path: flask_github/client/requests.py
# class IssueEventResponse(msgs.Message):
# response = msgs.MessageField('IssueEvent', 1)
#
# Path: flask_github/client/requests.py
# class IssueEventListResponse(msgs.Message):
# response = msgs.MessageField('IssueEvent', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, id), msg_type=IssueEventResponse)
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class IssuesEvents:
def __init__(self, client):
self.client = client
def list(self, repo, issue_id=None, user=None):
'repos/%s/%s/issues/events' % (self.client.user(user), repo)
if issue_id:
url = 'repos/%s/%s/issues/%s/events' % (
self.client.user(user), repo, issue_id)
<|code_end|>
. Write the next line using the current file imports:
from ..messages import IssueEvent
from ..requests import IssueEventResponse
from ..requests import IssueEventListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class IssueEvent(msgs.Message):
# pass
#
# Path: flask_github/client/requests.py
# class IssueEventResponse(msgs.Message):
# response = msgs.MessageField('IssueEvent', 1)
#
# Path: flask_github/client/requests.py
# class IssueEventListResponse(msgs.Message):
# response = msgs.MessageField('IssueEvent', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | return self.client.get(url, msg_type=IssueEventListResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class ReposStarring:
def __init__(self, client):
self.client = client
def list_stargazers(self, repo, user=None, page=1):
return self.client.get(
'repos/%s/%s/stargazers' % (
<|code_end|>
, predict the next line using imports from the current file:
from ..requests import UserListResponse
from ..requests import RepoListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo), msg_type=UserListResponse) |
Based on the snippet: <|code_start|>from __future__ import unicode_literals
class ReposStarring:
def __init__(self, client):
self.client = client
def list_stargazers(self, repo, user=None, page=1):
return self.client.get(
'repos/%s/%s/stargazers' % (
self.client.user(user), repo), msg_type=UserListResponse)
def list_starred_repos(self, user=None, page=1):
url = 'user/starred'
if user is not None and user != self.client._username:
url = 'users/%s/starred' % user
<|code_end|>
, predict the immediate next line with the help of imports:
from ..requests import UserListResponse
from ..requests import RepoListResponse
and context (classes, functions, sometimes code) from other files:
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
. Output only the next line. | return self.client.get(url, msg_type=RepoListResponse) |
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class GitDataBlobs:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/blobs/%s' % (
self.client.user(user), repo, sha), msg_type=BlobResponse)
def create(self, repo, content, encoding, user=None):
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import Blob
from ..requests import BlobResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class Blob(msgs.Message):
# content = msgs.BytesField(1)
# encoding = msgs.StringField(2, default='utf-8')
# sha = msgs.StringField(3)
# size = msgs.IntegerField(4, default=0)
#
# Path: flask_github/client/requests.py
# class BlobResponse(msgs.Message):
# response = msgs.MessageField('Blob', 1)
. Output only the next line. | msg = Blob(
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class GitDataBlobs:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/blobs/%s' % (
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import Blob
from ..requests import BlobResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Blob(msgs.Message):
# content = msgs.BytesField(1)
# encoding = msgs.StringField(2, default='utf-8')
# sha = msgs.StringField(3)
# size = msgs.IntegerField(4, default=0)
#
# Path: flask_github/client/requests.py
# class BlobResponse(msgs.Message):
# response = msgs.MessageField('Blob', 1)
. Output only the next line. | self.client.user(user), repo, sha), msg_type=BlobResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class GitDataCommits:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/commits/%s' % (
self.client.user(user), repo, sha), msg_type=GitDataCommitListResponse)
def create(self, repo, message, tree, parents, author_name=None,
author_email=None, author_date=None, committer_name=None,
committer_email=None, commiter_date=None, user=None):
msg = Commit(
message=message,
parents=parents,
tree=tree,
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import User
from ..messages import Commit
from ..requests import GitDataCommitResponse
from ..requests import GitDataCommitListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Commit(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# committer = msgs.MessageField('User', 3)
# author = msgs.MessageField('User', 4)
# comment_count = msgs.IntegerField(5, default=0)
# message = msgs.StringField(6)
# # string reference allows for recursion..
# tree = msgs.MessageField('Commit', 7)
# parents = msgs.MessageField('Commit', 8, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(9)
# mode = msgs.StringField(10)
# type = msgs.StringField(11)
# size = msgs.IntegerField(12, default=0)
# # fields for the hooks payload..
# id = msgs.StringField(13)
# timestamp = msgs.StringField(14)
# added = msgs.StringField(15, repeated=True)
# removed = msgs.StringField(16, repeated=True)
# modified = msgs.StringField(17, repeated=True)
# commit = msgs.MessageField('Commit', 18)
#
# Path: flask_github/client/requests.py
# class GitDataCommitResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1)
#
# Path: flask_github/client/requests.py
# class GitDataCommitListResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1, repeated=True)
. Output only the next line. | author=User(
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class GitDataCommits:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/commits/%s' % (
self.client.user(user), repo, sha), msg_type=GitDataCommitListResponse)
def create(self, repo, message, tree, parents, author_name=None,
author_email=None, author_date=None, committer_name=None,
committer_email=None, commiter_date=None, user=None):
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import User
from ..messages import Commit
from ..requests import GitDataCommitResponse
from ..requests import GitDataCommitListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Commit(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# committer = msgs.MessageField('User', 3)
# author = msgs.MessageField('User', 4)
# comment_count = msgs.IntegerField(5, default=0)
# message = msgs.StringField(6)
# # string reference allows for recursion..
# tree = msgs.MessageField('Commit', 7)
# parents = msgs.MessageField('Commit', 8, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(9)
# mode = msgs.StringField(10)
# type = msgs.StringField(11)
# size = msgs.IntegerField(12, default=0)
# # fields for the hooks payload..
# id = msgs.StringField(13)
# timestamp = msgs.StringField(14)
# added = msgs.StringField(15, repeated=True)
# removed = msgs.StringField(16, repeated=True)
# modified = msgs.StringField(17, repeated=True)
# commit = msgs.MessageField('Commit', 18)
#
# Path: flask_github/client/requests.py
# class GitDataCommitResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1)
#
# Path: flask_github/client/requests.py
# class GitDataCommitListResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1, repeated=True)
. Output only the next line. | msg = Commit(
|
Given the following code snippet before the placeholder: <|code_start|>
class GitDataCommits:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/commits/%s' % (
self.client.user(user), repo, sha), msg_type=GitDataCommitListResponse)
def create(self, repo, message, tree, parents, author_name=None,
author_email=None, author_date=None, committer_name=None,
committer_email=None, commiter_date=None, user=None):
msg = Commit(
message=message,
parents=parents,
tree=tree,
author=User(
name=author_name,
email=author_email,
date=author_date),
committer = User(
name=committer_name,
email=committer_email,
date=commiter_date))
return self._create(repo=repo, msg=msg, user=user)
def _create(self, repo, msg, user=None):
return self.client.post(
'repos/%s/%s/git/commits' % (
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import User
from ..messages import Commit
from ..requests import GitDataCommitResponse
from ..requests import GitDataCommitListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Commit(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# committer = msgs.MessageField('User', 3)
# author = msgs.MessageField('User', 4)
# comment_count = msgs.IntegerField(5, default=0)
# message = msgs.StringField(6)
# # string reference allows for recursion..
# tree = msgs.MessageField('Commit', 7)
# parents = msgs.MessageField('Commit', 8, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(9)
# mode = msgs.StringField(10)
# type = msgs.StringField(11)
# size = msgs.IntegerField(12, default=0)
# # fields for the hooks payload..
# id = msgs.StringField(13)
# timestamp = msgs.StringField(14)
# added = msgs.StringField(15, repeated=True)
# removed = msgs.StringField(16, repeated=True)
# modified = msgs.StringField(17, repeated=True)
# commit = msgs.MessageField('Commit', 18)
#
# Path: flask_github/client/requests.py
# class GitDataCommitResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1)
#
# Path: flask_github/client/requests.py
# class GitDataCommitListResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo), data=msg, msg_type=GitDataCommitResponse)
|
Predict the next line after this snippet: <|code_start|>from __future__ import unicode_literals
class GitDataCommits:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/commits/%s' % (
<|code_end|>
using the current file's imports:
from ..messages import User
from ..messages import Commit
from ..requests import GitDataCommitResponse
from ..requests import GitDataCommitListResponse
and any relevant context from other files:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Commit(msgs.Message):
# url = msgs.StringField(1)
# sha = msgs.StringField(2)
# committer = msgs.MessageField('User', 3)
# author = msgs.MessageField('User', 4)
# comment_count = msgs.IntegerField(5, default=0)
# message = msgs.StringField(6)
# # string reference allows for recursion..
# tree = msgs.MessageField('Commit', 7)
# parents = msgs.MessageField('Commit', 8, repeated=True)
# # fields that live on the tree api responses..
# path = msgs.StringField(9)
# mode = msgs.StringField(10)
# type = msgs.StringField(11)
# size = msgs.IntegerField(12, default=0)
# # fields for the hooks payload..
# id = msgs.StringField(13)
# timestamp = msgs.StringField(14)
# added = msgs.StringField(15, repeated=True)
# removed = msgs.StringField(16, repeated=True)
# modified = msgs.StringField(17, repeated=True)
# commit = msgs.MessageField('Commit', 18)
#
# Path: flask_github/client/requests.py
# class GitDataCommitResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1)
#
# Path: flask_github/client/requests.py
# class GitDataCommitListResponse(msgs.Message):
# response = msgs.MessageField('Commit', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, sha), msg_type=GitDataCommitListResponse)
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class UsersEmails:
def __init__(self, client):
self.client = client
def list(self):
return self.client.get(
'user/emails', msg_type=UserEmailListResponse)
def add(self, emails):
return self.client.post(
<|code_end|>
, generate the next line using the imports in this file:
from ..requests import UserEmailResponse
from ..requests import UserEmailListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/requests.py
# class UserEmailResponse(msgs.Message):
# response = msgs.MessageField('UserEmail', 1)
#
# Path: flask_github/client/requests.py
# class UserEmailListResponse(msgs.Message):
# response = msgs.MessageField('UserEmail', 1, repeated=True)
. Output only the next line. | 'user/emails', data=emails, msg_type=UserEmailResponse)
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class UsersEmails:
def __init__(self, client):
self.client = client
def list(self):
return self.client.get(
<|code_end|>
, generate the next line using the imports in this file:
from ..requests import UserEmailResponse
from ..requests import UserEmailListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/requests.py
# class UserEmailResponse(msgs.Message):
# response = msgs.MessageField('UserEmail', 1)
#
# Path: flask_github/client/requests.py
# class UserEmailListResponse(msgs.Message):
# response = msgs.MessageField('UserEmail', 1, repeated=True)
. Output only the next line. | 'user/emails', msg_type=UserEmailListResponse)
|
Given snippet: <|code_start|>from __future__ import unicode_literals
class GitDataRefs:
def __init__(self, client):
self.client = client
def list(self, repo, subnamespace=None, user=None):
url = 'repos/%s/%s/git/refs' % (repo, self.client.user(user))
if subnamespace:
if subnamespace[0] == '/':
url += subnamespace
else:
url += subnamespace
return self.client.get(url, msg_type=RefListResponse)
def get(self, repo, ref, user=None):
return self.client.get(
'repos/%s/%s/git/refs/%s' % (
self.client.user(user), repo, ref), msg_type=RefResponse)
def create(self, repo, ref, sha, user=None):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ..messages import Ref
from ..requests import RefResponse
from ..requests import RefListResponse
and context:
# Path: flask_github/client/messages.py
# class Ref(msgs.Message):
# sha = msgs.StringField(1)
# ref = msgs.StringField(2)
# force = msgs.BooleanField(3, default=False)
#
# Path: flask_github/client/requests.py
# class RefResponse(msgs.Message):
# response = msgs.MessageField('Ref', 1)
#
# Path: flask_github/client/requests.py
# class RefListResponse(msgs.Message):
# response = msgs.MessageField('Ref', 1, repeated=True)
which might include code, classes, or functions. Output only the next line. | msg = Ref(
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class GitDataRefs:
def __init__(self, client):
self.client = client
def list(self, repo, subnamespace=None, user=None):
url = 'repos/%s/%s/git/refs' % (repo, self.client.user(user))
if subnamespace:
if subnamespace[0] == '/':
url += subnamespace
else:
url += subnamespace
return self.client.get(url, msg_type=RefListResponse)
def get(self, repo, ref, user=None):
return self.client.get(
'repos/%s/%s/git/refs/%s' % (
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import Ref
from ..requests import RefResponse
from ..requests import RefListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class Ref(msgs.Message):
# sha = msgs.StringField(1)
# ref = msgs.StringField(2)
# force = msgs.BooleanField(3, default=False)
#
# Path: flask_github/client/requests.py
# class RefResponse(msgs.Message):
# response = msgs.MessageField('Ref', 1)
#
# Path: flask_github/client/requests.py
# class RefListResponse(msgs.Message):
# response = msgs.MessageField('Ref', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, ref), msg_type=RefResponse)
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class GitDataRefs:
def __init__(self, client):
self.client = client
def list(self, repo, subnamespace=None, user=None):
url = 'repos/%s/%s/git/refs' % (repo, self.client.user(user))
if subnamespace:
if subnamespace[0] == '/':
url += subnamespace
else:
url += subnamespace
<|code_end|>
. Write the next line using the current file imports:
from ..messages import Ref
from ..requests import RefResponse
from ..requests import RefListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Ref(msgs.Message):
# sha = msgs.StringField(1)
# ref = msgs.StringField(2)
# force = msgs.BooleanField(3, default=False)
#
# Path: flask_github/client/requests.py
# class RefResponse(msgs.Message):
# response = msgs.MessageField('Ref', 1)
#
# Path: flask_github/client/requests.py
# class RefListResponse(msgs.Message):
# response = msgs.MessageField('Ref', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | return self.client.get(url, msg_type=RefListResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class GitDataTags:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/tags/%s' % (
self.client.user(user), repo, sha), msg_type=TagResponse)
def create(self, repo, tag, message, object, type, tagger_name,
tagger_email, tagger_date, user=None):
msg = Tag(
tag=tag,
message=message,
object=object,
type=type)
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import User
from ..messages import Tag
from ..requests import TagResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Tag(msgs.Message):
# tag = msgs.StringField(1)
# message = msgs.StringField(2)
# tagger = msgs.MessageField('User', 4)
# # fields for tag objects..
# object = msgs.MessageField('Tag', 5)
# type = msgs.StringField(6)
# sha = msgs.StringField(7)
# url = msgs.StringField(8)
# name = msgs.StringField(9)
# commit = msgs.MessageField('Commit', 10)
# zipball_url = msgs.StringField(11)
# tarball_url = msgs.StringField(12)
#
# Path: flask_github/client/requests.py
# class TagResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1)
. Output only the next line. | msg.tagger = User(
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class GitDataTags:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/tags/%s' % (
self.client.user(user), repo, sha), msg_type=TagResponse)
def create(self, repo, tag, message, object, type, tagger_name,
tagger_email, tagger_date, user=None):
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import User
from ..messages import Tag
from ..requests import TagResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Tag(msgs.Message):
# tag = msgs.StringField(1)
# message = msgs.StringField(2)
# tagger = msgs.MessageField('User', 4)
# # fields for tag objects..
# object = msgs.MessageField('Tag', 5)
# type = msgs.StringField(6)
# sha = msgs.StringField(7)
# url = msgs.StringField(8)
# name = msgs.StringField(9)
# commit = msgs.MessageField('Commit', 10)
# zipball_url = msgs.StringField(11)
# tarball_url = msgs.StringField(12)
#
# Path: flask_github/client/requests.py
# class TagResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1)
. Output only the next line. | msg = Tag(
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class GitDataTags:
def __init__(self, client):
self.client = client
def get(self, repo, sha, user=None):
return self.client.get(
'repos/%s/%s/git/tags/%s' % (
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import User
from ..messages import Tag
from ..requests import TagResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class User(msgs.Message):
# name = msgs.StringField(1)
# email = msgs.StringField(2)
# id = msgs.IntegerField(3, default=0)
# login = msgs.StringField(4)
# url = msgs.StringField(5)
# blog = msgs.StringField(6)
# company = msgs.StringField(7)
# location = msgs.StringField(8)
# hireable = msgs.BooleanField(9, default=False)
# bio = msgs.StringField(10)
# avatar_url = msgs.StringField(11)
# gravatar_id = msgs.StringField(12)
# _links = msgs.MessageField('Link', 13, repeated=True)
# date = msgs.StringField(14)
# created_at = msgs.StringField(15)
# type = msgs.StringField(16)
# following = msgs.IntegerField(17, default=0)
# followers = msgs.IntegerField(18, default=0)
# public_repos = msgs.IntegerField(19, default=0)
# public_gists = msgs.IntegerField(20, default=0)
# total_private_repos = msgs.IntegerField(21, default=0)
# owned_private_repos = msgs.IntegerField(22, default=0)
# private_gists = msgs.IntegerField(23, default=0)
# disk_usage = msgs.IntegerField(24, default=0)
# collaborators = msgs.IntegerField(25, default=0)
# html_url = msgs.StringField(26)
# repos_url = msgs.StringField(27)
# events_url = msgs.StringField(28)
# members_url = msgs.StringField(29)
# public_members_url = msgs.StringField(30)
#
# Path: flask_github/client/messages.py
# class Tag(msgs.Message):
# tag = msgs.StringField(1)
# message = msgs.StringField(2)
# tagger = msgs.MessageField('User', 4)
# # fields for tag objects..
# object = msgs.MessageField('Tag', 5)
# type = msgs.StringField(6)
# sha = msgs.StringField(7)
# url = msgs.StringField(8)
# name = msgs.StringField(9)
# commit = msgs.MessageField('Commit', 10)
# zipball_url = msgs.StringField(11)
# tarball_url = msgs.StringField(12)
#
# Path: flask_github/client/requests.py
# class TagResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1)
. Output only the next line. | self.client.user(user), repo, sha), msg_type=TagResponse)
|
Based on the snippet: <|code_start|>from __future__ import unicode_literals
class PullReviewComments:
def __init__(self, client):
self.client = client
def list(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s/comments' % (
self.client.user(user), repo, id),
msg_type=PullReviewCommentListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/comments/%s' % (
self.client.user(user), repo, id), msg_type=PullReviewCommentResponse)
def create(self, repo, id, body, commit_id, path, position, user=None):
<|code_end|>
, predict the immediate next line with the help of imports:
from ..messages import PullReviewComment
from ..requests import PullReviewCommentResponse
from ..requests import PullReviewCommentListResponse
and context (classes, functions, sometimes code) from other files:
# Path: flask_github/client/messages.py
# class PullReviewComment(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullReviewCommentResponse(msgs.Message):
# response = msgs.MessageField('PullReviewComment', 1)
#
# Path: flask_github/client/requests.py
# class PullReviewCommentListResponse(msgs.Message):
# response = msgs.MessageField('PullReviewComment', 1, repeated=True)
. Output only the next line. | msg = PullReviewComment(
|
Next line prediction: <|code_start|>from __future__ import unicode_literals
class PullReviewComments:
def __init__(self, client):
self.client = client
def list(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s/comments' % (
self.client.user(user), repo, id),
msg_type=PullReviewCommentListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/comments/%s' % (
<|code_end|>
. Use current file imports:
(from ..messages import PullReviewComment
from ..requests import PullReviewCommentResponse
from ..requests import PullReviewCommentListResponse
)
and context including class names, function names, or small code snippets from other files:
# Path: flask_github/client/messages.py
# class PullReviewComment(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullReviewCommentResponse(msgs.Message):
# response = msgs.MessageField('PullReviewComment', 1)
#
# Path: flask_github/client/requests.py
# class PullReviewCommentListResponse(msgs.Message):
# response = msgs.MessageField('PullReviewComment', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, id), msg_type=PullReviewCommentResponse)
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class PullReviewComments:
def __init__(self, client):
self.client = client
def list(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s/comments' % (
self.client.user(user), repo, id),
<|code_end|>
. Write the next line using the current file imports:
from ..messages import PullReviewComment
from ..requests import PullReviewCommentResponse
from ..requests import PullReviewCommentListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class PullReviewComment(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullReviewCommentResponse(msgs.Message):
# response = msgs.MessageField('PullReviewComment', 1)
#
# Path: flask_github/client/requests.py
# class PullReviewCommentListResponse(msgs.Message):
# response = msgs.MessageField('PullReviewComment', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | msg_type=PullReviewCommentListResponse)
|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class ReposDownloads:
def __init__(self, client):
self.client = client
def list(self, repo, user=None):
return self.client.get(
'repos/%s/%s/downloads' % (
self.client.username(user), repo), msg_type=RepoDownloadListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/downloads/%s' % (
<|code_end|>
with the help of current file imports:
import json
from ..requests import RepoDownloadResponse
from ..requests import RepoDownloadListResponse
and context from other files:
# Path: flask_github/client/requests.py
# class RepoDownloadResponse(msgs.Message):
# response = msgs.MessageField('RepoDownload', 1)
#
# Path: flask_github/client/requests.py
# class RepoDownloadListResponse(msgs.Message):
# response = msgs.MessageField('RepoDownload', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | self.client.username(user), repo, id), msg_type=RepoDownloadResponse)
|
Here is a snippet: <|code_start|>from __future__ import unicode_literals
class ReposDownloads:
def __init__(self, client):
self.client = client
def list(self, repo, user=None):
return self.client.get(
'repos/%s/%s/downloads' % (
<|code_end|>
. Write the next line using the current file imports:
import json
from ..requests import RepoDownloadResponse
from ..requests import RepoDownloadListResponse
and context from other files:
# Path: flask_github/client/requests.py
# class RepoDownloadResponse(msgs.Message):
# response = msgs.MessageField('RepoDownload', 1)
#
# Path: flask_github/client/requests.py
# class RepoDownloadListResponse(msgs.Message):
# response = msgs.MessageField('RepoDownload', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | self.client.username(user), repo), msg_type=RepoDownloadListResponse)
|
Using the snippet: <|code_start|>
class Repos:
def __init__(self, client):
self.client = client
self.keys = ReposKeys(self.client)
self.forks = ReposForks(self.client)
self.hooks = ReposHooks(self.client)
self.commits = ReposCommits(self.client)
self.starring = ReposStarring(self.client)
self.watching = ReposWatching(self.client)
self.downloads = ReposDownloads(self.client)
self.collaborators = ReposCollaborators(self.client)
def list(self, org=None, user=None):
url = 'user/repos'
if org:
url = 'orgs/%s/repos' % org
else:
if user and user != self.client._username:
url = 'users/%s/repos' % self.client.user(user)
return self.client.get(url, msg_type=RepoListResponse)
def get(self, repo, user=None):
return self.client.get(
'repos/%s/%s' % (
self.client.user(user), repo), msg_type=RepoResponse)
def create(self, name, org=None, description=None, homepage=None,
private=False, has_issues=True, has_wiki=True, has_downloads=True):
<|code_end|>
, determine the next line of code. You have imports:
from reposkeys import ReposKeys
from reposhooks import ReposHooks
from reposforks import ReposForks
from reposcommits import ReposCommits
from reposwatching import ReposWatching
from reposstarring import ReposStarring
from reposdownloads import ReposDownloads
from reposcollaborators import ReposCollaborators
from ..messages import Repo
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import TagListResponse
from ..requests import UserListResponse
from ..requests import TeamListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class Repo(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# name = msgs.StringField(2)
# full_name = msgs.StringField(3)
# description = msgs.StringField(4)
# owner = msgs.MessageField('User', 5)
# created_at = msgs.StringField(6)
# pushed_at = msgs.StringField(7)
# updated_at = msgs.StringField(8)
# has_wiki = msgs.BooleanField(9, default=False)
# has_issues = msgs.BooleanField(10, default=False)
# has_downloads = msgs.BooleanField(11, default=False)
# private = msgs.BooleanField(12, default=False)
# size = msgs.IntegerField(13, default=0)
# forks = msgs.IntegerField(14, default=0)
# forks_count = msgs.IntegerField(15, default=0)
# watchers = msgs.IntegerField(16, default=0)
# watchers_count = msgs.IntegerField(17, default=0)
# open_issues_count = msgs.IntegerField(18, default=0)
# open_issues = msgs.IntegerField(19, default=0)
# language = msgs.StringField(20)
# fork = msgs.BooleanField(21, default=False)
# permissions = msgs.MessageField('RepoPermission', 22, repeated=True)
# url = msgs.StringField(23)
# git_url = msgs.StringField(24)
# svn_url = msgs.StringField(25)
# ssh_url = msgs.StringField(26)
# html_url = msgs.StringField(27)
# clone_url = msgs.StringField(28)
# mirror_url = msgs.StringField(29)
# homepage = msgs.StringField(30)
# ref = msgs.StringField(31)
# master_branch = msgs.StringField(32)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TagListResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
. Output only the next line. | msg = Repo(
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class Repos:
def __init__(self, client):
self.client = client
self.keys = ReposKeys(self.client)
self.forks = ReposForks(self.client)
self.hooks = ReposHooks(self.client)
self.commits = ReposCommits(self.client)
self.starring = ReposStarring(self.client)
self.watching = ReposWatching(self.client)
self.downloads = ReposDownloads(self.client)
self.collaborators = ReposCollaborators(self.client)
def list(self, org=None, user=None):
url = 'user/repos'
if org:
url = 'orgs/%s/repos' % org
else:
if user and user != self.client._username:
url = 'users/%s/repos' % self.client.user(user)
return self.client.get(url, msg_type=RepoListResponse)
def get(self, repo, user=None):
return self.client.get(
'repos/%s/%s' % (
<|code_end|>
, generate the next line using the imports in this file:
from reposkeys import ReposKeys
from reposhooks import ReposHooks
from reposforks import ReposForks
from reposcommits import ReposCommits
from reposwatching import ReposWatching
from reposstarring import ReposStarring
from reposdownloads import ReposDownloads
from reposcollaborators import ReposCollaborators
from ..messages import Repo
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import TagListResponse
from ..requests import UserListResponse
from ..requests import TeamListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class Repo(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# name = msgs.StringField(2)
# full_name = msgs.StringField(3)
# description = msgs.StringField(4)
# owner = msgs.MessageField('User', 5)
# created_at = msgs.StringField(6)
# pushed_at = msgs.StringField(7)
# updated_at = msgs.StringField(8)
# has_wiki = msgs.BooleanField(9, default=False)
# has_issues = msgs.BooleanField(10, default=False)
# has_downloads = msgs.BooleanField(11, default=False)
# private = msgs.BooleanField(12, default=False)
# size = msgs.IntegerField(13, default=0)
# forks = msgs.IntegerField(14, default=0)
# forks_count = msgs.IntegerField(15, default=0)
# watchers = msgs.IntegerField(16, default=0)
# watchers_count = msgs.IntegerField(17, default=0)
# open_issues_count = msgs.IntegerField(18, default=0)
# open_issues = msgs.IntegerField(19, default=0)
# language = msgs.StringField(20)
# fork = msgs.BooleanField(21, default=False)
# permissions = msgs.MessageField('RepoPermission', 22, repeated=True)
# url = msgs.StringField(23)
# git_url = msgs.StringField(24)
# svn_url = msgs.StringField(25)
# ssh_url = msgs.StringField(26)
# html_url = msgs.StringField(27)
# clone_url = msgs.StringField(28)
# mirror_url = msgs.StringField(29)
# homepage = msgs.StringField(30)
# ref = msgs.StringField(31)
# master_branch = msgs.StringField(32)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TagListResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo), msg_type=RepoResponse)
|
Next line prediction: <|code_start|>from __future__ import unicode_literals
class Repos:
def __init__(self, client):
self.client = client
self.keys = ReposKeys(self.client)
self.forks = ReposForks(self.client)
self.hooks = ReposHooks(self.client)
self.commits = ReposCommits(self.client)
self.starring = ReposStarring(self.client)
self.watching = ReposWatching(self.client)
self.downloads = ReposDownloads(self.client)
self.collaborators = ReposCollaborators(self.client)
def list(self, org=None, user=None):
url = 'user/repos'
if org:
url = 'orgs/%s/repos' % org
else:
if user and user != self.client._username:
url = 'users/%s/repos' % self.client.user(user)
<|code_end|>
. Use current file imports:
(from reposkeys import ReposKeys
from reposhooks import ReposHooks
from reposforks import ReposForks
from reposcommits import ReposCommits
from reposwatching import ReposWatching
from reposstarring import ReposStarring
from reposdownloads import ReposDownloads
from reposcollaborators import ReposCollaborators
from ..messages import Repo
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import TagListResponse
from ..requests import UserListResponse
from ..requests import TeamListResponse
)
and context including class names, function names, or small code snippets from other files:
# Path: flask_github/client/messages.py
# class Repo(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# name = msgs.StringField(2)
# full_name = msgs.StringField(3)
# description = msgs.StringField(4)
# owner = msgs.MessageField('User', 5)
# created_at = msgs.StringField(6)
# pushed_at = msgs.StringField(7)
# updated_at = msgs.StringField(8)
# has_wiki = msgs.BooleanField(9, default=False)
# has_issues = msgs.BooleanField(10, default=False)
# has_downloads = msgs.BooleanField(11, default=False)
# private = msgs.BooleanField(12, default=False)
# size = msgs.IntegerField(13, default=0)
# forks = msgs.IntegerField(14, default=0)
# forks_count = msgs.IntegerField(15, default=0)
# watchers = msgs.IntegerField(16, default=0)
# watchers_count = msgs.IntegerField(17, default=0)
# open_issues_count = msgs.IntegerField(18, default=0)
# open_issues = msgs.IntegerField(19, default=0)
# language = msgs.StringField(20)
# fork = msgs.BooleanField(21, default=False)
# permissions = msgs.MessageField('RepoPermission', 22, repeated=True)
# url = msgs.StringField(23)
# git_url = msgs.StringField(24)
# svn_url = msgs.StringField(25)
# ssh_url = msgs.StringField(26)
# html_url = msgs.StringField(27)
# clone_url = msgs.StringField(28)
# mirror_url = msgs.StringField(29)
# homepage = msgs.StringField(30)
# ref = msgs.StringField(31)
# master_branch = msgs.StringField(32)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TagListResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
. Output only the next line. | return self.client.get(url, msg_type=RepoListResponse)
|
Predict the next line for this snippet: <|code_start|> if org:
url = 'orgs/%s/repos' % org
return self.client.post(
url, data=msg, msg_type=RepoResponse)
def edit(self, repo, name, description=None, homepage=None, private=False,
has_issues=True, has_wiki=True, has_downloads=True, user=None):
msg = Repo(
name=name,
private=private,
has_issues=has_issues,
has_wiki=has_wiki,
has_downloads=has_downloads,
description=description,
homepage=homepage)
return self._edit(repo=repo, msg=msg, user=user)
def _edit(self, repo, msg, user=None):
return self.client.patch(
'repos/%s/%s' % (
self.client.user(user), repo), data=msg)
def list_contributors(self, repo, user=None):
return self.client.get(
'repos/%s/%s/contributors' % (
self.client.user(user), repo), msg_type=UserListResponse)
def list_tags(self, repo, user=None):
return self.client.get(
'repos/%s/%s/tags' % (
<|code_end|>
with the help of current file imports:
from reposkeys import ReposKeys
from reposhooks import ReposHooks
from reposforks import ReposForks
from reposcommits import ReposCommits
from reposwatching import ReposWatching
from reposstarring import ReposStarring
from reposdownloads import ReposDownloads
from reposcollaborators import ReposCollaborators
from ..messages import Repo
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import TagListResponse
from ..requests import UserListResponse
from ..requests import TeamListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Repo(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# name = msgs.StringField(2)
# full_name = msgs.StringField(3)
# description = msgs.StringField(4)
# owner = msgs.MessageField('User', 5)
# created_at = msgs.StringField(6)
# pushed_at = msgs.StringField(7)
# updated_at = msgs.StringField(8)
# has_wiki = msgs.BooleanField(9, default=False)
# has_issues = msgs.BooleanField(10, default=False)
# has_downloads = msgs.BooleanField(11, default=False)
# private = msgs.BooleanField(12, default=False)
# size = msgs.IntegerField(13, default=0)
# forks = msgs.IntegerField(14, default=0)
# forks_count = msgs.IntegerField(15, default=0)
# watchers = msgs.IntegerField(16, default=0)
# watchers_count = msgs.IntegerField(17, default=0)
# open_issues_count = msgs.IntegerField(18, default=0)
# open_issues = msgs.IntegerField(19, default=0)
# language = msgs.StringField(20)
# fork = msgs.BooleanField(21, default=False)
# permissions = msgs.MessageField('RepoPermission', 22, repeated=True)
# url = msgs.StringField(23)
# git_url = msgs.StringField(24)
# svn_url = msgs.StringField(25)
# ssh_url = msgs.StringField(26)
# html_url = msgs.StringField(27)
# clone_url = msgs.StringField(28)
# mirror_url = msgs.StringField(29)
# homepage = msgs.StringField(30)
# ref = msgs.StringField(31)
# master_branch = msgs.StringField(32)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TagListResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | self.client.user(user), repo), msg_type=TagListResponse)
|
Here is a snippet: <|code_start|> homepage=homepage)
return self._create(org=org, msg=msg)
def _create(self, msg, org=None):
url = 'user/repos'
if org:
url = 'orgs/%s/repos' % org
return self.client.post(
url, data=msg, msg_type=RepoResponse)
def edit(self, repo, name, description=None, homepage=None, private=False,
has_issues=True, has_wiki=True, has_downloads=True, user=None):
msg = Repo(
name=name,
private=private,
has_issues=has_issues,
has_wiki=has_wiki,
has_downloads=has_downloads,
description=description,
homepage=homepage)
return self._edit(repo=repo, msg=msg, user=user)
def _edit(self, repo, msg, user=None):
return self.client.patch(
'repos/%s/%s' % (
self.client.user(user), repo), data=msg)
def list_contributors(self, repo, user=None):
return self.client.get(
'repos/%s/%s/contributors' % (
<|code_end|>
. Write the next line using the current file imports:
from reposkeys import ReposKeys
from reposhooks import ReposHooks
from reposforks import ReposForks
from reposcommits import ReposCommits
from reposwatching import ReposWatching
from reposstarring import ReposStarring
from reposdownloads import ReposDownloads
from reposcollaborators import ReposCollaborators
from ..messages import Repo
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import TagListResponse
from ..requests import UserListResponse
from ..requests import TeamListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Repo(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# name = msgs.StringField(2)
# full_name = msgs.StringField(3)
# description = msgs.StringField(4)
# owner = msgs.MessageField('User', 5)
# created_at = msgs.StringField(6)
# pushed_at = msgs.StringField(7)
# updated_at = msgs.StringField(8)
# has_wiki = msgs.BooleanField(9, default=False)
# has_issues = msgs.BooleanField(10, default=False)
# has_downloads = msgs.BooleanField(11, default=False)
# private = msgs.BooleanField(12, default=False)
# size = msgs.IntegerField(13, default=0)
# forks = msgs.IntegerField(14, default=0)
# forks_count = msgs.IntegerField(15, default=0)
# watchers = msgs.IntegerField(16, default=0)
# watchers_count = msgs.IntegerField(17, default=0)
# open_issues_count = msgs.IntegerField(18, default=0)
# open_issues = msgs.IntegerField(19, default=0)
# language = msgs.StringField(20)
# fork = msgs.BooleanField(21, default=False)
# permissions = msgs.MessageField('RepoPermission', 22, repeated=True)
# url = msgs.StringField(23)
# git_url = msgs.StringField(24)
# svn_url = msgs.StringField(25)
# ssh_url = msgs.StringField(26)
# html_url = msgs.StringField(27)
# clone_url = msgs.StringField(28)
# mirror_url = msgs.StringField(29)
# homepage = msgs.StringField(30)
# ref = msgs.StringField(31)
# master_branch = msgs.StringField(32)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TagListResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | self.client.user(user), repo), msg_type=UserListResponse)
|
Here is a snippet: <|code_start|> has_issues=has_issues,
has_wiki=has_wiki,
has_downloads=has_downloads,
description=description,
homepage=homepage)
return self._edit(repo=repo, msg=msg, user=user)
def _edit(self, repo, msg, user=None):
return self.client.patch(
'repos/%s/%s' % (
self.client.user(user), repo), data=msg)
def list_contributors(self, repo, user=None):
return self.client.get(
'repos/%s/%s/contributors' % (
self.client.user(user), repo), msg_type=UserListResponse)
def list_tags(self, repo, user=None):
return self.client.get(
'repos/%s/%s/tags' % (
self.client.user(user), repo), msg_type=TagListResponse)
def list_langs(self, repo, user=None):
return self.client.get(
'repos/%s/%s/languages' % (
self.client.user(user), repo))
def list_teams(self, repo, user=None):
return self.client.get(
'repos/%s/%s/teams' % (
<|code_end|>
. Write the next line using the current file imports:
from reposkeys import ReposKeys
from reposhooks import ReposHooks
from reposforks import ReposForks
from reposcommits import ReposCommits
from reposwatching import ReposWatching
from reposstarring import ReposStarring
from reposdownloads import ReposDownloads
from reposcollaborators import ReposCollaborators
from ..messages import Repo
from ..requests import RepoResponse
from ..requests import RepoListResponse
from ..requests import TagListResponse
from ..requests import UserListResponse
from ..requests import TeamListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class Repo(msgs.Message):
# id = msgs.IntegerField(1, default=0)
# name = msgs.StringField(2)
# full_name = msgs.StringField(3)
# description = msgs.StringField(4)
# owner = msgs.MessageField('User', 5)
# created_at = msgs.StringField(6)
# pushed_at = msgs.StringField(7)
# updated_at = msgs.StringField(8)
# has_wiki = msgs.BooleanField(9, default=False)
# has_issues = msgs.BooleanField(10, default=False)
# has_downloads = msgs.BooleanField(11, default=False)
# private = msgs.BooleanField(12, default=False)
# size = msgs.IntegerField(13, default=0)
# forks = msgs.IntegerField(14, default=0)
# forks_count = msgs.IntegerField(15, default=0)
# watchers = msgs.IntegerField(16, default=0)
# watchers_count = msgs.IntegerField(17, default=0)
# open_issues_count = msgs.IntegerField(18, default=0)
# open_issues = msgs.IntegerField(19, default=0)
# language = msgs.StringField(20)
# fork = msgs.BooleanField(21, default=False)
# permissions = msgs.MessageField('RepoPermission', 22, repeated=True)
# url = msgs.StringField(23)
# git_url = msgs.StringField(24)
# svn_url = msgs.StringField(25)
# ssh_url = msgs.StringField(26)
# html_url = msgs.StringField(27)
# clone_url = msgs.StringField(28)
# mirror_url = msgs.StringField(29)
# homepage = msgs.StringField(30)
# ref = msgs.StringField(31)
# master_branch = msgs.StringField(32)
#
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TagListResponse(msgs.Message):
# response = msgs.MessageField('Tag', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class TeamListResponse(msgs.Message):
# response = msgs.MessageField('Team', 1, repeated=True)
, which may include functions, classes, or code. Output only the next line. | self.client.user(user), repo), msg_type=TeamListResponse)
|
Given the code snippet: <|code_start|>from __future__ import unicode_literals
class IssuesComments:
def __init__(self, client):
self.client = client
def list(self, repo, id, user=None):
return self.client.get('repos/%s/%s/issues/%s/comments' % (
self.client.user(user), repo, id), msg_type=IssueCommentListResponse)
def get(self, repo, id, user=None):
return self.client.get('repos/%s/%s/issues/comments/%s' % (
self.client.user(user), repo, id), msg_type=IssueCommentResponse)
def edit(self, repo, id, body, user=None):
<|code_end|>
, generate the next line using the imports in this file:
from ..messages import IssueComment
from ..requests import IssueCommentResponse
from ..requests import IssueCommentListResponse
and context (functions, classes, or occasionally code) from other files:
# Path: flask_github/client/messages.py
# class IssueComment(msgs.Message):
# body = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class IssueCommentResponse(msgs.Message):
# response = msgs.MessageField('IssueComment', 1)
#
# Path: flask_github/client/requests.py
# class IssueCommentListResponse(msgs.Message):
# response = msgs.MessageField('IssueComment', 1, repeated=True)
. Output only the next line. | msg = IssueComment(
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class IssuesComments:
def __init__(self, client):
self.client = client
def list(self, repo, id, user=None):
return self.client.get('repos/%s/%s/issues/%s/comments' % (
self.client.user(user), repo, id), msg_type=IssueCommentListResponse)
def get(self, repo, id, user=None):
return self.client.get('repos/%s/%s/issues/comments/%s' % (
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import IssueComment
from ..requests import IssueCommentResponse
from ..requests import IssueCommentListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class IssueComment(msgs.Message):
# body = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class IssueCommentResponse(msgs.Message):
# response = msgs.MessageField('IssueComment', 1)
#
# Path: flask_github/client/requests.py
# class IssueCommentListResponse(msgs.Message):
# response = msgs.MessageField('IssueComment', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, id), msg_type=IssueCommentResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class IssuesComments:
def __init__(self, client):
self.client = client
def list(self, repo, id, user=None):
return self.client.get('repos/%s/%s/issues/%s/comments' % (
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import IssueComment
from ..requests import IssueCommentResponse
from ..requests import IssueCommentListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class IssueComment(msgs.Message):
# body = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class IssueCommentResponse(msgs.Message):
# response = msgs.MessageField('IssueComment', 1)
#
# Path: flask_github/client/requests.py
# class IssueCommentListResponse(msgs.Message):
# response = msgs.MessageField('IssueComment', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, id), msg_type=IssueCommentListResponse)
|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class ReposWatching:
def __init__(self, client):
self.client = client
def list_watchers(self, repo, user=None, page=1):
return self.client.get(
'repos/%s/%s/subscribers' % (
<|code_end|>
with the help of current file imports:
from ..requests import UserListResponse
from ..requests import RepoListResponse
and context from other files:
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | self.client.user(user), repo), msg_type=UserListResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class ReposWatching:
def __init__(self, client):
self.client = client
def list_watchers(self, repo, user=None, page=1):
return self.client.get(
'repos/%s/%s/subscribers' % (
self.client.user(user), repo), msg_type=UserListResponse)
def list_watched_repos(self, user=None, page=1):
url = 'user/subscriptions'
if user is not None and user != self.client._username:
url = 'users/%s/subscriptions' % user
<|code_end|>
, determine the next line of code. You have imports:
from ..requests import UserListResponse
from ..requests import RepoListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/requests.py
# class UserListResponse(msgs.Message):
# response = msgs.MessageField('User', 1, repeated=True)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
. Output only the next line. | return self.client.get(url, msg_type=RepoListResponse)
|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class ReposForks:
def __init__(self, client):
self.client = client
def list(self, repo, sort=None, user=None):
query = None
if sort:
query = {'sort': sort}
return self.client.get('repos/%s/%s/forks' % (
self.client.user(user), repo), query=query, msg_type=RepoListResponse)
def create(self, repo, org=None, user=None):
query = None
if org:
query = {'org': org}
return self.client.post('repos/%s/%s/forks' % (
<|code_end|>
with the help of current file imports:
from ..requests import RepoResponse
from ..requests import RepoListResponse
and context from other files:
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | self.client.user(user), repo), query=query, msg_type=RepoResponse)
|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class ReposForks:
def __init__(self, client):
self.client = client
def list(self, repo, sort=None, user=None):
query = None
if sort:
query = {'sort': sort}
return self.client.get('repos/%s/%s/forks' % (
<|code_end|>
with the help of current file imports:
from ..requests import RepoResponse
from ..requests import RepoListResponse
and context from other files:
# Path: flask_github/client/requests.py
# class RepoResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1)
#
# Path: flask_github/client/requests.py
# class RepoListResponse(msgs.Message):
# response = msgs.MessageField('Repo', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | self.client.user(user), repo), query=query, msg_type=RepoListResponse)
|
Given snippet: <|code_start|>from __future__ import unicode_literals
class GistsComments:
def __init__(self, client):
self.client = client
def list(self, id):
return self.client.get(
'gists/%s/comments' % id, msg_type=GistCommentListResponse)
def get(self, id):
return self.client.get(
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from ..messages import GistComment
from ..requests import GistCommentResponse
from ..requests import GistCommentListResponse
and context:
# Path: flask_github/client/messages.py
# class GistComment(msgs.Message):
# pass
#
# Path: flask_github/client/requests.py
# class GistCommentResponse(msgs.Message):
# response = msgs.MessageField('GistComment', 1)
#
# Path: flask_github/client/requests.py
# class GistCommentListResponse(msgs.Message):
# response = msgs.MessageField('GistComment', 1, repeated=True)
which might include code, classes, or functions. Output only the next line. | 'gists/comments/%s' % id, msg_type=GistCommentResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class GistsComments:
def __init__(self, client):
self.client = client
def list(self, id):
return self.client.get(
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import GistComment
from ..requests import GistCommentResponse
from ..requests import GistCommentListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class GistComment(msgs.Message):
# pass
#
# Path: flask_github/client/requests.py
# class GistCommentResponse(msgs.Message):
# response = msgs.MessageField('GistComment', 1)
#
# Path: flask_github/client/requests.py
# class GistCommentListResponse(msgs.Message):
# response = msgs.MessageField('GistComment', 1, repeated=True)
. Output only the next line. | 'gists/%s/comments' % id, msg_type=GistCommentListResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class PullRequests:
def __init__(self, client):
self.client = client
self.reviewcomments = PullReviewComments(self.client)
def list(self, repo, state=None, user=None):
query = None
if state:
query = {'state': state}
return self.client.get('repos/%s/%s/pulls' % (self.client.user(user),
repo), query=query, msg_type=PullRequestListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s' % (
self.client.user(user), repo, id), msg_type=PullRequestResponse)
def create(self, repo, title, base, head, body=None, user=None):
<|code_end|>
, predict the next line using imports from the current file:
from pullreqsreviewcomments import PullReviewComments
from ..messages import PullRequest
from ..messages import CommitMessage
from ..requests import PullRequestResponse
from ..requests import PullRequestListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class PullRequest(msgs.Message):
# title = msgs.StringField(1)
# base = msgs.StringField(2)
# head = msgs.StringField(3)
# body = msgs.StringField(4)
# issue = msgs.StringField(5)
#
# Path: flask_github/client/messages.py
# class CommitMessage(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullRequestResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1)
#
# Path: flask_github/client/requests.py
# class PullRequestListResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1, repeated=True)
. Output only the next line. | msg = PullRequest(
|
Given the following code snippet before the placeholder: <|code_start|> return self.client.post(
'repos/%s/%s/pulls' % (self.client.user(user), repo), data=msg,
msg_type=PullRequestResponse)
def create_from_issue(self, repo, issue, base, head, user=None):
msg = PullRequest(
issue=issue,
base=base,
head=head)
return self.client.post(
'repos/%s/%s/pulls' % (
self.client.user(user), repo), data=msg, msg_type=PullRequestResponse)
def list_commits(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s/commits' % (
self.client.user(user), repo, id), msg_type=None)
def list_files(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s/files' % (
self.client.user(user), repo, id), msg_type=None)
def get_if_merged(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s/merge' % (
self.client.user(user), repo, id), msg_type=None)
def merge(self, repo, id, commit_message=None, user=None):
if commit_message:
<|code_end|>
, predict the next line using imports from the current file:
from pullreqsreviewcomments import PullReviewComments
from ..messages import PullRequest
from ..messages import CommitMessage
from ..requests import PullRequestResponse
from ..requests import PullRequestListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class PullRequest(msgs.Message):
# title = msgs.StringField(1)
# base = msgs.StringField(2)
# head = msgs.StringField(3)
# body = msgs.StringField(4)
# issue = msgs.StringField(5)
#
# Path: flask_github/client/messages.py
# class CommitMessage(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullRequestResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1)
#
# Path: flask_github/client/requests.py
# class PullRequestListResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1, repeated=True)
. Output only the next line. | msg = CommitMessage(
|
Continue the code snippet: <|code_start|>from __future__ import unicode_literals
class PullRequests:
def __init__(self, client):
self.client = client
self.reviewcomments = PullReviewComments(self.client)
def list(self, repo, state=None, user=None):
query = None
if state:
query = {'state': state}
return self.client.get('repos/%s/%s/pulls' % (self.client.user(user),
repo), query=query, msg_type=PullRequestListResponse)
def get(self, repo, id, user=None):
return self.client.get(
'repos/%s/%s/pulls/%s' % (
<|code_end|>
. Use current file imports:
from pullreqsreviewcomments import PullReviewComments
from ..messages import PullRequest
from ..messages import CommitMessage
from ..requests import PullRequestResponse
from ..requests import PullRequestListResponse
and context (classes, functions, or code) from other files:
# Path: flask_github/client/messages.py
# class PullRequest(msgs.Message):
# title = msgs.StringField(1)
# base = msgs.StringField(2)
# head = msgs.StringField(3)
# body = msgs.StringField(4)
# issue = msgs.StringField(5)
#
# Path: flask_github/client/messages.py
# class CommitMessage(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullRequestResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1)
#
# Path: flask_github/client/requests.py
# class PullRequestListResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1, repeated=True)
. Output only the next line. | self.client.user(user), repo, id), msg_type=PullRequestResponse)
|
Given snippet: <|code_start|>from __future__ import unicode_literals
class PullRequests:
def __init__(self, client):
self.client = client
self.reviewcomments = PullReviewComments(self.client)
def list(self, repo, state=None, user=None):
query = None
if state:
query = {'state': state}
return self.client.get('repos/%s/%s/pulls' % (self.client.user(user),
<|code_end|>
, continue by predicting the next line. Consider current file imports:
from pullreqsreviewcomments import PullReviewComments
from ..messages import PullRequest
from ..messages import CommitMessage
from ..requests import PullRequestResponse
from ..requests import PullRequestListResponse
and context:
# Path: flask_github/client/messages.py
# class PullRequest(msgs.Message):
# title = msgs.StringField(1)
# base = msgs.StringField(2)
# head = msgs.StringField(3)
# body = msgs.StringField(4)
# issue = msgs.StringField(5)
#
# Path: flask_github/client/messages.py
# class CommitMessage(msgs.Message):
# commit_message = msgs.StringField(1)
#
# Path: flask_github/client/requests.py
# class PullRequestResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1)
#
# Path: flask_github/client/requests.py
# class PullRequestListResponse(msgs.Message):
# response = msgs.MessageField('PullRequest', 1, repeated=True)
which might include code, classes, or functions. Output only the next line. | repo), query=query, msg_type=PullRequestListResponse)
|
Given the following code snippet before the placeholder: <|code_start|>from __future__ import unicode_literals
class IssuesMilestones:
def __init__(self, client):
self.client = client
def list(self, repo, state=None, sort=None, direction=None, user=None):
query = {
'state': state,
'sort': sort,
'direction': direction}
return self.client.get('repos/%s/%s/milestones' % (
self.client.user(user), repo), query=query,
msg_type=IssueMilestoneListResponse)
def get(self, repo, number, user=None):
return self.client.get('repos/%s/%s/milestones/%s' % (
repo, user, number), msg_type=IssueMilestoneResponse)
def create(self, repo, title, state=None, description=None,
due_on=None, user=None):
<|code_end|>
, predict the next line using imports from the current file:
from ..messages import IssueMilestone
from ..requests import IssueMilestoneResponse
from ..requests import IssueMilestoneListResponse
and context including class names, function names, and sometimes code from other files:
# Path: flask_github/client/messages.py
# class IssueMilestone(msgs.Message):
# title = msgs.StringField(1)
# state = msgs.StringField(2)
# description = msgs.StringField(3)
# due_on = msgs.StringField(4)
#
# Path: flask_github/client/requests.py
# class IssueMilestoneResponse(msgs.Message):
# response = msgs.MessageField('IssueMilestone', 1)
#
# Path: flask_github/client/requests.py
# class IssueMilestoneListResponse(msgs.Message):
# response = msgs.MessageField('IssueMilestone', 1, repeated=True)
. Output only the next line. | msg = IssueMilestone(
|
Predict the next line for this snippet: <|code_start|>from __future__ import unicode_literals
class IssuesMilestones:
def __init__(self, client):
self.client = client
def list(self, repo, state=None, sort=None, direction=None, user=None):
query = {
'state': state,
'sort': sort,
'direction': direction}
return self.client.get('repos/%s/%s/milestones' % (
self.client.user(user), repo), query=query,
msg_type=IssueMilestoneListResponse)
def get(self, repo, number, user=None):
return self.client.get('repos/%s/%s/milestones/%s' % (
<|code_end|>
with the help of current file imports:
from ..messages import IssueMilestone
from ..requests import IssueMilestoneResponse
from ..requests import IssueMilestoneListResponse
and context from other files:
# Path: flask_github/client/messages.py
# class IssueMilestone(msgs.Message):
# title = msgs.StringField(1)
# state = msgs.StringField(2)
# description = msgs.StringField(3)
# due_on = msgs.StringField(4)
#
# Path: flask_github/client/requests.py
# class IssueMilestoneResponse(msgs.Message):
# response = msgs.MessageField('IssueMilestone', 1)
#
# Path: flask_github/client/requests.py
# class IssueMilestoneListResponse(msgs.Message):
# response = msgs.MessageField('IssueMilestone', 1, repeated=True)
, which may contain function names, class names, or code. Output only the next line. | repo, user, number), msg_type=IssueMilestoneResponse)
|
Using the snippet: <|code_start|>from __future__ import unicode_literals
class IssuesMilestones:
def __init__(self, client):
self.client = client
def list(self, repo, state=None, sort=None, direction=None, user=None):
query = {
'state': state,
'sort': sort,
'direction': direction}
return self.client.get('repos/%s/%s/milestones' % (
self.client.user(user), repo), query=query,
<|code_end|>
, determine the next line of code. You have imports:
from ..messages import IssueMilestone
from ..requests import IssueMilestoneResponse
from ..requests import IssueMilestoneListResponse
and context (class names, function names, or code) available:
# Path: flask_github/client/messages.py
# class IssueMilestone(msgs.Message):
# title = msgs.StringField(1)
# state = msgs.StringField(2)
# description = msgs.StringField(3)
# due_on = msgs.StringField(4)
#
# Path: flask_github/client/requests.py
# class IssueMilestoneResponse(msgs.Message):
# response = msgs.MessageField('IssueMilestone', 1)
#
# Path: flask_github/client/requests.py
# class IssueMilestoneListResponse(msgs.Message):
# response = msgs.MessageField('IssueMilestone', 1, repeated=True)
. Output only the next line. | msg_type=IssueMilestoneListResponse)
|
Predict the next line after this snippet: <|code_start|>"""
Kernel which places a prior over periodic functions.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['Periodic']
@printable
<|code_end|>
using the current file's imports:
import numpy as np
from ._real import RealKernel
from ._distances import diff, sqdist
from ..utils.models import printable
and any relevant context from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/kernels/_distances.py
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
. Output only the next line. | class Periodic(RealKernel): |
Using the snippet: <|code_start|>
def grad(self, X1, X2=None):
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
p = np.exp(self._logp)
# get the distance and a few transformations
D = np.sqrt(sqdist(X1, X2)) * np.pi / p
R = np.sin(D) / ell
S = R**2
E = 2 * sf2 * np.exp(-2*S)
yield E
yield 2*E*S
yield 2*E*R*D * np.cos(D) / ell
def dget(self, X1):
return np.exp(self._logsf*2) * np.ones(len(X1))
def dgrad(self, X):
yield 2 * self.dget(X)
yield np.zeros(len(X))
yield np.zeros(len(X))
def gradx(self, X1, X2=None):
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
p = np.exp(self._logp)
# get the distance and a few transformations
<|code_end|>
, determine the next line of code. You have imports:
import numpy as np
from ._real import RealKernel
from ._distances import diff, sqdist
from ..utils.models import printable
and context (class names, function names, or code) available:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/kernels/_distances.py
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
. Output only the next line. | D = diff(X1, X2) * np.pi / p |
Using the snippet: <|code_start|> given by::
k(x, y) = sf^2 exp(-2 sin^2( ||x-y|| pi / p ) / ell^2)
"""
def __init__(self, sf, ell, p):
self._logsf = np.log(float(sf))
self._logell = np.log(float(ell))
self._logp = np.log(float(p))
self.ndim = 1
self.nhyper = 3
def _params(self):
return [
('sf', 1, True),
('ell', 1, True),
('p', 1, True),
]
def get_hyper(self):
return np.r_[self._logsf, self._logell, self._logp]
def set_hyper(self, hyper):
self._logsf = hyper[0]
self._logell = hyper[1]
self._logp = hyper[2]
def get(self, X1, X2=None):
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
p = np.exp(self._logp)
<|code_end|>
, determine the next line of code. You have imports:
import numpy as np
from ._real import RealKernel
from ._distances import diff, sqdist
from ..utils.models import printable
and context (class names, function names, or code) available:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/kernels/_distances.py
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
. Output only the next line. | D = np.sqrt(sqdist(X1, X2)) * np.pi / p |
Based on the snippet: <|code_start|>"""
Kernel which places a prior over periodic functions.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['Periodic']
<|code_end|>
, predict the immediate next line with the help of imports:
import numpy as np
from ._real import RealKernel
from ._distances import diff, sqdist
from ..utils.models import printable
and context (classes, functions, sometimes code) from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/kernels/_distances.py
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
. Output only the next line. | @printable |
Given snippet: <|code_start|>"""
Base class for real-valued kernels.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# import the generic sum/product kernels and change their names. We'll call the
# real-valued versions SumKernel and ProductKernel as well since they really
# shouldn't be used outside of this module anyway.
# exported symbols
__all__ = ['RealKernel']
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import numpy as np
from abc import abstractmethod
from ._base import Kernel
from ._combo import SumKernel as SumKernel_
from ._combo import ProductKernel as ProductKernel_
from ._combo import combine
from ._combo import product_but
and context:
# Path: pygp/kernels/_base.py
# class Kernel(Parameterized):
# """
# The base Kernel interface.
# """
# def __call__(self, x1, x2):
# return self.get(x1[None], x2[None])[0]
#
# @abstractmethod
# def get(self, X1, X2=None):
# """
# Evaluate the kernel.
#
# Returns the matrix of covariances between points in `X1` and `X2`. If
# `X2` is not given this will return the pairwise covariances between
# points in `X1`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dget(self, X):
# """Evaluate the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def grad(self, X1, X2=None):
# """
# Evaluate the gradient of the kernel.
#
# Returns an iterator over the gradients of the covariances between
# points in `X1` and `X2`. If `X2` is not given this will iterate over
# the the gradients of the pairwise covariances.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dgrad(self, X):
# """Evaluate the gradients of the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def transform(self, X):
# """Format the inputs X as arrays."""
# raise NotImplementedError
#
# Path: pygp/kernels/_combo.py
# class SumKernel(ComboKernel):
# """Kernel representing a sum of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return sum(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return sum(fiterable)
#
# def grad(self, X1, X2=None):
# giterable = (p.grad(X1, X2) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# def dgrad(self, X):
# giterable = (p.dgrad(X) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# Path: pygp/kernels/_combo.py
# class ProductKernel(ComboKernel):
# """Kernel representing a product of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return product(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return product(fiterable)
#
# def grad(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# giterable = (p.grad(X1, X2) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# def dgrad(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# giterable = (p.dgrad(X) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# Path: pygp/kernels/_combo.py
# def combine(cls, *parts):
# """
# Given a list of kernels return another list of kernels where objects of
# type cls have been "combined". This applies to ComboKernel objects which
# represent associative operations.
# """
# combined = []
# for part in parts:
# combined += part._parts if isinstance(part, cls) else [part]
# return combined
#
# Path: pygp/kernels/_combo.py
# def product_but(fiterable):
# """
# Given an iterator over function evaluations return an array such that
# `M[i]` is the product of every evaluation except for the ith one.
# """
# A = list(fiterable)
#
# # allocate memory for M and fill everything but the last element with
# # the product of A[i+1:]. Note that we're using the cumprod in place.
# M = np.empty_like(A)
# np.cumprod(A[:0:-1], axis=0, out=M[:-1][::-1])
#
# # use an explicit loop to iteratively set M[-1] equal to the product of
# # A[:-1]. While doing this we can multiply M[i] by A[:i].
# M[-1] = A[0]
# for i in xrange(1, len(A)-1):
# M[i] *= M[-1]
# M[-1] *= A[i]
#
# return M
which might include code, classes, or functions. Output only the next line. | class RealKernel(Kernel): |
Continue the code snippet: <|code_start|>
@abstractmethod
def gradxy(self, X1, X2=None):
"""
Derivatives of the kernel with respect to both its first and second
arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
"""
raise NotImplementedError
@abstractmethod
def sample_spectrum(self, N, rng=None):
"""
Sample N values from the spectral density of the kernel, returning a
set of weights W of size (n,d) and a scalar value representing the
normalizing constant.
"""
raise NotImplementedError
def _can_combine(*parts):
"""
Return whether a set of real-valued kernels can be combined. Here this
requires them to all be RealKernel objects and have the same number of
input dimensions.
"""
return (all(isinstance(_, RealKernel) for _ in parts) and
all(_.ndim == parts[0].ndim for _ in parts))
<|code_end|>
. Use current file imports:
import numpy as np
from abc import abstractmethod
from ._base import Kernel
from ._combo import SumKernel as SumKernel_
from ._combo import ProductKernel as ProductKernel_
from ._combo import combine
from ._combo import product_but
and context (classes, functions, or code) from other files:
# Path: pygp/kernels/_base.py
# class Kernel(Parameterized):
# """
# The base Kernel interface.
# """
# def __call__(self, x1, x2):
# return self.get(x1[None], x2[None])[0]
#
# @abstractmethod
# def get(self, X1, X2=None):
# """
# Evaluate the kernel.
#
# Returns the matrix of covariances between points in `X1` and `X2`. If
# `X2` is not given this will return the pairwise covariances between
# points in `X1`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dget(self, X):
# """Evaluate the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def grad(self, X1, X2=None):
# """
# Evaluate the gradient of the kernel.
#
# Returns an iterator over the gradients of the covariances between
# points in `X1` and `X2`. If `X2` is not given this will iterate over
# the the gradients of the pairwise covariances.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dgrad(self, X):
# """Evaluate the gradients of the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def transform(self, X):
# """Format the inputs X as arrays."""
# raise NotImplementedError
#
# Path: pygp/kernels/_combo.py
# class SumKernel(ComboKernel):
# """Kernel representing a sum of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return sum(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return sum(fiterable)
#
# def grad(self, X1, X2=None):
# giterable = (p.grad(X1, X2) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# def dgrad(self, X):
# giterable = (p.dgrad(X) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# Path: pygp/kernels/_combo.py
# class ProductKernel(ComboKernel):
# """Kernel representing a product of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return product(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return product(fiterable)
#
# def grad(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# giterable = (p.grad(X1, X2) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# def dgrad(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# giterable = (p.dgrad(X) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# Path: pygp/kernels/_combo.py
# def combine(cls, *parts):
# """
# Given a list of kernels return another list of kernels where objects of
# type cls have been "combined". This applies to ComboKernel objects which
# represent associative operations.
# """
# combined = []
# for part in parts:
# combined += part._parts if isinstance(part, cls) else [part]
# return combined
#
# Path: pygp/kernels/_combo.py
# def product_but(fiterable):
# """
# Given an iterator over function evaluations return an array such that
# `M[i]` is the product of every evaluation except for the ith one.
# """
# A = list(fiterable)
#
# # allocate memory for M and fill everything but the last element with
# # the product of A[i+1:]. Note that we're using the cumprod in place.
# M = np.empty_like(A)
# np.cumprod(A[:0:-1], axis=0, out=M[:-1][::-1])
#
# # use an explicit loop to iteratively set M[-1] equal to the product of
# # A[:-1]. While doing this we can multiply M[i] by A[:i].
# M[-1] = A[0]
# for i in xrange(1, len(A)-1):
# M[i] *= M[-1]
# M[-1] *= A[i]
#
# return M
. Output only the next line. | class SumKernel(RealKernel, SumKernel_): |
Next line prediction: <|code_start|> requires them to all be RealKernel objects and have the same number of
input dimensions.
"""
return (all(isinstance(_, RealKernel) for _ in parts) and
all(_.ndim == parts[0].ndim for _ in parts))
class SumKernel(RealKernel, SumKernel_):
"""A sum of real-valued kernels."""
def __init__(self, *parts):
if not _can_combine(*parts):
raise ValueError('cannot add mismatched kernels')
super(SumKernel, self).__init__(*parts)
self.ndim = self._parts[0].ndim
def gradx(self, X1, X2=None):
return sum(p.gradx(X1, X2) for p in self._parts)
def grady(self, X1, X2=None):
return sum(p.grady(X1, X2) for p in self._parts)
def gradxy(self, X1, X2=None):
return sum(p.gradxy(X1, X2) for p in self._parts)
def sample_spectrum(self, N, rng=None):
raise NotImplementedError
<|code_end|>
. Use current file imports:
(import numpy as np
from abc import abstractmethod
from ._base import Kernel
from ._combo import SumKernel as SumKernel_
from ._combo import ProductKernel as ProductKernel_
from ._combo import combine
from ._combo import product_but)
and context including class names, function names, or small code snippets from other files:
# Path: pygp/kernels/_base.py
# class Kernel(Parameterized):
# """
# The base Kernel interface.
# """
# def __call__(self, x1, x2):
# return self.get(x1[None], x2[None])[0]
#
# @abstractmethod
# def get(self, X1, X2=None):
# """
# Evaluate the kernel.
#
# Returns the matrix of covariances between points in `X1` and `X2`. If
# `X2` is not given this will return the pairwise covariances between
# points in `X1`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dget(self, X):
# """Evaluate the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def grad(self, X1, X2=None):
# """
# Evaluate the gradient of the kernel.
#
# Returns an iterator over the gradients of the covariances between
# points in `X1` and `X2`. If `X2` is not given this will iterate over
# the the gradients of the pairwise covariances.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dgrad(self, X):
# """Evaluate the gradients of the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def transform(self, X):
# """Format the inputs X as arrays."""
# raise NotImplementedError
#
# Path: pygp/kernels/_combo.py
# class SumKernel(ComboKernel):
# """Kernel representing a sum of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return sum(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return sum(fiterable)
#
# def grad(self, X1, X2=None):
# giterable = (p.grad(X1, X2) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# def dgrad(self, X):
# giterable = (p.dgrad(X) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# Path: pygp/kernels/_combo.py
# class ProductKernel(ComboKernel):
# """Kernel representing a product of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return product(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return product(fiterable)
#
# def grad(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# giterable = (p.grad(X1, X2) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# def dgrad(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# giterable = (p.dgrad(X) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# Path: pygp/kernels/_combo.py
# def combine(cls, *parts):
# """
# Given a list of kernels return another list of kernels where objects of
# type cls have been "combined". This applies to ComboKernel objects which
# represent associative operations.
# """
# combined = []
# for part in parts:
# combined += part._parts if isinstance(part, cls) else [part]
# return combined
#
# Path: pygp/kernels/_combo.py
# def product_but(fiterable):
# """
# Given an iterator over function evaluations return an array such that
# `M[i]` is the product of every evaluation except for the ith one.
# """
# A = list(fiterable)
#
# # allocate memory for M and fill everything but the last element with
# # the product of A[i+1:]. Note that we're using the cumprod in place.
# M = np.empty_like(A)
# np.cumprod(A[:0:-1], axis=0, out=M[:-1][::-1])
#
# # use an explicit loop to iteratively set M[-1] equal to the product of
# # A[:-1]. While doing this we can multiply M[i] by A[:i].
# M[-1] = A[0]
# for i in xrange(1, len(A)-1):
# M[i] *= M[-1]
# M[-1] *= A[i]
#
# return M
. Output only the next line. | class ProductKernel(RealKernel, ProductKernel_): |
Based on the snippet: <|code_start|>"""
Base class for real-valued kernels.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# import the generic sum/product kernels and change their names. We'll call the
# real-valued versions SumKernel and ProductKernel as well since they really
# shouldn't be used outside of this module anyway.
# exported symbols
__all__ = ['RealKernel']
class RealKernel(Kernel):
"""Kernel whose inputs are real-valued vectors."""
def __add__(self, other):
<|code_end|>
, predict the immediate next line with the help of imports:
import numpy as np
from abc import abstractmethod
from ._base import Kernel
from ._combo import SumKernel as SumKernel_
from ._combo import ProductKernel as ProductKernel_
from ._combo import combine
from ._combo import product_but
and context (classes, functions, sometimes code) from other files:
# Path: pygp/kernels/_base.py
# class Kernel(Parameterized):
# """
# The base Kernel interface.
# """
# def __call__(self, x1, x2):
# return self.get(x1[None], x2[None])[0]
#
# @abstractmethod
# def get(self, X1, X2=None):
# """
# Evaluate the kernel.
#
# Returns the matrix of covariances between points in `X1` and `X2`. If
# `X2` is not given this will return the pairwise covariances between
# points in `X1`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dget(self, X):
# """Evaluate the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def grad(self, X1, X2=None):
# """
# Evaluate the gradient of the kernel.
#
# Returns an iterator over the gradients of the covariances between
# points in `X1` and `X2`. If `X2` is not given this will iterate over
# the the gradients of the pairwise covariances.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dgrad(self, X):
# """Evaluate the gradients of the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def transform(self, X):
# """Format the inputs X as arrays."""
# raise NotImplementedError
#
# Path: pygp/kernels/_combo.py
# class SumKernel(ComboKernel):
# """Kernel representing a sum of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return sum(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return sum(fiterable)
#
# def grad(self, X1, X2=None):
# giterable = (p.grad(X1, X2) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# def dgrad(self, X):
# giterable = (p.dgrad(X) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# Path: pygp/kernels/_combo.py
# class ProductKernel(ComboKernel):
# """Kernel representing a product of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return product(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return product(fiterable)
#
# def grad(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# giterable = (p.grad(X1, X2) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# def dgrad(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# giterable = (p.dgrad(X) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# Path: pygp/kernels/_combo.py
# def combine(cls, *parts):
# """
# Given a list of kernels return another list of kernels where objects of
# type cls have been "combined". This applies to ComboKernel objects which
# represent associative operations.
# """
# combined = []
# for part in parts:
# combined += part._parts if isinstance(part, cls) else [part]
# return combined
#
# Path: pygp/kernels/_combo.py
# def product_but(fiterable):
# """
# Given an iterator over function evaluations return an array such that
# `M[i]` is the product of every evaluation except for the ith one.
# """
# A = list(fiterable)
#
# # allocate memory for M and fill everything but the last element with
# # the product of A[i+1:]. Note that we're using the cumprod in place.
# M = np.empty_like(A)
# np.cumprod(A[:0:-1], axis=0, out=M[:-1][::-1])
#
# # use an explicit loop to iteratively set M[-1] equal to the product of
# # A[:-1]. While doing this we can multiply M[i] by A[:i].
# M[-1] = A[0]
# for i in xrange(1, len(A)-1):
# M[i] *= M[-1]
# M[-1] *= A[i]
#
# return M
. Output only the next line. | return SumKernel(*combine(SumKernel, self, other)) |
Predict the next line after this snippet: <|code_start|>
super(SumKernel, self).__init__(*parts)
self.ndim = self._parts[0].ndim
def gradx(self, X1, X2=None):
return sum(p.gradx(X1, X2) for p in self._parts)
def grady(self, X1, X2=None):
return sum(p.grady(X1, X2) for p in self._parts)
def gradxy(self, X1, X2=None):
return sum(p.gradxy(X1, X2) for p in self._parts)
def sample_spectrum(self, N, rng=None):
raise NotImplementedError
class ProductKernel(RealKernel, ProductKernel_):
"""A product of real-valued kernels."""
def __init__(self, *parts):
if not _can_combine(*parts):
raise ValueError('cannot multiply mismatched kernels')
super(ProductKernel, self).__init__(*parts)
self.ndim = self._parts[0].ndim
def gradx(self, X1, X2=None):
fiterable = (p.get(X1, X2)[:, :, None] for p in self._parts)
giterable = (p.gradx(X1, X2) for p in self._parts)
<|code_end|>
using the current file's imports:
import numpy as np
from abc import abstractmethod
from ._base import Kernel
from ._combo import SumKernel as SumKernel_
from ._combo import ProductKernel as ProductKernel_
from ._combo import combine
from ._combo import product_but
and any relevant context from other files:
# Path: pygp/kernels/_base.py
# class Kernel(Parameterized):
# """
# The base Kernel interface.
# """
# def __call__(self, x1, x2):
# return self.get(x1[None], x2[None])[0]
#
# @abstractmethod
# def get(self, X1, X2=None):
# """
# Evaluate the kernel.
#
# Returns the matrix of covariances between points in `X1` and `X2`. If
# `X2` is not given this will return the pairwise covariances between
# points in `X1`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dget(self, X):
# """Evaluate the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def grad(self, X1, X2=None):
# """
# Evaluate the gradient of the kernel.
#
# Returns an iterator over the gradients of the covariances between
# points in `X1` and `X2`. If `X2` is not given this will iterate over
# the the gradients of the pairwise covariances.
# """
# raise NotImplementedError
#
# @abstractmethod
# def dgrad(self, X):
# """Evaluate the gradients of the self covariances."""
# raise NotImplementedError
#
# @abstractmethod
# def transform(self, X):
# """Format the inputs X as arrays."""
# raise NotImplementedError
#
# Path: pygp/kernels/_combo.py
# class SumKernel(ComboKernel):
# """Kernel representing a sum of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return sum(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return sum(fiterable)
#
# def grad(self, X1, X2=None):
# giterable = (p.grad(X1, X2) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# def dgrad(self, X):
# giterable = (p.dgrad(X) for p in self._parts)
# return it.chain.from_iterable(giterable)
#
# Path: pygp/kernels/_combo.py
# class ProductKernel(ComboKernel):
# """Kernel representing a product of other kernels."""
#
# def get(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# return product(fiterable)
#
# def dget(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# return product(fiterable)
#
# def grad(self, X1, X2=None):
# fiterable = (p.get(X1, X2) for p in self._parts)
# giterable = (p.grad(X1, X2) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# def dgrad(self, X):
# fiterable = (p.dget(X) for p in self._parts)
# giterable = (p.dgrad(X) for p in self._parts)
# for Mi, grads in zip(product_but(fiterable), giterable):
# for dM in grads:
# yield Mi*dM
#
# Path: pygp/kernels/_combo.py
# def combine(cls, *parts):
# """
# Given a list of kernels return another list of kernels where objects of
# type cls have been "combined". This applies to ComboKernel objects which
# represent associative operations.
# """
# combined = []
# for part in parts:
# combined += part._parts if isinstance(part, cls) else [part]
# return combined
#
# Path: pygp/kernels/_combo.py
# def product_but(fiterable):
# """
# Given an iterator over function evaluations return an array such that
# `M[i]` is the product of every evaluation except for the ith one.
# """
# A = list(fiterable)
#
# # allocate memory for M and fill everything but the last element with
# # the product of A[i+1:]. Note that we're using the cumprod in place.
# M = np.empty_like(A)
# np.cumprod(A[:0:-1], axis=0, out=M[:-1][::-1])
#
# # use an explicit loop to iteratively set M[-1] equal to the product of
# # A[:-1]. While doing this we can multiply M[i] by A[:i].
# M[-1] = A[0]
# for i in xrange(1, len(A)-1):
# M[i] *= M[-1]
# M[-1] *= A[i]
#
# return M
. Output only the next line. | return sum(f*g for f, g in zip(product_but(fiterable), giterable)) |
Given the following code snippet before the placeholder: <|code_start|>"""
Kernel which places a prior over periodic functions.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['RQ']
@printable
<|code_end|>
, predict the next line using imports from the current file:
import numpy as np
from ._real import RealKernel
from ..utils.models import printable
from ._distances import rescale, diff, sqdist, sqdist_foreach
and context including class names, function names, and sometimes code from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
#
# Path: pygp/kernels/_distances.py
# def rescale(ell, X1, X2):
# """
# Rescale the two sets of vectors by `ell`.
# """
# X1 = X1 / ell
# X2 = X2 / ell if (X2 is not None) else None
# return X1, X2
#
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# def sqdist_foreach(X1, X2=None):
# """
# Return an iterator over each dimension returning the squared-distance
# between two sets of vector. If `X2` is not given this will iterate over the
# pairwise squared-distances in `X1` in each dimension.
# """
# X2 = X1 if (X2 is None) else X2
# for i in xrange(X1.shape[1]):
# yield ssd.cdist(X1[:, i, None], X2[:, i, None], 'sqeuclidean')
. Output only the next line. | class RQ(RealKernel): |
Given the code snippet: <|code_start|>"""
Kernel which places a prior over periodic functions.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['RQ']
<|code_end|>
, generate the next line using the imports in this file:
import numpy as np
from ._real import RealKernel
from ..utils.models import printable
from ._distances import rescale, diff, sqdist, sqdist_foreach
and context (functions, classes, or occasionally code) from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
#
# Path: pygp/kernels/_distances.py
# def rescale(ell, X1, X2):
# """
# Rescale the two sets of vectors by `ell`.
# """
# X1 = X1 / ell
# X2 = X2 / ell if (X2 is not None) else None
# return X1, X2
#
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# def sqdist_foreach(X1, X2=None):
# """
# Return an iterator over each dimension returning the squared-distance
# between two sets of vector. If `X2` is not given this will iterate over the
# pairwise squared-distances in `X1` in each dimension.
# """
# X2 = X1 if (X2 is None) else X2
# for i in xrange(X1.shape[1]):
# yield ssd.cdist(X1[:, i, None], X2[:, i, None], 'sqeuclidean')
. Output only the next line. | @printable |
Using the snippet: <|code_start|> self.nhyper = 2 + np.size(self._logell)
if ndim is not None:
if np.size(self._logell) == 1:
self._logell = float(self._logell)
self._iso = True
self.ndim = ndim
else:
raise ValueError('ndim only usable with scalar lengthscales')
def _params(self):
return [
('sf', 1, True),
('ell', self.nhyper-2, True),
('alpha', 1, True),
]
def get_hyper(self):
return np.r_[self._logsf, self._logell, self._logalpha]
def set_hyper(self, hyper):
self._logsf = hyper[0]
self._logell = hyper[1] if self._iso else hyper[1:-1]
self._logalpha = hyper[-1]
def get(self, X1, X2=None):
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
alpha = np.exp(self._logalpha)
<|code_end|>
, determine the next line of code. You have imports:
import numpy as np
from ._real import RealKernel
from ..utils.models import printable
from ._distances import rescale, diff, sqdist, sqdist_foreach
and context (class names, function names, or code) available:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
#
# Path: pygp/kernels/_distances.py
# def rescale(ell, X1, X2):
# """
# Rescale the two sets of vectors by `ell`.
# """
# X1 = X1 / ell
# X2 = X2 / ell if (X2 is not None) else None
# return X1, X2
#
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# def sqdist_foreach(X1, X2=None):
# """
# Return an iterator over each dimension returning the squared-distance
# between two sets of vector. If `X2` is not given this will iterate over the
# pairwise squared-distances in `X1` in each dimension.
# """
# X2 = X1 if (X2 is None) else X2
# for i in xrange(X1.shape[1]):
# yield ssd.cdist(X1[:, i, None], X2[:, i, None], 'sqeuclidean')
. Output only the next line. | X1, X2 = rescale(ell, X1, X2) |
Predict the next line for this snippet: <|code_start|> D = sqdist(X1, X2)
E = 1 + 0.5*D/alpha
K = sf2 * E**(-alpha)
M = K*D/E
yield 2*K # derivative wrt logsf
if self._iso:
yield M # derivative wrt logell (iso)
else:
for D in sqdist_foreach(X1, X2):
yield K*D/E # derivative wrt logell (ard)
yield 0.5*M - alpha*K*np.log(E) # derivative wrt alpha
def dget(self, X1):
return np.exp(self._logsf*2) * np.ones(len(X1))
def dgrad(self, X):
yield 2 * self.dget(X)
for _ in xrange(self.nhyper-2):
yield np.zeros(len(X))
yield np.zeros(len(X))
def gradx(self, X1, X2=None):
# hypers
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
alpha = np.exp(self._logalpha)
# precomputations
X1, X2 = rescale(ell, X1, X2)
<|code_end|>
with the help of current file imports:
import numpy as np
from ._real import RealKernel
from ..utils.models import printable
from ._distances import rescale, diff, sqdist, sqdist_foreach
and context from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
#
# Path: pygp/kernels/_distances.py
# def rescale(ell, X1, X2):
# """
# Rescale the two sets of vectors by `ell`.
# """
# X1 = X1 / ell
# X2 = X2 / ell if (X2 is not None) else None
# return X1, X2
#
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# def sqdist_foreach(X1, X2=None):
# """
# Return an iterator over each dimension returning the squared-distance
# between two sets of vector. If `X2` is not given this will iterate over the
# pairwise squared-distances in `X1` in each dimension.
# """
# X2 = X1 if (X2 is None) else X2
# for i in xrange(X1.shape[1]):
# yield ssd.cdist(X1[:, i, None], X2[:, i, None], 'sqeuclidean')
, which may contain function names, class names, or code. Output only the next line. | D = diff(X1, X2) |
Based on the snippet: <|code_start|>
if ndim is not None:
if np.size(self._logell) == 1:
self._logell = float(self._logell)
self._iso = True
self.ndim = ndim
else:
raise ValueError('ndim only usable with scalar lengthscales')
def _params(self):
return [
('sf', 1, True),
('ell', self.nhyper-2, True),
('alpha', 1, True),
]
def get_hyper(self):
return np.r_[self._logsf, self._logell, self._logalpha]
def set_hyper(self, hyper):
self._logsf = hyper[0]
self._logell = hyper[1] if self._iso else hyper[1:-1]
self._logalpha = hyper[-1]
def get(self, X1, X2=None):
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
alpha = np.exp(self._logalpha)
X1, X2 = rescale(ell, X1, X2)
<|code_end|>
, predict the immediate next line with the help of imports:
import numpy as np
from ._real import RealKernel
from ..utils.models import printable
from ._distances import rescale, diff, sqdist, sqdist_foreach
and context (classes, functions, sometimes code) from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
#
# Path: pygp/kernels/_distances.py
# def rescale(ell, X1, X2):
# """
# Rescale the two sets of vectors by `ell`.
# """
# X1 = X1 / ell
# X2 = X2 / ell if (X2 is not None) else None
# return X1, X2
#
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# def sqdist_foreach(X1, X2=None):
# """
# Return an iterator over each dimension returning the squared-distance
# between two sets of vector. If `X2` is not given this will iterate over the
# pairwise squared-distances in `X1` in each dimension.
# """
# X2 = X1 if (X2 is None) else X2
# for i in xrange(X1.shape[1]):
# yield ssd.cdist(X1[:, i, None], X2[:, i, None], 'sqeuclidean')
. Output only the next line. | K = sf2 * (1 + 0.5*sqdist(X1, X2)/alpha) ** (-alpha) |
Here is a snippet: <|code_start|> self._logsf = hyper[0]
self._logell = hyper[1] if self._iso else hyper[1:-1]
self._logalpha = hyper[-1]
def get(self, X1, X2=None):
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
alpha = np.exp(self._logalpha)
X1, X2 = rescale(ell, X1, X2)
K = sf2 * (1 + 0.5*sqdist(X1, X2)/alpha) ** (-alpha)
return K
def grad(self, X1, X2=None):
# hypers
sf2 = np.exp(self._logsf*2)
ell = np.exp(self._logell)
alpha = np.exp(self._logalpha)
# precomputations
X1, X2 = rescale(ell, X1, X2)
D = sqdist(X1, X2)
E = 1 + 0.5*D/alpha
K = sf2 * E**(-alpha)
M = K*D/E
yield 2*K # derivative wrt logsf
if self._iso:
yield M # derivative wrt logell (iso)
else:
<|code_end|>
. Write the next line using the current file imports:
import numpy as np
from ._real import RealKernel
from ..utils.models import printable
from ._distances import rescale, diff, sqdist, sqdist_foreach
and context from other files:
# Path: pygp/kernels/_real.py
# class RealKernel(Kernel):
# """Kernel whose inputs are real-valued vectors."""
#
# def __add__(self, other):
# return SumKernel(*combine(SumKernel, self, other))
#
# def __mul__(self, other):
# return ProductKernel(*combine(ProductKernel, self, other))
#
# def transform(self, X):
# return np.array(X, ndmin=2, dtype=float, copy=False)
#
# @abstractmethod
# def gradx(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its first argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def grady(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to its second argument. Returns
# an (m,n,d)-array.
# """
# raise NotImplementedError
#
# @abstractmethod
# def gradxy(self, X1, X2=None):
# """
# Derivatives of the kernel with respect to both its first and second
# arguments. Returns an (m,n,d,d)-array. The (a,b,i,j)th element
# corresponds to the derivative with respect to `X1[a,i]` and `X2[b,j]`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def sample_spectrum(self, N, rng=None):
# """
# Sample N values from the spectral density of the kernel, returning a
# set of weights W of size (n,d) and a scalar value representing the
# normalizing constant.
# """
# raise NotImplementedError
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
#
# Path: pygp/kernels/_distances.py
# def rescale(ell, X1, X2):
# """
# Rescale the two sets of vectors by `ell`.
# """
# X1 = X1 / ell
# X2 = X2 / ell if (X2 is not None) else None
# return X1, X2
#
# def diff(X1, X2=None):
# """
# Return the differences between vectors in `X1` and `X2`. If `X2` is not
# given this will return the pairwise differences in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return X1[:, None, :] - X2[None, :, :]
#
# def sqdist(X1, X2=None):
# """
# Return the squared-distance between two sets of vector. If `X2` is not
# given this will return the pairwise squared-distances in `X1`.
# """
# X2 = X1 if (X2 is None) else X2
# return ssd.cdist(X1, X2, 'sqeuclidean')
#
# def sqdist_foreach(X1, X2=None):
# """
# Return an iterator over each dimension returning the squared-distance
# between two sets of vector. If `X2` is not given this will iterate over the
# pairwise squared-distances in `X1` in each dimension.
# """
# X2 = X1 if (X2 is None) else X2
# for i in xrange(X1.shape[1]):
# yield ssd.cdist(X1[:, i, None], X2[:, i, None], 'sqeuclidean')
, which may include functions, classes, or code. Output only the next line. | for D in sqdist_foreach(X1, X2): |
Using the snippet: <|code_start|>"""
Implementation of the Gaussian likelihood model.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['Gaussian']
@printable
<|code_end|>
, determine the next line of code. You have imports:
import numpy as np
from mwhutils.random import rstate
from ._base import RealLikelihood
from ..utils.models import printable
and context (class names, function names, or code) available:
# Path: pygp/likelihoods/_base.py
# class RealLikelihood(Likelihood):
# """
# Likelihood model with real-valued outputs.
# """
# def transform(self, y):
# return np.array(y, ndmin=1, dtype=float, copy=False)
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
. Output only the next line. | class Gaussian(RealLikelihood): |
Next line prediction: <|code_start|>"""
Implementation of the Gaussian likelihood model.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['Gaussian']
<|code_end|>
. Use current file imports:
(import numpy as np
from mwhutils.random import rstate
from ._base import RealLikelihood
from ..utils.models import printable)
and context including class names, function names, or small code snippets from other files:
# Path: pygp/likelihoods/_base.py
# class RealLikelihood(Likelihood):
# """
# Likelihood model with real-valued outputs.
# """
# def transform(self, y):
# return np.array(y, ndmin=1, dtype=float, copy=False)
#
# Path: pygp/utils/models.py
# def printable(cls):
# """
# Decorator which marks classes as being able to be pretty-printed as a
# function of their hyperparameters. This decorator defines a __repr__ method
# for the given class which uses the class's `get_hyper` and `_params`
# methods to print it.
# """
# def _repr(obj):
# """Represent the object as a function of its hyperparameters."""
# hyper = obj.get_hyper()
# substrings = []
# for key, block, log in get_params(obj):
# val = hyper[block]
# val = val[0] if (len(val) == 1) else val
# val = np.exp(val) if log else val
# substrings += ['%s=%s' % (key, val)]
# return obj.__class__.__name__ + '(' + ', '.join(substrings) + ')'
# cls.__repr__ = _repr
# return cls
. Output only the next line. | @printable |
Predict the next line after this snippet: <|code_start|>
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['optimize']
def optimize(gp, priors=None):
"""
Perform type-II maximum likelihood to fit GP hyperparameters.
If given the priors object should be a dictionary mapping named parameters
to an object which implements `prior.loglikelihood(hyper, grad)`. If a
parameter is mapped to the `None` value then this will be assumed fixed.
Note: nothing is returned by this function. Instead it will modify the
hyperparameters of the given GP object in place.
"""
hyper0 = gp.get_hyper()
active = np.ones(gp.nhyper, dtype=bool)
# this just manipulates a few lists so that we transform priors into a list
# of tuples of the form (block, log, prior) for each named prior.
<|code_end|>
using the current file's imports:
import numpy as np
import scipy.optimize as so
from ..utils.models import get_params
and any relevant context from other files:
# Path: pygp/utils/models.py
# def get_params(obj):
# """
# Helper function which translates the values returned by _params() into
# something more meaningful.
# """
# offset = 0
# for param in obj._params():
# key, size, log = param
# block = slice(offset, offset+size)
# offset += size
# yield key, block, log
. Output only the next line. | params = dict((key, (block, log)) for (key, block, log) in get_params(gp)) |
Given snippet: <|code_start|>
# local imports
# exported symbols
__all__ = ['SMC']
def _sample_prior(model, priors, n, rng=None):
rng = rstate(rng)
# unpack priors
# TODO -- Bobak: This snippet is copied from learning/sampling.py
# and should probably be put into a Prior base class.
priors = dict(priors)
active = np.ones(model.nhyper, dtype=bool)
logged = np.ones(model.nhyper, dtype=bool)
for (key, block, log) in get_params(model):
inactive = (key in priors) and (priors[key] is None)
logged[block] = log
active[block] = not inactive
if inactive:
del priors[key]
else:
priors[key] = (block, log, priors[key])
priors = priors.values()
# sample hyperparameters from prior
hypers = np.tile(model.get_hyper(), (n, 1))
for (block, log, prior) in priors:
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import numpy as np
from scipy.misc import logsumexp
from mwhutils.random import rstate
from ..learning.sampling import sample
from ..utils.models import get_params
and context:
# Path: pygp/learning/sampling.py
# def sample(gp, priors, n, raw=True, rng=None):
# rng = rstate(rng)
# priors = dict(priors)
# active = np.ones(gp.nhyper, dtype=bool)
# logged = np.ones(gp.nhyper, dtype=bool)
#
# for (key, block, log) in get_params(gp):
# inactive = (key in priors) and (priors[key] is None)
# logged[block] = log
# active[block] = not inactive
# if inactive:
# del priors[key]
# else:
# priors[key] = (block, log, priors[key])
#
# # priors is now just a list of the form (block, log, prior).
# priors = priors.values()
#
# # get the initial hyperparameters and transform into the non-log space.
# hyper0 = gp.get_hyper()
# hyper0[logged] = np.exp(hyper0[logged])
#
# def logprob(x):
# # copy the initial hyperparameters and then assign the "active"
# # parameters that come from x.
# hyper = hyper0.copy()
# hyper[active] = x
# logprob = 0
#
# # compute the prior probabilities. we do this first so that if there
# # are any infs they'll be caught in the least expensive computations
# # first.
# for block, log, prior in priors:
# logprob += prior.logprior(hyper[block])
# if np.isinf(logprob):
# break
#
# # now compute the likelihood term. note that we'll have to take the log
# # of any logspace parameters before calling set_hyper.
# if not np.isinf(logprob):
# hyper[logged] = np.log(hyper[logged])
# gp.set_hyper(hyper)
# logprob += gp.loglikelihood()
#
# return logprob
#
# # create a big list of the hyperparameters so that we can just assign to
# # the components that are active. also get an initial sample x
# # corresponding only to the active parts of hyper0.
# hypers = np.tile(hyper0, (n, 1))
# x = hyper0.copy()[active]
#
# # do the sampling.
# for i in xrange(n):
# x = _slice_sample(logprob, x, rng=rng)
# hypers[i][active] = x
#
# # change the logspace components back into logspace.
# hypers[:, logged] = np.log(hypers[:, logged])
#
# # make sure the gp gets updated to the last sampled hyperparameter.
# gp.set_hyper(hypers[-1])
#
# if raw:
# return hypers
# else:
# return [gp.copy(h) for h in hypers]
#
# Path: pygp/utils/models.py
# def get_params(obj):
# """
# Helper function which translates the values returned by _params() into
# something more meaningful.
# """
# offset = 0
# for param in obj._params():
# key, size, log = param
# block = slice(offset, offset+size)
# offset += size
# yield key, block, log
which might include code, classes, or functions. Output only the next line. | hypers[:, block] = (np.log(prior.sample(n, rng=rng)) if log else |
Given the code snippet: <|code_start|>"""
Meta models which take care of hyperparameter marginalization whenever data is
added.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['SMC']
def _sample_prior(model, priors, n, rng=None):
rng = rstate(rng)
# unpack priors
# TODO -- Bobak: This snippet is copied from learning/sampling.py
# and should probably be put into a Prior base class.
priors = dict(priors)
active = np.ones(model.nhyper, dtype=bool)
logged = np.ones(model.nhyper, dtype=bool)
<|code_end|>
, generate the next line using the imports in this file:
import numpy as np
from scipy.misc import logsumexp
from mwhutils.random import rstate
from ..learning.sampling import sample
from ..utils.models import get_params
and context (functions, classes, or occasionally code) from other files:
# Path: pygp/learning/sampling.py
# def sample(gp, priors, n, raw=True, rng=None):
# rng = rstate(rng)
# priors = dict(priors)
# active = np.ones(gp.nhyper, dtype=bool)
# logged = np.ones(gp.nhyper, dtype=bool)
#
# for (key, block, log) in get_params(gp):
# inactive = (key in priors) and (priors[key] is None)
# logged[block] = log
# active[block] = not inactive
# if inactive:
# del priors[key]
# else:
# priors[key] = (block, log, priors[key])
#
# # priors is now just a list of the form (block, log, prior).
# priors = priors.values()
#
# # get the initial hyperparameters and transform into the non-log space.
# hyper0 = gp.get_hyper()
# hyper0[logged] = np.exp(hyper0[logged])
#
# def logprob(x):
# # copy the initial hyperparameters and then assign the "active"
# # parameters that come from x.
# hyper = hyper0.copy()
# hyper[active] = x
# logprob = 0
#
# # compute the prior probabilities. we do this first so that if there
# # are any infs they'll be caught in the least expensive computations
# # first.
# for block, log, prior in priors:
# logprob += prior.logprior(hyper[block])
# if np.isinf(logprob):
# break
#
# # now compute the likelihood term. note that we'll have to take the log
# # of any logspace parameters before calling set_hyper.
# if not np.isinf(logprob):
# hyper[logged] = np.log(hyper[logged])
# gp.set_hyper(hyper)
# logprob += gp.loglikelihood()
#
# return logprob
#
# # create a big list of the hyperparameters so that we can just assign to
# # the components that are active. also get an initial sample x
# # corresponding only to the active parts of hyper0.
# hypers = np.tile(hyper0, (n, 1))
# x = hyper0.copy()[active]
#
# # do the sampling.
# for i in xrange(n):
# x = _slice_sample(logprob, x, rng=rng)
# hypers[i][active] = x
#
# # change the logspace components back into logspace.
# hypers[:, logged] = np.log(hypers[:, logged])
#
# # make sure the gp gets updated to the last sampled hyperparameter.
# gp.set_hyper(hypers[-1])
#
# if raw:
# return hypers
# else:
# return [gp.copy(h) for h in hypers]
#
# Path: pygp/utils/models.py
# def get_params(obj):
# """
# Helper function which translates the values returned by _params() into
# something more meaningful.
# """
# offset = 0
# for param in obj._params():
# key, size, log = param
# block = slice(offset, offset+size)
# offset += size
# yield key, block, log
. Output only the next line. | for (key, block, log) in get_params(model): |
Here is a snippet: <|code_start|>"""
Meta models which take care of hyperparameter marginalization whenever data is
added.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['MCMC']
class MCMC(object):
def __init__(self, model, prior, n=100, burn=100, rng=None):
self._model = model.copy()
self._prior = prior
self._samples = []
self._n = n
self._burn = burn
self._rng = rstate(rng)
if self._model.ndata > 0:
if self._burn > 0:
<|code_end|>
. Write the next line using the current file imports:
import numpy as np
from mwhutils.random import rstate
from ..learning.sampling import sample
and context from other files:
# Path: pygp/learning/sampling.py
# def sample(gp, priors, n, raw=True, rng=None):
# rng = rstate(rng)
# priors = dict(priors)
# active = np.ones(gp.nhyper, dtype=bool)
# logged = np.ones(gp.nhyper, dtype=bool)
#
# for (key, block, log) in get_params(gp):
# inactive = (key in priors) and (priors[key] is None)
# logged[block] = log
# active[block] = not inactive
# if inactive:
# del priors[key]
# else:
# priors[key] = (block, log, priors[key])
#
# # priors is now just a list of the form (block, log, prior).
# priors = priors.values()
#
# # get the initial hyperparameters and transform into the non-log space.
# hyper0 = gp.get_hyper()
# hyper0[logged] = np.exp(hyper0[logged])
#
# def logprob(x):
# # copy the initial hyperparameters and then assign the "active"
# # parameters that come from x.
# hyper = hyper0.copy()
# hyper[active] = x
# logprob = 0
#
# # compute the prior probabilities. we do this first so that if there
# # are any infs they'll be caught in the least expensive computations
# # first.
# for block, log, prior in priors:
# logprob += prior.logprior(hyper[block])
# if np.isinf(logprob):
# break
#
# # now compute the likelihood term. note that we'll have to take the log
# # of any logspace parameters before calling set_hyper.
# if not np.isinf(logprob):
# hyper[logged] = np.log(hyper[logged])
# gp.set_hyper(hyper)
# logprob += gp.loglikelihood()
#
# return logprob
#
# # create a big list of the hyperparameters so that we can just assign to
# # the components that are active. also get an initial sample x
# # corresponding only to the active parts of hyper0.
# hypers = np.tile(hyper0, (n, 1))
# x = hyper0.copy()[active]
#
# # do the sampling.
# for i in xrange(n):
# x = _slice_sample(logprob, x, rng=rng)
# hypers[i][active] = x
#
# # change the logspace components back into logspace.
# hypers[:, logged] = np.log(hypers[:, logged])
#
# # make sure the gp gets updated to the last sampled hyperparameter.
# gp.set_hyper(hypers[-1])
#
# if raw:
# return hypers
# else:
# return [gp.copy(h) for h in hypers]
, which may include functions, classes, or code. Output only the next line. | sample(self._model, self._prior, self._burn, rng=self._rng) |
Given snippet: <|code_start|>"""
Interface for latent function inference in Gaussian process models. These
models will assume that the hyperparameters are fixed and any optimization
and/or sampling of these parameters will be left to a higher-level wrapper.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['GP']
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import numpy as np
import scipy.linalg as sla
from mwhutils.abc import abstractmethod, abstractclassmethod
from mwhutils.random import rstate
from ..utils.models import Parameterized
from ._fourier import FourierSample
and context:
# Path: pygp/utils/models.py
# class Parameterized(object):
# """
# Interface for objects that are parameterized by some set of
# hyperparameters.
# """
# __metaclass__ = ABCMeta
#
# @abstractmethod
# def _params(self):
# """
# Define the set of parameters for the model. This should return a list
# of tuples of the form `(name, size, islog)`. If only a 2-tuple is given
# then islog will be assumed to be `True`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def get_hyper(self):
# """Return a vector of model hyperparameters."""
# raise NotImplementedError
#
# @abstractmethod
# def set_hyper(self, hyper):
# """Set the model hyperparameters to the given vector."""
# raise NotImplementedError
#
# def copy(self, hyper=None):
# """
# Copy the model. If `hyper` is given use this vector to immediately set
# the copied model's hyperparameters.
# """
# model = copy.deepcopy(self)
# if hyper is not None:
# model.set_hyper(hyper)
# return model
#
# Path: pygp/inference/_fourier.py
# class FourierSample(object):
# """
# Approximate sample from a Gaussian process, approximated using random
# Fourier features.
# """
# def __init__(self, N, likelihood, kernel, mean, X, y, rng=None):
# # if given a seed or an instantiated RandomState make sure that we use
# # it here, but also within the sample_spectrum code.
# rng = rstate(rng)
#
# if not isinstance(likelihood, Gaussian):
# raise ValueError('Fourier samples only defined for Gaussian'
# 'likelihoods')
#
# # this randomizes the feature.
# W, alpha = kernel.sample_spectrum(N, rng)
#
# self._W = W
# self._b = rng.rand(N) * 2 * np.pi
# self._a = np.sqrt(2 * alpha / N)
# self._mean = mean
# self._theta = None
#
# if X is not None:
# # evaluate the features
# Z = np.dot(X, self._W.T) + self._b
# Phi = np.cos(Z) * self._a
#
# # get the components for regression
# A = np.dot(Phi.T, Phi) + likelihood.s2 * np.eye(Phi.shape[1])
# R = sla.cholesky(A)
# r = y - mean
# p = np.sqrt(likelihood.s2) * rng.randn(N)
#
# # FIXME: we can do a smarter update here when the number of points
# # is less than the number of features.
#
# self._theta = sla.cho_solve((R, False), np.dot(Phi.T, r))
# self._theta += sla.solve_triangular(R, p)
#
# else:
# self._theta = rng.randn(N)
#
# def get(self, X, grad=False):
# """
# Evaluate the function at a collection of points.
# """
# X = np.array(X, ndmin=2, copy=False)
# Z = np.dot(X, self._W.T) + self._b
#
# # evaluate the sample
# F = np.dot(self._a * np.cos(Z), self._theta) + self._mean
#
# if not grad:
# return F
#
# # evaluate the gradient
# dPhi = (-self._a * np.sin(Z))[:, :, None] * self._W[None]
# G = np.einsum('ijk,j', dPhi, self._theta)
#
# return F, G
#
# def __call__(self, x, grad=False):
# if grad:
# F, G = self.get(x, True)
# return F[0], G[0]
# else:
# return self.get(x)[0]
which might include code, classes, or functions. Output only the next line. | class GP(Parameterized): |
Using the snippet: <|code_start|> # if a seed or instantiated RandomState is given use that, otherwise
# use the global object.
rng = rstate(rng)
# add a tiny amount to the diagonal to make the cholesky of Sigma
# stable and then add this correlated noise onto mu to get the sample.
mu, Sigma = self._full_posterior(X)
Sigma += 1e-10 * np.eye(n)
f = mu[None] + np.dot(rng.normal(size=(m, n)), sla.cholesky(Sigma))
if not latent:
f = self._likelihood.sample(f.ravel(), rng).reshape(m, n)
return f.ravel() if flatten else f
def posterior(self, X, grad=False):
"""
Return the marginal posterior. This should return the mean and variance
of the given points, and if `grad == True` should return their
derivatives with respect to the input location as well (i.e. a
4-tuple).
"""
return self._marg_posterior(self._kernel.transform(X), grad)
def sample_fourier(self, N, rng=None):
"""
Approximately sample a function from the GP using a fourier-basis
expansion with N bases. See the documentation on `FourierSample` for
details on the returned function object.
"""
<|code_end|>
, determine the next line of code. You have imports:
import numpy as np
import scipy.linalg as sla
from mwhutils.abc import abstractmethod, abstractclassmethod
from mwhutils.random import rstate
from ..utils.models import Parameterized
from ._fourier import FourierSample
and context (class names, function names, or code) available:
# Path: pygp/utils/models.py
# class Parameterized(object):
# """
# Interface for objects that are parameterized by some set of
# hyperparameters.
# """
# __metaclass__ = ABCMeta
#
# @abstractmethod
# def _params(self):
# """
# Define the set of parameters for the model. This should return a list
# of tuples of the form `(name, size, islog)`. If only a 2-tuple is given
# then islog will be assumed to be `True`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def get_hyper(self):
# """Return a vector of model hyperparameters."""
# raise NotImplementedError
#
# @abstractmethod
# def set_hyper(self, hyper):
# """Set the model hyperparameters to the given vector."""
# raise NotImplementedError
#
# def copy(self, hyper=None):
# """
# Copy the model. If `hyper` is given use this vector to immediately set
# the copied model's hyperparameters.
# """
# model = copy.deepcopy(self)
# if hyper is not None:
# model.set_hyper(hyper)
# return model
#
# Path: pygp/inference/_fourier.py
# class FourierSample(object):
# """
# Approximate sample from a Gaussian process, approximated using random
# Fourier features.
# """
# def __init__(self, N, likelihood, kernel, mean, X, y, rng=None):
# # if given a seed or an instantiated RandomState make sure that we use
# # it here, but also within the sample_spectrum code.
# rng = rstate(rng)
#
# if not isinstance(likelihood, Gaussian):
# raise ValueError('Fourier samples only defined for Gaussian'
# 'likelihoods')
#
# # this randomizes the feature.
# W, alpha = kernel.sample_spectrum(N, rng)
#
# self._W = W
# self._b = rng.rand(N) * 2 * np.pi
# self._a = np.sqrt(2 * alpha / N)
# self._mean = mean
# self._theta = None
#
# if X is not None:
# # evaluate the features
# Z = np.dot(X, self._W.T) + self._b
# Phi = np.cos(Z) * self._a
#
# # get the components for regression
# A = np.dot(Phi.T, Phi) + likelihood.s2 * np.eye(Phi.shape[1])
# R = sla.cholesky(A)
# r = y - mean
# p = np.sqrt(likelihood.s2) * rng.randn(N)
#
# # FIXME: we can do a smarter update here when the number of points
# # is less than the number of features.
#
# self._theta = sla.cho_solve((R, False), np.dot(Phi.T, r))
# self._theta += sla.solve_triangular(R, p)
#
# else:
# self._theta = rng.randn(N)
#
# def get(self, X, grad=False):
# """
# Evaluate the function at a collection of points.
# """
# X = np.array(X, ndmin=2, copy=False)
# Z = np.dot(X, self._W.T) + self._b
#
# # evaluate the sample
# F = np.dot(self._a * np.cos(Z), self._theta) + self._mean
#
# if not grad:
# return F
#
# # evaluate the gradient
# dPhi = (-self._a * np.sin(Z))[:, :, None] * self._W[None]
# G = np.einsum('ijk,j', dPhi, self._theta)
#
# return F, G
#
# def __call__(self, x, grad=False):
# if grad:
# F, G = self.get(x, True)
# return F[0], G[0]
# else:
# return self.get(x)[0]
. Output only the next line. | return FourierSample(N, |
Next line prediction: <|code_start|>"""
Definition of the kernel interface.
"""
# future imports
from __future__ import division
from __future__ import absolute_import
from __future__ import print_function
# global imports
# local imports
# exported symbols
__all__ = ['Kernel']
### BASE KERNEL INTERFACE #####################################################
<|code_end|>
. Use current file imports:
(from abc import abstractmethod
from ..utils.models import Parameterized)
and context including class names, function names, or small code snippets from other files:
# Path: pygp/utils/models.py
# class Parameterized(object):
# """
# Interface for objects that are parameterized by some set of
# hyperparameters.
# """
# __metaclass__ = ABCMeta
#
# @abstractmethod
# def _params(self):
# """
# Define the set of parameters for the model. This should return a list
# of tuples of the form `(name, size, islog)`. If only a 2-tuple is given
# then islog will be assumed to be `True`.
# """
# raise NotImplementedError
#
# @abstractmethod
# def get_hyper(self):
# """Return a vector of model hyperparameters."""
# raise NotImplementedError
#
# @abstractmethod
# def set_hyper(self, hyper):
# """Set the model hyperparameters to the given vector."""
# raise NotImplementedError
#
# def copy(self, hyper=None):
# """
# Copy the model. If `hyper` is given use this vector to immediately set
# the copied model's hyperparameters.
# """
# model = copy.deepcopy(self)
# if hyper is not None:
# model.set_hyper(hyper)
# return model
. Output only the next line. | class Kernel(Parameterized): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.