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() self.stop() if self.__timeout is not None: self.io_loop.remove_timeout(self.__timeout) self.__timeout = self.io_loop.add_timeout(time.time() + timeout, timeout_func) while True: self.__running = True with NullContext(): # Wipe out the StackContext that was established in # self.run() so that all callbacks executed inside the # IOLoop will re-run it. self.io_loop.start() if (self.__failure is not None or condition is None or condition()): break assert self.__stopped self.__stopped = False self.__rethrow() result = self.__stop_args self.__stop_args = None return result def __rethrow(self): if self.__failure is not None: failure = self.__failure self.__failure = None <|code_end|> with the help of current file imports: import sys import time import unittest import logging import mimetypes from tornado.httpclient import AsyncHTTPClient from tornado.ioloop import IOLoop from tornado.stack_context import NullContext from tornado.escape import json_encode from tornado import web from tornado.web import HTTPError from torext.utils import raise_exc_info from torext.compat import SimpleCookie, quote, urlencode, httplib and context from other files: # Path: torext/utils.py # def generate_cookie_secret(): # def timesince(t): # def pprint(o): # def instance(cls, *args, **kwgs): # def split_kwargs(kwgs_tuple, kwgs): # def __getattr__(self, key): # def __setattr__(self, key, value): # def __delattr__(self, key): # def __str__(self): # def _resolve_name(name, package, level): # def import_module(name, package=None): # def add_to_syspath(pth, relative_to=None): # def start_shell(extra_vars=None): # def complete(self, text, state): # def fix_request_arguments(arguments): # def __init__(self, local, name=None): # def get_current_object(self): # def __dict__(self): # def __repr__(self): # def __bool__(self): # def __unicode__(self): # def __dir__(self): # def __getattr__(self, name): # def __setitem__(self, key, value): # def __delitem__(self, key): # def __setslice__(self, i, j, seq): # def __delslice__(self, i, j): # class SingletonMixin(object): # class ObjectDict(dict): # class CustomCompleter(rlcompleter.Completer): # class LocalProxy(object): # # Path: torext/compat.py # PY3 = sys.version_info.major == 3 # PY2 = sys.version_info.major == 2 # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): , which may contain function names, class names, or code. Output only the next line.
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 invoking `setup` successfully within next test function It is suggested to be called in `TestCase.tearDown` """ # start::tornado.testing.AsyncHTTPTestCase self.http_server.stop() if (not IOLoop.initialized() or self.http_client.io_loop is not IOLoop.instance()): self.http_client.close() # end::tornado.testing.AsyncHTTPTestCase # start::tornado.testing.AsyncTestCase if (not IOLoop.initialized() or self.io_loop is not IOLoop.instance()): # Try to clean up any file descriptors left open in the ioloop. # This avoids leaks, especially when tests are run repeatedly # in the same process with autoreload (because curl does not # set FD_CLOEXEC on its file descriptors) self.io_loop.close(all_fds=True) # end::tornado.testing.AsyncTestCase def _parse_cookies(self, resp): if COOKIE_HEADER_KEY in resp.headers: <|code_end|> , generate the next line using the imports in this file: import sys import time import unittest import logging import mimetypes from tornado.httpclient import AsyncHTTPClient from tornado.ioloop import IOLoop from tornado.stack_context import NullContext from tornado.escape import json_encode from tornado import web from tornado.web import HTTPError from torext.utils import raise_exc_info from torext.compat import SimpleCookie, quote, urlencode, httplib and context (functions, classes, or occasionally code) from other files: # Path: torext/utils.py # def generate_cookie_secret(): # def timesince(t): # def pprint(o): # def instance(cls, *args, **kwgs): # def split_kwargs(kwgs_tuple, kwgs): # def __getattr__(self, key): # def __setattr__(self, key, value): # def __delattr__(self, key): # def __str__(self): # def _resolve_name(name, package, level): # def import_module(name, package=None): # def add_to_syspath(pth, relative_to=None): # def start_shell(extra_vars=None): # def complete(self, text, state): # def fix_request_arguments(arguments): # def __init__(self, local, name=None): # def get_current_object(self): # def __dict__(self): # def __repr__(self): # def __bool__(self): # def __unicode__(self): # def __dir__(self): # def __getattr__(self, name): # def __setitem__(self, key, value): # def __delitem__(self, key): # def __setslice__(self, i, j, seq): # def __delslice__(self, i, j): # class SingletonMixin(object): # class ObjectDict(dict): # class CustomCompleter(rlcompleter.Completer): # class LocalProxy(object): # # Path: torext/compat.py # PY3 = sys.version_info.major == 3 # PY2 = sys.version_info.major == 2 # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): . Output only the next line.
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 = parts[i][0:2] if len(h) == 2 and h.isalnum(): c = chr(int(h, 16)) if c in UNRESERVED_SET: parts[i] = c + parts[i][2:] else: parts[i] = '%' + parts[i] else: parts[i] = '%' + parts[i] return ''.join(parts) def requote_uri(uri): """Re-quote the given URI. This function passes the given URI through an unquote/quote cycle to ensure that it is fully and consistently quoted. """ # Unquote only the unreserved characters # Then quote only illegal characters (do not quote reserved, unreserved, # or '%') <|code_end|> . Write the next line using the current file imports: import sys import time import unittest import logging import mimetypes from tornado.httpclient import AsyncHTTPClient from tornado.ioloop import IOLoop from tornado.stack_context import NullContext from tornado.escape import json_encode from tornado import web from tornado.web import HTTPError from torext.utils import raise_exc_info from torext.compat import SimpleCookie, quote, urlencode, httplib and context from other files: # Path: torext/utils.py # def generate_cookie_secret(): # def timesince(t): # def pprint(o): # def instance(cls, *args, **kwgs): # def split_kwargs(kwgs_tuple, kwgs): # def __getattr__(self, key): # def __setattr__(self, key, value): # def __delattr__(self, key): # def __str__(self): # def _resolve_name(name, package, level): # def import_module(name, package=None): # def add_to_syspath(pth, relative_to=None): # def start_shell(extra_vars=None): # def complete(self, text, state): # def fix_request_arguments(arguments): # def __init__(self, local, name=None): # def get_current_object(self): # def __dict__(self): # def __repr__(self): # def __bool__(self): # def __unicode__(self): # def __dir__(self): # def __getattr__(self, name): # def __setitem__(self, key, value): # def __delitem__(self, key): # def __setslice__(self, i, j, seq): # def __delslice__(self, i, j): # class SingletonMixin(object): # class ObjectDict(dict): # class CustomCompleter(rlcompleter.Completer): # class LocalProxy(object): # # Path: torext/compat.py # PY3 = sys.version_info.major == 3 # PY2 = sys.version_info.major == 2 # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): , which may include functions, classes, or code. Output only the next line.
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-Type'] = 'multipart/form-data; boundary=%s' % boundary L = [] if data: for k, v in data.items(): L.append('--' + boundary) L.append('Content-Disposition: form-data; name="%s"' % k) L.append('') L.append(v) for k, f in files.items(): L.append('--' + boundary) L.append('Content-Disposition: form-data; name="%s"; filename="%s"' % (k, f[0])) L.append('Content-Type: %s' % mimetypes.guess_type(f[0])[0] or 'application/octet-stream') L.append('') L.append(f[1]) L.append('--%s--' % boundary) L.append('') body = '\r\n'.join(L) else: if data: if json: body = json_encode(data) headers['Content-Type'] = 'application/json' else: headers['Content-Type'] = 'application/x-www-form-urlencoded' <|code_end|> . Use current file imports: (import sys import time import unittest import logging import mimetypes from tornado.httpclient import AsyncHTTPClient from tornado.ioloop import IOLoop from tornado.stack_context import NullContext from tornado.escape import json_encode from tornado import web from tornado.web import HTTPError from torext.utils import raise_exc_info from torext.compat import SimpleCookie, quote, urlencode, httplib) and context including class names, function names, or small code snippets from other files: # Path: torext/utils.py # def generate_cookie_secret(): # def timesince(t): # def pprint(o): # def instance(cls, *args, **kwgs): # def split_kwargs(kwgs_tuple, kwgs): # def __getattr__(self, key): # def __setattr__(self, key, value): # def __delattr__(self, key): # def __str__(self): # def _resolve_name(name, package, level): # def import_module(name, package=None): # def add_to_syspath(pth, relative_to=None): # def start_shell(extra_vars=None): # def complete(self, text, state): # def fix_request_arguments(arguments): # def __init__(self, local, name=None): # def get_current_object(self): # def __dict__(self): # def __repr__(self): # def __bool__(self): # def __unicode__(self): # def __dir__(self): # def __getattr__(self, name): # def __setitem__(self, key, value): # def __delitem__(self, key): # def __setslice__(self, i, j, seq): # def __delslice__(self, i, j): # class SingletonMixin(object): # class ObjectDict(dict): # class CustomCompleter(rlcompleter.Completer): # class LocalProxy(object): # # Path: torext/compat.py # PY3 = sys.version_info.major == 3 # PY2 = sys.version_info.major == 2 # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): . Output only the next line.
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(), self.get_http_port(), path) def get_handler_exc(self): if self._handler_exc_info: raise_exc_info(self._handler_exc_info) def patch_handler(self, hdr): if not isinstance(hdr, web.StaticFileHandler): hdr._testing_app_client = self hdr._handle_request_exception = _handle_request_exception def patch_app_handlers(self): for host_pattern, rules in self.app.application.handlers: for r in rules: self.patch_handler(r.handler_class) def _handle_request_exception(self, e): if isinstance(e, HTTPError): if e.log_message: format = "%d %s: " + e.log_message args = [e.status_code, self._request_summary()] + list(e.args) logging.warning(format, *args) <|code_end|> , predict the next line using imports from the current file: import sys import time import unittest import logging import mimetypes from tornado.httpclient import AsyncHTTPClient from tornado.ioloop import IOLoop from tornado.stack_context import NullContext from tornado.escape import json_encode from tornado import web from tornado.web import HTTPError from torext.utils import raise_exc_info from torext.compat import SimpleCookie, quote, urlencode, httplib and context including class names, function names, and sometimes code from other files: # Path: torext/utils.py # def generate_cookie_secret(): # def timesince(t): # def pprint(o): # def instance(cls, *args, **kwgs): # def split_kwargs(kwgs_tuple, kwgs): # def __getattr__(self, key): # def __setattr__(self, key, value): # def __delattr__(self, key): # def __str__(self): # def _resolve_name(name, package, level): # def import_module(name, package=None): # def add_to_syspath(pth, relative_to=None): # def start_shell(extra_vars=None): # def complete(self, text, state): # def fix_request_arguments(arguments): # def __init__(self, local, name=None): # def get_current_object(self): # def __dict__(self): # def __repr__(self): # def __bool__(self): # def __unicode__(self): # def __dir__(self): # def __getattr__(self, name): # def __setitem__(self, key, value): # def __delitem__(self, key): # def __setslice__(self, i, j, seq): # def __delslice__(self, i, j): # class SingletonMixin(object): # class ObjectDict(dict): # class CustomCompleter(rlcompleter.Completer): # class LocalProxy(object): # # Path: torext/compat.py # PY3 = sys.version_info.major == 3 # PY2 = sys.version_info.major == 2 # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): # def unicode_(s, *args): # def decode_(s, *args): # def bytes_(s): # def str_(s): . Output only the next line.
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 predicting the next line. Consider current file imports: from torext.errors import CommandArgumentError from torext.script import Command from nose.tools import assert_raises and context: # Path: torext/errors.py # class CommandArgumentError(TorextException): # pass # # Path: torext/script.py # class Command(object): # allow_types = (int, float, str, str, bool) # # def __init__(self, func, profile=False): # self.func = func # self.profile_flag = profile # # spec = inspect.getargspec(func) # # argnames = (spec.args or [])[:] # defaults = list(spec.defaults or []) # # self.parameters = argnames[:len(argnames) - len(defaults)] # self.keyword_parameters = dict(list(zip(argnames[- len(defaults):], defaults))) # # # Check defined keyword parameters # for k, v in self.keyword_parameters.items(): # self._get_value_type(v) # # self.has_varargs = bool(spec.varargs) # self.has_kwargs = bool(spec.keywords) # # if func.__doc__: # doc = func.__doc__ # if '\n' in doc: # doc = ' '.join(i.strip() for i in doc.split('\n')) # else: # doc = "Command '%s' in manage script" % func.__name__ # self.doc = doc # # def parse_args(self, all_args=None): # if all_args is not None: # all_args = all_args[:] # else: # all_args = sys.argv[2:] # # _kw_pos = [] # for loop, i in enumerate(all_args): # if i.startswith('--'): # _kw_pos.append(loop) # # if _kw_pos: # # Check positions # all_args_len = len(all_args) # _fixed_kw_pos = _kw_pos + [all_args_len] # for loop, i in enumerate(_fixed_kw_pos): # if i == all_args_len: # continue # if _fixed_kw_pos[loop + 1] - i != 2: # raise CommandArgumentError( # 'Invalid arguments: %s should have one and only one value' % all_args[i]) # # # Get args and keyword_args # args = all_args[:_kw_pos[0]] # #keyword_args = {all_args[i][2:]: all_args[i + 1] for i in _kw_pos} # keyword_args = dict((all_args[i][2:], all_args[i + 1]) for i in _kw_pos) # else: # args = all_args # keyword_args = {} # # # Check args # if len(args) < len(self.parameters): # raise CommandArgumentError('Arguments too little') # else: # if not self.has_varargs and\ # len(args) > len(self.parameters) + len(self.keyword_parameters): # raise CommandArgumentError('Arguments too much') # # # Check keyword args # if not self.has_kwargs: # for i in keyword_args: # if not i in self.keyword_parameters: # raise CommandArgumentError('Unknown keyword parameter %s' % i) # # # Convert keyword args type # # NOTE As keyword arguments passed as arguments are allwed, # # and only recognized keyword arguments will be converted, # # so keyword arguments passed as arguments will not be converted. # for i in keyword_args: # if i in self.keyword_parameters: # default = self.keyword_parameters[i] # converted = self._convert_to_type( # keyword_args[i], self._get_value_type(default)) # keyword_args[i] = converted # # return args, keyword_args # # def _get_value_type(self, value): # if isinstance(value, self.allow_types): # typ = type(value) # elif value is None: # typ = None # else: # raise TypeError('Parameters for command function can only be type of %s' % self.allow_types) # return typ # # def _convert_to_type(self, source, typ): # if typ in (int, float, str, str): # try: # v = typ(source) # except ValueError: # raise CommandArgumentError("'%s' could not be converted to %s" # % (source, typ)) # elif typ == bool: # if source in ('True', '1'): # v = True # elif source in ('False', '0'): # v = False # else: # raise CommandArgumentError("'%s' could not be converted to bool type" % source) # elif typ is None: # v = source # # return v # # def execute(self, all_args=()): # if not all_args: # return self.func() # else: # args, keyword_args = self.parse_args(all_args) # return self.func(*args, **keyword_args) which might include code, classes, or functions. Output only the next line.
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 Command from nose.tools import assert_raises and context (class names, function names, or code) available: # Path: torext/errors.py # class CommandArgumentError(TorextException): # pass # # Path: torext/script.py # class Command(object): # allow_types = (int, float, str, str, bool) # # def __init__(self, func, profile=False): # self.func = func # self.profile_flag = profile # # spec = inspect.getargspec(func) # # argnames = (spec.args or [])[:] # defaults = list(spec.defaults or []) # # self.parameters = argnames[:len(argnames) - len(defaults)] # self.keyword_parameters = dict(list(zip(argnames[- len(defaults):], defaults))) # # # Check defined keyword parameters # for k, v in self.keyword_parameters.items(): # self._get_value_type(v) # # self.has_varargs = bool(spec.varargs) # self.has_kwargs = bool(spec.keywords) # # if func.__doc__: # doc = func.__doc__ # if '\n' in doc: # doc = ' '.join(i.strip() for i in doc.split('\n')) # else: # doc = "Command '%s' in manage script" % func.__name__ # self.doc = doc # # def parse_args(self, all_args=None): # if all_args is not None: # all_args = all_args[:] # else: # all_args = sys.argv[2:] # # _kw_pos = [] # for loop, i in enumerate(all_args): # if i.startswith('--'): # _kw_pos.append(loop) # # if _kw_pos: # # Check positions # all_args_len = len(all_args) # _fixed_kw_pos = _kw_pos + [all_args_len] # for loop, i in enumerate(_fixed_kw_pos): # if i == all_args_len: # continue # if _fixed_kw_pos[loop + 1] - i != 2: # raise CommandArgumentError( # 'Invalid arguments: %s should have one and only one value' % all_args[i]) # # # Get args and keyword_args # args = all_args[:_kw_pos[0]] # #keyword_args = {all_args[i][2:]: all_args[i + 1] for i in _kw_pos} # keyword_args = dict((all_args[i][2:], all_args[i + 1]) for i in _kw_pos) # else: # args = all_args # keyword_args = {} # # # Check args # if len(args) < len(self.parameters): # raise CommandArgumentError('Arguments too little') # else: # if not self.has_varargs and\ # len(args) > len(self.parameters) + len(self.keyword_parameters): # raise CommandArgumentError('Arguments too much') # # # Check keyword args # if not self.has_kwargs: # for i in keyword_args: # if not i in self.keyword_parameters: # raise CommandArgumentError('Unknown keyword parameter %s' % i) # # # Convert keyword args type # # NOTE As keyword arguments passed as arguments are allwed, # # and only recognized keyword arguments will be converted, # # so keyword arguments passed as arguments will not be converted. # for i in keyword_args: # if i in self.keyword_parameters: # default = self.keyword_parameters[i] # converted = self._convert_to_type( # keyword_args[i], self._get_value_type(default)) # keyword_args[i] = converted # # return args, keyword_args # # def _get_value_type(self, value): # if isinstance(value, self.allow_types): # typ = type(value) # elif value is None: # typ = None # else: # raise TypeError('Parameters for command function can only be type of %s' % self.allow_types) # return typ # # def _convert_to_type(self, source, typ): # if typ in (int, float, str, str): # try: # v = typ(source) # except ValueError: # raise CommandArgumentError("'%s' could not be converted to %s" # % (source, typ)) # elif typ == bool: # if source in ('True', '1'): # v = True # elif source in ('False', '0'): # v = False # else: # raise CommandArgumentError("'%s' could not be converted to bool type" % source) # elif typ is None: # v = source # # return v # # def execute(self, all_args=()): # if not all_args: # return self.func() # else: # args, keyword_args = self.parse_args(all_args) # return self.func(*args, **keyword_args) . Output only the next line.
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 names, or small code snippets from other files: # Path: torext/compat.py # def decode_(s, *args): # return s.decode(*args) # # PY2 = sys.version_info.major == 2 . Output only the next line.
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 torext.compat import decode_, PY2) and context including class names, function names, or small code snippets from other files: # Path: torext/compat.py # def decode_(s, *args): # return s.decode(*args) # # PY2 = sys.version_info.major == 2 . Output only the next line.
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 IndexError: raise CommandInputError('one arg is required') # If it's not a valid directory/file name. if not re.search(r'^[_a-zA-Z]\w*$', name): # Provide a smart error message, depending on the error. if not re.search(r'^[_a-zA-Z]', name): message = 'make sure the name begins with a letter or underscore' else: message = 'use only numbers, letters and underscores' raise CommandInputError(message) cwd = os.getcwd() torext_path = os.path.dirname(torext.__file__) # Check that the project name cannot be imported. try: <|code_end|> . Write the next line using the current file imports: import os import re import sys import shutil import optparse import torext from torext.utils import import_module and context from other files: # Path: torext/utils.py # def import_module(name, package=None): # """Import a module. # # The 'package' argument is required when performing a relative import. It # specifies the package to use as the anchor point from which to resolve the # relative import to an absolute import. # # Usage: # >>> epoll_module = import_module('tornado.platform.epoll') # """ # if name.startswith('.'): # if not package: # raise TypeError("relative imports require the 'package' argument") # level = 0 # for character in name: # if character != '.': # break # level += 1 # name = _resolve_name(name[level:], package, level) # __import__(name) # return sys.modules[name] , which may include functions, classes, or code. Output only the next line.
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 = os.path.join(os.path.dirname(__file__), 'test.gpx') <|code_end|> . Use current file imports: (import os import pytest from D3HRE.core.route_utility import * from D3HRE.core.file_reading_utility import read_route_from_gpx) and context including class names, function names, or small code snippets from other files: # Path: D3HRE/core/file_reading_utility.py # def read_route_from_gpx(file): # """ # Read route from gpx file # # :param file: str, path to the .gpx file # :return: numpy array, contains all routes # """ # gpx_file = open(file) # gpx = gpxpy.parse(gpx_file) # all_routes = [] # for route in gpx.routes: # route_list = [] # for point in route.points: # route_list.append([point.latitude, point.longitude]) # all_routes.append(route_list) # return np.array(all_routes) . Output only the next line.
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.route = route self.speed = speed self.df = get_mission(self.start_time, self.route, self.speed) self.get_ID() def __str__(self): return "This mission {ID} is start from {a} at {b} UTC.".format( a=self.route[0], b=self.start_time, ID=self.ID ) def custom_set(self, mission_df, ID): self.df = mission_df self.ID = ID def get_ID(self): route_tuple = tuple(self.route.flatten().tolist()) if isinstance(self.speed, list): speed_tuple = tuple(self.speed) else: speed_tuple = self.speed ID_tuple = (self.start_time, route_tuple, speed_tuple) <|code_end|> . Use current file imports: import numpy as np import pandas as pd import nvector as nv from math import radians, cos, sin, asin, sqrt from datetime import timedelta from D3HRE.core.get_hash import hash_value from D3HRE.core.dataframe_utility import full_day_cut and context (classes, functions, or code) from other files: # Path: D3HRE/core/get_hash.py # def hash_value(data): # """ # Get hash of python object # # :param data: object or data # :return: the hash value for the data (full length) # """ # hashId = hashlib.md5() # hashId.update(repr(data).encode('utf-8')) # return hashId.hexdigest() # # Path: D3HRE/core/dataframe_utility.py # def full_day_cut(df): # ''' # Crop dataFrame at the end of the day # # :param df: pandas data frame # :return: pandas data frame that end at full day # ''' # df = df[0 : int(floor(len(df) / 24)) * 24] # return df . Output only the next line.
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(index + timedelta(hours=int(find_timezone(lons, row.lon)))) # time difference into timedelta # t_diff = list(map(lambda x: timedelta(hours=x), time_diff)) # local_time = mission.index + t_diff mission['local_time'] = local_time return mission def get_mission(start_time, route, speed): """ Calculate position dataFrame at given start time, route and speed :param start_time: str or Pandas Timestamp, the str input should have format YYYY-MM-DD close the day :param route: numpy array shape (n,2) list of way points formatted as [lat, lon] :param speed: int, float or (n) list, speed of platform unit in km/h :return: Pandas dataFrame """ if type(start_time) == str: start_time = pd.Timestamp(start_time) <|code_end|> . Use current file imports: import numpy as np import pandas as pd import nvector as nv from math import radians, cos, sin, asin, sqrt from datetime import timedelta from D3HRE.core.get_hash import hash_value from D3HRE.core.dataframe_utility import full_day_cut and context (classes, functions, or code) from other files: # Path: D3HRE/core/get_hash.py # def hash_value(data): # """ # Get hash of python object # # :param data: object or data # :return: the hash value for the data (full length) # """ # hashId = hashlib.md5() # hashId.update(repr(data).encode('utf-8')) # return hashId.hexdigest() # # Path: D3HRE/core/dataframe_utility.py # def full_day_cut(df): # ''' # Crop dataFrame at the end of the day # # :param df: pandas data frame # :return: pandas data frame that end at full day # ''' # df = df[0 : int(floor(len(df) / 24)) * 24] # return df . Output only the next line.
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 dataframe['kt'] = dataframe.SWGDN / (dataframe.SWTDN * zenith_cosine_list) # Maximum clearness index for hourly data pvlib dataframe.loc[dataframe.kt > 0.82, 'kt'] = 0.82 # Temperature processing dataframe['temperature'] = dataframe.T2M - 273.15 # Wind speed at 2 metres height dataframe['V2'] = np.sqrt(dataframe.V2M ** 2 + dataframe.U2M ** 2) # Get true wind direction from north ward and east ward wind speed dataframe['true_wind_direction'] = ( np.degrees(np.arctan2(dataframe['U2M'], dataframe['V2M'])) + 360 ) % 360 location_list = [tuple(x) for x in dataframe[['lat', 'lon']].values] # Calculate heading with initial compass bearing heading = [] for a, b in zip(location_list[:-1], location_list[1:]): <|code_end|> . Write the next line using the current file imports: import ephem import math import numpy as np from D3HRE.core.navigation_utility import calculate_initial_compass_bearing and context from other files: # Path: D3HRE/core/navigation_utility.py # def calculate_initial_compass_bearing(pointA, pointB): # """ # Calculate the compass bearing of the mvoing platform on point A and B. # # :param pointA: tuple or list in the format of [lat, lon] # :param pointB: tuple or list in the format of [lat, lon] # :return: float degrees compass bearing between A and B # """ # if (type(pointA) != tuple) or (type(pointB) != tuple): # raise TypeError("Only tuples are supported as arguments") # lat1 = math.radians(pointA[0]) # lat2 = math.radians(pointB[0]) # diffLong = math.radians(pointB[1] - pointA[1]) # x = math.sin(diffLong) * math.cos(lat2) # y = math.cos(lat1) * math.sin(lat2) - ( # math.sin(lat1) * math.cos(lat2) * math.cos(diffLong) # ) # initial_bearing = math.atan2(x, y) # # Now we have the initial bearing but math.atan2 return values # # from -180° to + 180° which is not what we want for a compass bearing # # The solution is to normalize the initial bearing as shown below # initial_bearing = math.degrees(initial_bearing) # compass_bearing = (initial_bearing + 360) % 360 # # return compass_bearing , which may include functions, classes, or code. Output only the next line.
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}, 'webcam': {'power': [0.6], 'duty_cycle': 1}, 'gps': {'power': [0.04, 0.4], 'duty_cycle': 0.9}, 'imu': {'power': [0.67, 1.1], 'duty_cycle': 0.9}, 'sonar': {'power': [0.5, 50], 'duty_cycle': 0.5}, 'ph_sensor': {'power': [0.08, 0.1], 'duty_cycle': 0.95}, 'temp_sensor': {'power': [0.04], 'duty_cycle': 1}, 'wind_sensor': {'power': [0.67, 1.1], 'duty_cycle': 0.5}, 'servo_motors': {'power': [0.4, 1.35], 'duty_cycle': 0.5}, 'radio_transmitter': {'power': [0.5, 20], 'duty_cycle': 0.2}} <|code_end|> , continue by predicting the next line. Consider current file imports: import pytest import numpy as np from D3HRE.core.mission_utility import Mission from D3HRE.simulation import Task from PyResis import propulsion_power and context: # Path: D3HRE/core/mission_utility.py # 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.route = route # self.speed = speed # self.df = get_mission(self.start_time, self.route, self.speed) # self.get_ID() # # def __str__(self): # return "This mission {ID} is start from {a} at {b} UTC.".format( # a=self.route[0], b=self.start_time, ID=self.ID # ) # # def custom_set(self, mission_df, ID): # self.df = mission_df # self.ID = ID # # def get_ID(self): # route_tuple = tuple(self.route.flatten().tolist()) # if isinstance(self.speed, list): # speed_tuple = tuple(self.speed) # else: # speed_tuple = self.speed # # ID_tuple = (self.start_time, route_tuple, speed_tuple) # self.ID = hash_value(ID_tuple) # return self.ID # # Path: D3HRE/simulation.py # class Task: # """ # Task is a high level object that contains the mission and the robot object. # """ # def __init__(self, mission, robot, power_consumption_list={}): # """ # # :param mission: Object mission object # :param robot: Object robot object # :param power_consumption_list: optional the list of demand load, only use in legacy mode # """ # self.mission = mission # self.robot = robot # if power_consumption_list != {}: # self.power_consumption_list = power_consumption_list # self.estimate_demand_load_compatible() # else: # self.estimate_demand_load() # # def estimate_demand_load_compatible(self): # new_robot = MaritimeRobot(self.power_consumption_list) # new_robot.set_from_PyResis(self.robot) # self.robot = new_robot # self.estimate_demand_load() # # def estimate_demand_load(self): # self.robot.estimate_demand_load(self.mission) # self.hotel_load = self.robot.hotel_load # self.prop_load = self.robot.prop_load # self.critical_hotel_load = self.robot.critical_hotel_load # self.critical_prop_load = self.robot.critical_prop_load # self.load_demand = self.hotel_load + self.prop_load which might include code, classes, or functions. Output only the next line.
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': 0.5}, 'webcam': {'power': [0.6], 'duty_cycle': 1}, 'gps': {'power': [0.04, 0.4], 'duty_cycle': 0.9}, 'imu': {'power': [0.67, 1.1], 'duty_cycle': 0.9}, 'sonar': {'power': [0.5, 50], 'duty_cycle': 0.5}, 'ph_sensor': {'power': [0.08, 0.1], 'duty_cycle': 0.95}, 'temp_sensor': {'power': [0.04], 'duty_cycle': 1}, 'wind_sensor': {'power': [0.67, 1.1], 'duty_cycle': 0.5}, 'servo_motors': {'power': [0.4, 1.35], 'duty_cycle': 0.5}, 'radio_transmitter': {'power': [0.5, 20], 'duty_cycle': 0.2}} test_mission = Mission('2014-01-01', test_route, 2) <|code_end|> , predict the immediate next line with the help of imports: import pytest import numpy as np from D3HRE.core.mission_utility import Mission from D3HRE.simulation import Task from PyResis import propulsion_power and context (classes, functions, sometimes code) from other files: # Path: D3HRE/core/mission_utility.py # 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.route = route # self.speed = speed # self.df = get_mission(self.start_time, self.route, self.speed) # self.get_ID() # # def __str__(self): # return "This mission {ID} is start from {a} at {b} UTC.".format( # a=self.route[0], b=self.start_time, ID=self.ID # ) # # def custom_set(self, mission_df, ID): # self.df = mission_df # self.ID = ID # # def get_ID(self): # route_tuple = tuple(self.route.flatten().tolist()) # if isinstance(self.speed, list): # speed_tuple = tuple(self.speed) # else: # speed_tuple = self.speed # # ID_tuple = (self.start_time, route_tuple, speed_tuple) # self.ID = hash_value(ID_tuple) # return self.ID # # Path: D3HRE/simulation.py # class Task: # """ # Task is a high level object that contains the mission and the robot object. # """ # def __init__(self, mission, robot, power_consumption_list={}): # """ # # :param mission: Object mission object # :param robot: Object robot object # :param power_consumption_list: optional the list of demand load, only use in legacy mode # """ # self.mission = mission # self.robot = robot # if power_consumption_list != {}: # self.power_consumption_list = power_consumption_list # self.estimate_demand_load_compatible() # else: # self.estimate_demand_load() # # def estimate_demand_load_compatible(self): # new_robot = MaritimeRobot(self.power_consumption_list) # new_robot.set_from_PyResis(self.robot) # self.robot = new_robot # self.estimate_demand_load() # # def estimate_demand_load(self): # self.robot.estimate_demand_load(self.mission) # self.hotel_load = self.robot.hotel_load # self.prop_load = self.robot.prop_load # self.critical_hotel_load = self.robot.critical_hotel_load # self.critical_prop_load = self.robot.critical_prop_load # self.load_demand = self.hotel_load + self.prop_load . Output only the next line.
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.25, u"grain_type": u"lme", }, { u"name": u"White Wheat Malt", u"weight": 0.25, u"grain_type": u"specialty", }, { u"name": u"Caramel Crystal Malt 10l", u"weight": 0.25, u"grain_type": u"specialty", }, ], u"hops": [ {u"name": u"Vanguard", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"hersbrucker", u"weight": 1.0, u"boil_time": 0.0}, ], u"yeast": {u"name": u"White Labs Wlp029"}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } 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.parsers import JSONDataLoader from brew.parsers import parse_recipe and context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer , which may include functions, classes, or code. Output only the next line.
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", }, { u"name": u"White Wheat Malt", u"weight": 0.25, u"grain_type": u"specialty", }, { u"name": u"Caramel Crystal Malt 10l", u"weight": 0.25, u"grain_type": u"specialty", }, ], u"hops": [ {u"name": u"Vanguard", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"hersbrucker", u"weight": 1.0, u"boil_time": 0.0}, ], u"yeast": {u"name": u"White Labs Wlp029"}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> . Use current file imports: (import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe) and context including class names, function names, or small code snippets from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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 20l", u"weight": 1.0, u"grain_type": u"specialty", }, {u"name": u"Munich Malt", u"weight": 0.5, u"grain_type": u"specialty"}, { u"name": u"Cara Pils Dextrine", u"weight": 0.5, u"grain_type": u"specialty", }, ], u"hops": [ {u"name": u"Centennial", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"Centennial", u"weight": 1.0, u"boil_time": 30.0}, {u"name": u"Cascade US", u"weight": 1.0, u"boil_time": 10.0}, {u"name": u"Cascade US", u"weight": 1.0, u"boil_time": 0.0}, ], u"yeast": {u"name": u"Wyeast 1056"}, u"data": {u"brew_house_yield": 0.425, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> , continue by predicting the next line. Consider current file imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe from brew.utilities.efficiency import calculate_brew_house_yield # noqa and context: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer # # Path: brew/utilities/efficiency.py # 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 specific gravity of the wort # :param list grain_additions: A list of grain additions in the wort # :type grain_additions: list of GrainAddition objects # :return: The brew house yield as a percentage # # Brew House Yield is a function of the wort volume, the measured specific # gravity, and the grain additions used to make the wort. This equation is # thrown off by use of LME or DME since both have 100% efficiency in a brew. # A better measure is to look at just the grains that needed to be steeped # seperately and measure the specific gravity of that process. # """ # total_gu = sum([grain_add.gu for grain_add in grain_additions]) # return (sg_to_gu(sg) * wort_volume) / total_gu which might include code, classes, or functions. Output only the next line.
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 Malt 20l", u"weight": 1.0, u"grain_type": u"specialty", }, {u"name": u"Munich Malt", u"weight": 0.5, u"grain_type": u"specialty"}, { u"name": u"Cara Pils Dextrine", u"weight": 0.5, u"grain_type": u"specialty", }, ], u"hops": [ {u"name": u"Centennial", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"Centennial", u"weight": 1.0, u"boil_time": 30.0}, {u"name": u"Cascade US", u"weight": 1.0, u"boil_time": 10.0}, {u"name": u"Cascade US", u"weight": 1.0, u"boil_time": 0.0}, ], u"yeast": {u"name": u"Wyeast 1056"}, u"data": {u"brew_house_yield": 0.425, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> . Write the next line using the current file imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe from brew.utilities.efficiency import calculate_brew_house_yield # noqa and context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer # # Path: brew/utilities/efficiency.py # 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 specific gravity of the wort # :param list grain_additions: A list of grain additions in the wort # :type grain_additions: list of GrainAddition objects # :return: The brew house yield as a percentage # # Brew House Yield is a function of the wort volume, the measured specific # gravity, and the grain additions used to make the wort. This equation is # thrown off by use of LME or DME since both have 100% efficiency in a brew. # A better measure is to look at just the grains that needed to be steeped # seperately and measure the specific gravity of that process. # """ # total_gu = sum([grain_add.gu for grain_add in grain_additions]) # return (sg_to_gu(sg) * wort_volume) / total_gu , which may include functions, classes, or code. Output only the next line.
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"color": 20.0, u"ppg": 35}, u"weight": 0.78, }, ], u"hops": [ { u"name": u"centennial", u"data": {u"percent_alpha_acids": 0.14}, u"weight": 0.57, u"boil_time": 60.0, }, { u"name": u"cascade us", u"data": {u"percent_alpha_acids": 0.07}, u"weight": 0.76, u"boil_time": 5.0, }, ], u"yeast": {u"name": u"Wyeast 1056", u"data": {u"percent_attenuation": 0.75}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> using the current file's imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and any relevant context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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}, u"weight": 0.78, }, ], u"hops": [ { u"name": u"centennial", u"data": {u"percent_alpha_acids": 0.14}, u"weight": 0.57, u"boil_time": 60.0, }, { u"name": u"cascade us", u"data": {u"percent_alpha_acids": 0.07}, u"weight": 0.76, u"boil_time": 5.0, }, ], u"yeast": {u"name": u"Wyeast 1056", u"data": {u"percent_attenuation": 0.75}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> . Use current file imports: (import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe) and context including class names, function names, or small code snippets from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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"}, { u"name": u"Caramel Crystal Malt 10l", u"weight": 1.0, u"grain_type": u"specialty", }, { u"name": u"Caramel Crystal Malt 60l", u"weight": 1.0, u"grain_type": u"specialty", }, { u"name": u"Caramel Crystal Malt 80l", u"weight": 1.0, u"grain_type": u"specialty", }, ], u"hops": [ {u"name": u"Chinook", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"Chinook", u"weight": 1.0, u"boil_time": 15.0}, ], u"yeast": {u"name": u"Wyeast 1084"}, u"data": {u"brew_house_yield": 0.7, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> . Use current file imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and context (classes, functions, or code) from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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 10l", u"weight": 1.0, u"grain_type": u"specialty", }, { u"name": u"Caramel Crystal Malt 60l", u"weight": 1.0, u"grain_type": u"specialty", }, { u"name": u"Caramel Crystal Malt 80l", u"weight": 1.0, u"grain_type": u"specialty", }, ], u"hops": [ {u"name": u"Chinook", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"Chinook", u"weight": 1.0, u"boil_time": 15.0}, ], u"yeast": {u"name": u"Wyeast 1084"}, u"data": {u"brew_house_yield": 0.7, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> . Use current file imports: (import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe) and context including class names, function names, or small code snippets from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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"percent_alpha_acids": 0.08}, u"weight": 1.43, u"boil_time": 60.0, }, { u"name": u"fuggle", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 1.5, u"boil_time": 10.0, }, { u"name": u"east kent golding", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 1.5, u"boil_time": 0.0, }, ], u"yeast": {u"name": u"Wyeast 1028", u"data": {u"percent_attenuation": 0.74}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> using the current file's imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and any relevant context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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, u"boil_time": 60.0, }, { u"name": u"fuggle", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 1.5, u"boil_time": 10.0, }, { u"name": u"east kent golding", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 1.5, u"boil_time": 0.0, }, ], u"yeast": {u"name": u"Wyeast 1028", u"data": {u"percent_attenuation": 0.74}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> with the help of current file imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer , which may contain function names, class names, or code. Output only the next line.
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.assertRaises(ValidatorException) as ctx: validate_grain_type(u"bad grain type") self.assertEquals( str(ctx.exception), u"Unkown grain type 'bad grain type', must use cereal, specialty, dme, lme", ) # noqa def test_validate_hop_type(self): <|code_end|> . Use current file imports: import unittest from brew.constants import GRAIN_TYPE_CEREAL from brew.constants import HOP_TYPE_PELLET from brew.exceptions import ValidatorException from brew.validators import validate_grain_type from brew.validators import validate_hop_type from brew.validators import validate_optional_fields from brew.validators import validate_percentage from brew.validators import validate_required_fields from brew.validators import validate_units and context (classes, functions, or code) from other files: # Path: brew/constants.py # GRAIN_TYPE_CEREAL = u"cereal" # # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass # # Path: brew/validators.py # 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: # return grain_type # raise ValidatorException( # u"Unkown grain type '{}', must use {}".format( # grain_type, u", ".join(GRAIN_TYPE_LIST) # ) # ) # # Path: brew/validators.py # def validate_hop_type(hop_type): # """ # Validate a hop type # # :param str hop_type: Type of Grain # :return: hop type # :rtype: str # :raises ValidatorException: If hop type is unknown # """ # 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)) # ) # # Path: brew/validators.py # def validate_optional_fields(data, optional_fields, data_field=u"data"): # """ # Validate fields which are optional as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) optional_fields: Values and types to check for in data # :param str data_field: The key in the data dictionary containing the optional fields # :raises ValidatorException: Optional field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # noqa # # If no optional data field present then return # if data_field not in data: # return # for field, field_type in optional_fields: # if field in data[data_field]: # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # # With optional fields only check the type as they are overrides # # and not all overrides need to be present # if not isinstance(data[data_field][field], field_type): # raise ValidatorException( # u"Optional field '{}' in '{}' is not of type '{}'".format( # noqa # field, data_field, field_type # ) # ) # # Path: brew/validators.py # def validate_percentage(percent): # """ # Validate decimal percentage # # :param float percent: Percentage between 0.0 and 1.0 # :return: percentage # :rtype: float # :raises ValidatorException: If decimal percentage not between 0.0 and 1.0 # """ # if 0.0 <= percent <= 1.0: # return percent # raise ValidatorException(u"Percentage values should be in decimal format") # # Path: brew/validators.py # def validate_required_fields(data, required_fields): # """ # Validate fields which are required as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) required_fields: Values and types to check for in data # :raises ValidatorException: Required field is missing from data # :raises ValidatorException: Required field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # for field, field_type in required_fields: # if field not in data: # raise ValidatorException( # u"Required field '{}' missing from data".format(field) # noqa # ) # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # if not isinstance(data[field], field_type): # raise ValidatorException( # u"Required field '{}' is not of type '{}'".format( # noqa # field, field_type # ) # ) # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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 current file imports: import unittest from brew.constants import GRAIN_TYPE_CEREAL from brew.constants import HOP_TYPE_PELLET from brew.exceptions import ValidatorException from brew.validators import validate_grain_type from brew.validators import validate_hop_type from brew.validators import validate_optional_fields from brew.validators import validate_percentage from brew.validators import validate_required_fields from brew.validators import validate_units and context (classes, functions, or code) from other files: # Path: brew/constants.py # GRAIN_TYPE_CEREAL = u"cereal" # # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass # # Path: brew/validators.py # 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: # return grain_type # raise ValidatorException( # u"Unkown grain type '{}', must use {}".format( # grain_type, u", ".join(GRAIN_TYPE_LIST) # ) # ) # # Path: brew/validators.py # def validate_hop_type(hop_type): # """ # Validate a hop type # # :param str hop_type: Type of Grain # :return: hop type # :rtype: str # :raises ValidatorException: If hop type is unknown # """ # 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)) # ) # # Path: brew/validators.py # def validate_optional_fields(data, optional_fields, data_field=u"data"): # """ # Validate fields which are optional as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) optional_fields: Values and types to check for in data # :param str data_field: The key in the data dictionary containing the optional fields # :raises ValidatorException: Optional field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # noqa # # If no optional data field present then return # if data_field not in data: # return # for field, field_type in optional_fields: # if field in data[data_field]: # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # # With optional fields only check the type as they are overrides # # and not all overrides need to be present # if not isinstance(data[data_field][field], field_type): # raise ValidatorException( # u"Optional field '{}' in '{}' is not of type '{}'".format( # noqa # field, data_field, field_type # ) # ) # # Path: brew/validators.py # def validate_percentage(percent): # """ # Validate decimal percentage # # :param float percent: Percentage between 0.0 and 1.0 # :return: percentage # :rtype: float # :raises ValidatorException: If decimal percentage not between 0.0 and 1.0 # """ # if 0.0 <= percent <= 1.0: # return percent # raise ValidatorException(u"Percentage values should be in decimal format") # # Path: brew/validators.py # def validate_required_fields(data, required_fields): # """ # Validate fields which are required as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) required_fields: Values and types to check for in data # :raises ValidatorException: Required field is missing from data # :raises ValidatorException: Required field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # for field, field_type in required_fields: # if field not in data: # raise ValidatorException( # u"Required field '{}' missing from data".format(field) # noqa # ) # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # if not isinstance(data[field], field_type): # raise ValidatorException( # u"Required field '{}' is not of type '{}'".format( # noqa # field, field_type # ) # ) # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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.assertRaises(ValidatorException) as ctx: validate_grain_type(u"bad grain type") self.assertEquals( str(ctx.exception), u"Unkown grain type 'bad grain type', must use cereal, specialty, dme, lme", ) # noqa def test_validate_hop_type(self): <|code_end|> . Use current file imports: (import unittest from brew.constants import GRAIN_TYPE_CEREAL from brew.constants import HOP_TYPE_PELLET from brew.exceptions import ValidatorException from brew.validators import validate_grain_type from brew.validators import validate_hop_type from brew.validators import validate_optional_fields from brew.validators import validate_percentage from brew.validators import validate_required_fields from brew.validators import validate_units) and context including class names, function names, or small code snippets from other files: # Path: brew/constants.py # GRAIN_TYPE_CEREAL = u"cereal" # # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass # # Path: brew/validators.py # 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: # return grain_type # raise ValidatorException( # u"Unkown grain type '{}', must use {}".format( # grain_type, u", ".join(GRAIN_TYPE_LIST) # ) # ) # # Path: brew/validators.py # def validate_hop_type(hop_type): # """ # Validate a hop type # # :param str hop_type: Type of Grain # :return: hop type # :rtype: str # :raises ValidatorException: If hop type is unknown # """ # 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)) # ) # # Path: brew/validators.py # def validate_optional_fields(data, optional_fields, data_field=u"data"): # """ # Validate fields which are optional as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) optional_fields: Values and types to check for in data # :param str data_field: The key in the data dictionary containing the optional fields # :raises ValidatorException: Optional field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # noqa # # If no optional data field present then return # if data_field not in data: # return # for field, field_type in optional_fields: # if field in data[data_field]: # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # # With optional fields only check the type as they are overrides # # and not all overrides need to be present # if not isinstance(data[data_field][field], field_type): # raise ValidatorException( # u"Optional field '{}' in '{}' is not of type '{}'".format( # noqa # field, data_field, field_type # ) # ) # # Path: brew/validators.py # def validate_percentage(percent): # """ # Validate decimal percentage # # :param float percent: Percentage between 0.0 and 1.0 # :return: percentage # :rtype: float # :raises ValidatorException: If decimal percentage not between 0.0 and 1.0 # """ # if 0.0 <= percent <= 1.0: # return percent # raise ValidatorException(u"Percentage values should be in decimal format") # # Path: brew/validators.py # def validate_required_fields(data, required_fields): # """ # Validate fields which are required as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) required_fields: Values and types to check for in data # :raises ValidatorException: Required field is missing from data # :raises ValidatorException: Required field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # for field, field_type in required_fields: # if field not in data: # raise ValidatorException( # u"Required field '{}' missing from data".format(field) # noqa # ) # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # if not isinstance(data[field], field_type): # raise ValidatorException( # u"Required field '{}' is not of type '{}'".format( # noqa # field, field_type # ) # ) # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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"Percentage values should be in decimal format" ) with self.assertRaises(ValidatorException) as ctx: validate_percentage(-0.01) self.assertEquals( str(ctx.exception), u"Percentage values should be in decimal format" ) def test_validate_units(self): out = validate_units(u"metric") self.assertEquals(out, u"metric") def test_validate_units_raises(self): with self.assertRaises(ValidatorException) as ctx: validate_units(u"bad") self.assertEquals( str(ctx.exception), u"Unkown units 'bad', must use imperial or metric" ) def test_validate_required_fields(self): data = {u"required": u"data"} required_fields = [(u"required", str)] <|code_end|> , continue by predicting the next line. Consider current file imports: import unittest from brew.constants import GRAIN_TYPE_CEREAL from brew.constants import HOP_TYPE_PELLET from brew.exceptions import ValidatorException from brew.validators import validate_grain_type from brew.validators import validate_hop_type from brew.validators import validate_optional_fields from brew.validators import validate_percentage from brew.validators import validate_required_fields from brew.validators import validate_units and context: # Path: brew/constants.py # GRAIN_TYPE_CEREAL = u"cereal" # # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass # # Path: brew/validators.py # 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: # return grain_type # raise ValidatorException( # u"Unkown grain type '{}', must use {}".format( # grain_type, u", ".join(GRAIN_TYPE_LIST) # ) # ) # # Path: brew/validators.py # def validate_hop_type(hop_type): # """ # Validate a hop type # # :param str hop_type: Type of Grain # :return: hop type # :rtype: str # :raises ValidatorException: If hop type is unknown # """ # 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)) # ) # # Path: brew/validators.py # def validate_optional_fields(data, optional_fields, data_field=u"data"): # """ # Validate fields which are optional as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) optional_fields: Values and types to check for in data # :param str data_field: The key in the data dictionary containing the optional fields # :raises ValidatorException: Optional field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # noqa # # If no optional data field present then return # if data_field not in data: # return # for field, field_type in optional_fields: # if field in data[data_field]: # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # # With optional fields only check the type as they are overrides # # and not all overrides need to be present # if not isinstance(data[data_field][field], field_type): # raise ValidatorException( # u"Optional field '{}' in '{}' is not of type '{}'".format( # noqa # field, data_field, field_type # ) # ) # # Path: brew/validators.py # def validate_percentage(percent): # """ # Validate decimal percentage # # :param float percent: Percentage between 0.0 and 1.0 # :return: percentage # :rtype: float # :raises ValidatorException: If decimal percentage not between 0.0 and 1.0 # """ # if 0.0 <= percent <= 1.0: # return percent # raise ValidatorException(u"Percentage values should be in decimal format") # # Path: brew/validators.py # def validate_required_fields(data, required_fields): # """ # Validate fields which are required as part of the data. # # :param dict data: A python dictionary to check for required fields # :param list(tuple) required_fields: Values and types to check for in data # :raises ValidatorException: Required field is missing from data # :raises ValidatorException: Required field is of the wrong type # # The format is a list of tuples where the first element is a string with # a value that should be a key found in the data dict and # where the second element is a python type or list/tuple of # python types to check the field against. # """ # for field, field_type in required_fields: # if field not in data: # raise ValidatorException( # u"Required field '{}' missing from data".format(field) # noqa # ) # if field_type == str: # try: # field_type = unicode # except NameError: # field_type = str # if not isinstance(data[field], field_type): # raise ValidatorException( # u"Required field '{}' is not of type '{}'".format( # noqa # field, field_type # ) # ) # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) which might include code, classes, or functions. Output only the next line.
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_out - Type of conversion ('b', 'p', 's', or None) """ brix, plato, sg = 0.0, 0.0, 0.0 if brix_in: brix = brix_in <|code_end|> with the help of current file imports: import argparse import sys import textwrap from brew.utilities.sugar import brix_to_plato from brew.utilities.sugar import brix_to_sg from brew.utilities.sugar import plato_to_brix from brew.utilities.sugar import plato_to_sg from brew.utilities.sugar import sg_to_brix from brew.utilities.sugar import sg_to_plato and context from other files: # Path: brew/utilities/sugar.py # def brix_to_plato(brix): # """ # Degrees Brix to Degrees Plato # # :param float brix: Degrees Brix # :return: Degrees Plato # :rtype: float # # The difference between the degBx and degP as calculated from the respective # polynomials is: # # :math:`\\text{degP} - \\text{degBx} = \\big(\\big(\\big(-2.81615*sg + 8.79724\\big) \\times sg - 9.1626\\big) \\times sg + 3.18213\\big)` # # The difference is generally less than +/-0.0005 degBx or degP with the # exception being for weak solutions. # # Source: # # * https://en.wikipedia.org/wiki/Brix # """ # noqa # return sg_to_plato(brix_to_sg(brix)) # # Path: brew/utilities/sugar.py # def brix_to_sg(brix): # """ # Degrees Brix to Specific Gravity # # :param float brix: Degrees Brix # :return: Specific Gravity # :rtype: float # # Source: # # * http://www.brewersfriend.com/brix-converter/ # """ # return (brix / (258.6 - ((brix / 258.2) * 227.1))) + 1 # # Path: brew/utilities/sugar.py # def plato_to_brix(plato): # """ # Degrees Plato to Degrees Brix # # :param float brix: Degrees Plato # :return: Degrees Brix # :rtype: float # """ # return sg_to_brix(plato_to_sg(plato)) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_brix(sg): # """ # Specific Gravity to Degrees Brix # # :param float sg: Specific Gravity # :return: Degrees Brix # :rtype: float # # Source: # # * http://en.wikipedia.org/wiki/Brix # * http://www.brewersfriend.com/brix-converter/ # """ # if sg > 1.17874: # raise SugarException(u"Above 40 degBx this function no longer works") # return ((182.4601 * sg - 775.6821) * sg + 1262.7794) * sg - 669.5622 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 , which may contain function names, class names, or code. Output only the next line.
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 conversion ('b', 'p', 's', or None) """ brix, plato, sg = 0.0, 0.0, 0.0 if brix_in: brix = brix_in plato = brix_to_plato(brix_in) <|code_end|> . Use current file imports: import argparse import sys import textwrap from brew.utilities.sugar import brix_to_plato from brew.utilities.sugar import brix_to_sg from brew.utilities.sugar import plato_to_brix from brew.utilities.sugar import plato_to_sg from brew.utilities.sugar import sg_to_brix from brew.utilities.sugar import sg_to_plato and context (classes, functions, or code) from other files: # Path: brew/utilities/sugar.py # def brix_to_plato(brix): # """ # Degrees Brix to Degrees Plato # # :param float brix: Degrees Brix # :return: Degrees Plato # :rtype: float # # The difference between the degBx and degP as calculated from the respective # polynomials is: # # :math:`\\text{degP} - \\text{degBx} = \\big(\\big(\\big(-2.81615*sg + 8.79724\\big) \\times sg - 9.1626\\big) \\times sg + 3.18213\\big)` # # The difference is generally less than +/-0.0005 degBx or degP with the # exception being for weak solutions. # # Source: # # * https://en.wikipedia.org/wiki/Brix # """ # noqa # return sg_to_plato(brix_to_sg(brix)) # # Path: brew/utilities/sugar.py # def brix_to_sg(brix): # """ # Degrees Brix to Specific Gravity # # :param float brix: Degrees Brix # :return: Specific Gravity # :rtype: float # # Source: # # * http://www.brewersfriend.com/brix-converter/ # """ # return (brix / (258.6 - ((brix / 258.2) * 227.1))) + 1 # # Path: brew/utilities/sugar.py # def plato_to_brix(plato): # """ # Degrees Plato to Degrees Brix # # :param float brix: Degrees Plato # :return: Degrees Brix # :rtype: float # """ # return sg_to_brix(plato_to_sg(plato)) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_brix(sg): # """ # Specific Gravity to Degrees Brix # # :param float sg: Specific Gravity # :return: Degrees Brix # :rtype: float # # Source: # # * http://en.wikipedia.org/wiki/Brix # * http://www.brewersfriend.com/brix-converter/ # """ # if sg > 1.17874: # raise SugarException(u"Above 40 degBx this function no longer works") # return ((182.4601 * sg - 775.6821) * sg + 1262.7794) * sg - 669.5622 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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 conversion ('b', 'p', 's', or None) """ brix, plato, sg = 0.0, 0.0, 0.0 if brix_in: brix = brix_in plato = brix_to_plato(brix_in) sg = brix_to_sg(brix_in) elif plato_in: <|code_end|> . Write the next line using the current file imports: import argparse import sys import textwrap from brew.utilities.sugar import brix_to_plato from brew.utilities.sugar import brix_to_sg from brew.utilities.sugar import plato_to_brix from brew.utilities.sugar import plato_to_sg from brew.utilities.sugar import sg_to_brix from brew.utilities.sugar import sg_to_plato and context from other files: # Path: brew/utilities/sugar.py # def brix_to_plato(brix): # """ # Degrees Brix to Degrees Plato # # :param float brix: Degrees Brix # :return: Degrees Plato # :rtype: float # # The difference between the degBx and degP as calculated from the respective # polynomials is: # # :math:`\\text{degP} - \\text{degBx} = \\big(\\big(\\big(-2.81615*sg + 8.79724\\big) \\times sg - 9.1626\\big) \\times sg + 3.18213\\big)` # # The difference is generally less than +/-0.0005 degBx or degP with the # exception being for weak solutions. # # Source: # # * https://en.wikipedia.org/wiki/Brix # """ # noqa # return sg_to_plato(brix_to_sg(brix)) # # Path: brew/utilities/sugar.py # def brix_to_sg(brix): # """ # Degrees Brix to Specific Gravity # # :param float brix: Degrees Brix # :return: Specific Gravity # :rtype: float # # Source: # # * http://www.brewersfriend.com/brix-converter/ # """ # return (brix / (258.6 - ((brix / 258.2) * 227.1))) + 1 # # Path: brew/utilities/sugar.py # def plato_to_brix(plato): # """ # Degrees Plato to Degrees Brix # # :param float brix: Degrees Plato # :return: Degrees Brix # :rtype: float # """ # return sg_to_brix(plato_to_sg(plato)) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_brix(sg): # """ # Specific Gravity to Degrees Brix # # :param float sg: Specific Gravity # :return: Degrees Brix # :rtype: float # # Source: # # * http://en.wikipedia.org/wiki/Brix # * http://www.brewersfriend.com/brix-converter/ # """ # if sg > 1.17874: # raise SugarException(u"Above 40 degBx this function no longer works") # return ((182.4601 * sg - 775.6821) * sg + 1262.7794) * sg - 669.5622 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 , which may include functions, classes, or code. Output only the next line.
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 conversion ('b', 'p', 's', or None) """ brix, plato, sg = 0.0, 0.0, 0.0 if brix_in: brix = brix_in plato = brix_to_plato(brix_in) sg = brix_to_sg(brix_in) elif plato_in: brix = plato_to_brix(plato_in) plato = plato_in <|code_end|> . Use current file imports: (import argparse import sys import textwrap from brew.utilities.sugar import brix_to_plato from brew.utilities.sugar import brix_to_sg from brew.utilities.sugar import plato_to_brix from brew.utilities.sugar import plato_to_sg from brew.utilities.sugar import sg_to_brix from brew.utilities.sugar import sg_to_plato) and context including class names, function names, or small code snippets from other files: # Path: brew/utilities/sugar.py # def brix_to_plato(brix): # """ # Degrees Brix to Degrees Plato # # :param float brix: Degrees Brix # :return: Degrees Plato # :rtype: float # # The difference between the degBx and degP as calculated from the respective # polynomials is: # # :math:`\\text{degP} - \\text{degBx} = \\big(\\big(\\big(-2.81615*sg + 8.79724\\big) \\times sg - 9.1626\\big) \\times sg + 3.18213\\big)` # # The difference is generally less than +/-0.0005 degBx or degP with the # exception being for weak solutions. # # Source: # # * https://en.wikipedia.org/wiki/Brix # """ # noqa # return sg_to_plato(brix_to_sg(brix)) # # Path: brew/utilities/sugar.py # def brix_to_sg(brix): # """ # Degrees Brix to Specific Gravity # # :param float brix: Degrees Brix # :return: Specific Gravity # :rtype: float # # Source: # # * http://www.brewersfriend.com/brix-converter/ # """ # return (brix / (258.6 - ((brix / 258.2) * 227.1))) + 1 # # Path: brew/utilities/sugar.py # def plato_to_brix(plato): # """ # Degrees Plato to Degrees Brix # # :param float brix: Degrees Plato # :return: Degrees Brix # :rtype: float # """ # return sg_to_brix(plato_to_sg(plato)) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_brix(sg): # """ # Specific Gravity to Degrees Brix # # :param float sg: Specific Gravity # :return: Degrees Brix # :rtype: float # # Source: # # * http://en.wikipedia.org/wiki/Brix # * http://www.brewersfriend.com/brix-converter/ # """ # if sg > 1.17874: # raise SugarException(u"Above 40 degBx this function no longer works") # return ((182.4601 * sg - 775.6821) * sg + 1262.7794) * sg - 669.5622 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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 conversion ('b', 'p', 's', or None) """ brix, plato, sg = 0.0, 0.0, 0.0 if brix_in: brix = brix_in plato = brix_to_plato(brix_in) sg = brix_to_sg(brix_in) elif plato_in: brix = plato_to_brix(plato_in) plato = plato_in sg = plato_to_sg(plato_in) elif sg_in: <|code_end|> , generate the next line using the imports in this file: import argparse import sys import textwrap from brew.utilities.sugar import brix_to_plato from brew.utilities.sugar import brix_to_sg from brew.utilities.sugar import plato_to_brix from brew.utilities.sugar import plato_to_sg from brew.utilities.sugar import sg_to_brix from brew.utilities.sugar import sg_to_plato and context (functions, classes, or occasionally code) from other files: # Path: brew/utilities/sugar.py # def brix_to_plato(brix): # """ # Degrees Brix to Degrees Plato # # :param float brix: Degrees Brix # :return: Degrees Plato # :rtype: float # # The difference between the degBx and degP as calculated from the respective # polynomials is: # # :math:`\\text{degP} - \\text{degBx} = \\big(\\big(\\big(-2.81615*sg + 8.79724\\big) \\times sg - 9.1626\\big) \\times sg + 3.18213\\big)` # # The difference is generally less than +/-0.0005 degBx or degP with the # exception being for weak solutions. # # Source: # # * https://en.wikipedia.org/wiki/Brix # """ # noqa # return sg_to_plato(brix_to_sg(brix)) # # Path: brew/utilities/sugar.py # def brix_to_sg(brix): # """ # Degrees Brix to Specific Gravity # # :param float brix: Degrees Brix # :return: Specific Gravity # :rtype: float # # Source: # # * http://www.brewersfriend.com/brix-converter/ # """ # return (brix / (258.6 - ((brix / 258.2) * 227.1))) + 1 # # Path: brew/utilities/sugar.py # def plato_to_brix(plato): # """ # Degrees Plato to Degrees Brix # # :param float brix: Degrees Plato # :return: Degrees Brix # :rtype: float # """ # return sg_to_brix(plato_to_sg(plato)) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_brix(sg): # """ # Specific Gravity to Degrees Brix # # :param float sg: Specific Gravity # :return: Degrees Brix # :rtype: float # # Source: # # * http://en.wikipedia.org/wiki/Brix # * http://www.brewersfriend.com/brix-converter/ # """ # if sg > 1.17874: # raise SugarException(u"Above 40 degBx this function no longer works") # return ((182.4601 * sg - 775.6821) * sg + 1262.7794) * sg - 669.5622 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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_out - Type of conversion ('b', 'p', 's', or None) """ brix, plato, sg = 0.0, 0.0, 0.0 if brix_in: brix = brix_in plato = brix_to_plato(brix_in) sg = brix_to_sg(brix_in) elif plato_in: brix = plato_to_brix(plato_in) plato = plato_in sg = plato_to_sg(plato_in) elif sg_in: brix = sg_to_brix(sg_in) <|code_end|> with the help of current file imports: import argparse import sys import textwrap from brew.utilities.sugar import brix_to_plato from brew.utilities.sugar import brix_to_sg from brew.utilities.sugar import plato_to_brix from brew.utilities.sugar import plato_to_sg from brew.utilities.sugar import sg_to_brix from brew.utilities.sugar import sg_to_plato and context from other files: # Path: brew/utilities/sugar.py # def brix_to_plato(brix): # """ # Degrees Brix to Degrees Plato # # :param float brix: Degrees Brix # :return: Degrees Plato # :rtype: float # # The difference between the degBx and degP as calculated from the respective # polynomials is: # # :math:`\\text{degP} - \\text{degBx} = \\big(\\big(\\big(-2.81615*sg + 8.79724\\big) \\times sg - 9.1626\\big) \\times sg + 3.18213\\big)` # # The difference is generally less than +/-0.0005 degBx or degP with the # exception being for weak solutions. # # Source: # # * https://en.wikipedia.org/wiki/Brix # """ # noqa # return sg_to_plato(brix_to_sg(brix)) # # Path: brew/utilities/sugar.py # def brix_to_sg(brix): # """ # Degrees Brix to Specific Gravity # # :param float brix: Degrees Brix # :return: Specific Gravity # :rtype: float # # Source: # # * http://www.brewersfriend.com/brix-converter/ # """ # return (brix / (258.6 - ((brix / 258.2) * 227.1))) + 1 # # Path: brew/utilities/sugar.py # def plato_to_brix(plato): # """ # Degrees Plato to Degrees Brix # # :param float brix: Degrees Plato # :return: Degrees Brix # :rtype: float # """ # return sg_to_brix(plato_to_sg(plato)) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_brix(sg): # """ # Specific Gravity to Degrees Brix # # :param float sg: Specific Gravity # :return: Degrees Brix # :rtype: float # # Source: # # * http://en.wikipedia.org/wiki/Brix # * http://www.brewersfriend.com/brix-converter/ # """ # if sg > 1.17874: # raise SugarException(u"Above 40 degBx this function no longer works") # return ((182.4601 * sg - 775.6821) * sg + 1262.7794) * sg - 669.5622 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 , which may contain function names, class names, or code. Output only the next line.
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 to convert from :param str new_type: The new hop type to convert to :return: New weight of the hops :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: return weight conversion = 1.0 if old_type == HOP_TYPE_WHOLE_WET: conversion /= HOP_WHOLE_DRY_TO_WET elif new_type == HOP_TYPE_WHOLE_WET: conversion *= HOP_WHOLE_DRY_TO_WET <|code_end|> . Write the next line using the current file imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) , which may include functions, classes, or code. Output only the next line.
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 type and another :param float weight: Weight of the hops :param str old_type: The old hop type to convert from :param str new_type: The new hop type to convert to :return: New weight of the hops :rtype: float """ # If same type then no change if old_type == new_type: return weight # If hop types are equivalent then no change <|code_end|> . Use current file imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (classes, functions, or code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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 another :param float weight: Weight of the hops :param str old_type: The old hop type to convert from :param str new_type: The new hop type to convert to :return: New weight of the hops :rtype: float """ # If same type then no change if old_type == new_type: return weight # If hop types are equivalent then no change <|code_end|> . Write the next line using the current file imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) , which may include functions, classes, or code. Output only the next line.
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 :param float weight: Weight of the hops :param str old_type: The old hop type to convert from :param str new_type: The new hop type to convert to :return: New weight of the hops :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: return weight conversion = 1.0 <|code_end|> , generate the next line using the imports in this file: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (functions, classes, or occasionally code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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 new_type: The new hop type to convert to :return: New weight of the hops :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: return weight conversion = 1.0 if old_type == HOP_TYPE_WHOLE_WET: conversion /= HOP_WHOLE_DRY_TO_WET elif new_type == HOP_TYPE_WHOLE_WET: conversion *= HOP_WHOLE_DRY_TO_WET if old_type == HOP_TYPE_PELLET: <|code_end|> , predict the immediate next line with the help of imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (classes, functions, sometimes code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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 :param float weight: Weight of the hops :param str old_type: The old hop type to convert from :param str new_type: The new hop type to convert to :return: New weight of the hops :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: return weight conversion = 1.0 if old_type == HOP_TYPE_WHOLE_WET: <|code_end|> . Use current file imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (classes, functions, or code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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): """ Change units of the class from one type to the other :return: Hop Addition in new unit type :rtype: HopAddition """ if self.units == IMPERIAL_UNITS: units = SI_UNITS elif self.units == SI_UNITS: units = IMPERIAL_UNITS return HopsUtilization(self.hop_addition, units=units) def get_ibus(self, sg, final_volume): """ Get the IBUs :param float sg: Specific Gravity :param float final_volume: The Final Volume of the wort :return: The IBUs of the wort :rtype: float """ <|code_end|> , continue by predicting the next line. Consider current file imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) which might include code, classes, or functions. Output only the next line.
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 other :return: Hop Addition in new unit type :rtype: HopAddition """ if self.units == IMPERIAL_UNITS: units = SI_UNITS elif self.units == SI_UNITS: units = IMPERIAL_UNITS return HopsUtilization(self.hop_addition, units=units) def get_ibus(self, sg, final_volume): """ Get the IBUs :param float sg: Specific Gravity :param float final_volume: The Final Volume of the wort :return: The IBUs of the wort :rtype: float """ hops_constant = HOPS_CONSTANT_IMPERIAL if self.units == SI_UNITS: <|code_end|> , continue by predicting the next line. Consider current file imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) which might include code, classes, or functions. Output only the next line.
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__(self, hop_addition, units=IMPERIAL_UNITS): """ :param HopAddition hop_addition: A hop addition :param str units: The units """ self.hop_addition = hop_addition # Manage units self.set_units(units) def set_units(self, units): """ Set the units and unit types :param str units: The units """ self.units = validate_units(units) if self.units == IMPERIAL_UNITS: <|code_end|> , predict the immediate next line with the help of imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (classes, functions, sometimes code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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: return weight conversion = 1.0 if old_type == HOP_TYPE_WHOLE_WET: conversion /= HOP_WHOLE_DRY_TO_WET elif new_type == HOP_TYPE_WHOLE_WET: conversion *= HOP_WHOLE_DRY_TO_WET 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.com/hops """ <|code_end|> , predict the immediate next line with the help of imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (classes, functions, sometimes code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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: A hop addition :param str units: The units """ self.hop_addition = hop_addition # Manage units self.set_units(units) def set_units(self, units): """ Set the units and unit types :param str units: The units """ self.units = validate_units(units) if self.units == IMPERIAL_UNITS: self.types = IMPERIAL_TYPES elif self.units == SI_UNITS: <|code_end|> , determine the next line of code. You have imports: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (class names, function names, or code) available: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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): """ :param HopAddition hop_addition: A hop addition :param str units: The units """ self.hop_addition = hop_addition # Manage units self.set_units(units) def set_units(self, units): """ Set the units and unit types :param str units: The units """ self.units = validate_units(units) if self.units == IMPERIAL_UNITS: self.types = IMPERIAL_TYPES <|code_end|> . Use current file imports: (import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units) and context including class names, function names, or small code snippets from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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.com/hops """ def __init__(self, hop_addition, units=IMPERIAL_UNITS): """ :param HopAddition hop_addition: A hop addition :param str units: The units """ self.hop_addition = hop_addition # Manage units self.set_units(units) def set_units(self, units): """ Set the units and unit types :param str units: The units """ <|code_end|> , generate the next line using the imports in this file: import math from ..constants import HOP_TYPE_PELLET from ..constants import HOP_TYPE_PLUG from ..constants import HOP_TYPE_WHOLE from ..constants import HOP_TYPE_WHOLE_WET from ..constants import HOP_UTILIZATION_SCALE_PELLET from ..constants import HOP_WHOLE_DRY_TO_WET from ..constants import HOPS_CONSTANT_IMPERIAL from ..constants import HOPS_CONSTANT_SI from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import SI_TYPES from ..constants import SI_UNITS from ..validators import validate_units and context (functions, classes, or occasionally code) from other files: # Path: brew/constants.py # HOP_TYPE_PELLET = u"pellet" # # Path: brew/constants.py # HOP_TYPE_PLUG = u"plug" # # Path: brew/constants.py # HOP_TYPE_WHOLE = u"whole" # # Path: brew/constants.py # HOP_TYPE_WHOLE_WET = u"whole wet" # # Path: brew/constants.py # HOP_UTILIZATION_SCALE_PELLET = 1.1 # 110% # # Path: brew/constants.py # HOP_WHOLE_DRY_TO_WET = 5.5 # # Path: brew/constants.py # HOPS_CONSTANT_IMPERIAL = MG_PER_OZ * GAL_PER_LITER # # Path: brew/constants.py # HOPS_CONSTANT_SI = 1.0 # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) . Output only the next line.
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, fresh yeast only)": 0.55, u"Pro Brewer (Ale, LG)": 0.75, 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 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: <|code_end|> with the help of current file imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 , which may contain function names, class names, or code. Output only the next line.
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 * plato_per_gu elif units == SI_UNITS: return pitch_rate * LITER_PER_GAL / plato_per_gu class YeastModel(object): METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.0, u"stir plate": 0.0} def __init__(self, method, units=IMPERIAL_UNITS): if method not in self.METHOD_TO_GROWTH_ADJ.keys(): raise YeastException( u"Method '{}' not allowed for yeast model".format(method) # noqa ) self.method = method self.adjustment = self.METHOD_TO_GROWTH_ADJ[method] self.set_units(units) def set_units(self, units): self.units = validate_units(units) if self.units == IMPERIAL_UNITS: <|code_end|> , generate the next line using the imports in this file: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context (functions, classes, or occasionally code) from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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 / 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, fresh yeast only)": 0.55, u"Pro Brewer (Ale, LG)": 0.75, 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, } <|code_end|> , predict the next line using imports from the current file: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context including class names, function names, and sometimes code from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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 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 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_UNITS: <|code_end|> , predict the next line using imports from the current file: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context including class names, function names, and sometimes code from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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"pitch_rate_as_is": round(pitch_rate_as_is, 2), u"pitch_rate_cells": round(pitch_rate_cells, 2), u"cells_needed": round(pitch_rate_cells - cells, 2), u"required_growth_rate": round(required_growth_rate, 2), u"units": self.units, } def get_starter_volume( self, available_cells, starter_volume=2.0 * GAL_PER_LITER, original_gravity=1.036, ): """ Calculate the number of cells given a stater volume and gravity """ GPL = ( 2.845833 ) # g/P/L grams of extract per point of gravity per liter of starter # noqa dme = GPL * sg_to_gu(original_gravity) * starter_volume # in grams if self.units == IMPERIAL_UNITS: inoculation_rate = available_cells / ( starter_volume * LITER_PER_GAL ) # noqa <|code_end|> with the help of current file imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 , which may contain function names, class names, or code. Output only the next line.
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_UNITS: return pitch_rate * LITER_PER_GAL / plato_per_gu class YeastModel(object): METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.0, u"stir plate": 0.0} def __init__(self, method, units=IMPERIAL_UNITS): if method not in self.METHOD_TO_GROWTH_ADJ.keys(): raise YeastException( u"Method '{}' not allowed for yeast model".format(method) # noqa ) self.method = method self.adjustment = self.METHOD_TO_GROWTH_ADJ[method] self.set_units(units) def set_units(self, units): self.units = validate_units(units) if self.units == IMPERIAL_UNITS: self.types = IMPERIAL_TYPES elif self.units == SI_UNITS: <|code_end|> , continue by predicting the next line. Consider current file imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 which might include code, classes, or functions. Output only the next line.
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, 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 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 <|code_end|> , generate the next line using the imports in this file: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context (functions, classes, or occasionally code) from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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 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_UNITS: return pitch_rate * LITER_PER_GAL / plato_per_gu class YeastModel(object): METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.0, u"stir plate": 0.0} def __init__(self, method, units=IMPERIAL_UNITS): if method not in self.METHOD_TO_GROWTH_ADJ.keys(): <|code_end|> , generate the next line using the imports in this file: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context (functions, classes, or occasionally code) from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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_to_sg(1)) if units == IMPERIAL_UNITS: return pitch_rate * GAL_PER_LITER * plato_per_gu elif units == SI_UNITS: return pitch_rate * LITER_PER_GAL / plato_per_gu class YeastModel(object): METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.0, u"stir plate": 0.0} def __init__(self, method, units=IMPERIAL_UNITS): if method not in self.METHOD_TO_GROWTH_ADJ.keys(): raise YeastException( u"Method '{}' not allowed for yeast model".format(method) # noqa ) self.method = method self.adjustment = self.METHOD_TO_GROWTH_ADJ[method] self.set_units(units) def set_units(self, units): <|code_end|> with the help of current file imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 , which may contain function names, class names, or code. Output only the next line.
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 Recommended+ (Ale, fresh yeast only)": 0.55, u"Pro Brewer (Ale, LG)": 0.75, 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 should be given in: Imperial: B / (Gal * GU) SI: B / (L * P) Note: 1 M / (ml * P) == 1B / (L * P) """ <|code_end|> , determine the next line of code. You have imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context (class names, function names, or code) available: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 . Output only the next line.
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+ (Ale, fresh yeast only)": 0.55, u"Pro Brewer (Ale, LG)": 0.75, 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 should be given in: Imperial: B / (Gal * GU) SI: B / (L * P) Note: 1 M / (ml * P) == 1B / (L * P) """ <|code_end|> , continue by predicting the next line. Consider current file imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 which might include code, classes, or functions. Output only the next line.
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 * degP) yeast_type - liquid, dry cells_per_pack - Billions of cells num_packs - how many in units days_since_manufacture - the older the yeast the less viable units - imperial, metric Yeast Viability: lose 20% viability / month or 0.66% / day Imperial: B / Gal / GU Metric: M / ml / Plato Sources: - http://beersmith.com/blog/2011/01/10/yeast-starters-for-home-brewing-beer-part-2/ """ # noqa viability = self.get_viability(days_since_manufacture) cells = cells_per_pack * num_packs * viability if self.units == IMPERIAL_UNITS: modifier = sg_to_gu(original_gravity) elif self.units == SI_UNITS: <|code_end|> , continue by predicting the next line. Consider current file imports: import math from ..constants import GAL_PER_LITER from ..constants import IMPERIAL_TYPES from ..constants import IMPERIAL_UNITS from ..constants import LITER_PER_GAL from ..constants import OZ_PER_G from ..constants import SI_TYPES from ..constants import SI_UNITS from ..exceptions import YeastException from ..validators import validate_units from .sugar import plato_to_sg from .sugar import sg_to_gu from .sugar import sg_to_plato and context: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_TYPES = { # u"volume": u"gallon", # u"weight_large": u"lbs", # u"weight_small": u"oz", # u"temperature": u"degF", # } # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # LITER_PER_GAL = 3.78541 # # Path: brew/constants.py # OZ_PER_G = 1.0 / G_PER_OZ # # Path: brew/constants.py # SI_TYPES = { # u"volume": u"liter", # u"weight_large": u"kg", # u"weight_small": u"mg", # u"temperature": u"degC", # } # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/sugar.py # def plato_to_sg(deg_plato): # """ # Degrees Plato to Specific Gravity # # :param float deg_plato: Degrees Plato # :return: Specific Gravity # :rtype: float # # The simple formula for S.G. is: # # :math:`\\text{SG} = 1 + 0.004 \\times \\text{Plato}` # # The more precise calculation of SG is: # # :math:`\\text{SG} = \\frac{Plato}{258.6 - \\big(\\frac{Plato}{258.2} \\times 227.1\\big)} + 1` # # Source: # # * http://www.learntobrew.com/page/1mdhe/Shopping/Beer_Calculations.html # """ # noqa # return (deg_plato / (258.6 - ((deg_plato / 258.2) * 227.1))) + 1.0 # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/utilities/sugar.py # def sg_to_plato(sg): # """ # Specific Gravity to Degrees Plato # # :param float sg: Specific Gravity # :return: Degrees Plato # :rtype: float # # :math:`\\text{Plato} = \\frac{\\big(\\text{SG} - 1\\big) \\times 1000}{4}` # # The more precise calculation of Plato is: # # :math:`\\text{Plato} = -616.868 + 1111.14 \\times sg - 630.272 \\times sg^2 + 135.997 \\times sg^3` # # Source: # # * http://www.brewersfriend.com/2012/10/31/on-the-relationship-between-plato-and-specific-gravity/ # """ # noqa # # return (sg - 1.0) * 1000 / 4 # return ((135.997 * sg - 630.272) * sg + 1111.14) * sg - 616.868 which might include code, classes, or functions. Output only the next line.
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 (classes, functions, sometimes code) from other files: # Path: brew/hops.py # class Hop(object): # class HopAddition(object): # def __init__(self, name, percent_alpha_acids=None): # def __str__(self): # def __unicode__(self): # def __repr__(self): # def __eq__(self, other): # def __ne__(self, other): # def to_dict(self): # def to_json(self): # def format(self): # def __init__( # self, # hop, # weight=None, # boil_time=None, # hop_type=HOP_TYPE_PELLET, # utilization_cls=HopsUtilizationGlennTinseth, # utilization_cls_kwargs=None, # units=IMPERIAL_UNITS, # ): # def set_units(self, units): # def change_units(self): # def __str__(self): # def __unicode__(self): # def __repr__(self): # def __eq__(self, other): # def __ne__(self, other): # def to_dict(self): # def to_json(self): # def validate(cls, hop_data): # def format(self): # def get_ibus(self, sg, final_volume): # def get_alpha_acid_units(self): . Output only the next line.
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.0) ftemp = celsius_to_fahrenheit(-40.0) self.assertEquals(ftemp, -40.0) def test_fahrenheit_to_celsius(self): ctemp = fahrenheit_to_celsius(212.0) self.assertEquals(ctemp, 100.0) ctemp = fahrenheit_to_celsius(32.0) self.assertEquals(ctemp, 0.0) ctemp = fahrenheit_to_celsius(-40.0) self.assertEquals(ctemp, -40.0) def test_strike_temp(self): temp = strike_temp(104.0, 70.0, 1.0 / 1.0) self.assertEquals(round(temp, 2), 110.8) def test_mash_infusion(self): vol = mash_infusion(140.0, 104.0, 8.0, 8.0, 210.0) self.assertEquals(round(vol, 2), 4.94) def test_boiling_point(self): <|code_end|> , predict the immediate next line with the help of imports: import unittest from brew.utilities.temperature import boiling_point from brew.utilities.temperature import celsius_to_fahrenheit from brew.utilities.temperature import fahrenheit_to_celsius from brew.utilities.temperature import mash_infusion from brew.utilities.temperature import strike_temp and context (classes, functions, sometimes code) from other files: # Path: brew/utilities/temperature.py # def boiling_point(altitude): # """ # Get the boiling point at a specific altitude # # https://www.omnicalculator.com/chemistry/boiling-point-altitude # # :param float altitude: Altitude in feet (ft) # :return: The boiling point in degF # :rtype: float # """ # # pressure = 29.921 * pow((1 - 0.0000068753 * altitude), 5.2559) # boiling_point = 49.161 * math.log(pressure) + 44.932 # return boiling_point # # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 # # Path: brew/utilities/temperature.py # def fahrenheit_to_celsius(temp): # """ # Convert degrees Fahrenheit to degrees Celsius # # :param float temp: The temperature in Fahrenheit # :return: The temperature in Celsius # :rtype: float # """ # return (temp - 32.0) / 1.8 # # Path: brew/utilities/temperature.py # def mash_infusion( # target_temp, initial_temp, grain_weight, water_volume, infusion_temp=212 # ): # """ # Get Volume of water to infuse into mash to reach scheduled temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float inital_temp: Mash Temperature # :param float grain_weight: Total weight of grain in mash (lbs) # :param float water_volume: Total volume of water in mash (qt) # :param float infusion_temp: Temperature of water to infuse # :return: The volume of water to add to the mash (qt) # :rtype: float # """ # return ( # (target_temp - initial_temp) # * (0.2 * grain_weight + water_volume) # / (infusion_temp - target_temp) # ) # # Path: brew/utilities/temperature.py # def strike_temp(target_temp, initial_temp, liquor_to_grist_ratio=1.5): # """ # Get Strike Water Temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float initial_temp: Malt Temperature # :param float liquor_to_grist_ratio: The Liquor to Grist Ratio (qt:lbs) # :return: The strike water temperature # :rtype: float # """ # noqa # return (0.2 / liquor_to_grist_ratio) * (target_temp - initial_temp) + target_temp . Output only the next line.
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) ftemp = celsius_to_fahrenheit(-40.0) self.assertEquals(ftemp, -40.0) def test_fahrenheit_to_celsius(self): <|code_end|> , determine the next line of code. You have imports: import unittest from brew.utilities.temperature import boiling_point from brew.utilities.temperature import celsius_to_fahrenheit from brew.utilities.temperature import fahrenheit_to_celsius from brew.utilities.temperature import mash_infusion from brew.utilities.temperature import strike_temp and context (class names, function names, or code) available: # Path: brew/utilities/temperature.py # def boiling_point(altitude): # """ # Get the boiling point at a specific altitude # # https://www.omnicalculator.com/chemistry/boiling-point-altitude # # :param float altitude: Altitude in feet (ft) # :return: The boiling point in degF # :rtype: float # """ # # pressure = 29.921 * pow((1 - 0.0000068753 * altitude), 5.2559) # boiling_point = 49.161 * math.log(pressure) + 44.932 # return boiling_point # # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 # # Path: brew/utilities/temperature.py # def fahrenheit_to_celsius(temp): # """ # Convert degrees Fahrenheit to degrees Celsius # # :param float temp: The temperature in Fahrenheit # :return: The temperature in Celsius # :rtype: float # """ # return (temp - 32.0) / 1.8 # # Path: brew/utilities/temperature.py # def mash_infusion( # target_temp, initial_temp, grain_weight, water_volume, infusion_temp=212 # ): # """ # Get Volume of water to infuse into mash to reach scheduled temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float inital_temp: Mash Temperature # :param float grain_weight: Total weight of grain in mash (lbs) # :param float water_volume: Total volume of water in mash (qt) # :param float infusion_temp: Temperature of water to infuse # :return: The volume of water to add to the mash (qt) # :rtype: float # """ # return ( # (target_temp - initial_temp) # * (0.2 * grain_weight + water_volume) # / (infusion_temp - target_temp) # ) # # Path: brew/utilities/temperature.py # def strike_temp(target_temp, initial_temp, liquor_to_grist_ratio=1.5): # """ # Get Strike Water Temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float initial_temp: Malt Temperature # :param float liquor_to_grist_ratio: The Liquor to Grist Ratio (qt:lbs) # :return: The strike water temperature # :rtype: float # """ # noqa # return (0.2 / liquor_to_grist_ratio) * (target_temp - initial_temp) + target_temp . Output only the next line.
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) ftemp = celsius_to_fahrenheit(-40.0) self.assertEquals(ftemp, -40.0) def test_fahrenheit_to_celsius(self): ctemp = fahrenheit_to_celsius(212.0) self.assertEquals(ctemp, 100.0) ctemp = fahrenheit_to_celsius(32.0) self.assertEquals(ctemp, 0.0) ctemp = fahrenheit_to_celsius(-40.0) self.assertEquals(ctemp, -40.0) def test_strike_temp(self): temp = strike_temp(104.0, 70.0, 1.0 / 1.0) self.assertEquals(round(temp, 2), 110.8) def test_mash_infusion(self): <|code_end|> , determine the next line of code. You have imports: import unittest from brew.utilities.temperature import boiling_point from brew.utilities.temperature import celsius_to_fahrenheit from brew.utilities.temperature import fahrenheit_to_celsius from brew.utilities.temperature import mash_infusion from brew.utilities.temperature import strike_temp and context (class names, function names, or code) available: # Path: brew/utilities/temperature.py # def boiling_point(altitude): # """ # Get the boiling point at a specific altitude # # https://www.omnicalculator.com/chemistry/boiling-point-altitude # # :param float altitude: Altitude in feet (ft) # :return: The boiling point in degF # :rtype: float # """ # # pressure = 29.921 * pow((1 - 0.0000068753 * altitude), 5.2559) # boiling_point = 49.161 * math.log(pressure) + 44.932 # return boiling_point # # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 # # Path: brew/utilities/temperature.py # def fahrenheit_to_celsius(temp): # """ # Convert degrees Fahrenheit to degrees Celsius # # :param float temp: The temperature in Fahrenheit # :return: The temperature in Celsius # :rtype: float # """ # return (temp - 32.0) / 1.8 # # Path: brew/utilities/temperature.py # def mash_infusion( # target_temp, initial_temp, grain_weight, water_volume, infusion_temp=212 # ): # """ # Get Volume of water to infuse into mash to reach scheduled temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float inital_temp: Mash Temperature # :param float grain_weight: Total weight of grain in mash (lbs) # :param float water_volume: Total volume of water in mash (qt) # :param float infusion_temp: Temperature of water to infuse # :return: The volume of water to add to the mash (qt) # :rtype: float # """ # return ( # (target_temp - initial_temp) # * (0.2 * grain_weight + water_volume) # / (infusion_temp - target_temp) # ) # # Path: brew/utilities/temperature.py # def strike_temp(target_temp, initial_temp, liquor_to_grist_ratio=1.5): # """ # Get Strike Water Temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float initial_temp: Malt Temperature # :param float liquor_to_grist_ratio: The Liquor to Grist Ratio (qt:lbs) # :return: The strike water temperature # :rtype: float # """ # noqa # return (0.2 / liquor_to_grist_ratio) * (target_temp - initial_temp) + target_temp . Output only the next line.
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.assertEquals(ftemp, 32.0) ftemp = celsius_to_fahrenheit(-40.0) self.assertEquals(ftemp, -40.0) def test_fahrenheit_to_celsius(self): ctemp = fahrenheit_to_celsius(212.0) self.assertEquals(ctemp, 100.0) ctemp = fahrenheit_to_celsius(32.0) self.assertEquals(ctemp, 0.0) ctemp = fahrenheit_to_celsius(-40.0) self.assertEquals(ctemp, -40.0) def test_strike_temp(self): <|code_end|> with the help of current file imports: import unittest from brew.utilities.temperature import boiling_point from brew.utilities.temperature import celsius_to_fahrenheit from brew.utilities.temperature import fahrenheit_to_celsius from brew.utilities.temperature import mash_infusion from brew.utilities.temperature import strike_temp and context from other files: # Path: brew/utilities/temperature.py # def boiling_point(altitude): # """ # Get the boiling point at a specific altitude # # https://www.omnicalculator.com/chemistry/boiling-point-altitude # # :param float altitude: Altitude in feet (ft) # :return: The boiling point in degF # :rtype: float # """ # # pressure = 29.921 * pow((1 - 0.0000068753 * altitude), 5.2559) # boiling_point = 49.161 * math.log(pressure) + 44.932 # return boiling_point # # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 # # Path: brew/utilities/temperature.py # def fahrenheit_to_celsius(temp): # """ # Convert degrees Fahrenheit to degrees Celsius # # :param float temp: The temperature in Fahrenheit # :return: The temperature in Celsius # :rtype: float # """ # return (temp - 32.0) / 1.8 # # Path: brew/utilities/temperature.py # def mash_infusion( # target_temp, initial_temp, grain_weight, water_volume, infusion_temp=212 # ): # """ # Get Volume of water to infuse into mash to reach scheduled temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float inital_temp: Mash Temperature # :param float grain_weight: Total weight of grain in mash (lbs) # :param float water_volume: Total volume of water in mash (qt) # :param float infusion_temp: Temperature of water to infuse # :return: The volume of water to add to the mash (qt) # :rtype: float # """ # return ( # (target_temp - initial_temp) # * (0.2 * grain_weight + water_volume) # / (infusion_temp - target_temp) # ) # # Path: brew/utilities/temperature.py # def strike_temp(target_temp, initial_temp, liquor_to_grist_ratio=1.5): # """ # Get Strike Water Temperature # # All temperatures in F. # # http://howtobrew.com/book/section-3/the-methods-of-mashing/calculations-for-boiling-water-additions # # :param float target_temp: Mash Temperature to Achieve # :param float initial_temp: Malt Temperature # :param float liquor_to_grist_ratio: The Liquor to Grist Ratio (qt:lbs) # :return: The strike water temperature # :rtype: float # """ # noqa # return (0.2 / liquor_to_grist_ratio) * (target_temp - initial_temp) + target_temp , which may contain function names, class names, or code. Output only the next line.
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 is not typical and the book even states that you should expect moisture content at around 4.0% and Brew House Efficiency at arount 90.0%. This version has been modified with more typical values. """ def get_chart(): mc = 0.04 bhe = 0.9 chart = [] for dbcg in range(5000, 7600, 100) + range(7600, 8025, 25): <|code_end|> . Use current file imports: from brew.utilities.malt import sg_from_dry_basis from brew.utilities.sugar import sg_to_gu and context (classes, functions, or code) from other files: # Path: brew/utilities/malt.py # def sg_from_dry_basis( # dbcg, # moisture_content=MOISTURE_FINISHED_MALT, # moisture_correction=MOISTURE_CORRECTION, # brew_house_efficiency=0.90, # ): # """ # Specific Gravity from Dry Basis Percentage # # :param float dbcg: Dry Basis Coarse Grain in decimal form # :param float moisture_content: A percentage of moisture content in finished malt in decimal form # :param float moisture_correction: A percentage correction in decimal form # :param float brew_house_efficiency: The efficiency in decimal form # :return: Specific Gravity available from Malt # :rtype: float # """ # noqa # validate_percentage(dbcg) # validate_percentage(moisture_content) # validate_percentage(moisture_correction) # validate_percentage(brew_house_efficiency) # gu = ( # (dbcg - moisture_content - moisture_correction) # * brew_house_efficiency # * SUCROSE_PPG # ) # return gu_to_sg(gu) # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 . Output only the next line.
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 is not typical and the book even states that you should expect moisture content at around 4.0% and Brew House Efficiency at arount 90.0%. This version has been modified with more typical values. """ def get_chart(): mc = 0.04 bhe = 0.9 chart = [] for dbcg in range(5000, 7600, 100) + range(7600, 8025, 25): sg = sg_from_dry_basis( dbcg / 10000.0, moisture_content=mc, brew_house_efficiency=bhe ) <|code_end|> . Use current file imports: from brew.utilities.malt import sg_from_dry_basis from brew.utilities.sugar import sg_to_gu and context (classes, functions, or code) from other files: # Path: brew/utilities/malt.py # def sg_from_dry_basis( # dbcg, # moisture_content=MOISTURE_FINISHED_MALT, # moisture_correction=MOISTURE_CORRECTION, # brew_house_efficiency=0.90, # ): # """ # Specific Gravity from Dry Basis Percentage # # :param float dbcg: Dry Basis Coarse Grain in decimal form # :param float moisture_content: A percentage of moisture content in finished malt in decimal form # :param float moisture_correction: A percentage correction in decimal form # :param float brew_house_efficiency: The efficiency in decimal form # :return: Specific Gravity available from Malt # :rtype: float # """ # noqa # validate_percentage(dbcg) # validate_percentage(moisture_content) # validate_percentage(moisture_correction) # validate_percentage(brew_house_efficiency) # gu = ( # (dbcg - moisture_content - moisture_correction) # * brew_house_efficiency # * SUCROSE_PPG # ) # return gu_to_sg(gu) # # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 . Output only the next line.
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 Crystal Malt 80l", u"weight": 1.0, u"grain_type": u"specialty", }, { u"name": u"Smoked Malt", # Rausch means "Smoked" u"weight": 1.0, u"data": {u"color": 6.0}, u"grain_type": u"specialty", }, {u"name": u"Victory Malt", u"weight": 1.0, u"grain_type": u"specialty"}, ], u"hops": [ {u"name": u"Perle", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"Perle", u"weight": 1.0, u"boil_time": 30.0}, ], u"yeast": {u"name": u"Wyeast 1728"}, u"data": {u"brew_house_yield": 0.458, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> . Use current file imports: (import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe from brew.utilities.efficiency import calculate_brew_house_yield # noqa) and context including class names, function names, or small code snippets from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer # # Path: brew/utilities/efficiency.py # 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 specific gravity of the wort # :param list grain_additions: A list of grain additions in the wort # :type grain_additions: list of GrainAddition objects # :return: The brew house yield as a percentage # # Brew House Yield is a function of the wort volume, the measured specific # gravity, and the grain additions used to make the wort. This equation is # thrown off by use of LME or DME since both have 100% efficiency in a brew. # A better measure is to look at just the grains that needed to be steeped # seperately and measure the specific gravity of that process. # """ # total_gu = sum([grain_add.gu for grain_add in grain_additions]) # return (sg_to_gu(sg) * wort_volume) / total_gu . Output only the next line.
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 Malt 80l", u"weight": 1.0, u"grain_type": u"specialty", }, { u"name": u"Smoked Malt", # Rausch means "Smoked" u"weight": 1.0, u"data": {u"color": 6.0}, u"grain_type": u"specialty", }, {u"name": u"Victory Malt", u"weight": 1.0, u"grain_type": u"specialty"}, ], u"hops": [ {u"name": u"Perle", u"weight": 1.0, u"boil_time": 60.0}, {u"name": u"Perle", u"weight": 1.0, u"boil_time": 30.0}, ], u"yeast": {u"name": u"Wyeast 1728"}, u"data": {u"brew_house_yield": 0.458, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> . Write the next line using the current file imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe from brew.utilities.efficiency import calculate_brew_house_yield # noqa and context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer # # Path: brew/utilities/efficiency.py # 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 specific gravity of the wort # :param list grain_additions: A list of grain additions in the wort # :type grain_additions: list of GrainAddition objects # :return: The brew house yield as a percentage # # Brew House Yield is a function of the wort volume, the measured specific # gravity, and the grain additions used to make the wort. This equation is # thrown off by use of LME or DME since both have 100% efficiency in a brew. # A better measure is to look at just the grains that needed to be steeped # seperately and measure the specific gravity of that process. # """ # total_gu = sum([grain_add.gu for grain_add in grain_additions]) # return (sg_to_gu(sg) * wort_volume) / total_gu , which may include functions, classes, or code. Output only the next line.
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 using the imports in this file: import argparse import sys from brew.utilities.temperature import celsius_to_fahrenheit from brew.utilities.temperature import fahrenheit_to_celsius and context (functions, classes, or occasionally code) from other files: # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 # # Path: brew/utilities/temperature.py # def fahrenheit_to_celsius(temp): # """ # Convert degrees Fahrenheit to degrees Celsius # # :param float temp: The temperature in Fahrenheit # :return: The temperature in Celsius # :rtype: float # """ # return (temp - 32.0) / 1.8 . Output only the next line.
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.temperature import celsius_to_fahrenheit from brew.utilities.temperature import fahrenheit_to_celsius and context from other files: # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 # # Path: brew/utilities/temperature.py # def fahrenheit_to_celsius(temp): # """ # Convert degrees Fahrenheit to degrees Celsius # # :param float temp: The temperature in Fahrenheit # :return: The temperature in Celsius # :rtype: float # """ # return (temp - 32.0) / 1.8 , which may contain function names, class names, or code. Output only the next line.
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 StyleFactory and context from other files: # Path: brew/styles.py # class StyleFactory(object): # def __init__(self, filename): # """ # :param str filename: The filename of a JSON file containing Styles # """ # self.filename = filename # with open(filename, "r") as f: # self.data = json.loads(f.read()) # # def create_style(self, category, subcategory): # """ # Create a style given a category and subcategory. # # :param int category: The Style Category # :param str subcategory: The Style Subcategory # :return: A Style Object # :rtype: Style # """ # data = self.data.get(str(category), {}).get(subcategory, None) # return Style( # data["style"], # category=data["category"], # subcategory=data["subcategory"], # og=data["og"], # fg=data["fg"], # abv=data["abv"], # ibu=data["ibu"], # color=data["color"], # ) # # def format(self): # msg = [] # for category in sorted(self.data.keys(), key=int): # substyles = self.data[category] # for subcategory in sorted(substyles.keys()): # try: # style = self.create_style(category, subcategory) # msg.append(style.format()) # except StyleException: # name = self.data[category][subcategory]["style"] # msg.append( # "{}{} {} - Not parseable".format(category, subcategory, name) # ) # return "\n".join(msg) , which may include functions, classes, or code. Output only the next line.
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 Gravity (default: %(default)s)", ) parser.add_argument( u"--fv", metavar=u"V", type=float, default=5.0, help=u"Wort Final Volume (default: %(default)s)", ) parser.add_argument( u"--sg", metavar=u"O", type=float, default=1.036, help=u"Starter Original Gravity (default: %(default)s)", ) # noqa parser.add_argument( u"--sv", metavar=u"V", type=float, <|code_end|> using the current file's imports: import argparse import sys import textwrap from brew.constants import GAL_PER_LITER from brew.constants import IMPERIAL_UNITS from brew.constants import SI_UNITS from brew.utilities.yeast import KaiserYeastModel from brew.utilities.yeast import WhiteYeastModel and any relevant context from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/utilities/yeast.py # class KaiserYeastModel(YeastModel): # """ # Kaiser Yeast Model # # Only works for Stir Plage Growth # # Sources: # # * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ # """ # # METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0} # # def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS): # return super(KaiserYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # if 0 < growth_rate < 1.4: # return (2.33 - growth_rate) / 0.67 # elif 1.4 <= growth_rate: # return 1.4 # # def get_growth_rate(self, initial_cells): # """ # initial_cells - Billion / gram extract (B/g) # """ # if initial_cells < 1.4: # return 1.4 + self.adjustment # elif 1.4 <= initial_cells < 3.5: # return 2.33 - 0.67 * initial_cells + self.adjustment # else: # return 0.0 + self.adjustment # # Path: brew/utilities/yeast.py # class WhiteYeastModel(YeastModel): # """ # Sources: # # * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ # * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print. # """ # noqa # # # Linear Regression Least Squares # INOCULATION_CONST = [-0.999499, 12.547938, -0.459486] # METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0} # # def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS): # return super(WhiteYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # a, b, c = self.INOCULATION_CONST # return 10 ** (math.log10(b / (growth_rate - a)) / -c) # # def get_growth_rate(self, inoculation_rate): # """ # initial_cells - Billion / gram extract (B/g) # # G = (12.54793776 * x^-0.4594858324) - 0.9994994906 # """ # noqa # # if inoculation_rate > 200: # # raise YeastException(u"Yeast will not grow at more than 200 M/ml") # noqa # a, b, c = self.INOCULATION_CONST # growth_rate = a + b * inoculation_rate ** c + self.adjustment # # if growth_rate > 6: # # raise YeastException(u"Model does not allow for growth greater than 6") # noqa # return growth_rate . Output only the next line.
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", og=1.05, fv=5.0, sg=1.036, sv=0.53, target_pitch_rate=1.42, yeast_type=u"liquid", cells=100, num=1, days=0, <|code_end|> . Use current file imports: import argparse import sys import textwrap from brew.constants import GAL_PER_LITER from brew.constants import IMPERIAL_UNITS from brew.constants import SI_UNITS from brew.utilities.yeast import KaiserYeastModel from brew.utilities.yeast import WhiteYeastModel and context (classes, functions, or code) from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/utilities/yeast.py # class KaiserYeastModel(YeastModel): # """ # Kaiser Yeast Model # # Only works for Stir Plage Growth # # Sources: # # * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ # """ # # METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0} # # def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS): # return super(KaiserYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # if 0 < growth_rate < 1.4: # return (2.33 - growth_rate) / 0.67 # elif 1.4 <= growth_rate: # return 1.4 # # def get_growth_rate(self, initial_cells): # """ # initial_cells - Billion / gram extract (B/g) # """ # if initial_cells < 1.4: # return 1.4 + self.adjustment # elif 1.4 <= initial_cells < 3.5: # return 2.33 - 0.67 * initial_cells + self.adjustment # else: # return 0.0 + self.adjustment # # Path: brew/utilities/yeast.py # class WhiteYeastModel(YeastModel): # """ # Sources: # # * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ # * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print. # """ # noqa # # # Linear Regression Least Squares # INOCULATION_CONST = [-0.999499, 12.547938, -0.459486] # METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0} # # def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS): # return super(WhiteYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # a, b, c = self.INOCULATION_CONST # return 10 ** (math.log10(b / (growth_rate - a)) / -c) # # def get_growth_rate(self, inoculation_rate): # """ # initial_cells - Billion / gram extract (B/g) # # G = (12.54793776 * x^-0.4594858324) - 0.9994994906 # """ # noqa # # if inoculation_rate > 200: # # raise YeastException(u"Yeast will not grow at more than 200 M/ml") # noqa # a, b, c = self.INOCULATION_CONST # growth_rate = a + b * inoculation_rate ** c + self.adjustment # # if growth_rate > 6: # # raise YeastException(u"Model does not allow for growth greater than 6") # noqa # return growth_rate . Output only the next line.
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", 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)", ) return parser def main(parser_fn=get_parser, parser_kwargs=None): parser = None if not parser_kwargs: parser = parser_fn() else: parser = parser_fn(**parser_kwargs) args = parser.parse_args() # Check on output <|code_end|> using the current file's imports: import argparse import sys import textwrap from brew.constants import GAL_PER_LITER from brew.constants import IMPERIAL_UNITS from brew.constants import SI_UNITS from brew.utilities.yeast import KaiserYeastModel from brew.utilities.yeast import WhiteYeastModel and any relevant context from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/utilities/yeast.py # class KaiserYeastModel(YeastModel): # """ # Kaiser Yeast Model # # Only works for Stir Plage Growth # # Sources: # # * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ # """ # # METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0} # # def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS): # return super(KaiserYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # if 0 < growth_rate < 1.4: # return (2.33 - growth_rate) / 0.67 # elif 1.4 <= growth_rate: # return 1.4 # # def get_growth_rate(self, initial_cells): # """ # initial_cells - Billion / gram extract (B/g) # """ # if initial_cells < 1.4: # return 1.4 + self.adjustment # elif 1.4 <= initial_cells < 3.5: # return 2.33 - 0.67 * initial_cells + self.adjustment # else: # return 0.0 + self.adjustment # # Path: brew/utilities/yeast.py # class WhiteYeastModel(YeastModel): # """ # Sources: # # * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ # * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print. # """ # noqa # # # Linear Regression Least Squares # INOCULATION_CONST = [-0.999499, 12.547938, -0.459486] # METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0} # # def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS): # return super(WhiteYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # a, b, c = self.INOCULATION_CONST # return 10 ** (math.log10(b / (growth_rate - a)) / -c) # # def get_growth_rate(self, inoculation_rate): # """ # initial_cells - Billion / gram extract (B/g) # # G = (12.54793776 * x^-0.4594858324) - 0.9994994906 # """ # noqa # # if inoculation_rate > 200: # # raise YeastException(u"Yeast will not grow at more than 200 M/ml") # noqa # a, b, c = self.INOCULATION_CONST # growth_rate = a + b * inoculation_rate ** c + self.adjustment # # if growth_rate > 6: # # raise YeastException(u"Model does not allow for growth greater than 6") # noqa # return growth_rate . Output only the next line.
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)", ) return parser def main(parser_fn=get_parser, parser_kwargs=None): parser = None if not parser_kwargs: parser = parser_fn() else: parser = parser_fn(**parser_kwargs) args = parser.parse_args() # Check on output if args.units not in [IMPERIAL_UNITS, SI_UNITS]: print(u"Units must be in either {} or {}".format(IMPERIAL_UNITS, SI_UNITS)) sys.exit(1) model_cls = None if args.model == u"white": model_cls = WhiteYeastModel elif args.model == u"kaiser": <|code_end|> , predict the immediate next line with the help of imports: import argparse import sys import textwrap from brew.constants import GAL_PER_LITER from brew.constants import IMPERIAL_UNITS from brew.constants import SI_UNITS from brew.utilities.yeast import KaiserYeastModel from brew.utilities.yeast import WhiteYeastModel and context (classes, functions, sometimes code) from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/utilities/yeast.py # class KaiserYeastModel(YeastModel): # """ # Kaiser Yeast Model # # Only works for Stir Plage Growth # # Sources: # # * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ # """ # # METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0} # # def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS): # return super(KaiserYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # if 0 < growth_rate < 1.4: # return (2.33 - growth_rate) / 0.67 # elif 1.4 <= growth_rate: # return 1.4 # # def get_growth_rate(self, initial_cells): # """ # initial_cells - Billion / gram extract (B/g) # """ # if initial_cells < 1.4: # return 1.4 + self.adjustment # elif 1.4 <= initial_cells < 3.5: # return 2.33 - 0.67 * initial_cells + self.adjustment # else: # return 0.0 + self.adjustment # # Path: brew/utilities/yeast.py # class WhiteYeastModel(YeastModel): # """ # Sources: # # * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ # * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print. # """ # noqa # # # Linear Regression Least Squares # INOCULATION_CONST = [-0.999499, 12.547938, -0.459486] # METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0} # # def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS): # return super(WhiteYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # a, b, c = self.INOCULATION_CONST # return 10 ** (math.log10(b / (growth_rate - a)) / -c) # # def get_growth_rate(self, inoculation_rate): # """ # initial_cells - Billion / gram extract (B/g) # # G = (12.54793776 * x^-0.4594858324) - 0.9994994906 # """ # noqa # # if inoculation_rate > 200: # # raise YeastException(u"Yeast will not grow at more than 200 M/ml") # noqa # a, b, c = self.INOCULATION_CONST # growth_rate = a + b * inoculation_rate ** c + self.adjustment # # if growth_rate > 6: # # raise YeastException(u"Model does not allow for growth greater than 6") # noqa # return growth_rate . Output only the next line.
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 this file: import argparse import sys import textwrap from brew.constants import GAL_PER_LITER from brew.constants import IMPERIAL_UNITS from brew.constants import SI_UNITS from brew.utilities.yeast import KaiserYeastModel from brew.utilities.yeast import WhiteYeastModel and context (functions, classes, or occasionally code) from other files: # Path: brew/constants.py # GAL_PER_LITER = 1.0 / LITER_PER_GAL # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/utilities/yeast.py # class KaiserYeastModel(YeastModel): # """ # Kaiser Yeast Model # # Only works for Stir Plage Growth # # Sources: # # * http://braukaiser.com/blog/blog/2012/11/03/estimating-yeast-growth/ # """ # # METHOD_TO_GROWTH_ADJ = {u"stir plate": 0.0} # # def __init__(self, method=u"stir plate", units=IMPERIAL_UNITS): # return super(KaiserYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # if 0 < growth_rate < 1.4: # return (2.33 - growth_rate) / 0.67 # elif 1.4 <= growth_rate: # return 1.4 # # def get_growth_rate(self, initial_cells): # """ # initial_cells - Billion / gram extract (B/g) # """ # if initial_cells < 1.4: # return 1.4 + self.adjustment # elif 1.4 <= initial_cells < 3.5: # return 2.33 - 0.67 * initial_cells + self.adjustment # else: # return 0.0 + self.adjustment # # Path: brew/utilities/yeast.py # class WhiteYeastModel(YeastModel): # """ # Sources: # # * http://www.brewersfriend.com/yeast-pitch-rate-and-starter-calculator/ # * White, Chris, and Jamil Zainasheff. Yeast: The Practical Guide to Beer Fermentation. Boulder, CO: Brewers Publications, 2010. 139-44. Print. # """ # noqa # # # Linear Regression Least Squares # INOCULATION_CONST = [-0.999499, 12.547938, -0.459486] # METHOD_TO_GROWTH_ADJ = {u"no agitation": 0.0, u"shaking": 0.5, u"stir plate": 1.0} # # def __init__(self, method=u"no agitation", units=IMPERIAL_UNITS): # return super(WhiteYeastModel, self).__init__(method, units=units) # # def get_inoculation_rate(self, growth_rate): # a, b, c = self.INOCULATION_CONST # return 10 ** (math.log10(b / (growth_rate - a)) / -c) # # def get_growth_rate(self, inoculation_rate): # """ # initial_cells - Billion / gram extract (B/g) # # G = (12.54793776 * x^-0.4594858324) - 0.9994994906 # """ # noqa # # if inoculation_rate > 200: # # raise YeastException(u"Yeast will not grow at more than 200 M/ml") # noqa # a, b, c = self.INOCULATION_CONST # growth_rate = a + b * inoculation_rate ** c + self.adjustment # # if growth_rate > 6: # # raise YeastException(u"Model does not allow for growth greater than 6") # noqa # return growth_rate . Output only the next line.
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": u"Caramunich Malt", u"data": {u"color": 60.0}, u"weight": 1.0, u"grain_type": u"specialty", }, ], u"hops": [ { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.04}, u"weight": 1.5, u"boil_time": 60.0, }, { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.04}, u"weight": 0.5, u"boil_time": 20.0, }, ], u"yeast": {u"name": u"Wyeast 2206", u"data": {u"percent_attenuation": 0.73}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> , predict the immediate next line with the help of imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and context (classes, functions, sometimes code) from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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": u"Caramunich Malt", u"data": {u"color": 60.0}, u"weight": 1.0, u"grain_type": u"specialty", }, ], u"hops": [ { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.04}, u"weight": 1.5, u"boil_time": 60.0, }, { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.04}, u"weight": 0.5, u"boil_time": 20.0, }, ], u"yeast": {u"name": u"Wyeast 2206", u"data": {u"percent_attenuation": 0.73}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> using the current file's imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and any relevant context from other files: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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.efficiency import calculate_brew_house_yield from fixtures import recipe and context (classes, functions, sometimes code) from other files: # Path: brew/utilities/efficiency.py # 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 specific gravity of the wort # :param list grain_additions: A list of grain additions in the wort # :type grain_additions: list of GrainAddition objects # :return: The brew house yield as a percentage # # Brew House Yield is a function of the wort volume, the measured specific # gravity, and the grain additions used to make the wort. This equation is # thrown off by use of LME or DME since both have 100% efficiency in a brew. # A better measure is to look at just the grains that needed to be steeped # seperately and measure the specific gravity of that process. # """ # total_gu = sum([grain_add.gu for grain_add in grain_additions]) # return (sg_to_gu(sg) * wort_volume) / total_gu . Output only the next line.
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_conversion(None, None, self.sg, u"p") self.assertEquals(round(out, 1), self.plato) def test_get_sugar_conversion_sg_to_sg(self): out = get_sugar_conversion(None, None, self.sg, u"s") self.assertEquals(round(out, 3), self.sg) def test_get_sugar_conversion_all_brix(self): out = get_sugar_conversion(self.brix, None, None, None) expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0" self.assertEquals(out, expected) def test_get_sugar_conversion_all_plato(self): out = get_sugar_conversion(None, self.plato, None, None) expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0" self.assertEquals(out, expected) def test_get_sugar_conversion_all_sg(self): out = get_sugar_conversion(None, None, self.sg, None) expected = u"SG\tPlato\tBrix\n1.092\t22.0\t22.0" self.assertEquals(out, expected) class TestCliArgparserSugar(unittest.TestCase): def setUp(self): <|code_end|> , predict the next line using imports from the current file: import unittest from brew.cli.sugar import get_parser from brew.cli.sugar import get_sugar_conversion from brew.cli.sugar import main and context including class names, function names, and sometimes code from other files: # Path: brew/cli/sugar.py # def get_parser(): # parser = argparse.ArgumentParser(description=u"Sugar Conversion") # parser.add_argument( # u"-b", u"--brix", metavar=u"B", type=float, help=u"Degrees Brix" # ) # parser.add_argument( # u"-p", u"--plato", metavar=u"P", type=float, help=u"Degrees Plato" # ) # parser.add_argument( # u"-s", u"--sg", metavar=u"S", type=float, help=u"Specific Gravity" # ) # parser.add_argument( # u"-o", # u"--out", # metavar=u"O", # type=str, # help=u"Desired Output (b, p, s accepted)", # ) # return parser # # Path: brew/cli/sugar.py # 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 conversion ('b', 'p', 's', or None) # """ # brix, plato, sg = 0.0, 0.0, 0.0 # if brix_in: # brix = brix_in # plato = brix_to_plato(brix_in) # sg = brix_to_sg(brix_in) # elif plato_in: # brix = plato_to_brix(plato_in) # plato = plato_in # sg = plato_to_sg(plato_in) # elif sg_in: # brix = sg_to_brix(sg_in) # plato = sg_to_plato(sg_in) # sg = sg_in # # brix = round(brix, 1) # plato = round(plato, 1) # sg = round(sg, 3) # if sugar_out and sugar_out in [u"b", u"p", u"s"]: # if sugar_out == u"b": # return brix # elif sugar_out == u"p": # return plato # elif sugar_out == u"s": # return sg # else: # out = textwrap.dedent( # u"""\ # SG\tPlato\tBrix # {:0.3f}\t{:0.1f}\t{:0.1f}""".format( # sg, plato, brix # ) # ) # return out # # Path: brew/cli/sugar.py # def main(parser_fn=get_parser, parser_kwargs=None): # parser = None # if not parser_kwargs: # parser = parser_fn() # else: # parser = parser_fn(**parser_kwargs) # args = parser.parse_args() # # if sum(bool(arg) for arg in [args.brix, args.plato, args.sg]) != 1: # print(u"Must provide only one of Brix, Plato or Specific Gravity") # sys.exit(1) # print(get_sugar_conversion(args.brix, args.plato, args.sg, args.out)) . Output only the next line.
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 imports: import unittest from brew.cli.sugar import get_parser from brew.cli.sugar import get_sugar_conversion from brew.cli.sugar import main and context (classes, functions, sometimes code) from other files: # Path: brew/cli/sugar.py # def get_parser(): # parser = argparse.ArgumentParser(description=u"Sugar Conversion") # parser.add_argument( # u"-b", u"--brix", metavar=u"B", type=float, help=u"Degrees Brix" # ) # parser.add_argument( # u"-p", u"--plato", metavar=u"P", type=float, help=u"Degrees Plato" # ) # parser.add_argument( # u"-s", u"--sg", metavar=u"S", type=float, help=u"Specific Gravity" # ) # parser.add_argument( # u"-o", # u"--out", # metavar=u"O", # type=str, # help=u"Desired Output (b, p, s accepted)", # ) # return parser # # Path: brew/cli/sugar.py # 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 conversion ('b', 'p', 's', or None) # """ # brix, plato, sg = 0.0, 0.0, 0.0 # if brix_in: # brix = brix_in # plato = brix_to_plato(brix_in) # sg = brix_to_sg(brix_in) # elif plato_in: # brix = plato_to_brix(plato_in) # plato = plato_in # sg = plato_to_sg(plato_in) # elif sg_in: # brix = sg_to_brix(sg_in) # plato = sg_to_plato(sg_in) # sg = sg_in # # brix = round(brix, 1) # plato = round(plato, 1) # sg = round(sg, 3) # if sugar_out and sugar_out in [u"b", u"p", u"s"]: # if sugar_out == u"b": # return brix # elif sugar_out == u"p": # return plato # elif sugar_out == u"s": # return sg # else: # out = textwrap.dedent( # u"""\ # SG\tPlato\tBrix # {:0.3f}\t{:0.1f}\t{:0.1f}""".format( # sg, plato, brix # ) # ) # return out # # Path: brew/cli/sugar.py # def main(parser_fn=get_parser, parser_kwargs=None): # parser = None # if not parser_kwargs: # parser = parser_fn() # else: # parser = parser_fn(**parser_kwargs) # args = parser.parse_args() # # if sum(bool(arg) for arg in [args.brix, args.plato, args.sg]) != 1: # print(u"Must provide only one of Brix, Plato or Specific Gravity") # sys.exit(1) # print(get_sugar_conversion(args.brix, args.plato, args.sg, args.out)) . Output only the next line.
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.parse_args(args) expected = {u"brix": None, u"plato": None, u"sg": 1.060, u"out": u"b"} self.assertEquals(out.__dict__, expected) class TestCliMainSugar(unittest.TestCase): def setUp(self): class Parser(object): def __init__(self, output): self.output = output def parse_args(self): class Args(object): pass args = Args() if self.output: for k, v in self.output.items(): setattr(args, k, v) return args def g_parser(output=None): return Parser(output) self.parser_fn = g_parser <|code_end|> , predict the next line using imports from the current file: import unittest from brew.cli.sugar import get_parser from brew.cli.sugar import get_sugar_conversion from brew.cli.sugar import main and context including class names, function names, and sometimes code from other files: # Path: brew/cli/sugar.py # def get_parser(): # parser = argparse.ArgumentParser(description=u"Sugar Conversion") # parser.add_argument( # u"-b", u"--brix", metavar=u"B", type=float, help=u"Degrees Brix" # ) # parser.add_argument( # u"-p", u"--plato", metavar=u"P", type=float, help=u"Degrees Plato" # ) # parser.add_argument( # u"-s", u"--sg", metavar=u"S", type=float, help=u"Specific Gravity" # ) # parser.add_argument( # u"-o", # u"--out", # metavar=u"O", # type=str, # help=u"Desired Output (b, p, s accepted)", # ) # return parser # # Path: brew/cli/sugar.py # 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 conversion ('b', 'p', 's', or None) # """ # brix, plato, sg = 0.0, 0.0, 0.0 # if brix_in: # brix = brix_in # plato = brix_to_plato(brix_in) # sg = brix_to_sg(brix_in) # elif plato_in: # brix = plato_to_brix(plato_in) # plato = plato_in # sg = plato_to_sg(plato_in) # elif sg_in: # brix = sg_to_brix(sg_in) # plato = sg_to_plato(sg_in) # sg = sg_in # # brix = round(brix, 1) # plato = round(plato, 1) # sg = round(sg, 3) # if sugar_out and sugar_out in [u"b", u"p", u"s"]: # if sugar_out == u"b": # return brix # elif sugar_out == u"p": # return plato # elif sugar_out == u"s": # return sg # else: # out = textwrap.dedent( # u"""\ # SG\tPlato\tBrix # {:0.3f}\t{:0.1f}\t{:0.1f}""".format( # sg, plato, brix # ) # ) # return out # # Path: brew/cli/sugar.py # def main(parser_fn=get_parser, parser_kwargs=None): # parser = None # if not parser_kwargs: # parser = parser_fn() # else: # parser = parser_fn(**parser_kwargs) # args = parser.parse_args() # # if sum(bool(arg) for arg in [args.brix, args.plato, args.sg]) != 1: # print(u"Must provide only one of Brix, Plato or Specific Gravity") # sys.exit(1) # print(get_sugar_conversion(args.brix, args.plato, args.sg, args.out)) . Output only the next line.
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, u"grain_type": u"specialty", }, ], u"hops": [ { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 1.7, u"boil_time": 60.0, }, { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 0.75, u"boil_time": 0.0, }, ], u"yeast": {u"name": u"Wyeast 3724", u"data": {u"percent_attenuation": 0.86}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) <|code_end|> , determine the next line of code. You have imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and context (class names, function names, or code) available: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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", }, ], u"hops": [ { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 1.7, u"boil_time": 60.0, }, { u"name": u"Hallertau US", u"data": {u"percent_alpha_acids": 0.05}, u"weight": 0.75, u"boil_time": 0.0, }, ], u"yeast": {u"name": u"Wyeast 3724", u"data": {u"percent_attenuation": 0.86}}, u"data": {u"brew_house_yield": 0.70, u"units": u"imperial"}, } data_dir = os.path.abspath(os.path.join(os.getcwd(), "data/")) loader = JSONDataLoader(data_dir) <|code_end|> , determine the next line of code. You have imports: import os from brew.parsers import JSONDataLoader from brew.parsers import parse_recipe and context (class names, function names, or code) available: # Path: brew/parsers.py # class JSONDataLoader(DataLoader): # """ # Load data from JSON files inside the data_dir. # """ # # #: The JSON file extension # EXT = "json" # # @classmethod # def read_data(cls, filename): # """ # :param str filename: The filename of the file to read # :return: The data loaded from a JSON file # """ # data = None # with open(filename, "r") as data_file: # data = json.loads(data_file.read()) # return data # # Path: brew/parsers.py # def parse_recipe( # recipe, # loader, # cereals_loader=None, # hops_loader=None, # yeast_loader=None, # cereals_dir_suffix="cereals/", # hops_dir_suffix="hops/", # yeast_dir_suffix="yeast/", # ): # """ # Parse a recipe from a python Dict # # :param dict recipe: A representation of a recipe # :param DataLoader loader: A class to load additional information # :param DataLoader cereal_loader: A class to load additional information specific to cereals # :param DataLoader hops_loader: A class to load additional information specific to hops # :param DataLoader yeast_loader: A class to load additional information specific to yeast # # A recipe must have the following top level attributes: # # * name (str) # * start_volume (float) # * final_volume (float) # * grains (list(dict)) # * hops (list(dict)) # * yeast (dict) # # Additionally the recipe may contain override data in the 'data' # attribute with the following keys: # # * brew_house_yield (float) # * units (str) # # All other fields will be ignored and may be used for other metadata. # # The dict objects in the grains, hops, and yeast values are required to have # the key 'name' and the remaining attributes will be looked up in the data # directory if they are not provided. # """ # noqa # if cereals_loader is None: # cereals_loader = loader # if hops_loader is None: # hops_loader = loader # if yeast_loader is None: # yeast_loader = loader # # Recipe.validate(recipe) # # grain_additions = [] # for grain in recipe[u"grains"]: # grain_additions.append( # parse_cereals(grain, cereals_loader, dir_suffix=cereals_dir_suffix) # ) # # hop_additions = [] # for hop in recipe[u"hops"]: # hop_additions.append(parse_hops(hop, hops_loader, dir_suffix=hops_dir_suffix)) # # yeast = parse_yeast(recipe[u"yeast"], yeast_loader, dir_suffix=yeast_dir_suffix) # # recipe_kwargs = { # u"grain_additions": grain_additions, # u"hop_additions": hop_additions, # u"yeast": yeast, # u"start_volume": recipe[u"start_volume"], # u"final_volume": recipe[u"final_volume"], # } # if u"data" in recipe: # if u"brew_house_yield" in recipe[u"data"]: # recipe_kwargs[u"brew_house_yield"] = recipe[u"data"][u"brew_house_yield"] # if u"units" in recipe[u"data"]: # recipe_kwargs[u"units"] = recipe[u"data"][u"units"] # # beer = Recipe(recipe[u"name"], **recipe_kwargs) # return beer . Output only the next line.
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) def test_to_json(self): out = self.yeast.to_json() expected = ( u'{"data": {"percent_attenuation": 0.75}, "name": "Wyeast 1056"}' ) # noqa self.assertEquals(out, expected) def test_validate(self): data = self.yeast.to_dict() Yeast.validate(data) def test_format(self): out = self.yeast.format() msg = textwrap.dedent( u"""\ Wyeast 1056 Yeast ----------------------------------- Attenuation: 75.0%""" ) self.assertEquals(out, msg) def test_yeast_no_percent_attenuation(self): <|code_end|> . Use current file imports: import sys import textwrap import unittest from brew.exceptions import YeastException from brew.yeasts import Yeast from fixtures import cascade_add from fixtures import yeast and context (classes, functions, or code) from other files: # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/yeasts.py # class Yeast(object): # """ # A representation of a type of Yeast as added to a Recipe. # """ # # def __init__(self, name, percent_attenuation=0.75): # """ # :param float percent_attenuation: The percentage the yeast is expected to attenuate the sugar in the yeast to create alcohol # :raises YeastException: If percent_attenuation is not provided # """ # noqa # self.name = name # if percent_attenuation is None: # raise YeastException( # u"{}: Must provide percent attenuation".format(self.name) # noqa # ) # self.percent_attenuation = validate_percentage(percent_attenuation) # # def __str__(self): # if sys.version_info[0] >= 3: # return self.__unicode__() # else: # return self.__unicode__().encode(u"utf8") # # def __unicode__(self): # return u"{0}, attenuation {1:0.1%}".format( # self.name.capitalize(), self.percent_attenuation # ) # # def __repr__(self): # out = u"{0}('{1}'".format(type(self).__name__, self.name) # if self.percent_attenuation: # out = u"{0}, percent_attenuation={1}".format(out, self.percent_attenuation) # out = u"{0})".format(out) # return out # # def __eq__(self, other): # if not isinstance(other, self.__class__): # return False # if (self.name == other.name) and ( # self.percent_attenuation == other.percent_attenuation # ): # return True # return False # # def __ne__(self, other): # return not self.__eq__(other) # # def to_dict(self): # return { # u"name": self.name, # u"data": {u"percent_attenuation": self.percent_attenuation}, # } # # def to_json(self): # return json.dumps(self.to_dict(), sort_keys=True) # # @classmethod # def validate(cls, yeast_data): # required_fields = [(u"name", str)] # optional_fields = [(u"percent_attenuation", float)] # validate_required_fields(yeast_data, required_fields) # validate_optional_fields(yeast_data, optional_fields) # # def format(self): # msg = textwrap.dedent( # u"""\ # {name} Yeast # ----------------------------------- # Attenuation: {data[percent_attenuation]:0.1%}""".format( # **self.to_dict() # ) # ) # return msg . Output only the next line.
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(self): <|code_end|> . Use current file imports: import sys import textwrap import unittest from brew.exceptions import YeastException from brew.yeasts import Yeast from fixtures import cascade_add from fixtures import yeast and context (classes, functions, or code) from other files: # Path: brew/exceptions.py # class YeastException(BrewdayException): # pass # # Path: brew/yeasts.py # class Yeast(object): # """ # A representation of a type of Yeast as added to a Recipe. # """ # # def __init__(self, name, percent_attenuation=0.75): # """ # :param float percent_attenuation: The percentage the yeast is expected to attenuate the sugar in the yeast to create alcohol # :raises YeastException: If percent_attenuation is not provided # """ # noqa # self.name = name # if percent_attenuation is None: # raise YeastException( # u"{}: Must provide percent attenuation".format(self.name) # noqa # ) # self.percent_attenuation = validate_percentage(percent_attenuation) # # def __str__(self): # if sys.version_info[0] >= 3: # return self.__unicode__() # else: # return self.__unicode__().encode(u"utf8") # # def __unicode__(self): # return u"{0}, attenuation {1:0.1%}".format( # self.name.capitalize(), self.percent_attenuation # ) # # def __repr__(self): # out = u"{0}('{1}'".format(type(self).__name__, self.name) # if self.percent_attenuation: # out = u"{0}, percent_attenuation={1}".format(out, self.percent_attenuation) # out = u"{0})".format(out) # return out # # def __eq__(self, other): # if not isinstance(other, self.__class__): # return False # if (self.name == other.name) and ( # self.percent_attenuation == other.percent_attenuation # ): # return True # return False # # def __ne__(self, other): # return not self.__eq__(other) # # def to_dict(self): # return { # u"name": self.name, # u"data": {u"percent_attenuation": self.percent_attenuation}, # } # # def to_json(self): # return json.dumps(self.to_dict(), sort_keys=True) # # @classmethod # def validate(cls, yeast_data): # required_fields = [(u"name", str)] # optional_fields = [(u"percent_attenuation", float)] # validate_required_fields(yeast_data, required_fields) # validate_optional_fields(yeast_data, optional_fields) # # def format(self): # msg = textwrap.dedent( # u"""\ # {name} Yeast # ----------------------------------- # Attenuation: {data[percent_attenuation]:0.1%}""".format( # **self.to_dict() # ) # ) # return msg . Output only the next line.
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.assertEquals(out, 1.015) class TestCliArgparserTemp(unittest.TestCase): def setUp(self): <|code_end|> using the current file's imports: import unittest from brew.cli.gravity_volume import get_parser from brew.cli.gravity_volume import get_gravity from brew.cli.gravity_volume import main and any relevant context from other files: # Path: brew/cli/gravity_volume.py # def get_parser(): # parser = argparse.ArgumentParser(description=u"Gravity-Volume Conversion") # parser.add_argument( # u"-o", # u"--original-volume", # metavar=u"V", # type=float, # required=True, # help=u"Original Volume", # ) # parser.add_argument( # u"-f", # u"--final-volume", # metavar=u"V", # type=float, # required=True, # help=u"Final Volume", # ) # parser.add_argument( # u"-g", u"--gravity", metavar=u"G", type=float, required=True, help=u"Gravity" # ) # return parser # # Path: brew/cli/gravity_volume.py # def get_gravity(original_volume, final_volume, gravity): # """ # Convert gravity at original volume to gravity at final volume # """ # return gu_to_sg(sg_to_gu(gravity) * original_volume / final_volume) # # Path: brew/cli/gravity_volume.py # def main(parser_fn=get_parser, parser_kwargs=None): # parser = None # if not parser_kwargs: # parser = parser_fn() # else: # parser = parser_fn(**parser_kwargs) # args = parser.parse_args() # if not all([args.original_volume, args.final_volume, args.gravity]): # print("Please provide all arguments") # sys.exit(1) # out = get_gravity(args.original_volume, args.final_volume, args.gravity) # print("{:0.3f}".format(out)) . Output only the next line.
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 from brew.cli.gravity_volume import get_parser from brew.cli.gravity_volume import get_gravity from brew.cli.gravity_volume import main and context: # Path: brew/cli/gravity_volume.py # def get_parser(): # parser = argparse.ArgumentParser(description=u"Gravity-Volume Conversion") # parser.add_argument( # u"-o", # u"--original-volume", # metavar=u"V", # type=float, # required=True, # help=u"Original Volume", # ) # parser.add_argument( # u"-f", # u"--final-volume", # metavar=u"V", # type=float, # required=True, # help=u"Final Volume", # ) # parser.add_argument( # u"-g", u"--gravity", metavar=u"G", type=float, required=True, help=u"Gravity" # ) # return parser # # Path: brew/cli/gravity_volume.py # def get_gravity(original_volume, final_volume, gravity): # """ # Convert gravity at original volume to gravity at final volume # """ # return gu_to_sg(sg_to_gu(gravity) * original_volume / final_volume) # # Path: brew/cli/gravity_volume.py # def main(parser_fn=get_parser, parser_kwargs=None): # parser = None # if not parser_kwargs: # parser = parser_fn() # else: # parser = parser_fn(**parser_kwargs) # args = parser.parse_args() # if not all([args.original_volume, args.final_volume, args.gravity]): # print("Please provide all arguments") # sys.exit(1) # out = get_gravity(args.original_volume, args.final_volume, args.gravity) # print("{:0.3f}".format(out)) which might include code, classes, or functions. Output only the next line.
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.050} self.assertEquals(out.__dict__, expected) class TestCliMainTemp(unittest.TestCase): def setUp(self): class Parser(object): def __init__(self, output): self.output = output def parse_args(self): class Args(object): pass args = Args() if self.output: for k, v in self.output.items(): setattr(args, k, v) return args def g_parser(output=None): return Parser(output) self.parser_fn = g_parser <|code_end|> . Use current file imports: import unittest from brew.cli.gravity_volume import get_parser from brew.cli.gravity_volume import get_gravity from brew.cli.gravity_volume import main and context (classes, functions, or code) from other files: # Path: brew/cli/gravity_volume.py # def get_parser(): # parser = argparse.ArgumentParser(description=u"Gravity-Volume Conversion") # parser.add_argument( # u"-o", # u"--original-volume", # metavar=u"V", # type=float, # required=True, # help=u"Original Volume", # ) # parser.add_argument( # u"-f", # u"--final-volume", # metavar=u"V", # type=float, # required=True, # help=u"Final Volume", # ) # parser.add_argument( # u"-g", u"--gravity", metavar=u"G", type=float, required=True, help=u"Gravity" # ) # return parser # # Path: brew/cli/gravity_volume.py # def get_gravity(original_volume, final_volume, gravity): # """ # Convert gravity at original volume to gravity at final volume # """ # return gu_to_sg(sg_to_gu(gravity) * original_volume / final_volume) # # Path: brew/cli/gravity_volume.py # def main(parser_fn=get_parser, parser_kwargs=None): # parser = None # if not parser_kwargs: # parser = parser_fn() # else: # parser = parser_fn(**parser_kwargs) # args = parser.parse_args() # if not all([args.original_volume, args.final_volume, args.gravity]): # print("Please provide all arguments") # sys.exit(1) # out = get_gravity(args.original_volume, args.final_volume, args.gravity) # print("{:0.3f}".format(out)) . Output only the next line.
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): """ Validate a grain type :param str grain_type: Type of Grain :return: grain type :rtype: str :raises ValidatorException: If grain type is unknown """ <|code_end|> using the current file's imports: from .constants import GRAIN_TYPE_LIST from .constants import HOP_TYPE_LIST from .constants import IMPERIAL_UNITS from .constants import SI_UNITS from .exceptions import ValidatorException and any relevant context from other files: # Path: brew/constants.py # GRAIN_TYPE_LIST = [ # GRAIN_TYPE_CEREAL, # GRAIN_TYPE_SPECIALTY, # GRAIN_TYPE_DME, # GRAIN_TYPE_LME, # ] # # Path: brew/constants.py # HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG] # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass . Output only the next line.
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: return grain_type raise ValidatorException( u"Unkown grain type '{}', must use {}".format( grain_type, u", ".join(GRAIN_TYPE_LIST) ) ) def validate_hop_type(hop_type): """ Validate a hop type :param str hop_type: Type of Grain :return: hop type :rtype: str :raises ValidatorException: If hop type is unknown """ <|code_end|> with the help of current file imports: from .constants import GRAIN_TYPE_LIST from .constants import HOP_TYPE_LIST from .constants import IMPERIAL_UNITS from .constants import SI_UNITS from .exceptions import ValidatorException and context from other files: # Path: brew/constants.py # GRAIN_TYPE_LIST = [ # GRAIN_TYPE_CEREAL, # GRAIN_TYPE_SPECIALTY, # GRAIN_TYPE_DME, # GRAIN_TYPE_LME, # ] # # Path: brew/constants.py # HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG] # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass , which may contain function names, class names, or code. Output only the next line.
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: Percentage between 0.0 and 1.0 :return: percentage :rtype: float :raises ValidatorException: If decimal percentage not between 0.0 and 1.0 """ if 0.0 <= percent <= 1.0: return percent raise ValidatorException(u"Percentage values should be in decimal format") def validate_units(units): """ Validate units :param str units: Unit type :return: units :rtype: str :raises ValidatorException: If units is unknown """ <|code_end|> , continue by predicting the next line. Consider current file imports: from .constants import GRAIN_TYPE_LIST from .constants import HOP_TYPE_LIST from .constants import IMPERIAL_UNITS from .constants import SI_UNITS from .exceptions import ValidatorException and context: # Path: brew/constants.py # GRAIN_TYPE_LIST = [ # GRAIN_TYPE_CEREAL, # GRAIN_TYPE_SPECIALTY, # GRAIN_TYPE_DME, # GRAIN_TYPE_LME, # ] # # Path: brew/constants.py # HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG] # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass which might include code, classes, or functions. Output only the next line.
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: Percentage between 0.0 and 1.0 :return: percentage :rtype: float :raises ValidatorException: If decimal percentage not between 0.0 and 1.0 """ if 0.0 <= percent <= 1.0: return percent raise ValidatorException(u"Percentage values should be in decimal format") def validate_units(units): """ Validate units :param str units: Unit type :return: units :rtype: str :raises ValidatorException: If units is unknown """ <|code_end|> . Use current file imports: (from .constants import GRAIN_TYPE_LIST from .constants import HOP_TYPE_LIST from .constants import IMPERIAL_UNITS from .constants import SI_UNITS from .exceptions import ValidatorException) and context including class names, function names, or small code snippets from other files: # Path: brew/constants.py # GRAIN_TYPE_LIST = [ # GRAIN_TYPE_CEREAL, # GRAIN_TYPE_SPECIALTY, # GRAIN_TYPE_DME, # GRAIN_TYPE_LME, # ] # # Path: brew/constants.py # HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG] # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass . Output only the next line.
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 :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: return grain_type <|code_end|> , determine the next line of code. You have imports: from .constants import GRAIN_TYPE_LIST from .constants import HOP_TYPE_LIST from .constants import IMPERIAL_UNITS from .constants import SI_UNITS from .exceptions import ValidatorException and context (class names, function names, or code) available: # Path: brew/constants.py # GRAIN_TYPE_LIST = [ # GRAIN_TYPE_CEREAL, # GRAIN_TYPE_SPECIALTY, # GRAIN_TYPE_DME, # GRAIN_TYPE_LME, # ] # # Path: brew/constants.py # HOP_TYPE_LIST = [HOP_TYPE_PELLET, HOP_TYPE_WHOLE, HOP_TYPE_WHOLE_WET, HOP_TYPE_PLUG] # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class ValidatorException(BrewdayException): # pass . Output only the next line.
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 specific gravity of the wort :param list grain_additions: A list of grain additions in the wort :type grain_additions: list of GrainAddition objects :return: The brew house yield as a percentage Brew House Yield is a function of the wort volume, the measured specific gravity, and the grain additions used to make the wort. This equation is thrown off by use of LME or DME since both have 100% efficiency in a brew. A better measure is to look at just the grains that needed to be steeped seperately and measure the specific gravity of that process. """ total_gu = sum([grain_add.gu for grain_add in grain_additions]) <|code_end|> . Use current file imports: (from .sugar import sg_to_gu from ..constants import PPG_DME) and context including class names, function names, or small code snippets from other files: # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/constants.py # PPG_DME = 44.0 . Output only the next line.
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 float sg: THe specific gravity of the wort :param list grain_additions: A list of grain additions in the wort :type grain_additions: list of GrainAddition objects :return: The brew house yield as a percentage Brew House Yield is a function of the wort volume, the measured specific gravity, and the grain additions used to make the wort. This equation is thrown off by use of LME or DME since both have 100% efficiency in a brew. A better measure is to look at just the grains that needed to be steeped seperately and measure the specific gravity of that process. """ total_gu = sum([grain_add.gu for grain_add in grain_additions]) return (sg_to_gu(sg) * wort_volume) / total_gu def get_wort_correction( <|code_end|> with the help of current file imports: from .sugar import sg_to_gu from ..constants import PPG_DME and context from other files: # Path: brew/utilities/sugar.py # def sg_to_gu(sg): # """ # Specific Gravity to Gravity Units # # :param float sg: Specific Gravity # :return: Gravity Units # :rtype: float # """ # return (sg - 1) * 1000.0 # # Path: brew/constants.py # PPG_DME = 44.0 , which may contain function names, class names, or code. Output only the next line.
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)} = 1.313454 - 0.132674 \\times T + 2.057793e^{-3} \\times T^2 - 2.627634e^{-6} \\times T^3` where T is in degrees F. Sources: * http://www.topdownbrew.com/SGCorrection.html * http://hbd.org/brewery/library/HydromCorr0992.html * http://www.brewersfriend.com/hydrometer-temp/ * http://www.primetab.com/formulas.html """ # noqa validate_units(units) if units == SI_UNITS: if temp < 0.0 or 100.0 < temp: raise SugarException( u"Correction does not work outside temps 0 - 100C" ) # noqa temp = celsius_to_fahrenheit(temp) elif units == IMPERIAL_UNITS: if temp < 0.0 or 212.0 < temp: raise SugarException( u"Correction does not work outside temps 0 - 212F" ) # noqa <|code_end|> , determine the next line of code. You have imports: from ..constants import HYDROMETER_ADJUSTMENT_TEMP from ..constants import IMPERIAL_UNITS from ..constants import SI_UNITS from ..exceptions import SugarException from ..validators import validate_units from .temperature import celsius_to_fahrenheit and context (class names, function names, or code) available: # Path: brew/constants.py # HYDROMETER_ADJUSTMENT_TEMP = 59.0 # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class SugarException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 . Output only the next line.
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 Extract in degrees Plato :param float original_extract: Original degrees Plato :param float apparent_extract: Apparent degrees Plato of finished beer :return: Real degrees Plato of finished beer :rtype: float Source: * Formula from Balling: De Clerck, Jean, A Textbook Of Brewing, Chapman & Hall Ltd., 1958 """ # noqa attenuation_coeff = 0.22 + 0.001 * original_extract real_extract = (attenuation_coeff * original_extract + apparent_extract) / ( 1 + attenuation_coeff ) # noqa return real_extract <|code_end|> , determine the next line of code. You have imports: from ..constants import HYDROMETER_ADJUSTMENT_TEMP from ..constants import IMPERIAL_UNITS from ..constants import SI_UNITS from ..exceptions import SugarException from ..validators import validate_units from .temperature import celsius_to_fahrenheit and context (class names, function names, or code) available: # Path: brew/constants.py # HYDROMETER_ADJUSTMENT_TEMP = 59.0 # # Path: brew/constants.py # IMPERIAL_UNITS = u"imperial" # # Path: brew/constants.py # SI_UNITS = u"metric" # # Path: brew/exceptions.py # class SugarException(BrewdayException): # pass # # Path: brew/validators.py # def validate_units(units): # """ # Validate units # # :param str units: Unit type # :return: units # :rtype: str # :raises ValidatorException: If units is unknown # """ # if units in [IMPERIAL_UNITS, SI_UNITS]: # return units # raise ValidatorException( # u"Unkown units '{}', must use {} or {}".format(units, IMPERIAL_UNITS, SI_UNITS) # ) # # Path: brew/utilities/temperature.py # def celsius_to_fahrenheit(temp): # """ # Convert degrees Celsius to degrees Fahrenheit # # :param float temp: The temperature in Celsius # :return: The temperature in Fahrenheit # :rtype: float # """ # return (temp * 1.8) + 32.0 . Output only the next line.
def hydrometer_adjustment(sg, temp, units=IMPERIAL_UNITS):