Instruction stringlengths 362 7.83k | output_code stringlengths 1 945 |
|---|---|
Predict the next line for this snippet: <|code_start|> raise self.failureException(
'Async operation timed out after %s seconds' %
timeout)
except Exception:
self.__failure = sys.exc_info()
... | raise_exc_info(failure) |
Given the code snippet: <|code_start|> self.patch_app_handlers()
self.http_server = self.app.http_server
self.http_client = AsyncHTTPClient(io_loop=self.io_loop)
def close(self):
"""CLose http_server, io_loop by sequence, to ensure the environment
is cleaned up and invok... | c = SimpleCookie(resp.headers.get(COOKIE_HEADER_KEY)) |
Here is a snippet: <|code_start|> "0123456789-._~")
def unquote_unreserved(uri):
"""Un-escape any percent-escape sequences in a URI that are unreserved
characters. This leaves all reserved, illegal and non-ASCII bytes encoded.
"""
parts = uri.split('%')
for i in range(1, len(parts)):
h ... | return quote(unquote_unreserved(uri), safe="!#$%&'()*+,/:;=?@[]~") |
Next line prediction: <|code_start|> # `body` must be passed if method is one of those three
if method in ['POST', 'PUT', 'PATCH']:
headers = kwgs.setdefault('headers', {})
body = ''
if files:
boundary = '1234567890'
headers['Content-Typ... | body = urlencode(data) |
Given the following code snippet before the placeholder: <|code_start|> def get_http_port(self):
return self.app.settings['PORT']
def get_url(self, path):
"""Returns an absolute url for the given path on the test server."""
return '%s://localhost:%s%s' % (self.get_protocol(),
... | if e.status_code not in httplib.responses: |
Given snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
def test_func_parse():
def pri(a, b, c=True, d=3):
print('pri func')
return
c = Command(pri)
assert c.parameters == ['a', 'b']
assert c.keyword_parameters == {'c': True, 'd': 3}
<|code_end|>
, continue by pr... | with assert_raises(CommandArgumentError): |
Using the snippet: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
def test_func_parse():
def pri(a, b, c=True, d=3):
print('pri func')
return
<|code_end|>
, determine the next line of code. You have imports:
from torext.errors import CommandArgumentError
from torext.script import ... | c = Command(pri) |
Next line prediction: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
class TorextException(Exception):
def __init__(self, message=''):
if isinstance(message, str):
<|code_end|>
. Use current file imports:
(from torext.compat import decode_, PY2)
and context including class names, function ... | message = decode_(message, 'utf8') |
Next line prediction: <|code_start|>#!/usr/bin/env python
# -*- coding: utf-8 -*-
class TorextException(Exception):
def __init__(self, message=''):
if isinstance(message, str):
message = decode_(message, 'utf8')
self.message = message
<|code_end|>
. Use current file imports:
(from t... | if PY2: |
Here is a snippet: <|code_start|> self.msg = msg
print(self.__str__() + '\n')
parser.print_help()
sys.exit()
def __str__(self):
return self.__class__.__name__ + ': %s' % self.msg
def main():
options, args = parser.parse_args()
try:
name = args[0]
except... | import_module(name) |
Next line prediction: <|code_start|>
opencpn_XML='-69.4565,20.7236,0. -68.3182,21.8401,0. '
def test_coordinates_processing():
route = opencpn_coordinates_processing(opencpn_XML)
assert route.shape[1] == 2 # return a (n, 2) np array
assert route[0][0] == 20.7236
def test_gpx_route_reader():
file_name... | routes = read_route_from_gpx(file_name) |
Continue the code snippet: <|code_start|>
class Mission:
def __init__(self, start_time=None, route=None, speed=None):
if start_time is None or route is None or speed is None:
print('Please use custom mission setting.')
else:
self.start_time = start_time
self.rout... | self.ID = hash_value(ID_tuple) |
Continue the code snippet: <|code_start|> # Convert UTC time into local time
def find_timezone(array, value):
idx = (np.abs(array - value)).argmin()
return idx - 12
lons = np.linspace(-180, 180, 25)
local_time = []
for index, row in mission.iterrows():
local_time.append(inde... | position_df = full_day_cut(position_dataframe(start_time, route, speed)) |
Here is a snippet: <|code_start|> # Clearness index processing
zenith_cosine_list = []
for index, row in dataframe.iterrows():
zenith_cosine = calculate_zenith_cosine(index, row.lat, row.lon)
zenith_cosine_list.append(zenith_cosine)
dataframe['zenith_cos'] = zenith_cosine_list
dataf... | heading.append(calculate_initial_compass_bearing(a, b)) |
Given snippet: <|code_start|>
test_route = np.array([[ 10.69358 , -178.94713892], [ 11.06430687, +176.90022735]])
test_ship = propulsion_power.Ship()
test_ship.dimension(5.72, 0.248, 0.76, 1.2, 5.72/(0.549)**(1/3),0.613)
power_consumption_list = {'single_board_computer': {'power': [2, 10], 'duty_cycle': 0.5},
... | test_mission = Mission('2014-01-01', test_route, 2) |
Based on the snippet: <|code_start|>
test_route = np.array([[ 10.69358 , -178.94713892], [ 11.06430687, +176.90022735]])
test_ship = propulsion_power.Ship()
test_ship.dimension(5.72, 0.248, 0.76, 1.2, 5.72/(0.549)**(1/3),0.613)
power_consumption_list = {'single_board_computer': {'power': [2, 10], 'duty_cycle': ... | test_task = Task(test_mission, test_ship, power_consumption_list) |
Here is a snippet: <|code_start|> u"name": u"Pilsner Liquid Extract",
u"weight": 3.25,
u"grain_type": u"lme",
},
{
u"name": u"Munich Liquid Extract",
u"data": {u"color": 10.0, u"ppg": 36},
u"weight": 3... | loader = JSONDataLoader(data_dir) |
Next line prediction: <|code_start|> u"weight": 3.25,
u"grain_type": u"lme",
},
{
u"name": u"Munich Liquid Extract",
u"data": {u"color": 10.0, u"ppg": 36},
u"weight": 3.25,
u"grain_type": u"lme",
... | beer = parse_recipe(recipe, loader) |
Given snippet: <|code_start|>
recipe = {
u"name": u"Yellow Moon IPA (Extract)",
u"start_volume": 4.0,
u"final_volume": 5.0,
u"grains": [
{u"name": u"Pale Liquid Extract", u"weight": 7.0, u"grain_type": u"lme"},
{
u"name": u"Caramel Crystal Malt... | loader = JSONDataLoader(data_dir) |
Here is a snippet: <|code_start|> recipe = {
u"name": u"Yellow Moon IPA (Extract)",
u"start_volume": 4.0,
u"final_volume": 5.0,
u"grains": [
{u"name": u"Pale Liquid Extract", u"weight": 7.0, u"grain_type": u"lme"},
{
u"name": u"Caramel Crystal M... | beer = parse_recipe(recipe, loader) |
Predict the next line after this snippet: <|code_start|> {
u"name": u"pale malt 2-row us",
u"data": {u"color": 1.8, u"ppg": 37},
u"weight": 13.96,
},
{
u"name": u"caramel crystal malt 20l",
u"data": {u"col... | loader = JSONDataLoader(data_dir) |
Next line prediction: <|code_start|> u"name": u"pale malt 2-row us",
u"data": {u"color": 1.8, u"ppg": 37},
u"weight": 13.96,
},
{
u"name": u"caramel crystal malt 20l",
u"data": {u"color": 20.0, u"ppg": 35},
... | beer = parse_recipe(recipe, loader) |
Continue the code snippet: <|code_start|> u"start_volume": 4.0,
u"final_volume": 5.0,
u"grains": [
{u"name": u"Pale Liquid Extract", u"weight": 7.0, u"grain_type": u"lme"},
{u"name": u"Munich Malt", u"weight": 1.0, u"grain_type": u"specialty"},
{
... | loader = JSONDataLoader(data_dir) |
Next line prediction: <|code_start|> u"final_volume": 5.0,
u"grains": [
{u"name": u"Pale Liquid Extract", u"weight": 7.0, u"grain_type": u"lme"},
{u"name": u"Munich Malt", u"weight": 1.0, u"grain_type": u"specialty"},
{
u"name": u"Caramel Crystal Malt 1... | beer = parse_recipe(recipe, loader) |
Predict the next line after this snippet: <|code_start|> u"name": u"caramel crystal malt 120l",
u"weight": 0.375,
u"grain_type": u"specialty",
},
],
u"hops": [
{
u"name": u"challenger",
u"data": {u"per... | loader = JSONDataLoader(data_dir) |
Predict the next line for this snippet: <|code_start|> u"weight": 0.375,
u"grain_type": u"specialty",
},
],
u"hops": [
{
u"name": u"challenger",
u"data": {u"percent_alpha_acids": 0.08},
u"weight": 1.43... | beer = parse_recipe(recipe, loader) |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
class TestValidators(unittest.TestCase):
def test_validate_grain_type(self):
out = validate_grain_type(GRAIN_TYPE_CEREAL)
self.assertEqual(out, GRAIN_TYPE_CEREAL)
def test_validate_grain_type_raises(self):
with self.ass... | out = validate_hop_type(HOP_TYPE_PELLET) |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
class TestValidators(unittest.TestCase):
def test_validate_grain_type(self):
out = validate_grain_type(GRAIN_TYPE_CEREAL)
self.assertEqual(out, GRAIN_TYPE_CEREAL)
def test_validate_grain_type_raises(self):
<|code_end|>
. Use cu... | with self.assertRaises(ValidatorException) as ctx: |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
class TestValidators(unittest.TestCase):
def test_validate_grain_type(self):
out = validate_grain_type(GRAIN_TYPE_CEREAL)
self.assertEqual(out, GRAIN_TYPE_CEREAL)
def test_validate_grain_type_raises(self):
with self.assertRa... | out = validate_hop_type(HOP_TYPE_PELLET) |
Given snippet: <|code_start|> out = validate_percentage(0.97)
self.assertEquals(out, 0.97)
def test_validate_percentage_raises(self):
with self.assertRaises(ValidatorException) as ctx:
validate_percentage(1.01)
self.assertEquals(
str(ctx.exception), u"Percenta... | validate_required_fields(data, required_fields) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
"""
Convert one sugar unit to another or print all.
brix_in - Degrees Brix Input
plato_in - Degrees Plato Input
sg_in - Specific Gravity Input
sugar_ou... | plato = brix_to_plato(brix_in) |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
"""
Convert one sugar unit to another or print all.
brix_in - Degrees Brix Input
plato_in - Degrees Plato Input
sg_in - Specific Gravity Input
sugar_out - Type of c... | sg = brix_to_sg(brix_in) |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
"""
Convert one sugar unit to another or print all.
brix_in - Degrees Brix Input
plato_in - Degrees Plato Input
sg_in - Specific Gravity Input
sugar_out - Type of conversio... | brix = plato_to_brix(plato_in) |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
"""
Convert one sugar unit to another or print all.
brix_in - Degrees Brix Input
plato_in - Degrees Plato Input
sg_in - Specific Gravity Input
sugar_out - Type of conver... | sg = plato_to_sg(plato_in) |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
"""
Convert one sugar unit to another or print all.
brix_in - Degrees Brix Input
plato_in - Degrees Plato Input
sg_in - Specific Gravity Input
sugar_out - Type of conv... | brix = sg_to_brix(sg_in) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
def get_sugar_conversion(brix_in, plato_in, sg_in, sugar_out):
"""
Convert one sugar unit to another or print all.
brix_in - Degrees Brix Input
plato_in - Degrees Plato Input
sg_in - Specific Gravity Input
sugar_ou... | plato = sg_to_plato(sg_in) |
Here is a snippet: <|code_start|> u"HopsUtilizationJackieRager",
u"HopsUtilizationGlennTinseth",
]
def hop_type_weight_conversion(weight, old_type, new_type):
"""
Convert weight of hops between one type and another
:param float weight: Weight of the hops
:param str old_type: The old hop type t... | if old_type == HOP_TYPE_PELLET: |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
__all__ = [
u"hop_type_weight_conversion",
u"HopsUtilization",
u"HopsUtilizationJackieRager",
u"HopsUtilizationGlennTinseth",
]
def hop_type_weight_conversion(weight, old_type, new_type):
"""
Convert weight of hops between one ... | equivalent_types = [HOP_TYPE_PLUG, HOP_TYPE_WHOLE] |
Here is a snippet: <|code_start|># -*- coding: utf-8 -*-
__all__ = [
u"hop_type_weight_conversion",
u"HopsUtilization",
u"HopsUtilizationJackieRager",
u"HopsUtilizationGlennTinseth",
]
def hop_type_weight_conversion(weight, old_type, new_type):
"""
Convert weight of hops between one type and... | equivalent_types = [HOP_TYPE_PLUG, HOP_TYPE_WHOLE] |
Given the code snippet: <|code_start|>
__all__ = [
u"hop_type_weight_conversion",
u"HopsUtilization",
u"HopsUtilizationJackieRager",
u"HopsUtilizationGlennTinseth",
]
def hop_type_weight_conversion(weight, old_type, new_type):
"""
Convert weight of hops between one type and another
:para... | if old_type == HOP_TYPE_WHOLE_WET: |
Based on the snippet: <|code_start|> u"HopsUtilizationGlennTinseth",
]
def hop_type_weight_conversion(weight, old_type, new_type):
"""
Convert weight of hops between one type and another
:param float weight: Weight of the hops
:param str old_type: The old hop type to convert from
:param str ne... | conversion *= HOP_UTILIZATION_SCALE_PELLET |
Continue the code snippet: <|code_start|>
__all__ = [
u"hop_type_weight_conversion",
u"HopsUtilization",
u"HopsUtilizationJackieRager",
u"HopsUtilizationGlennTinseth",
]
def hop_type_weight_conversion(weight, old_type, new_type):
"""
Convert weight of hops between one type and another
:pa... | conversion /= HOP_WHOLE_DRY_TO_WET |
Given snippet: <|code_start|> :param str units: The units
"""
self.units = validate_units(units)
if self.units == IMPERIAL_UNITS:
self.types = IMPERIAL_TYPES
elif self.units == SI_UNITS:
self.types = SI_TYPES
def change_units(self):
"""
... | hops_constant = HOPS_CONSTANT_IMPERIAL |
Given snippet: <|code_start|> self.units = validate_units(units)
if self.units == IMPERIAL_UNITS:
self.types = IMPERIAL_TYPES
elif self.units == SI_UNITS:
self.types = SI_TYPES
def change_units(self):
"""
Change units of the class from one type to the ... | hops_constant = HOPS_CONSTANT_SI |
Based on the snippet: <|code_start|> conversion *= HOP_UTILIZATION_SCALE_PELLET
elif new_type == HOP_TYPE_PELLET:
conversion /= HOP_UTILIZATION_SCALE_PELLET
return weight * conversion
class HopsUtilization(object):
"""
http://www.boondocks-brewing.com/hops
"""
def __init__(sel... | self.types = IMPERIAL_TYPES |
Based on the snippet: <|code_start|> :rtype: float
"""
# If same type then no change
if old_type == new_type:
return weight
# If hop types are equivalent then no change
equivalent_types = [HOP_TYPE_PLUG, HOP_TYPE_WHOLE]
if old_type in equivalent_types and new_type in equivalent_types... | def __init__(self, hop_addition, units=IMPERIAL_UNITS): |
Using the snippet: <|code_start|> conversion /= HOP_UTILIZATION_SCALE_PELLET
return weight * conversion
class HopsUtilization(object):
"""
http://www.boondocks-brewing.com/hops
"""
def __init__(self, hop_addition, units=IMPERIAL_UNITS):
"""
:param HopAddition hop_addition:... | self.types = SI_TYPES |
Next line prediction: <|code_start|> elif new_type == HOP_TYPE_PELLET:
conversion /= HOP_UTILIZATION_SCALE_PELLET
return weight * conversion
class HopsUtilization(object):
"""
http://www.boondocks-brewing.com/hops
"""
def __init__(self, hop_addition, units=IMPERIAL_UNITS):
"""... | elif self.units == SI_UNITS: |
Given the code snippet: <|code_start|>
if old_type == HOP_TYPE_PELLET:
conversion *= HOP_UTILIZATION_SCALE_PELLET
elif new_type == HOP_TYPE_PELLET:
conversion /= HOP_UTILIZATION_SCALE_PELLET
return weight * conversion
class HopsUtilization(object):
"""
http://www.boondocks-brewing... | self.units = validate_units(units) |
Predict the next line for this snippet: <|code_start|>Ale: 0.75 M / ml / P = 0.71 B / G / SG
Lager: 1.50 M / ml / P = 1.42 B / G / SG
Hybrid: 1.00 M / ml / P = 0.948 B / G / SG
"""
# Pitch rate in M / ml / P
PITCH_RATE_MAP = {
u"MFG Recommended (Ale, fresh yeast only)": 0.35,
u"MFG Recommended+ (Ale, fr... | return pitch_rate * GAL_PER_LITER * plato_per_gu |
Given the code snippet: <|code_start|> Pitch Rate Conversion
Input should be given in:
Imperial: B / (Gal * GU)
SI: B / (L * P)
Note: 1 M / (ml * P) == 1B / (L * P)
"""
plato_per_gu = sg_to_gu(plato_to_sg(1))
if units == IMPERIAL_UNITS:
return pitch_rate * GAL_PER_LITER * ... | self.types = IMPERIAL_TYPES |
Given the following code snippet before the placeholder: <|code_start|> u"PITCH_RATE_MAP",
u"pitch_rate_conversion",
u"YeastModel",
u"KaiserYeastModel",
u"WhiteYeastModel",
]
"""
1 billion cells growth per gram of extract (B/g) =
13.3 Million cells / (ml * P)
Ale: 0.75 M / ml / P = 0.71 B ... | def pitch_rate_conversion(pitch_rate, units=IMPERIAL_UNITS): |
Given the following code snippet before the placeholder: <|code_start|>Hybrid: 1.00 M / ml / P = 0.948 B / G / SG
"""
# Pitch rate in M / ml / P
PITCH_RATE_MAP = {
u"MFG Recommended (Ale, fresh yeast only)": 0.35,
u"MFG Recommended+ (Ale, fresh yeast only)": 0.55,
u"Pro Brewer (Ale, LG)": 0.75,
u"Pro ... | return pitch_rate * LITER_PER_GAL / plato_per_gu |
Predict the next line for this snippet: <|code_start|> return {
u"original_gravity": original_gravity,
u"final_volume": final_volume,
u"target_pitch_rate": target_pitch_rate,
u"viability": round(viability, 2),
u"cells": round(cells, 2),
u"pi... | dme = dme * OZ_PER_G * LITER_PER_GAL |
Given snippet: <|code_start|> Input should be given in:
Imperial: B / (Gal * GU)
SI: B / (L * P)
Note: 1 M / (ml * P) == 1B / (L * P)
"""
plato_per_gu = sg_to_gu(plato_to_sg(1))
if units == IMPERIAL_UNITS:
return pitch_rate * GAL_PER_LITER * plato_per_gu
elif units == SI_UN... | self.types = SI_TYPES |
Given the code snippet: <|code_start|>Lager: 1.50 M / ml / P = 1.42 B / G / SG
Hybrid: 1.00 M / ml / P = 0.948 B / G / SG
"""
# Pitch rate in M / ml / P
PITCH_RATE_MAP = {
u"MFG Recommended (Ale, fresh yeast only)": 0.35,
u"MFG Recommended+ (Ale, fresh yeast only)": 0.55,
u"Pro Brewer (Ale, LG)": 0.75,
... | elif units == SI_UNITS: |
Given the code snippet: <|code_start|> u"Pro Brewer (Ale)": 1.0,
u"Pro Brewer (Ale, HG)": 1.25,
u"Pro Brewer (Lager, LG)": 1.5,
u"Pro Brewer (Lager)": 1.75,
u"Pro Brewer (Lager, HG)": 2.0,
}
def pitch_rate_conversion(pitch_rate, units=IMPERIAL_UNITS):
"""
Pitch Rate Conversion
Input sh... | raise YeastException( |
Predict the next line for this snippet: <|code_start|>def pitch_rate_conversion(pitch_rate, units=IMPERIAL_UNITS):
"""
Pitch Rate Conversion
Input should be given in:
Imperial: B / (Gal * GU)
SI: B / (L * P)
Note: 1 M / (ml * P) == 1B / (L * P)
"""
plato_per_gu = sg_to_gu(plato_t... | self.units = validate_units(units) |
Using the snippet: <|code_start|> 13.3 Million cells / (ml * P)
Ale: 0.75 M / ml / P = 0.71 B / G / SG
Lager: 1.50 M / ml / P = 1.42 B / G / SG
Hybrid: 1.00 M / ml / P = 0.948 B / G / SG
"""
# Pitch rate in M / ml / P
PITCH_RATE_MAP = {
u"MFG Recommended (Ale, fresh yeast only)": 0.35,
u"MFG Recomme... | plato_per_gu = sg_to_gu(plato_to_sg(1)) |
Given snippet: <|code_start|> 13.3 Million cells / (ml * P)
Ale: 0.75 M / ml / P = 0.71 B / G / SG
Lager: 1.50 M / ml / P = 1.42 B / G / SG
Hybrid: 1.00 M / ml / P = 0.948 B / G / SG
"""
# Pitch rate in M / ml / P
PITCH_RATE_MAP = {
u"MFG Recommended (Ale, fresh yeast only)": 0.35,
u"MFG Recommended... | plato_per_gu = sg_to_gu(plato_to_sg(1)) |
Given snippet: <|code_start|> num_packs=1,
days_since_manufacture=30,
):
"""
Determine yeast pitch rate
original_gravity - specific gravity of original beer
final_volume - volume of the batch post fermentation
target_pitch_rate - million cells / (ml * de... | modifier = sg_to_plato(original_gravity) |
Based on the snippet: <|code_start|>#! /usr/bin/env python
"""
This recreates Glenn Tinseth's Hop Utilization table from
http://realbeer.com/hops/research.html
"""
def main():
<|code_end|>
, predict the immediate next line with the help of imports:
from brew.hops import HopsUtilizationGlennTinseth
and context (c... | print(HopsUtilizationGlennTinseth.format_utilization_table()) |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class TestTemperatureUtilities(unittest.TestCase):
def test_celsius_to_fahrenheit(self):
ftemp = celsius_to_fahrenheit(100.0)
self.assertEquals(ftemp, 212.0)
ftemp = celsius_to_fahrenheit(0.0)
self.assertEquals(ftemp, 32.... | bp = boiling_point(0) |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
class TestTemperatureUtilities(unittest.TestCase):
def test_celsius_to_fahrenheit(self):
ftemp = celsius_to_fahrenheit(100.0)
self.assertEquals(ftemp, 212.0)
ftemp = celsius_to_fahrenheit(0.0)
self.assertEquals(ftemp, 32.0)
... | ctemp = fahrenheit_to_celsius(212.0) |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
class TestTemperatureUtilities(unittest.TestCase):
def test_celsius_to_fahrenheit(self):
ftemp = celsius_to_fahrenheit(100.0)
self.assertEquals(ftemp, 212.0)
ftemp = celsius_to_fahrenheit(0.0)
self.assertEquals(ftemp, 32.0)
... | vol = mash_infusion(140.0, 104.0, 8.0, 8.0, 210.0) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
class TestTemperatureUtilities(unittest.TestCase):
def test_celsius_to_fahrenheit(self):
ftemp = celsius_to_fahrenheit(100.0)
self.assertEquals(ftemp, 212.0)
ftemp = celsius_to_fahrenheit(0.0)
self.asser... | temp = strike_temp(104.0, 70.0, 1.0 / 1.0) |
Continue the code snippet: <|code_start|>#! /usr/bin/env python
"""
Ray Daniels
Designing Great Beers
Appendix 2: Course Grind Potential Extract (modified)
Notes:
The chart appears to have been developed with the moisture content set
to zero (0.0) and the Brew House Efficiency set to 100% (1.0). This
... | sg = sg_from_dry_basis( |
Continue the code snippet: <|code_start|>#! /usr/bin/env python
"""
Ray Daniels
Designing Great Beers
Appendix 2: Course Grind Potential Extract (modified)
Notes:
The chart appears to have been developed with the moisture content set
to zero (0.0) and the Brew House Efficiency set to 100% (1.0). This
... | gu = sg_to_gu(sg) |
Next line prediction: <|code_start|>
recipe = {
u"name": u"Scottish Amber (Extract)",
u"start_volume": 5.0,
u"final_volume": 5.0,
u"grains": [
{u"name": u"Pale Liquid Extract", u"weight": 7.0, u"grain_type": u"lme"},
{
u"name": u"Caramel Crysta... | loader = JSONDataLoader(data_dir) |
Here is a snippet: <|code_start|> recipe = {
u"name": u"Scottish Amber (Extract)",
u"start_volume": 5.0,
u"final_volume": 5.0,
u"grains": [
{u"name": u"Pale Liquid Extract", u"weight": 7.0, u"grain_type": u"lme"},
{
u"name": u"Caramel Crystal Ma... | beer = parse_recipe(recipe, loader) |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
def get_temp_conversion(fahrenheit, celsius):
"""
Convert temperature between fahrenheit and celsius
"""
if fahrenheit:
return round(fahrenheit_to_celsius(fahrenheit), 1)
elif celsius:
<|code_end|>
, generate the next line usin... | return round(celsius_to_fahrenheit(celsius), 1) |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
def get_temp_conversion(fahrenheit, celsius):
"""
Convert temperature between fahrenheit and celsius
"""
if fahrenheit:
<|code_end|>
with the help of current file imports:
import argparse
import sys
from brew.utilities.te... | return round(fahrenheit_to_celsius(fahrenheit), 1) |
Here is a snippet: <|code_start|>#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
A utility for visualizing beer styles
"""
def main():
data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/"))
<|code_end|>
. Write the next line using the current file imports:
import os
from brew.styles import StyleFa... | factory = StyleFactory(os.path.join(data_dir, "bjcp", "styles.json")) |
Predict the next line after this snippet: <|code_start|> return u"\n".join(msg_list)
def get_parser():
parser = argparse.ArgumentParser(description=u"Yeast Pitch Calculator")
parser.add_argument(
u"--og",
metavar=u"O",
type=float,
default=1.05,
help=u"Wort Original G... | default=2.0 * GAL_PER_LITER, |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
"""
Yeast Pitch Calculator
This replicates other calculators found here:
- http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
""" # noqa
def get_yeast_pitch_calculation(
model_cls=WhiteYeastModel,
method=u"stir plate"... | units=IMPERIAL_UNITS, |
Predict the next line after this snippet: <|code_start|> type=str,
default=u"white",
help=u"Model of yeast growth, white or kaiser (default: %(default)s)",
) # noqa
parser.add_argument(
u"--method",
metavar=u"M",
type=str,
default=u"stir plate",
he... | if args.units not in [IMPERIAL_UNITS, SI_UNITS]: |
Based on the snippet: <|code_start|> default=u"stir plate",
help=u"Method of growth (default: %(default)s)",
) # noqa
parser.add_argument(
u"--units",
metavar=u"U",
type=str,
default=IMPERIAL_UNITS,
help=u"Units to use (default: %(default)s)",
)
re... | model_cls = KaiserYeastModel |
Given the code snippet: <|code_start|># -*- coding: utf-8 -*-
"""
Yeast Pitch Calculator
This replicates other calculators found here:
- http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/
""" # noqa
def get_yeast_pitch_calculation(
<|code_end|>
, generate the next line using the imports in... | model_cls=WhiteYeastModel, |
Based on the snippet: <|code_start|> u"grains": [
{u"name": u"Pilsner 2 row Ger", u"data": {u"color": 2.3}, u"weight": 5.0},
{u"name": u"Munich Malt 10L", u"data": {u"color": 9.0}, u"weight": 4.0},
{u"name": u"Vienna Malt", u"weight": 3.0},
{
u"name... | loader = JSONDataLoader(data_dir) |
Predict the next line after this snippet: <|code_start|> {u"name": u"Pilsner 2 row Ger", u"data": {u"color": 2.3}, u"weight": 5.0},
{u"name": u"Munich Malt 10L", u"data": {u"color": 9.0}, u"weight": 4.0},
{u"name": u"Vienna Malt", u"weight": 3.0},
{
u"name"... | beer = parse_recipe(recipe, loader) |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class TestEfficiencyUtilities(unittest.TestCase):
def setUp(self):
self.recipe = recipe
def test_calculate_brew_house_yield(self):
<|code_end|>
, predict the immediate next line with the help of imports:
import unittest
from brew.utilities... | out = calculate_brew_house_yield( |
Given the following code snippet before the placeholder: <|code_start|> def test_get_sugar_conversion_sg_to_brix(self):
out = get_sugar_conversion(None, None, self.sg, u"b")
self.assertEquals(round(out, 1), self.brix)
def test_get_sugar_conversion_sg_to_plato(self):
out = get_sugar_conve... | self.parser = get_parser() |
Based on the snippet: <|code_start|># -*- coding: utf-8 -*-
class TestCliSugar(unittest.TestCase):
def setUp(self):
self.brix = 22.0
self.plato = 22.0
self.sg = 1.092
def test_get_sugar_conversion_brix_to_brix(self):
<|code_end|>
, predict the immediate next line with the help of imp... | out = get_sugar_conversion(self.brix, None, None, u"b") |
Given the following code snippet before the placeholder: <|code_start|> expected = {u"brix": None, u"plato": None, u"sg": 1.060, u"out": None}
self.assertEquals(out.__dict__, expected)
def test_get_parser_sg_in_brix_out(self):
args = [u"-s", u"1.060", u"-o", u"b"]
out = self.parser.p... | self.main = main |
Using the snippet: <|code_start|> u"data": {u"color": 9.0, u"ppg": 37},
u"weight": 0.5,
u"grain_type": u"lme",
},
{
u"name": u"Caramunich Malt",
u"data": {u"color": 60.0},
u"weight": 0.125,
... | loader = JSONDataLoader(data_dir) |
Using the snippet: <|code_start|> u"weight": 0.5,
u"grain_type": u"lme",
},
{
u"name": u"Caramunich Malt",
u"data": {u"color": 60.0},
u"weight": 0.125,
u"grain_type": u"specialty",
},
... | beer = parse_recipe(recipe, loader) |
Continue the code snippet: <|code_start|> def test_ne_yeast_add_class(self):
self.assertTrue(yeast != cascade_add)
def test_to_dict(self):
out = self.yeast.to_dict()
expected = {u"name": u"Wyeast 1056", u"data": {u"percent_attenuation": 0.75}}
self.assertEquals(out, expected)
... | with self.assertRaises(YeastException) as ctx: |
Continue the code snippet: <|code_start|># -*- coding: utf-8 -*-
class TestYeasts(unittest.TestCase):
def setUp(self):
# Define Yeasts
self.yeast = yeast
def test_str(self):
out = str(self.yeast)
self.assertEquals(out, u"Wyeast 1056, attenuation 75.0%")
def test_unicode... | yeast = Yeast(u"Kölsh", percent_attenuation=0.74) |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
class TestCliTemp(unittest.TestCase):
def setUp(self):
self.ov = 3
self.fv = 10
self.gravity = 1.050
def test_get_gravity(self):
out = get_gravity(self.ov, self.fv, self.gravity)
self.asse... | self.parser = get_parser() |
Given snippet: <|code_start|># -*- coding: utf-8 -*-
class TestCliTemp(unittest.TestCase):
def setUp(self):
self.ov = 3
self.fv = 10
self.gravity = 1.050
def test_get_gravity(self):
<|code_end|>
, continue by predicting the next line. Consider current file imports:
import unittest
f... | out = get_gravity(self.ov, self.fv, self.gravity) |
Continue the code snippet: <|code_start|> def setUp(self):
self.parser = get_parser()
def test_get_parser(self):
args = [u"-o", u"3.0", u"-f", u"10.0", u"-g", u"1.050"]
out = self.parser.parse_args(args)
expected = {u"original_volume": 3.0, u"final_volume": 10.0, u"gravity": 1.05... | self.main = main |
Predict the next line after this snippet: <|code_start|># -*- coding: utf-8 -*-
__all__ = [
u"validate_grain_type",
u"validate_hop_type",
u"validate_percentage",
u"validate_units",
u"validate_required_fields",
u"validate_optional_fields",
]
def validate_grain_type(grain_type):
"""
Val... | if grain_type in GRAIN_TYPE_LIST: |
Predict the next line for this snippet: <|code_start|>]
def validate_grain_type(grain_type):
"""
Validate a grain type
:param str grain_type: Type of Grain
:return: grain type
:rtype: str
:raises ValidatorException: If grain type is unknown
"""
if grain_type in GRAIN_TYPE_LIST:
... | if hop_type in HOP_TYPE_LIST: |
Given snippet: <|code_start|> if hop_type in HOP_TYPE_LIST:
return hop_type
raise ValidatorException(
u"Unkown hop type '{}', must use {}".format(hop_type, u", ".join(HOP_TYPE_LIST))
)
def validate_percentage(percent):
"""
Validate decimal percentage
:param float percent: Perce... | if units in [IMPERIAL_UNITS, SI_UNITS]: |
Next line prediction: <|code_start|> if hop_type in HOP_TYPE_LIST:
return hop_type
raise ValidatorException(
u"Unkown hop type '{}', must use {}".format(hop_type, u", ".join(HOP_TYPE_LIST))
)
def validate_percentage(percent):
"""
Validate decimal percentage
:param float percent... | if units in [IMPERIAL_UNITS, SI_UNITS]: |
Using the snippet: <|code_start|># -*- coding: utf-8 -*-
__all__ = [
u"validate_grain_type",
u"validate_hop_type",
u"validate_percentage",
u"validate_units",
u"validate_required_fields",
u"validate_optional_fields",
]
def validate_grain_type(grain_type):
"""
Validate a grain type
... | raise ValidatorException( |
Next line prediction: <|code_start|># -*- coding: utf-8 -*-
__all__ = [u"calculate_brew_house_yield", u"get_wort_correction"]
def calculate_brew_house_yield(wort_volume, sg, grain_additions):
"""
Calculate Brew House Yield
:param float wort_volume: The volume of the wort
:param float sg: THe specif... | return (sg_to_gu(sg) * wort_volume) / total_gu |
Predict the next line for this snippet: <|code_start|># -*- coding: utf-8 -*-
__all__ = [u"calculate_brew_house_yield", u"get_wort_correction"]
def calculate_brew_house_yield(wort_volume, sg, grain_additions):
"""
Calculate Brew House Yield
:param float wort_volume: The volume of the wort
:param fl... | boil_gravity, boil_volume, final_gravity, final_volume, efficiency=PPG_DME |
Using the snippet: <|code_start|> :rtype: float
:raises SugarException: If temperature outside freezing to boiling range of water
The correction formula is from Lyons (1992), who used the following formula
to fit data from the Handbook of Chemistry and Physics (CRC):
:math:`\\text{Correction(@59F)}... | if temp == HYDROMETER_ADJUSTMENT_TEMP: |
Using the snippet: <|code_start|> """
Degrees Plato to Degrees Brix
:param float brix: Degrees Plato
:return: Degrees Brix
:rtype: float
"""
return sg_to_brix(plato_to_sg(plato))
def apparent_extract_to_real_extract(original_extract, apparent_extract):
"""
Apparent Extract to Real ... | def hydrometer_adjustment(sg, temp, units=IMPERIAL_UNITS): |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.