Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Next line prediction: <|code_start|>
class ExposeError(RuntimeError):
def __init__(self, e):
super(RuntimeError, self).__init__(e.message)
self.e = e
class ExposeTimeout(ExposeError):
pass
class ExposeConnectionError(ExposeError):
pass
class Expose(object):
def __init__(self):
... | self.load() |
Given the following code snippet before the placeholder: <|code_start|>
return None, r.json()
def get_user(self, username):
url = self._api_url + '/api/users/%s' % username
r = self._requests.get(url, headers=self.get_headers('token'))
if r.status_code == 401:
return No... | url = self._api_url + '/api/replace' |
Continue the code snippet: <|code_start|> for service in self.list()]
return client.service(service_list, replace=True)
def add(self, box, announce=True):
project_name = box.project.name()
forwards = box.forwards()
if 'web' not in forwards:
return... | self._config.remove_option(project_name, box.name()) |
Predict the next line after this snippet: <|code_start|>
def enabled(self):
default = 'true'
if not config.get('aeris', 'url', default=None):
default = 'false'
return config.get('aeris', 'enabled', default=default) == 'true'
def announce(self):
client = expose_client... | (project_name, box.name(), port)) |
Using the snippet: <|code_start|>#!/usr/bin/env python
# we could import the flake8 package, but somehow their public API is just
# useless as their default reporter print directly to stdout with no way
# to catch what it is doing, just run the binary and work with it's output
python = ShCommand(os.path.join(aerisc... | if reports: |
Predict the next line after this snippet: <|code_start|>
click.echo(' line %s char %s: %s' % (
click.style(report['row'], fg='green'),
click.style(report['col'], fg='green'),
click.style(report['message'], fg='red'),
))
errors += 1
... | (id, name, test_file, ellipsis, res) = line.rstrip().split(' ') |
Given the code snippet: <|code_start|>def _run_ansible_lint(organization):
al_bin = os.path.join(aeriscloud_path, 'venv/bin/ansible-lint')
env = ansible_env(os.environ.copy())
if organization:
environment_files = glob.glob(get_env_path(organization) + '/*.yml')
else:
environment_files ... | click.echo('[%s]\n' % click.style('FAIL', fg='red')) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
# we could import the flake8 package, but somehow their public API is just
# useless as their default reporter print directly to stdout with no way
# to catch what it is doing, just run the binary and work with it's output
python = ShComman... | for report in reports: |
Given the code snippet: <|code_start|>#!/usr/bin/env python
# we could import the flake8 package, but somehow their public API is just
# useless as their default reporter print directly to stdout with no way
# to catch what it is doing, just run the binary and work with it's output
python = ShCommand(os.path.join(a... | reports = [dict(zip(keys, line.strip().split(':'))) |
Predict the next line after this snippet: <|code_start|>
click.echo('')
else:
click.echo('[%s]' % click.style('OK', fg='green'))
return errors
def _run_nosetests():
click.echo('Running unit tests ... ', nl=False)
nose_bin = os.path.join(aeriscloud_path, 'venv/bin/nosetests')
erro... | line = ' '.join([ |
Based on the snippet: <|code_start|> last_file = None
if reports:
click.echo('[%s]\n' % click.style('FAIL', fg='red'))
for report in reports:
report_file = report['file'][len(module_path()) + 1:]
if report_file != last_file:
click.secho(' Errors in file: ... | try: |
Based on the snippet: <|code_start|>
def services(organization, env='production'):
service_list = {}
if not organization:
return service_list
service_file = os.path.join(organization_path,
organization,
'env_%s.yml' % env)
<|code_e... | with open(service_file) as f: |
Based on the snippet: <|code_start|>
def _search_variables(search_path, variable):
files = set()
cmd = "grep -rI '%s = ' %s" % (variable, quote(search_path))
try:
grep = subprocess32.check_output(cmd, shell=True)
except subprocess32.CalledProcessError:
return []
for line in grep.sp... | if variable in line.decode('utf-8-sig'): |
Predict the next line after this snippet: <|code_start|>
return None, None
def _search_variables(search_path, variable):
files = set()
cmd = "grep -rI '%s = ' %s" % (variable, quote(search_path))
try:
grep = subprocess32.check_output(cmd, shell=True)
except subprocess32.CalledProcessError... | with open(filename) as input: |
Given the code snippet: <|code_start|>def _get_url(server, box):
if not box.project.initialized():
error("This project doesn't contain a %s file." % (
bold(".aeriscloud.yml")))
return None
if server == 'local':
return _get_local_url(box)
elif server == 'aeris.cd':
... | try: |
Predict the next line after this snippet: <|code_start|>from __future__ import print_function
def _get_local_url(box):
forwards = box.forwards()
if 'web' not in forwards:
raise RuntimeError('Box has no exposed web app')
port = forwards['web']['host_port']
return "http://%s:%s" % (local_ip(... | def _get_url(server, box): |
Given the code snippet: <|code_start|> if 'Assets' in files and 'ProjectSettings' in files:
return os.path.join(os.getcwd(), 'Assets'), 'Unity'
return None, None
def _search_variables(search_path, variable):
files = set()
cmd = "grep -rI '%s = ' %s" % (variable, quote(search_path))
try:
... | ) |
Predict the next line after this snippet: <|code_start|>def _get_local_url(box):
forwards = box.forwards()
if 'web' not in forwards:
raise RuntimeError('Box has no exposed web app')
port = forwards['web']['host_port']
return "http://%s:%s" % (local_ip(), port)
def _get_aeris_url(box):
re... | def _get_search_path(): |
Next line prediction: <|code_start|> fatal("Unsupported platform.")
unity_path = os.path.join(unity_path, "Unity.app/Contents/MacOS/Unity")
command = "{unity_path} -quit -batchmode " \
"-executeMethod {method} " \
"-logFile ./build.log " \
"-projectPath {curren... | "-exportProvisioningProfile \"wildcard_Development\"" |
Here is a snippet: <|code_start|>from __future__ import print_function
def _get_local_url(box):
forwards = box.forwards()
if 'web' not in forwards:
raise RuntimeError('Box has no exposed web app')
port = forwards['web']['host_port']
return "http://%s:%s" % (local_ip(), port)
def _get_aer... | if not box.project.initialized(): |
Here is a snippet: <|code_start|>
def _build_unity(platform, unity_path):
methods = {
'ios': 'BuildEditorScript.PerformiOSBuild',
'android': 'BuildEditorScript.PerformAndroidBuild',
'osx': 'BuildEditorScript.PerformMacOSXBuild'
}
if platform not in methods:
fatal("Unsupported... | "-archivePath Unity-iPhone.xcarchive" |
Here is a snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.argument('command', nargs=-1)
@standard_options()
<|code_end|>
. Write the next line using the current file imports:
import click
import sys
from aeriscloud.cli.aeris.sync import sync
from aeriscloud.cli.helpers import standa... | def cli(box, command): |
Based on the snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.argument('command', nargs=-1)
@standard_options()
<|code_end|>
, predict the immediate next line with the help of imports:
import click
import sys
from aeriscloud.cli.aeris.sync import sync
from aeriscloud.cli.helpers impo... | def cli(box, command): |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.argument('command', nargs=-1)
@standard_options()
<|code_end|>
. Use current file imports:
import click
import sys
from aeriscloud.cli.aeris.sync import sync
from aeriscloud.cli.helpers import standard_options, Comman... | def cli(box, command): |
Using the snippet: <|code_start|>#!/usr/bin/env python
def _display_option(section, option, value):
if sys.stdout.isatty():
click.echo('%s.%s = %s' % (
click.style(section, fg='blue'),
<|code_end|>
, determine the next line of code. You have imports:
import click
import sys
from aeriscloud.... | click.style(option, fg='blue'), |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
def _display_option(section, option, value):
if sys.stdout.isatty():
click.echo('%s.%s = %s' % (
click.style(section, fg='blue'),
click.style(option, fg='blue'),
click.style(value, fg='green')
))
... | def _unset_option(option): |
Given snippet: <|code_start|>#!/usr/bin/env python
def _parse_provision(ctx, param, value):
if not value:
return []
provisioners = value.split(',')
for provisioner in provisioners:
if provisioner not in ['ansible', 'shell']:
raise click.BadParameter('provisioner must be on o... | def cli(box, provision_with): |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python
def _parse_provision(ctx, param, value):
if not value:
return []
provisioners = value.split(',')
for provisioner in provisioners:
if provisioner not in ['ansible', 'shell']:
raise click.BadParamete... | @click.option('--provision-with', default=None, callback=_parse_provision) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
def _parse_provision(ctx, param, value):
if not value:
return []
provisioners = value.split(',')
for provisioner in provisioners:
if provisioner not in ['ansible', 'shell']:
raise click.BadParameter('provisioner ... | @click.option('--provision-with', default=None, callback=_parse_provision) |
Based on the snippet: <|code_start|>#!/usr/bin/env python
def _parse_provision(ctx, param, value):
if not value:
return []
provisioners = value.split(',')
for provisioner in provisioners:
if provisioner not in ['ansible', 'shell']:
raise click.BadParameter('provisioner must ... | 'shell') |
Based on the snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.option('--force', is_flag=True,
help='Connect anyway if project server is not set')
<|code_end|>
, predict the immediate next line with the help of imports:
import click
import sys
from aeriscloud.cli.helpers... | @click.argument('command', nargs=-1) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.option('--force', is_flag=True,
help='Connect anyway if project server is not set')
<|code_end|>
. Use current file imports:
import click
import sys
from aeriscloud.cli.helpers import standard_options, C... | @click.argument('command', nargs=-1) |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.option('--force', is_flag=True,
help='Connect anyway if project server is not set')
<|code_end|>
, predict the next line using imports from the current file:
import click
im... | @click.argument('command', nargs=-1) |
Here is a snippet: <|code_start|>
class Github:
def __init__(self, _ask_credentials=None, _ask_2fa=None):
self.last_error = None
self._ask_credentials = _ask_credentials
self._ask_2fa = _ask_2fa
self.gh = GitHub(token=self._get_authorization_token())
self.user = self.gh.u... | 'ask for credentials') |
Given the following code snippet before the placeholder: <|code_start|>
ansible_path = os.path.join(aeriscloud_path, 'ansible')
plugin_path = os.path.join(ansible_path, 'plugins')
job_path = os.path.join(ansible_path, 'jobs')
inventory_path = os.path.join(data_dir(), 'inventory')
organization_path = os.path.join(da... | constants.DEFAULT_CALLBACK_PLUGIN_PATH |
Predict the next line for this snippet: <|code_start|>from __future__ import print_function, absolute_import
ansible_path = os.path.join(aeriscloud_path, 'ansible')
plugin_path = os.path.join(ansible_path, 'plugins')
job_path = os.path.join(ansible_path, 'jobs')
inventory_path = os.path.join(data_dir(), 'inventory... | env['PATH'] |
Given the following code snippet before the placeholder: <|code_start|>ansible_path = os.path.join(aeriscloud_path, 'ansible')
plugin_path = os.path.join(ansible_path, 'plugins')
job_path = os.path.join(ansible_path, 'jobs')
inventory_path = os.path.join(data_dir(), 'inventory')
organization_path = os.path.join(data_di... | ) |
Next line prediction: <|code_start|>from __future__ import print_function, absolute_import
ansible_path = os.path.join(aeriscloud_path, 'ansible')
plugin_path = os.path.join(ansible_path, 'plugins')
job_path = os.path.join(ansible_path, 'jobs')
inventory_path = os.path.join(data_dir(), 'inventory')
organization_pa... | env['ANSIBLE_ACTION_PLUGINS'] = ':'.join( |
Continue the code snippet: <|code_start|>
ansible_path = os.path.join(aeriscloud_path, 'ansible')
plugin_path = os.path.join(ansible_path, 'plugins')
job_path = os.path.join(ansible_path, 'jobs')
inventory_path = os.path.join(data_dir(), 'inventory')
organization_path = os.path.join(data_dir(), 'organizations')
log... | ) |
Given snippet: <|code_start|> ])
# disable buffering for ansible
env['PYTHONUNBUFFERED'] = '1'
env['ANSIBLE_BASE_PATH'] = ansible_path
env['ANSIBLE_ACTION_PLUGINS'] = ':'.join(
[os.path.join(plugin_path, 'actions')] +
constants.DEFAULT_ACTION_PLUGIN_PATH
)
env['ANSIBLE_CALLB... | env['ANSIBLE_NOCOWS'] = '1' |
Given the code snippet: <|code_start|>#!/usr/bin/env python
status_table = CLITable('project', 'name', 'image', 'status')
def _status_sort(status):
return '%s-%s' % (status['project'], status['name'])
@click.command(cls=Command)
@click.option('--show-all', is_flag=True, default=False,
<|code_end|>
, generate... | help='Show boxes that are not created in virtualbox') |
Given the code snippet: <|code_start|>#!/usr/bin/env python
status_table = CLITable('project', 'name', 'image', 'status')
def _status_sort(status):
return '%s-%s' % (status['project'], status['name'])
@click.command(cls=Command)
@click.option('--show-all', is_flag=True, default=False,
help='Sho... | def cli(boxes, show_all): |
Given the following code snippet before the placeholder: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.option('-q', '--quiet', is_flag=True)
@standard_options()
<|code_end|>
, predict the next line using imports from the current file:
import arrow
import click
import re
import sys
from aer... | def cli(box, quiet): |
Predict the next line after this snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.option('-q', '--quiet', is_flag=True)
@standard_options()
<|code_end|>
using the current file's imports:
import arrow
import click
import re
import sys
from aeriscloud.cli.helpers import standard_optio... | def cli(box, quiet): |
Given snippet: <|code_start|>#!/usr/bin/env python
@click.command(cls=Command)
@click.option('-q', '--quiet', is_flag=True)
@standard_options()
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import arrow
import click
import re
import sys
from aeriscloud.cli.helpers import stand... | def cli(box, quiet): |
Given the code snippet: <|code_start|>#!/usr/bin/env python
from __future__ import print_function
class BoxCommandAutoRestart(AutoRestartTrick):
def __init__(self, box, command, **kwargs):
AutoRestartTrick.__init__(self, [], **kwargs)
self.box = box
<|code_end|>
, generate the next line using t... | self.command = command |
Using the snippet: <|code_start|>#!/usr/bin/env python
from __future__ import print_function
class BoxCommandAutoRestart(AutoRestartTrick):
def __init__(self, box, command, **kwargs):
AutoRestartTrick.__init__(self, [], **kwargs)
<|code_end|>
, determine the next line of code. You have imports:
import... | self.box = box |
Given snippet: <|code_start|>#!/usr/bin/env python
from __future__ import print_function
class BoxCommandAutoRestart(AutoRestartTrick):
def __init__(self, box, command, **kwargs):
AutoRestartTrick.__init__(self, [], **kwargs)
self.box = box
<|code_end|>
, continue by predicting the next line. C... | self.command = command |
Using the snippet: <|code_start|>#!/usr/bin/env python
# Import the CLI system
cmd_help = {
'aeris': 'Manage your local development environments',
'cloud': 'Manage your remote servers and datacenters'
<|code_end|>
, determine the next line of code. You have imports:
import os
import sys
from .helpers import ... | } |
Here is a snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
click.secho('warning: aeris.cd is not enabled', fg='yellow')
<|code_end|>
. Write the next line using the current file imports:
i... | sys.exit(1) |
Using the snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
<|code_end|>
, determine the next line of code. You have imports:
import click
import sys
from functools import update_wrapper
from json impo... | click.secho('warning: aeris.cd is not enabled', fg='yellow') |
Here is a snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
click.secho('warning: aeris.cd is not enabled', fg='yellow')
sys.exit(1)
try:
<|code_end|>
. Write the next li... | return ctx.invoke(func, *args, **kwargs) |
Using the snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
click.secho('warning: aeris.cd is not enabled', fg='yellow')
sys.exit(1)
try:
<|code_end|>
, determine the nex... | return ctx.invoke(func, *args, **kwargs) |
Based on the snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
click.secho('warning: aeris.cd is not enabled', fg='yellow')
<|code_end|>
, predict the immediate next line with the help of im... | sys.exit(1) |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
click.secho('warning: aeris.cd is not enabled', fg='yellow')
sys.exit(1)
<|code_end|>
. Use current file impor... | try: |
Continue the code snippet: <|code_start|>#!/usr/bin/env python
def check_expose(func):
@click.pass_context
def _deco(ctx, *args, **kwargs):
if not expose.enabled():
click.secho('warning: aeris.cd is not enabled', fg='yellow')
sys.exit(1)
try:
return ctx.i... | def cli(): |
Given snippet: <|code_start|>def sync(box, direction):
if not box.project.rsync_enabled():
return None
if direction == 'down':
click.secho('Syncing files down from the box...',
fg='cyan', bold=True)
if box.rsync_down():
click.secho('Sync down done!', fg='... | type=click.Choice(['up', 'down'])) |
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python
def sync(box, direction):
if not box.project.rsync_enabled():
return None
if direction == 'down':
click.secho('Syncing files down from the box...',
fg='cyan', bold=True)
if box.rsync_down... | click.secho('Sync up failed!', fg='red', bold=True) |
Given snippet: <|code_start|>
# python3 compat
if sys.version_info[0] < 3:
else:
@memoized
def module_path():
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import sys
import os
import ConfigParser as configparser
import configparser
from appdirs import user_config_dir,... | return os.path.dirname(__file__) |
Given snippet: <|code_start|> 'invoicing_customer_name': u'Matti Mallikas',
'invoicing_customer_name_extension': u'Masa',
'invoicing_customer_address_line': u'Pajukuja 1',
'invoicing_customer_additional_address_line': None,
'invoicing_customer_post_number': u'5... | 'discount_percentage': decimal.Decimal('0'), |
Using the snippet: <|code_start|>
class TestSalesInvoiceService(object):
def test_get(self, netvisor, responses):
responses.add(
method='GET',
url='http://koulutus.netvisor.fi/GetSalesInvoice.nv?NetvisorKey=5',
body=get_response_content('GetSalesInvoice.xml'),
... | 'invoicing_customer_address_line': u'Pajukuja 1', |
Predict the next line after this snippet: <|code_start|> 'date': date(2008, 12, 12),
'amount': decimal.Decimal('244.00'),
'status': 'unsent',
'invoicing_customer_identifier': u'1',
'payment_term_net_days': 14,
'payment_term_cash_discount_days': 5,
... | {'invoice_lines': [{'foo': 'bar'}]}, |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
class TestCompanyService(object):
def test_get(self, netvisor, responses):
responses.add(
method='GET',
url=(
'http://koulutus.netvisor.fi/GetCompanyInformation.nv?'
'Orga... | 'name': u'General Motors Finland', |
Predict the next line after this snippet: <|code_start|> 'date': date(2000, 1, 1),
'number': 13,
'description': 'Invoice 14',
'class': 'PI Purchase Invoice',
'linked_source': {'type': 'purchaseinvoice', 'key': 15},
'uri': 'ht... | 'linked_source': {'type': 'salesinvoice', 'key': 28}, |
Predict the next line for this snippet: <|code_start|>
class TestProductService(object):
def test_get(self, netvisor, responses):
responses.add(
method='GET',
url='http://koulutus.netvisor.fi/GetProduct.nv?id=5',
body=get_response_content('GetProduct.xml'),
... | 'is_active': True, |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
class TestProductService(object):
def test_get(self, netvisor, responses):
responses.add(
method='GET',
url='http://koulutus.netvisor.fi/GetProduct.nv?id=5',
body=get_response_content('GetProduct.xml'),
... | }, |
Given snippet: <|code_start|> ])
def test_create_with_unknown_fields(self, netvisor, responses, data):
with pytest.raises(ValidationError):
netvisor.customers.create(data)
def test_update(self, netvisor, responses):
responses.add(
method='POST',
url='http:... | 'is_active': True, |
Given snippet: <|code_start|> 'name': u'Matti Meikäläinen',
'name_extension': u'Toimitusjohtaja',
'street_address': u'c/o Yritys Oy',
'additional_address_line': u'Pajukuja 1',
'city': u'Lappeenranta',
'post_number': u'53100',... | }, |
Using the snippet: <|code_start|> url='http://koulutus.netvisor.fi/CustomerList.nv',
body=get_response_content('CustomerList.xml'),
content_type='text/html; charset=utf-8',
match_querystring=True
)
customers = netvisor.customers.list()
assert custom... | assert customers == [] |
Based on the snippet: <|code_start|>
BoxSize = 100.
Q = numpy.zeros((100, 3))
@MPITest([1, 4])
def test_create(comm):
matter = Matter(cosmo, BoxSize, Q, comm)
cdm = CDM(cosmo, BoxSize, Q, comm)
cdm.a['S'] = 1.0
cdm.a['P'] = 1.0
baryon = Baryon(cosmo, BoxSize, Q, comm)
baryon.a['S'] = 1.0
... | state.a['P'] = 1.0 |
Given the code snippet: <|code_start|>
BoxSize = 100.
Q = numpy.zeros((100, 3))
@MPITest([1, 4])
def test_create(comm):
matter = Matter(cosmo, BoxSize, Q, comm)
cdm = CDM(cosmo, BoxSize, Q, comm)
cdm.a['S'] = 1.0
cdm.a['P'] = 1.0
baryon = Baryon(cosmo, BoxSize, Q, comm)
baryon.a['S'] = 1.0
<... | baryon.a['P'] = 1.0 |
Using the snippet: <|code_start|>
BoxSize = 100.
Q = numpy.zeros((100, 3))
@MPITest([1, 4])
<|code_end|>
, determine the next line of code. You have imports:
from fastpm.state import StateVector, Matter, Baryon, CDM, NCDM
from runtests.mpi import MPITest
from nbodykit.cosmology import Planck15 as cosmo
import numpy ... | def test_create(comm): |
Next line prediction: <|code_start|>solver_ncdm = SolverNCDM(pm, Planck15, B=2)
wn = solver.whitenoise(400)
dlin = solver.linear(wn, EHPower(Planck15, 0))
lpt = solver.lpt(dlin, Q, stages[0])
#lpt.S = numpy.float32(lpt.S)
def monitor(action, ai, ac, af, state, event):
if pm.comm.rank == 0:
print(state.a['... | fig = Figure() |
Based on the snippet: <|code_start|>
stages = numpy.linspace(0.1, 1.0, 20, endpoint=True)
solver = Solver(pm, Planck15, B=2)
solver_ncdm = SolverNCDM(pm, Planck15, B=2)
wn = solver.whitenoise(400)
dlin = solver.linear(wn, EHPower(Planck15, 0))
lpt = solver.lpt(dlin, Q, stages[0])
#lpt.S = numpy.float32(lpt.S)
def mo... | r2.save('NCDM/ncdm-power.json') |
Given snippet: <|code_start|>
class Step(object):
pass
class Solver(object):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import numpy
from pmesh.pm import ParticleMesh
from .background import PerturbationGrowth
from nbodykit.cosmology import Cosmology
from .state import S... | def __init__(self, pm, cosmology, B=1): |
Predict the next line after this snippet: <|code_start|>
pm = ParticleMesh(BoxSize=32., Nmesh=[16, 16, 16])
def test_solver():
Plin = LinearPower(Planck15, redshift=0, transfer='EisensteinHu')
solver = Solver(pm, Planck15, B=2)
Q = pm.generate_uniform_particle_grid(shift=0)
wn = solver.whitenoise(1234... | state = solver.lpt(dlin, Q, a=0.3, order=2) |
Using the snippet: <|code_start|>stages = numpy.linspace(0.1, 1.0, 10, endpoint=True)
solver = Solver(pm, Planck15, B=2)
wn = solver.whitenoise(400)
dlin = solver.linear(wn, EHPower(Planck15, 0))
state = solver.lpt(dlin, Q, stages[0])
X = numpy.fromfile('pos')
V = numpy.fromfile('vel')
Q = X - V* aafqwe
start = pm... | fof = FOF(cat, linking_length=0.2, nmin=12) |
Predict the next line after this snippet: <|code_start|>
pm = ParticleMesh(BoxSize=128, Nmesh=[128, 128, 128])
Q = pm.generate_uniform_particle_grid()
stages = numpy.linspace(0.1, 1.0, 10, endpoint=True)
solver = Solver(pm, Planck15, B=2)
wn = solver.whitenoise(400)
dlin = solver.linear(wn, EHPower(Planck15, 0))
st... | X = [] |
Given the code snippet: <|code_start|>
@MPITest([1, 4])
def test_ncdm(comm):
pm = ParticleMesh(BoxSize=512., Nmesh=[8, 8, 8], comm=comm)
<|code_end|>
, generate the next line using the imports in this file:
from runtests.mpi import MPITest
from fastpm.core import leapfrog, autostages
from fastpm.background impo... | Plin = LinearPower(Planck15, redshift=0, transfer='EisensteinHu') |
Given snippet: <|code_start|>class FastPMCatalogSource(CatalogSource):
def __repr__(self):
return "FastPMSimulation()" %self.attrs
def __init__(self, linear, astart=0.1, aend=1.0, boost=2, Nsteps=5, cosmo=None):
self.comm = linear.comm
if cosmo is None:
cosmo = linear.Plin.... | state = solver.lpt(dlin, Q, a=astart, order=2) |
Based on the snippet: <|code_start|>
pm = ParticleMesh(BoxSize=128., Nmesh=[8, 8, 8])
def test_glass():
X = generate_glass_particle_grid(pm, 123)
<|code_end|>
, predict the immediate next line with the help of imports:
from fastpm.glass import generate_glass_particle_grid, ParticleMesh
from numpy.testing import... | assert pm.comm.allreduce(len(X)) == pm.Nmesh.prod() |
Based on the snippet: <|code_start|>
pm = ParticleMesh(BoxSize=128., Nmesh=[8, 8, 8])
def test_glass():
X = generate_glass_particle_grid(pm, 123)
<|code_end|>
, predict the immediate next line with the help of imports:
from fastpm.glass import generate_glass_particle_grid, ParticleMesh
from numpy.testing import... | assert pm.comm.allreduce(len(X)) == pm.Nmesh.prod() |
Using the snippet: <|code_start|>
# compute the force first as we didn't save it
yield ('F', stages[-1], stages[-1], stages[-1])
for action, ai, ac, af in list(leapfrog(stages))[::-1]:
if action == 'D':
yield action, af, ac, ai
for action, af, ac, ai in stack:
... | assert_allclose(lpt.X, reverse.X) |
Based on the snippet: <|code_start|># This script tests if full reversability like
# JANUS is achieved by FastPM, without
# using int64 fixed point.
#
# JANUS: https://arxiv.org/pdf/1704.07715v1.pdf
#
# We do not need the high precision int64 representable
# because we only use very few steps (I think)
# Using float32 ... | print(state.a['S'], state.a['P'], state.a['F'], state.S[0], state.P[0], action, ai, ac, af) |
Next line prediction: <|code_start|>
class StateVector(object):
def __init__(self, solver, Q):
self.solver = solver
self.pm = solver.pm
self.Q = Q
self.csize = solver.pm.comm.allreduce(len(self.Q))
self.dtype = self.Q.dtype
self.cosmology = solver.cosmology
... | self.a = dict(S=None, P=None, F=None) |
Based on the snippet: <|code_start|># This file is released under the GNU GPL, version 3 or a later revision.
# For further details see the COPYING file
class TestExternalAddressbookGetContacts(unittest.TestCase):
"""Some test cases for
alot.addressbook.external.ExternalAddressbook.get_contacts"""
rege... | abook.get_contacts() |
Given the following code snippet before the placeholder: <|code_start|>
address = None
"""this accounts main email address"""
aliases = []
"""list of alternative addresses"""
alias_regexp = ""
"""regex matching alternative addresses"""
realname = None
"""real name used to format from-hea... | message_id_domain=None, |
Given the following code snippet before the placeholder: <|code_start|> self.alias_regexp = alias_regexp
self.realname = realname
self.encrypt_to_self = encrypt_to_self
self.gpg_key = gpg_key
self.signature = signature
self.signature_filename = signature_filename
s... | self._alias_regexp = re.compile( |
Next line prediction: <|code_start|>
class Spider(CrawlSpider):
# Public
name = 'pfizer'
allowed_domains = ['pfizer.com']
def __init__(self, conf=None, conn=None):
# Save conf/conn
self.conf = conf
self.conn = conn
# Make urls
self.start_urls = [
... | super(Spider, self).__init__() |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
<|code_end|>
, generate the next line using the imports in this file:
from scrapy.crawler import CrawlerProcess
from .spider import Spider
and cont... | from __future__ import unicode_literals |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# Module API
def collect(conf, conn):
process = CrawlerProcess(conf['SCRAPY_SETTINGS'])
process.cra... | process.start() |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# Module API
def parse_record(res):
# Init data
data = {}
# Description
<|code_end|>
, gen... | key = 'study_type' |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
<|code_end|>
. Use current file imports:
(from collectors.gsk.parser import parse_record)
and context including class names, function names, or small... | from __future__ import unicode_literals |
Given snippet: <|code_start|>
# Module API
class Spider(CrawlSpider):
# Public
name = 'takeda'
allowed_domains = ['takedaclinicaltrials.com']
def __init__(self, conf=None, conn=None):
# Save conf/conn
self.conf = conf
self.conn = conn
# Make urls
self.star... | )), |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class TestHRACollector(object):
def test_make_request_url(self):
<|code_end|>
using... | date_from = datetime.date(2015, 1, 1) |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
class TestHRACollector(object):
def test_make_request_url(self):
date_from =... | deferred_item_stub |
Here is a snippet: <|code_start|> day=medline['DateCompleted']['Day']['#text'])
if 'DateRevised' in medline:
data['date_revised'] = '{year}-{month}-{day}'.format(
year=medline['DateRevised']['Year']['#text'],
month=medline['DateRevised']['Month']['#text'],
day=... | if 'Abstract' in article: |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
<|code_end|>
. Write the next line using the current file imports:
from collectors.takeda.parser import parse_... | class TestTakedaParser(object): |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
<|code_end|>
. Write the next line using the current file imports:
import io
import logging
import zipfile
impor... | logger = logging.getLogger(__name__) |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
# Tests
def test_make_start_urls():
result = _make_start_urls(
'https:/... | '2015-01-01', '2015-01-02') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.