Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Given the following code snippet before the placeholder: <|code_start|> def test_create(): db = DB() user = create_user() title = random_string(10) blog_id = BlogAction.create( db, owner_id=user.id, title=title, ) found_blog = BlogLoader.find_by_id(db, blog_id) <|cod...
assert found_blog.id == blog_id
Based on the snippet: <|code_start|> def test_create(): db = DB() user = create_user() title = random_string(10) blog_id = BlogAction.create( db, owner_id=user.id, title=title, <|code_end|> , predict the immediate next line with the help of imports: import tests.hakoblog # ...
)
Using the snippet: <|code_start|> def test_create(): db = DB() user = create_user() title = random_string(10) blog_id = BlogAction.create( db, owner_id=user.id, title=title, ) found_blog = BlogLoader.find_by_id(db, blog_id) assert found_blog.id == blog_id <|code_...
assert found_blog.owner_id == user.id
Given the following code snippet before the placeholder: <|code_start|> def test_create(): db = DB() user = create_user() title = random_string(10) blog_id = BlogAction.create( db, <|code_end|> , predict the next line using imports from the current file: import tests.hakoblog # noqa: F401 ...
owner_id=user.id,
Using the snippet: <|code_start|> def test_create(): db = DB() user = create_user() title = random_string(10) blog_id = BlogAction.create( db, owner_id=user.id, title=title, ) found_blog = BlogLoader.find_by_id(db, blog_id) assert found_blog.id == blog_id <|code_...
assert found_blog.owner_id == user.id
Predict the next line after this snippet: <|code_start|> def test_create(): db = DB() user = create_user() title = random_string(10) blog_id = BlogAction.create( db, owner_id=user.id, <|code_end|> using the current file's imports: import tests.hakoblog # noqa: F401 from hakoblog.d...
title=title,
Predict the next line after this snippet: <|code_start|> def test_security_header(): with global_user(random_string(5)): res = web_client().get('/') assert res.status == '200 OK' assert res.headers['X-Frame-Options'] == 'DENY' assert res.headers['X-Content-Type-Options'] == 'nosnif...
assert res.headers['Content-Security-Policy'] == "default-src 'self'"
Based on the snippet: <|code_start|> def test_security_header(): with global_user(random_string(5)): res = web_client().get('/') assert res.status == '200 OK' assert res.headers['X-Frame-Options'] == 'DENY' <|code_end|> , predict the immediate next line with the help of imports: import te...
assert res.headers['X-Content-Type-Options'] == 'nosniff'
Continue the code snippet: <|code_start|> def test_security_header(): with global_user(random_string(5)): res = web_client().get('/') assert res.status == '200 OK' assert res.headers['X-Frame-Options'] == 'DENY' <|code_end|> . Use current file imports: import tests.hakoblog # noqa: F401 ...
assert res.headers['X-Content-Type-Options'] == 'nosniff'
Using the snippet: <|code_start|> class DB: def __init__(self): self.conn = MySQLdb.connect( db=CONFIG.DATABASE, host=CONFIG.DATABASE_HOST, user=CONFIG.DATABASE_USER, password=CONFIG.DATABASE_PASS, <|code_end|> , determine the next line of code. You have impo...
cursorclass=MySQLdb.cursors.DictCursor,
Given snippet: <|code_start|> @web.route("/entry/<int:entry_id>") def entry(entry_id): blog = BlogAction.ensure_global_blog_created(get_db()) entry = EntryLoader.find_by_id(get_db(), entry_id) if entry is None: abort(404) if entry.blog_id != blog.id: abort(403) return render_templ...
if int(blog_id) != blog.id:
Predict the next line for this snippet: <|code_start|> web = Flask(__name__) web.config.from_object(CONFIG) def get_db(): db = getattr(flask_g, "_database", None) if db is None: db = flask_g._database = DB() return db @web.teardown_appcontext def close_connection(exception): db = getattr(f...
db.close()
Given snippet: <|code_start|> @web.route("/entry/<int:entry_id>") def entry(entry_id): blog = BlogAction.ensure_global_blog_created(get_db()) entry = EntryLoader.find_by_id(get_db(), entry_id) if entry is None: abort(404) if entry.blog_id != blog.id: abort(403) return render_templa...
abort(400)
Given snippet: <|code_start|> web = Flask(__name__) web.config.from_object(CONFIG) def get_db(): db = getattr(flask_g, "_database", None) if db is None: db = flask_g._database = DB() return db @web.teardown_appcontext def close_connection(exception): db = getattr(flask_g, "_database", None...
response.headers.add("X-XSS-Protection", "1;mode=block")
Here is a snippet: <|code_start|> web = Flask(__name__) web.config.from_object(CONFIG) def get_db(): db = getattr(flask_g, "_database", None) if db is None: db = flask_g._database = DB() return db @web.teardown_appcontext def close_connection(exception): db = getattr(flask_g, "_database", ...
response.headers.add("X-Content-Type-Options", "nosniff")
Predict the next line for this snippet: <|code_start|> with global_user(random_string(5)): res = web_client().get('/-/post') assert res.status == '200 OK' def test_post_create_entry(): db = DB() with global_user(random_string(5)), web_client() as wc: blog = BlogAction.ensure_global...
res2 = wc.post('/-/post', data=dict(
Given the code snippet: <|code_start|> def test_post_create_entry(): db = DB() with global_user(random_string(5)), web_client() as wc: blog = BlogAction.ensure_global_blog_created(db) res = wc.post('/-/post', data=dict( title='はろー', body='こんにちは', blog_id=blo...
))
Given the code snippet: <|code_start|> def test_post_show_form(): with global_user(random_string(5)): res = web_client().get('/-/post') assert res.status == '200 OK' def test_post_create_entry(): db = DB() with global_user(random_string(5)), web_client() as wc: blog = BlogAction.e...
assert res1.status == '400 BAD REQUEST'
Given the code snippet: <|code_start|> def test_post_show_form(): with global_user(random_string(5)): res = web_client().get('/-/post') <|code_end|> , generate the next line using the imports in this file: import tests.hakoblog # noqa: F401 from flask import url_for from hakoblog.db import DB from hak...
assert res.status == '200 OK'
Predict the next line for this snippet: <|code_start|> def test_post_create_entry(): db = DB() with global_user(random_string(5)), web_client() as wc: blog = BlogAction.ensure_global_blog_created(db) res = wc.post('/-/post', data=dict( title='はろー', body='こんにちは', ...
))
Predict the next line after this snippet: <|code_start|> res = web_client().get('/-/post') assert res.status == '200 OK' def test_post_create_entry(): db = DB() with global_user(random_string(5)), web_client() as wc: blog = BlogAction.ensure_global_blog_created(db) res = wc.po...
title='はろー',
Predict the next line for this snippet: <|code_start|> "-q", "--quiet", action="store_true", dest="quiet", default=False ) parser.add_argument("--every", nargs="*", dest="every", default=[]) if not command: parser.add_argument("command", nargs="*") at_or_in = parse...
else:
Predict the next line after this snippet: <|code_start|> class NoExitParser(argparse.ArgumentParser): def error(self, message): raise BadArgument() @dataclasses.dataclass() class Schedule: start: datetime command: str recur: Optional[timedelta] = None quiet: bool = False def to_tuple...
parser = NoExitParser(description="Scheduler event parsing", add_help=False)
Using the snippet: <|code_start|>from __future__ import annotations log = logging.getLogger("red.sinbadcogs.rss") DONT_HTML_SCRUB = ["link", "source", "updated", "updated_parsed"] USABLE_FIELDS = [ "author", "author_detail", "description", "comments", "content", "contributors", "create...
"updated_parsed",
Next line prediction: <|code_start|>from __future__ import annotations log = logging.getLogger("red.sinbadcogs.rss") DONT_HTML_SCRUB = ["link", "source", "updated", "updated_parsed"] USABLE_FIELDS = [ "author", "author_detail", "description", "comments", "content", "contributors", "cre...
"updated_parsed",
Given the code snippet: <|code_start|>from __future__ import annotations log = logging.getLogger("red.sinbadcogs.rss") DONT_HTML_SCRUB = ["link", "source", "updated", "updated_parsed"] USABLE_FIELDS = [ "author", "author_detail", "description", "comments", "content", "contributors", "c...
"publisher",
Based on the snippet: <|code_start|>from __future__ import annotations log = logging.getLogger("red.sinbadcogs.rss") DONT_HTML_SCRUB = ["link", "source", "updated", "updated_parsed"] USABLE_FIELDS = [ "author", "author_detail", "description", "comments", "content", "contributors", "cre...
"updated",
Using the snippet: <|code_start|> now = datetime.now(timezone.utc) next_run_at = now + timedelta(seconds=self.next_call_delay) embed = discord.Embed(color=color, timestamp=next_run_at) embed.title = f"Now viewing {index} of {page_count} selected tasks" embed.add_field(name="Comman...
f"\nIt repeats every {humanize_timedelta(timedelta=self.recur)}"
Here is a snippet: <|code_start|>from __future__ import annotations GuildList = List[discord.Guild] GuildSet = Set[discord.Guild] UserLike = Union[discord.Member, discord.User] def mock_user(idx: int) -> UserLike: return cast(discord.User, discord.Object(id=idx)) async def create_case( bot: Red, gui...
moderator: Optional[UserLike] = None,
Given snippet: <|code_start|>from __future__ import annotations GuildList = List[discord.Guild] GuildSet = Set[discord.Guild] UserLike = Union[discord.Member, discord.User] def mock_user(idx: int) -> UserLike: return cast(discord.User, discord.Object(id=idx)) async def create_case( <|code_end|> , continue b...
bot: Red,
Using the snippet: <|code_start|>from __future__ import annotations CHANNEL_RE = re.compile(r"^<#(\d{15,21})>$|^(\d{15,21})$") class GlobalTextChannel(NamedTuple): matched_channel: discord.TextChannel @classmethod async def convert(cls, ctx: commands.Context, argument: str): bot = ctx.bot ...
if match:
Given the following code snippet before the placeholder: <|code_start|> """Takes a channel, removes that channel from the clone list""" await self.ar_config.channel(channel).clear() await ctx.tick() @aa_active() @checks.admin_or_permissions(manage_channels=True) @autoroomset.command...
if val is None:
Given the code snippet: <|code_start|> clist.append("({0.id}) {0.name}".format(c)) output = ", ".join(clist) page_gen = cast(Generator[str, None, None], pagify(output)) try: for page in page_gen: await ctx.send(page) finally: page_g...
async def togglecreatorname(
Here is a snippet: <|code_start|> class Moo: @classmethod async def convert(cls, ctx, arg): if arg[:3].lower() == "moo": return cls() raise commands.BadArgument() <|code_end|> . Write the next line using the current file imports: import json import random from typing import Li...
class Fortune(commands.Cog):
Continue the code snippet: <|code_start|>from __future__ import annotations log = logging.getLogger("red.sinbadcogs.modnotes") class Note(NamedTuple): uid: int author_id: int subject_id: int guild_id: int note: str created_at: int def embed(self, ctx, color) -> discord.Embed: ...
f"{author} ({self.author_id})"
Based on the snippet: <|code_start|>from __future__ import annotations log = logging.getLogger("red.sinbadcogs.modnotes") class Note(NamedTuple): uid: int author_id: int subject_id: int guild_id: int note: str created_at: int def embed(self, ctx, color) -> discord.Embed: <|code_end|> ...
e = discord.Embed(
Predict the next line for this snippet: <|code_start|># TODO: Pull the logic out of d.py converter to not do this here... async def handle_color(ctx, to_set) -> int: x: int try: conv = discord.ext.commands.ColourConverter() x = (await conv.convert(ctx, to_set)).value except Exception: ...
to_set = handle_timestamp(to_set)
Given snippet: <|code_start|> ts = float(to_set) return ts # TODO: Pull the logic out of d.py converter to not do this here... async def handle_color(ctx, to_set) -> int: x: int try: conv = discord.ext.commands.ColourConverter() x = (await conv.convert(ctx, to_set)).value excep...
for outer_key in ["initable", "settable"]:
Next line prediction: <|code_start|> A / 2 B = FloatTensor().resizeAs(A).geometric(0.9) myeval('B') myeval('A + B') myeval('A - B') myexec('A += B') myeval('A') myexec('A -= B') myeval('A') def test_pytorch_Float_constructors(): FloatTensor = PyTorch.FloatTensor a = FloatTen...
def test_Pytorch_Float_operator_plusequals():
Given the code snippet: <|code_start|> PyTorch.manualSeed(123) numpy.random.seed(123) DoubleTensor = PyTorch.DoubleTensor D = PyTorch.DoubleTensor(5, 3).fill(1) print('D', D) D[2][2] = 4 print('D', D) D[3].fill(9) print('D', D) D.narrow(1, 2, 1).fill(0) print('D', D) ...
print(type(PyTorch.DoubleTensor(2, 3)))
Given the following code snippet before the placeholder: <|code_start|>from __future__ import print_function, division def test_refcount(): D = PyTorch.FloatTensor(1000, 1000).fill(1) myeval('D.isContiguous()') myeval('D.refCount') assert D.refCount == 1 print('\nget storage into Ds') Ds = D....
assert Ds.refCount == 2
Predict the next line after this snippet: <|code_start|>from __future__ import print_function def test_long_tensor(): PyTorch.manualSeed(123) print('test_long_tensor') <|code_end|> using the current file's imports: import PyTorch from test.test_helpers import myeval, myexec and any relevant context from ot...
a = PyTorch.LongTensor(3, 2).geometric()
Next line prediction: <|code_start|>from __future__ import print_function def test_long_tensor(): PyTorch.manualSeed(123) print('test_long_tensor') a = PyTorch.LongTensor(3, 2).geometric() <|code_end|> . Use current file imports: (import PyTorch from test.test_helpers import myeval, myexec) and context ...
print('a', a)
Predict the next line for this snippet: <|code_start|>] %} {% for typedict in types -%} {%- set Real = typedict['Real'] -%} {%- set real = typedict['real'] -%} def test_pytorch{{Real}}(): PyTorch.manualSeed(123) numpy.random.seed(123) {{Real}}Tensor = PyTorch.{{Real}}Tensor {% if Real == 'Float' -%}...
print('A', A)
Next line prediction: <|code_start|> print('add 7 to tensorA') tensorA2 = tensorA + 7 print('tensorA2', tensorA2) print('tensorA', tensorA) tensorAB = tensorA * tensorB print('tensorAB', tensorAB) print('A.dot(B)', A.dot(B)) print('tensorA[2]', tensorA[2]) {% endif -%} D = Py...
print(PyTorch.{{Real}}Tensor(3, 4).exponential())
Given snippet: <|code_start|> def test_brackets_of_simple_peak(): y = array((10, 11, 12, 11, 10)) left, right = _choose_brackets(y) assert list(left) == [1, 2] assert list(right) == [2, 3] def test_brackets_of_small_plateau(): y = array((10, 11, 12, 12, 11, 10)) left, right = _choose_brackets(y...
x = array((2451545.0, 2451546.0, 2451547.0))
Based on the snippet: <|code_start|> def test_brackets_of_small_plateau(): y = array((10, 11, 12, 12, 11, 10)) left, right = _choose_brackets(y) assert list(left) == [1, 2, 3] assert list(right) == [2, 3, 4] def test_brackets_of_wide_plateau(): y = array((10, 11, 12, 12, 12, 12, 12, 11, 10)) le...
y = array((12, 11, 12, 12, 11, 13, 11, 12, 12))
Given the code snippet: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, 'jupiter': 1047.3486, 'saturn': 3497...
}
Using the snippet: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, 'jupiter': 1047.3486, 'saturn': 3497.898,...
def add_deflection(position, observer, ephemeris, t,
Based on the snippet: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, 'jupiter': 1047.3486, 'saturn': 3497.8...
}
Next line prediction: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, 'jupiter': 1047.3486, 'saturn': 3497.8...
'sun': 1.0,
Predict the next line after this snippet: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, 'jupiter': 1047.3486, ...
def add_deflection(position, observer, ephemeris, t,
Using the snippet: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, 'jupiter': 1047.3486, <|code_end|> , determin...
'saturn': 3497.898,
Predict the next line for this snippet: <|code_start|> deflectors = ['sun', 'jupiter', 'saturn', 'moon', 'venus', 'uranus', 'neptune'] rmasses = { # earth-moon barycenter: 328900.561400 'mercury': 6023600.0, 'venus': 408523.71, 'earth': 332946.050895, 'mars': 3098708.0, <|code_end|> with the help ...
'jupiter': 1047.3486,
Based on the snippet: <|code_start|>#!/usr/bin/env python3 ATTRIBUTES = ( 'J', 'delta_t', 'dut1', 'gmst', # (lambda t: t.toordinal()), 'tai_fraction', 'tdb_fraction', 'ut1_fraction', ) def main(): ts = load.timescale() t = ts.utc(2020, 10, 24) for attribute in ATTRIBUTES: step_width, ...
steps_down = (diff < 0.0).sum()
Predict the next line for this snippet: <|code_start|>#!/usr/bin/env python3 ATTRIBUTES = ( 'J', 'delta_t', 'dut1', 'gmst', # (lambda t: t.toordinal()), 'tai_fraction', 'tdb_fraction', 'ut1_fraction', ) def main(): ts = load.timescale() t = ts.utc(2020, 10, 24) for attribute in ATTRIBUTES: ...
for tenth in 0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0:
Continue the code snippet: <|code_start|> 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH""" assert repr(v) == """\ <VectorSum of 2 vectors: 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER 'de421.bsp' segment 3 EARTH BARYCENTER -> 399 EARTH>""" assert str(v.at(t)) == "\ <Barycentric ...
Sum of 4 vectors:
Given the code snippet: <|code_start|> def test_negation(): ts = load.timescale() t = ts.utc(2020, 8, 30, 16, 5) usno = Topos('38.9215 N', '77.0669 W', elevation_m=92.0) neg = -usno p1 = usno.at(t) p2 = neg.at(t) assert (p1.position.au == - p2.position.au).all() assert (p1.velocity.au_pe...
assert repr(v) == """\
Based on the snippet: <|code_start|> ts = load.timescale() t = ts.tt(2017, 1, 23, 10, 44) planets = load('de421.bsp') earth = planets['earth'] mars = planets['mars'] v = earth assert str(v) == """\ Sum of 2 vectors: 'de421.bsp' segment 0 SOLAR SYSTEM BARYCENTER -> 3 EARTH BARYCENTER 'de4...
assert repr(v) == """\
Given the code snippet: <|code_start|> def test_lunar_eclipses(): # The documentation test already confirms the dates of these two # eclipses; here, we confirm that the data structures all match. ts = load.timescale() eph = load('de421.bsp') t0 = ts.utc(2019, 1, 1) <|code_end|> , generate the next ...
t1 = ts.utc(2020, 1, 1)
Predict the next line after this snippet: <|code_start|> def test_lunar_eclipses(): # The documentation test already confirms the dates of these two # eclipses; here, we confirm that the data structures all match. ts = load.timescale() eph = load('de421.bsp') t0 = ts.utc(2019, 1, 1) t1 = ts.utc...
for name, item in details.items():
Here is a snippet: <|code_start|> sat = api.EarthSatellite(*tle[1:3], name=tle[0]) topos = api.Topos('42.3581 N', '71.0636 W') timescale = api.load.timescale() t0 = timescale.tai(2014, 11, 10) t1 = timescale.tai(2014, 11, 11) horizon = 20 nexpected = 12 times, yis = sat.find_events(topos...
Ariane 5B
Continue the code snippet: <|code_start|> axes.xaxis.set_minor_locator(HourLocator([0, 6, 12, 18])) axes.xaxis.set_major_formatter(DateFormatter('0h\n%Y %b %d\n%A')) axes.xaxis.set_minor_formatter(DateFormatter('%Hh')) for label in ax.xaxis.get_ticklabels(which='both'): label.set_horizontalalignm...
fig, ax = plt.subplots()
Next line prediction: <|code_start|> 'GOCE', ) # Build the time range `t` over which to plot, plus other values. ts = load.timescale() t = ts.tt_jd(np.arange(sat.epoch.tt - 2.0, sat.epoch.tt + 2.0, 0.005)) reentry = ts.utc(2013, 11, 11, 0, 16) earth_radius_km = 6371.0 # Compute geocentric positions for the satell...
ax.text(x, y - 9, 'Epoch of TLE data ', ha='right')
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- line1 = '1 25544U 98067A 18184.80969102 .00001614 00000-0 31745-4 0 9993' line2 = '2 25544 51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106' # Here are numbers from HORIZONS, which I copied into the test below: # #Ephemeris / WWW_USE...
hp = array([
Predict the next line after this snippet: <|code_start|>#2458304.500000000 = A.D. 2018-Jul-05 00:00:00.0000 TDB # X =-2.136440257814821E-05 Y =-2.084170814514480E-05 Z =-3.415494123796893E-05 # VX= 2.143876266215405E-03 VY=-3.752167957502106E-03 VZ= 9.484159290242074E-04 # TODO: try with array of dates def test_iss_a...
assert abs(p.velocity.au_per_d - hv).max() < three_km_per_hour
Using the snippet: <|code_start|># -*- coding: utf-8 -*- line1 = '1 25544U 98067A 18184.80969102 .00001614 00000-0 31745-4 0 9993' line2 = '2 25544 51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106' # Here are numbers from HORIZONS, which I copied into the test below: # #Ephemeris / WWW_USER Wed Ju...
]).T
Given snippet: <|code_start|># VX=-1.751248694205384E-03 VY= 4.065407557020968E-03 VZ= 1.363540232307603E-04 #2458304.500000000 = A.D. 2018-Jul-05 00:00:00.0000 TDB # X =-2.136440257814821E-05 Y =-2.084170814514480E-05 Z =-3.415494123796893E-05 # VX= 2.143876266215405E-03 VY=-3.752167957502106E-03 VZ= 9.484159290242074...
assert abs(p.position.au - hp).max() < two_meters
Given snippet: <|code_start|># -*- coding: utf-8 -*- line1 = '1 25544U 98067A 18184.80969102 .00001614 00000-0 31745-4 0 9993' line2 = '2 25544 51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106' # Here are numbers from HORIZONS, which I copied into the test below: # #Ephemeris / WWW_USER Wed Jul 4...
[-2.136440257814821E-5, -2.084170814514480E-5, -3.415494123796893E-5],
Next line prediction: <|code_start|># -*- coding: utf-8 -*- line1 = '1 25544U 98067A 18184.80969102 .00001614 00000-0 31745-4 0 9993' line2 = '2 25544 51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106' # Here are numbers from HORIZONS, which I copied into the test below: # #Ephemeris / WWW_USER Wed...
hv = array([
Here is a snippet: <|code_start|># #Ephemeris / WWW_USER Wed Jul 4 19:16:45 2018 Pasadena, USA / Horizons #... #2458303.500000000 = A.D. 2018-Jul-04 00:00:00.0000 TDB # X = 2.633404251158200E-05 Y = 1.015087620439817E-05 Z = 3.544778677556393E-05 # VX=-1.751248694205384E-03 VY= 4.065407557020968E-03 VZ= 1.3635402...
assert abs(p.position.au - hp[:,0]).max() < two_meters
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*- line1 = '1 25544U 98067A 18184.80969102 .00001614 00000-0 31745-4 0 9993' line2 = '2 25544 51.6414 295.8524 0003435 262.6267 204.2868 15.54005638121106' # Here are numbers from HORIZONS, which I copied into the test below: # #Ephemeris / WWW_USE...
[-1.751248694205384E-3, 4.065407557020968E-3, 1.363540232307603E-4],
Given the code snippet: <|code_start|> ts = load.timescale() eph = load('de421.bsp') sun = eph['sun'] earth = eph['earth'] #bluffton = earth + api.wgs84.latlon(40.8939, -83.8917) bluffton = api.wgs84.latlon(40.8939, -83.8917) <|code_end|> , generate the next line using the imports in this file: from skyfield import a...
t0 = ts.utc(2020, 1, 1)
Using the snippet: <|code_start|> slope = rise / run timebump = adjustment / slope print(timebump) t3 = ts.tt_jd(t2.tt + timebump) ha3, dec3, _ = observer.at(t3).observe(body).apparent().hadec() setting_ha3 = _sunrise_hour_angle_radians(geo.latitude, dec3, stdalt) rising_ha3 = - setting_ha3...
T0 = time()
Predict the next line for this snippet: <|code_start|> i, = np.nonzero(np.diff(difference) < 0.0) print(i) a = tau - difference[i] b = difference[i + 1] print(a) print(b) tt = t.tt new_tt = (b * tt[i] + a * tt[i+1]) / (a + b) print(tt) print(new_tt) t2 = ts.tt_jd(new_tt) ...
timebump = adjustment / slope
Next line prediction: <|code_start|> rise = ha2.radians - ha.radians[i] run = t2.tt - t[i].tt slope = rise / run timebump = adjustment / slope print(timebump) t3 = ts.tt_jd(t2.tt + timebump) ha3, dec3, _ = observer.at(t3).observe(body).apparent().hadec() setting_ha3 = _sunrise_hour_angl...
DUR_NEW = time() - T0
Given snippet: <|code_start|> ts = api.load.timescale() t0 = ts.tt(-1000, 1, 1) t1 = ts.tt(2000, 1, 1) days = int(t1 - t0) if 1: t = ts.tt(-1000, 1, range(days)) gy, gm, gd = t.tt_calendar()[:3] ts.julian_calendar_cutoff = 99999999999999999 #api.GREGORIAN_START jy, jm, jd = t.tt_calendar()[:3] prin...
fig.savefig('tmp.png')
Based on the snippet: <|code_start|> ts = api.load.timescale() t0 = ts.tt(-1000, 1, 1) t1 = ts.tt(2000, 1, 1) days = int(t1 - t0) if 1: t = ts.tt(-1000, 1, range(days)) <|code_end|> , predict the immediate next line with the help of imports: from skyfield import almanac from skyfield import api import matplot...
gy, gm, gd = t.tt_calendar()[:3]
Here is a snippet: <|code_start|> # Compare with USNO: # http://aa.usno.navy.mil/cgi-bin/aa_moonill2.pl?form=1&year=2018&task=00&tz=-05 def test_fraction_illuminated(): ts = api.load.timescale() t0 = ts.utc(2018, 9, range(9, 19), 5) e = api.load('de421.bsp') i = almanac.fraction_illuminated(e, 'moon', ...
print(strings)
Next line prediction: <|code_start|> ts = api.load.timescale() t0 = ts.utc(2018, 9, 11) t1 = ts.utc(2018, 9, 30) e = api.load('de421.bsp') t, y = almanac.find_discrete(t0, t1, almanac.moon_phases(e)) strings = t.utc_strftime('%Y-%m-%d %H:%M') assert strings == ['2018-09-16 23:15', '2018-09-25...
def test_oppositions_conjunctions_of_moon():
Predict the next line after this snippet: <|code_start|> Angle(angle=another_angle) Angle(radians=value) Angle(degrees=value) Angle(hours=value) where `value` can be either a Python float, a list of Python floats, or a NumPy array of floats""" class Angle(Unit): def __init__(self, angle=None, radians=None, degre...
self.signed = signed
Here is a snippet: <|code_start|> """Units per day of Terrestrial Time.""" return self._per_day @reify def per_hour(self): """Units per hour of Terrestrial Time.""" return self._per_day / 24.0 @reify def per_minute(self): """Units per minute of Terrestrial Time."...
class Angle(Unit):
Using the snippet: <|code_start|> """Units per day of Terrestrial Time.""" return self._per_day @reify def per_hour(self): """Units per hour of Terrestrial Time.""" return self._per_day / 24.0 @reify def per_minute(self): """Units per minute of Terrestrial Time."...
class Angle(Unit):
Here is a snippet: <|code_start|> where `value` can be either a Python float, a list of Python floats, or a NumPy array of floats""" class Angle(Unit): def __init__(self, angle=None, radians=None, degrees=None, hours=None, preference=None, signed=False): if angle is not None: ...
self = cls.__new__(cls)
Using the snippet: <|code_start|> def per_second(self): """Units per second of Terrestrial Time.""" return self._per_day / 86400.0 # Angle units. _instantiation_instructions = """to instantiate an Angle, try one of: Angle(angle=another_angle) Angle(radians=value) Angle(degrees=value) Angle(hours=v...
elif hours is not None:
Here is a snippet: <|code_start|>class Angle(Unit): def __init__(self, angle=None, radians=None, degrees=None, hours=None, preference=None, signed=False): if angle is not None: if not isinstance(angle, Angle): raise ValueError(_instantiation_instructions) ...
self.signed = signed
Given snippet: <|code_start|>class Angle(Unit): def __init__(self, angle=None, radians=None, degrees=None, hours=None, preference=None, signed=False): if angle is not None: if not isinstance(angle, Angle): raise ValueError(_instantiation_instructions) ...
self.signed = signed
Based on the snippet: <|code_start|># Angle units. _instantiation_instructions = """to instantiate an Angle, try one of: Angle(angle=another_angle) Angle(radians=value) Angle(degrees=value) Angle(hours=value) where `value` can be either a Python float, a list of Python floats, or a NumPy array of floats""" class An...
self.preference = (preference if preference is not None
Given the following code snippet before the placeholder: <|code_start|># -*- coding: utf-8 -*- def main(): print('Skyfield version: {0}'.format(skyfield.__version__)) print('jplephem version: {0}'.format(version_of('jplephem'))) print('sgp4 version: {0}'.format(version_of('sgp4'))) ts = load.timescal...
except pkg_resources.DistributionNotFound:
Given the code snippet: <|code_start|># -*- coding: utf-8 -*- def main(): print('Skyfield version: {0}'.format(skyfield.__version__)) print('jplephem version: {0}'.format(version_of('jplephem'))) print('sgp4 version: {0}'.format(version_of('sgp4'))) ts = load.timescale() fmt = '%Y-%m-%d' fin...
.format(start.utc_strftime(fmt), end.utc_strftime(fmt)))
Continue the code snippet: <|code_start|> ts = load.timescale() ephem = load('de430t.bsp') earth = ephem['earth'] sun = ephem['sun'] moon = ephem['moon'] mars = ephem['mars barycenter'] greenwich = earth + Topos(latitude_degrees=(51, 28, 40), longitude_degrees=(0, 0, -5)) <|code_end|> . Use current file imports: fr...
iss_tle = """\
Continue the code snippet: <|code_start|> ts = load.timescale() ephem = load('de430t.bsp') earth = ephem['earth'] sun = ephem['sun'] <|code_end|> . Use current file imports: from skyfield.api import load, Topos, EarthSatellite, Star from almanac2 import seasons, moon_phases, meridian_transits, culminations, twilights...
moon = ephem['moon']
Predict the next line after this snippet: <|code_start|> ts = load.timescale() ephem = load('de430t.bsp') earth = ephem['earth'] <|code_end|> using the current file's imports: from skyfield.api import load, Topos, EarthSatellite, Star from almanac2 import seasons, moon_phases, meridian_transits, culminations, twilig...
sun = ephem['sun']
Predict the next line for this snippet: <|code_start|> ts = load.timescale() ephem = load('de430t.bsp') earth = ephem['earth'] sun = ephem['sun'] <|code_end|> with the help of current file imports: from skyfield.api import load, Topos, EarthSatellite, Star from almanac2 import seasons, moon_phases, meridian_transits...
moon = ephem['moon']
Predict the next line after this snippet: <|code_start|> mag = m._earth_magnitude(0.983331936476, 1.41317594650699, 8.7897) assert abs(-3.269 - mag) < 0.0005 mag = m._earth_magnitude(0.983356079811, 0.26526856764726, 4.1369) assert abs(-6.909 - mag) < 0.0005 mag = m._earth_magnitude(0.983356467727, 0...
expected = [-2.862, 1.788, 8.977]
Continue the code snippet: <|code_start|> assert np.isnan(mag) args = [ A[9.014989659493, 9.438629261423, 9.026035315474, 9.026035315474], A[8.03160470546889, 8.47601935508925, 10.1321497654765, 10.1321497654765], A[0.1055, 1.8569, 169.8958, 169.8958], A[-26.224864126755417, -8.0...
expected = [5.381, 6.025, 8.318]
Given snippet: <|code_start|> # Compare with Hong Kong Observatory: # https://www.hko.gov.hk/tc/gts/astronomy/Solar_Term.htm access at 2019-12-14 def test_solar_terms(): ts = api.load.timescale() e = api.load('de421.bsp') f = skyfield.almanac_east_asia.solar_terms(e) # https://en.wikipedia.org/wiki/Li...
t1 = ts.utc(2019, 5, 6)
Based on the snippet: <|code_start|> # Compare with Hong Kong Observatory: # https://www.hko.gov.hk/tc/gts/astronomy/Solar_Term.htm access at 2019-12-14 def test_solar_terms(): ts = api.load.timescale() e = api.load('de421.bsp') f = skyfield.almanac_east_asia.solar_terms(e) # https://en.wikipedia.org/...
assert strings == ['2019-02-04 03:14']
Given the code snippet: <|code_start|> def a(*args): return array(args) def test_intersect_line_and_sphere(): near, far = intersect_line_and_sphere(a(1000, 0, 0), a(2, 0, 0), 1) assert near == 1.0 assert far == 3.0 near, far = intersect_line_and_sphere(a(-1000, 0, 0), a(3, 0, 0), 1) assert nea...
assert isnan(near)
Given the code snippet: <|code_start|> def test_reverse_terra_with_zero_iterations(): # With zero iterations, should return "geocentric" rather than # "geodetic" (="correct") longitude and latitude. lat, lon, elevation = reverse_terra(array([1, 0, 1]), 0, iterations=0) assert abs(lat - tau / 8) < 1e-16 ...
assert lon == 0.0