Instruction
stringlengths
362
7.83k
output_code
stringlengths
1
945
Next line prediction: <|code_start|> class BidirectionalIndex: NOT_FOUND = -2 def __init__(self, goals: Iterable[int]): self.m = {g: i + 1 for i, g in enumerate(sorted(g for g in goals if g > 0))} self.length = len(self.m) def forward(self, goal_id: int) -> int: if goal_id < 0: ...
new_id += 100 * ((goal_id - 1) // 100 + 1)
Predict the next line after this snippet: <|code_start|> self.m = {g: i + 1 for i, g in enumerate(sorted(g for g in goals if g > 0))} self.length = len(self.m) def forward(self, goal_id: int) -> int: if goal_id < 0: return goal_id goal_id = self.m[goal_id] new_id ...
self._update_mapping()
Given the following code snippet before the placeholder: <|code_start|> @fixture def goaltree(): return ProgressView( build_goaltree( open_(1, "Root", [2, 3], select=selected), open_(2, "With blocker", [], [4]), open_(3, "With subgoal", [4]), open_(4, "Top g...
4: {"name": "[0/1] Top goal"},
Here is a snippet: <|code_start|> 1: {"name": "[0/4] Root"}, 2: {"name": "[0/1] With blocker"}, 3: {"name": "[0/2] With subgoal"}, 4: {"name": "[0/1] Top goal"}, } def test_toggle_hide_progress(goaltree): goaltree.accept_all(ToggleProgress(), ToggleProgress()) assert goaltre...
4: {"name": "[1/1] Top goal"},
Using the snippet: <|code_start|> @fixture def goaltree(): return ProgressView( build_goaltree( open_(1, "Root", [2, 3], select=selected), open_(2, "With blocker", [], [4]), open_(3, "With subgoal", [4]), open_(4, "Top goal"), ) ) def test_no_p...
2: {"name": "With blocker"},
Given snippet: <|code_start|> @fixture def goaltree(): return ProgressView( build_goaltree( open_(1, "Root", [2, 3], select=selected), open_(2, "With blocker", [], [4]), open_(3, "With subgoal", [4]), open_(4, "Top goal"), ) ) def test_no_progr...
assert goaltree.q("name") == {
Next line prediction: <|code_start|> @fixture def goaltree(): return ProgressView( build_goaltree( open_(1, "Root", [2, 3], select=selected), open_(2, "With blocker", [], [4]), open_(3, "With subgoal", [4]), open_(4, "Top goal"), ) ) def test_n...
4: {"name": "[0/1] Top goal"},
Predict the next line for this snippet: <|code_start|> @fixture def goaltree(): return ProgressView( build_goaltree( open_(1, "Root", [2, 3], select=selected), open_(2, "With blocker", [], [4]), open_(3, "With subgoal", [4]), open_(4, "Top goal"), <|code_end...
)
Continue the code snippet: <|code_start|> @fixture def goaltree(): return ProgressView( build_goaltree( open_(1, "Root", [2, 3], select=selected), open_(2, "With blocker", [], [4]), open_(3, "With subgoal", [4]), open_(4, "Top goal"), ) ) def t...
1: {"name": "Root"},
Predict the next line for this snippet: <|code_start|> @dataclass(frozen=True) class ToggleProgress(Command): pass class ProgressView(Graph): def __init__(self, goaltree: Graph): super().__init__(goaltree) self.show_progress = False def accept_ToggleProgress(self, command: ToggleProgres...
if not self.show_progress:
Given snippet: <|code_start|> @dataclass(frozen=True) class ToggleProgress(Command): pass class ProgressView(Graph): def __init__(self, goaltree: Graph): super().__init__(goaltree) <|code_end|> , continue by predicting the next line. Consider current file imports: from dataclasses import dataclass ...
self.show_progress = False
Next line prediction: <|code_start|> @dataclass(frozen=True) class ToggleProgress(Command): pass class ProgressView(Graph): def __init__(self, goaltree: Graph): super().__init__(goaltree) self.show_progress = False def accept_ToggleProgress(self, command: ToggleProgress) -> None: ...
super().reconfigure_from(origin)
Given the following code snippet before the placeholder: <|code_start|> @dataclass(frozen=True) class ToggleSwitchableView(Command): """Switch between "only switchable goals" and "all goals" views""" class SwitchableView(Graph): """Non-persistent layer that allows to show only switchable and/or selected...
super().__init__(goaltree)
Given snippet: <|code_start|> @dataclass(frozen=True) class ToggleSwitchableView(Command): """Switch between "only switchable goals" and "all goals" views""" class SwitchableView(Graph): """Non-persistent layer that allows to show only switchable and/or selected goals""" def __init__(self, goaltree...
def q(self, keys: str = "name") -> Dict[int, Any]:
Next line prediction: <|code_start|> @dataclass(frozen=True) class ToggleSwitchableView(Command): """Switch between "only switchable goals" and "all goals" views""" class SwitchableView(Graph): """Non-persistent layer that allows to show only switchable and/or selected goals""" def __init__(self, g...
return self._only_switchable
Continue the code snippet: <|code_start|> for row_vals in result_index.values(): left: int = 0 edges: List[str] = [] phase: str = "goals" for _, new_goal_id in sorted(row_vals.items(), key=lambda x: x[0]): if isinstance(new_goal_id, int): ...
result[index] = value
Continue the code snippet: <|code_start|> new_layer.append(new_goal_name) sorted_goals.add(new_goal_name) self.layers[current_layer] = new_layer current_layer += 1 incoming_edges.update(outgoing_edges) outgoing_edges.clear() self.pos...
new_positions: Dict[GoalId, int] = {
Next line prediction: <|code_start|> "2", "a Build simple test", "3", "c", ] io = DummyIO(commands, log) db_name = ":memory:" goals = load(db_name, update_message) loop(io, goals, db_name) verify("\n".join(log), reporter=GenericDiffReporterFactory().get_first_worki...
"f Toggle",
Predict the next line after this snippet: <|code_start|> verify("\n".join(log), reporter=GenericDiffReporterFactory().get_first_working()) def test_complex_scenario(): log = [] commands = [ "r Cover all current features", "a Filter view", "a Toggle show open/closed goals", "...
"4",
Given the code snippet: <|code_start|> return command self.log.append("*USER BREAK*") raise EOFError("Commands list is empty") def test_simple_scenario(): log = [] commands = [ "r Approval testing", "a Measure coverage", "2", "a Build simple test", ...
"a Toggle zoom and unzoom",
Given the code snippet: <|code_start|> log = [] commands = [ "r Approval testing", "a Measure coverage", "2", "a Build simple test", "3", "c", ] io = DummyIO(commands, log) db_name = ":memory:" goals = load(db_name, update_message) loop(io, goal...
"z",
Given snippet: <|code_start|> # type: (GoalsData, EdgesData, OptionsData, Callable[[str], None]) -> Goals result = Goals("", message_fn) result._events.clear() goals_dict = {g[0]: g[1] for g in goals} result.goals = { i: goals_dict.get(i) for i in range(1, max(goals_di...
]
Given the following code snippet before the placeholder: <|code_start|> Select(self._first_open_and_switchable(command.root)) ) self.accept(HoldSelect()) else: self.error("This goal can't be closed because it have open subgoals") def _m...
self.error("Root goal can't be deleted")
Predict the next line after this snippet: <|code_start|># coding: utf-8 GoalsData = List[Tuple[int, Optional[str], bool]] EdgesData = List[Tuple[int, int, EdgeType]] OptionsData = List[Tuple[str, int]] class Goals(Graph): ROOT_ID = 1 def __init__(self, name: str, message_fn: Callable[[str], None] = None) -...
if self.message_fn:
Continue the code snippet: <|code_start|> return all(g.target in self.closed for g in self._forward_edges(self.selection)) def _may_be_reopened(self) -> bool: blocked_by_selected = [e.source for e in self._back_edges(self.selection)] return all(g not in self.closed for g in blocked_by_select...
def _delete_subtree(self, goal_id: int) -> None:
Here is a snippet: <|code_start|> e.target for e in self._forward_edges(next_goal) if e.target not in self.closed and e.type == EdgeType.PARENT ] front.extend(subgoals) candidates.extend(g for g in subgoals if self._switchable(g)) ...
self.edges = {k: v for k, v in self.edges.items() if goal_id not in k}
Based on the snippet: <|code_start|> def _forward_edges(self, goal: int) -> List[Edge]: return [Edge(goal, k, v) for k, v in self.edges_forward[goal].items()] def _back_edges(self, goal: int) -> List[Edge]: return [Edge(k, goal, v) for k, v in self.edges_backward[goal].items()] def _parent(...
add_to = command.add_to or self.selection
Given the code snippet: <|code_start|> if e not in visited: front.add(e.target) return lower in total def verify(self) -> bool: assert all( g.target in self.closed for p in self.closed for g in self._forward_edges(p) ), "Open goals could not be...
)
Based on the snippet: <|code_start|> self._events.append(("select", goal_id)) def accept_HoldSelect(self, command: HoldSelect): self.previous_selection = self.selection self._events.append(("hold_select", self.selection)) def q(self, keys: str = "name") -> Dict[int, Any]: de...
return any(e.source not in self.closed for e in back_edges)
Given the following code snippet before the placeholder: <|code_start|> g.target for g in self._forward_edges(goal) if g.target not in visited and self.goals[g.target] is not None ) visited.add(goal) assert visited == { x for x i...
), "Each goal must have at most 1 parent"
Given the following code snippet before the placeholder: <|code_start|> }, "All subgoals must be accessible from the root goal" deleted_nodes = [g for g, v in self.goals.items() if v is None] assert all( not self._forward_edges(n) for n in deleted_nodes ), "Deleted goals must...
result = Goals("", message_fn)
Using the snippet: <|code_start|> def accept_ToggleClose(self, command: ToggleClose) -> None: if self.selection in self.closed: if self._may_be_reopened(): self.closed.remove(self.selection) self._events.append(("toggle_close", True, self.selection)) el...
candidates: List[int] = []
Based on the snippet: <|code_start|> @dataclass(frozen=True) class ToggleOpenView(Command): """Switch between "only open goals" and "all goals" views""" class OpenView(Graph): """Non-persistent view layer that allows to switch between only-open (plus selected) and all goals""" def __init__(self, go...
super().reconfigure_from(origin)
Here is a snippet: <|code_start|> self._open = not self._open def settings(self, key: str) -> Any: if key == "filter_open": return self._open return self.goaltree.settings(key) def reconfigure_from(self, origin: "Graph") -> None: super().reconfigure_from(origin) ...
if edge[0] > 1:
Given the following code snippet before the placeholder: <|code_start|> @dataclass(frozen=True) class ToggleOpenView(Command): """Switch between "only open goals" and "all goals" views""" class OpenView(Graph): """Non-persistent view layer that allows to switch between only-open (plus selected) and all ...
self._open: bool = True
Given snippet: <|code_start|>@dataclass(frozen=True) class ToggleOpenView(Command): """Switch between "only open goals" and "all goals" views""" class OpenView(Graph): """Non-persistent view layer that allows to switch between only-open (plus selected) and all goals""" def __init__(self, goaltree: Gr...
k: {}
Continue the code snippet: <|code_start|> @pytest.fixture def trivial(): g = build_goaltree(open_(1, "Start", [], [], select=selected)) return OpenView(g) @pytest.fixture def two_goals(): g = build_goaltree(open_(1, "Open", [2], [], select=selected), clos_(2, "Closed")) return OpenView(g) def test...
assert trivial.q("name") == {1: {"name": "Start"}}
Given the following code snippet before the placeholder: <|code_start|> "select": "prev", "open": True, "edge": [(2, EdgeType.PARENT), (3, EdgeType.PARENT)], }, 2: {"name": "1", "select": "select", "open": True, "edge": []}, 3: {"name": "2", "select": None, "op...
1: {"name": "Root", "open": True, "select": None},
Using the snippet: <|code_start|> @pytest.fixture def trivial(): g = build_goaltree(open_(1, "Start", [], [], select=selected)) return OpenView(g) @pytest.fixture def two_goals(): g = build_goaltree(open_(1, "Open", [2], [], select=selected), clos_(2, "Closed")) return OpenView(g) <|code_end|> , d...
def test_open_goal_is_shown_by_default(trivial):
Given snippet: <|code_start|>@pytest.fixture def trivial(): g = build_goaltree(open_(1, "Start", [], [], select=selected)) return OpenView(g) @pytest.fixture def two_goals(): g = build_goaltree(open_(1, "Open", [2], [], select=selected), clos_(2, "Closed")) return OpenView(g) def test_open_goal_is_s...
def test_closed_goal_is_not_shown_by_default(two_goals):
Given snippet: <|code_start|>@pytest.fixture def trivial(): g = build_goaltree(open_(1, "Start", [], [], select=selected)) return OpenView(g) @pytest.fixture def two_goals(): g = build_goaltree(open_(1, "Open", [2], [], select=selected), clos_(2, "Closed")) return OpenView(g) def test_open_goal_is_s...
def test_closed_goal_is_not_shown_by_default(two_goals):
Given snippet: <|code_start|> } two_goals.accept(ToggleOpenView()) assert two_goals.q("name,open,edge") == { 1: {"name": "Open", "open": True, "edge": []} } def test_simple_open_enumeration_workflow(): e = OpenView( build_goaltree( open_(1, "Root", [2, 3], select=previou...
"open": True,
Based on the snippet: <|code_start|> 1: {"name": "Open", "open": True, "edge": [(2, EdgeType.PARENT)]}, 2: {"name": "Closed", "open": False, "edge": []}, } two_goals.accept(ToggleOpenView()) assert two_goals.q("name,open,edge") == { 1: {"name": "Open", "open": True, "edge": []} } ...
"name": "Root",
Given the following code snippet before the placeholder: <|code_start|> def test_closed_goal_is_shown_after_switch(two_goals): two_goals.accept(ToggleOpenView()) assert two_goals.q("name,open,edge") == { 1: {"name": "Open", "open": True, "edge": [(2, EdgeType.PARENT)]}, 2: {"name": "Closed", "o...
3: {"name": "2", "select": None, "open": True, "edge": []},
Given the code snippet: <|code_start|> g = build_goaltree(open_(1, "Start", [], [], select=selected)) return OpenView(g) @pytest.fixture def two_goals(): g = build_goaltree(open_(1, "Open", [2], [], select=selected), clos_(2, "Closed")) return OpenView(g) def test_open_goal_is_shown_by_default(trivia...
1: {"name": "Open", "open": True, "edge": []}
Based on the snippet: <|code_start|> @pytest.fixture def trivial(): g = build_goaltree(open_(1, "Start", [], [], select=selected)) return OpenView(g) @pytest.fixture def two_goals(): g = build_goaltree(open_(1, "Open", [2], [], select=selected), clos_(2, "Closed")) return OpenView(g) <|code_end|> ...
def test_open_goal_is_shown_by_default(trivial):
Predict the next line after this snippet: <|code_start|> } v.accept(ToggleOpenView()) # Still show: open goals, selected goals assert v.q("name,select,open") == { 1: {"name": "Root", "open": True, "select": None}, 2: {"name": "closed", "open": False, "select": "prev"}, 3: {"name":...
)
Using the snippet: <|code_start|> class WebSearchManager (object): def __init__(self, typeIconPath): self.docsetFolder = 'Docsets/WebSearch' self.docsetIndexFileName = os.path.join(self.docsetFolder, 'WebSearch.db') self.typeManager = TypeManager.TypeManager(typeIconPath) self.connection = None self.__creat...
os.mkdir(self.docsetFolder)
Predict the next line for this snippet: <|code_start|> @pytest.mark.parametrize("input, keys, output", [ (1, ["foo"], 1), ({"foo": 1}, ["foo"], 1) ]) <|code_end|> with the help of current file imports: import pytest import re from aioconsul.util import extract_attr, extract_pattern and context from other fi...
def test_extract(input, keys, output):
Given the code snippet: <|code_start|> @pytest.mark.parametrize("input, keys, output", [ (1, ["foo"], 1), ({"foo": 1}, ["foo"], 1) ]) def test_extract(input, keys, output): assert extract_attr(input, keys=keys) == output @pytest.mark.parametrize("input, keys", [ ({"foo": 1}, ["bar"]), ]) def test_ext...
with pytest.raises(TypeError):
Using the snippet: <|code_start|> class RequestHandler: def __init__(self, address, *, loop=None): self.address = parse_addr(address, proto="http", host="localhost") self.loop = loop or asyncio.get_event_loop() self.session = aiohttp.ClientSession(loop=self.loop) self.json_loader =...
async with self.session.request(method, url, **kwargs) as response:
Using the snippet: <|code_start|> class RequestHandler: def __init__(self, address, *, loop=None): self.address = parse_addr(address, proto="http", host="localhost") self.loop = loop or asyncio.get_event_loop() self.session = aiohttp.ClientSession(loop=self.loop) self.json_loader =...
status=response.status,
Next line prediction: <|code_start|> @pytest.mark.parametrize("input, expected", [ (None, (None, {})), ("foo", ("foo", {})), ({"ID": "foo"}, ("foo", {})), ({"Node": "foo"}, ("foo", {})), ({ "Node": { "Node": "foobar", "Address": "10.1.10.12", "TaggedAddre...
"TaggedAddresses": {
Continue the code snippet: <|code_start|> def bootstrap_devenv(): try: os.makedirs(".devenv") except OSError: pass if not os.path.exists(".devenv/buildrecipes-common"): subprocess.check_call([ "git", "clone", "http://github.com/simphony/buildrecipes-common....
bootstrap_devenv()
Given the code snippet: <|code_start|> def bootstrap_devenv(): try: os.makedirs(".devenv") except OSError: pass if not os.path.exists(".devenv/buildrecipes-common"): subprocess.check_call([ "git", "clone", "http://github.com/simphony/buildrecipes-common.git...
".devenv/buildrecipes-common"
Using the snippet: <|code_start|> def bootstrap_devenv(): try: os.makedirs(".devenv") except OSError: pass if not os.path.exists(".devenv/buildrecipes-common"): subprocess.check_call([ "git", "clone", "http://github.com/simphony/buildrecipes-common.git", ...
@click.group()
Predict the next line after this snippet: <|code_start|> self.assertIsInstance(key, CUBA) def test_initialization_with_keywords(self): data = {key: index + 3 for index, key in enumerate(CUBA.__members__)} container = DataContainer(**data) self.assertEqual( container, ...
with self.assertRaises(ValueError):
Based on the snippet: <|code_start|>from __future__ import print_function dict_data = {key: 3 for key in CUBA} data_container = DataContainer(dict_data) indices = [key for key in CUBA] random.shuffle(indices) def data_container_setup(): return DataContainer(dict_data) def iteration(container): for i in c...
def getitem_access(data, indices):
Here is a snippet: <|code_start|>indices = [key for key in CUBA] random.shuffle(indices) def data_container_setup(): return DataContainer(dict_data) def iteration(container): for i in container: pass def getitem_access(data, indices): return [data[index] for index in indices] def setitem_wit...
section is comparable.
Continue the code snippet: <|code_start|> # Read description with open('README.rst', 'r') as readme: README_TEXT = readme.read() # Install the compiler subprocess.check_call(["pip", "install", "-r", "build_requirements.txt"]) def create_ontology_classes(): ontology_dir = os.path.join( os.path.dirnam...
check_call(cmd_args)
Given snippet: <|code_start|> # Read description with open('README.rst', 'r') as readme: README_TEXT = readme.read() # Install the compiler subprocess.check_call(["pip", "install", "-r", "build_requirements.txt"]) def create_ontology_classes(): ontology_dir = os.path.join( os.path.dirname(os.path.ab...
class Build(build_py):
Given snippet: <|code_start|>try: PYOMO3 = False except ImportError: PYOMO3 = True base_directory = os.path.join('data', 'moosh') building_shapefile = os.path.join(base_directory, 'building') <|code_end|> , continue by predicting the next line. Consider current file imports: import pyomo.environ impor...
edge_shapefile = os.path.join(base_directory, 'edge')
Here is a snippet: <|code_start|> # Consts inp_dir = os.path.normpath(r"C:\Users\Kristof\GIT\Masterarbeit\rivus\data\haag15") out_dir = os.path.normpath(r"C:\Users\Kristof\GIT\Masterarbeit\rivus\data\haag15") EPSG_XY = 32632 # IN <|code_end|> . Write the next line using the current file imports: import geopandas impo...
buildings_apath = os.path.join(inp_dir, 'building.shp')
Here is a snippet: <|code_start|> FutureWarning, stacklevel=2) COLORS = { # (R,G,B) tuples with range (0-255) # defaults 'base': (192, 192, 192), 'building': (192, 192, 192), 'decoration': (128, 128, 128), # commodities 'Heat': (230, 112, 36), 'Cool': (0, 0, 255), 'Ele...
'restaurant': (227, 26, 28),
Predict the next line for this snippet: <|code_start|>try: PYOMO3 = False except ImportError: PYOMO3 = True base_directory = os.path.join('data', 'haag') building_shapefile = os.path.join(base_directory, 'building') edge_shapefile = os.path.join(base_directory, 'edge') <|code_end|> with the help of current fi...
vertex_shapefile = os.path.join(base_directory, 'vertex')
Based on the snippet: <|code_start|>try: PYOMO3 = False except ImportError: PYOMO3 = True base_directory = os.path.join('data', 'haag') building_shapefile = os.path.join(base_directory, 'building') edge_shapefile = os.path.join(base_directory, 'edge') vertex_shapefile = os.path.join(base_directory, 'vertex') d...
def scenario_base(data, vertex, edge):
Predict the next line for this snippet: <|code_start|>try: PYOMO3 = False except ImportError: PYOMO3 = True base_directory = os.path.join('data', 'haag15') building_shapefile = os.path.join(base_directory, 'building') edge_shapefile = os.path.join(base_directory, 'edge') to_edge_shapefile = os.path.join(base_d...
def scale_peak_demand(model, multiplier):
Predict the next line after this snippet: <|code_start|> # Consts work_dir = os.path.normpath(r"C:\Users\Kristof\GIT\Masterarbeit\rivus\data\haag15") EPSG_XY = 32632 # IN streets_filename = 'streets.shp' streets_filename_abs = os.path.join(work_dir, 'streets.shp') # OUT <|code_end|> using the current file's imports:...
edge_apath = os.path.join(work_dir, 'edgeout.shp')
Given snippet: <|code_start|>streets_filename_abs = os.path.join(work_dir, 'streets.shp') # OUT edge_apath = os.path.join(work_dir, 'edgeout.shp') vertex_apath = os.path.join(work_dir, 'vertexout.shp') streets = geopandas.read_file(streets_filename) streets = streets.to_crs(epsg=EPSG_XY) # EPSG:32632 == UTM Zone 32...
edge = edge.to_crs(epsg=4326) # World Geodetic System (WGS84)
Given snippet: <|code_start|> # Consts work_dir = os.path.normpath(r"C:\Users\Kristof\GIT\Masterarbeit\rivus\data\haag15") EPSG_XY = 32632 # IN streets_filename = 'streets.shp' streets_filename_abs = os.path.join(work_dir, 'streets.shp') # OUT edge_apath = os.path.join(work_dir, 'edgeout.shp') vertex_apath = os.path....
streets = geopandas.read_file(streets_filename)
Given the following code snippet before the placeholder: <|code_start|>try: PYOMO3 = False except ImportError: PYOMO3 = True base_directory = os.path.join('data', 'mnl') building_shapefile = os.path.join(base_directory, 'building') edge_shapefile = os.path.join(base_directory, 'edge') vertex_shapefile = os.pat...
data_spreadsheet = os.path.join(base_directory, 'data.xlsx')
Given snippet: <|code_start|>try: PYOMO3 = False except ImportError: PYOMO3 = True base_directory = os.path.join('data', 'mnl') building_shapefile = os.path.join(base_directory, 'building') edge_shapefile = os.path.join(base_directory, 'edge') vertex_shapefile = os.path.join(base_directory, 'vertex') data_spre...
edge = edge.join(total_area)
Predict the next line after this snippet: <|code_start|> # known LineStrings with length and LonLat(x-y) coordinates lines = (LineString(((11.6625881, 48.2680606), (11.6527176, 48.2493919), (11.6424179, 48.2366107), (1...
def test_pair_vertex_to_edge(self):
Given snippet: <|code_start|> COLORS = { # (R,G,B) tuples with range (0-255) # defaults 'base': (192, 192, 192), 'building': (192, 192, 192), 'decoration': (128, 128, 128), # commodities 'Heat': (230, 112, 36), 'Cool': (0, 0, 255), 'Elec': (255, 170, 0), 'Demand': (0, 255, 0), ...
'industrial': (240, 198, 116),
Here is a snippet: <|code_start|> # (R,G,B) tuples with range (0-255) # defaults 'base': (192, 192, 192), 'building': (192, 192, 192), 'decoration': (128, 128, 128), # commodities 'Heat': (230, 112, 36), 'Cool': (0, 0, 255), 'Elec': (255, 170, 0), 'Demand': (0, 255, 0), 'Gas':...
'school': (29, 103, 214),
Given the code snippet: <|code_start|>COLORS = { # (R,G,B) tuples with range (0-255) # defaults 'base': (192, 192, 192), 'building': (192, 192, 192), 'decoration': (128, 128, 128), # commodities 'Heat': (230, 112, 36), 'Cool': (0, 0, 255), 'Elec': (255, 170, 0), 'Demand': (0, 255...
'retail': (129, 162, 190),
Using the snippet: <|code_start|> COLORS = { # (R,G,B) tuples with range (0-255) # defaults 'base': (192, 192, 192), 'building': (192, 192, 192), 'decoration': (128, 128, 128), # commodities 'Heat': (230, 112, 36), 'Cool': (0, 0, 255), 'Elec': (255, 170, 0), 'Demand': (0, 255, 0...
'hospital': (129, 221, 190),
Next line prediction: <|code_start|> values = dict(row, process=key[0], commodity=key[1], direction=key[2].lower(), run_id=run_id) with connection.cursor() as curs: curs.execute(""" INSERT INTO process_commodity ...
(vertex_id, commodity_id, time_id, capacity)
Next line prediction: <|code_start|> WHERE E.run_id = %s ORDER BY 1,2; """ df = read_sql(sql, engine, params=(run_id,), index_col=['Vertex1', 'Vertex2', 'commodity'] ).unstack(level=-1).fillna(0) df = df['capacity'] elif...
WHERE V.run_id = %s
Predict the next line after this snippet: <|code_start|> # from django.contrib.auth.decorators import login_required def home(request): return render_to_response("home/base.html", context_instance=RequestContext(request)) <|code_end|> using the current file's imports: import tim...
def post(request, post_id):
Given snippet: <|code_start|> # from django.contrib.auth.decorators import login_required def home(request): return render_to_response("home/base.html", context_instance=RequestContext(request)) <|code_end|> , continue by predicting the next line. Consider current file imports: i...
def post(request, post_id):
Given the following code snippet before the placeholder: <|code_start|> class LoginForm(forms.Form): email = forms.EmailField(widget=forms.TextInput( attrs={'size': '48', 'class': 'form-control'})) password = forms.CharField(max_length=32, widget=forms.PasswordInput) class Registration...
if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
Continue the code snippet: <|code_start|> # A CharField that checks that the value is a valid email address. email = forms.EmailField(widget=forms.TextInput( attrs={'size': '48', 'class': 'form-control'})) Body = forms.CharField(widget=forms.Textarea( attrs={'cols': 50, 'rows':...
password2 = forms.CharField(widget=forms.PasswordInput(attrs=dict(required=True, max_length=30, render_value=False)), label=_("Password (again)"))
Based on the snippet: <|code_start|> class BlogEntriesTest(TestCase): def setUp(self): self.c = Client() self.author = User.objects.create(username="Yashwanth", email="yashwanth@agiliq.com", password="yashwanth")...
def test_blog_access(self):
Next line prediction: <|code_start|> response = self.c.get(reverse('post', args=[self.post.id])) self.assertEqual(200, response.status_code) def test_blog_post_add_comment_access(self): response = self.c.get(reverse('add_comment', args=[self.post.id])) self.assertEqual(200, response....
def test_blog_recent_posts_access(self):
Continue the code snippet: <|code_start|> class TraverseTreeDepthFirst(CreateTree): def traverse(self, marker, tree, node): marker.append(node) tree.stats.traversed_nodes += 1 tree.sync() for child in node.children: self.traverse(marker, tree, child) <|code_end|> . Use ...
def run(self, **kwargs):
Predict the next line for this snippet: <|code_start|> class TestSequenced(unittest.TestCase): def test_ascending(self): generator = SequencedDataGenerator(dict(n=8)) self.assertEquals(next(generator.values), 0) self.assertEquals(list(generator.values), [1, 2, 3, 4, 5, 6, 7]) def test_...
n=8,
Predict the next line for this snippet: <|code_start|> logger = logging.getLogger(__name__) class TestScenes(TestContainer): def test_check_scenes(self): home_page = pages.Home(self._browser.driver) home_page.goto() scene_links = home_page.scene_links self.assertEqual(len(self._c...
"not all client processes (scenes) were successfully connected")
Next line prediction: <|code_start|> class InsertionSort(Sort): def sort(self, **kwargs): array = kwargs['container'] right_marker = array.create_marker("right", 0) left_marker = array.create_marker("left", 0) left1_marker = array.create_marker("left+1", 0) <|code_end|> . Use curren...
array.sync()
Continue the code snippet: <|code_start|> class TreeMultiMarker(TreeCreateNode): def run(self, **kwargs): tree = kwargs['container'] marker = tree.create_multi_marker("multi marker") super().run(**kwargs) tree.sync() marker.append(self.nodes[0]) marker.append(self.no...
marker.remove(self.nodes[1])
Continue the code snippet: <|code_start|> class BoobleSort(Sort): def sort(self, **kwargs): array = kwargs['container'] changed = True right_marker = array.create_marker("right", array.size()-1) array.sync() right = array.size() while changed: changed = F...
right -= 1
Given the code snippet: <|code_start|> logger = logging.getLogger(__name__) class Backend(ResourceFactory): @staticmethod def create(config_path): return LocalBackend(config_path) class LocalBackend(Resource): def __init__(self, config_path): logger.info("setting up backend") sel...
self._process.start()
Next line prediction: <|code_start|> logger = logging.getLogger(__name__) class Backend(ResourceFactory): @staticmethod <|code_end|> . Use current file imports: (import time import logging import multiprocessing from alvi import server from alvi.tests.resources.base import ResourceFactory from alvi.tests.resourc...
def create(config_path):
Using the snippet: <|code_start|> logger = logging.getLogger(__name__) class Backend(ResourceFactory): @staticmethod def create(config_path): <|code_end|> , determine the next line of code. You have imports: import time import logging import multiprocessing from alvi import server from alvi.tests.resources.b...
return LocalBackend(config_path)
Here is a snippet: <|code_start|> logger = logging.getLogger(__name__) class TestTree(TestContainer): options = dict(n=7, parents="0, 0, 1, 1, 4, 4") def test_create_node(self): page = pages.Tree(self._browser.driver, "TreeCreateNode") page.run(options=TestTree.options) self.assertEq...
node_data = sorted(page.svg.node_data, key=lambda d: d['id'])
Predict the next line for this snippet: <|code_start|> class RandomDataGenerator(DataGenerator): def _values(self): qty = self.quantity() <|code_end|> with the help of current file imports: import random from alvi.client.data_generators.base import DataGenerator and context from other files: # Path: al...
return (random.randint(1, qty) for _ in range(qty)).__iter__()
Predict the next line after this snippet: <|code_start|> logger = logging.getLogger(__name__) class TestArray(TestContainer): def test_array(self): cartesian_scene = pages.Cartesian(self._browser.driver, "ArrayCreateNode") cartesian_scene.run(options=dict(n=4)) self.assertEqual(4, len(car...
node_values = [d['y'] for d in cartesian_page.svg.node_data]
Predict the next line after this snippet: <|code_start|> def sort(self, **kwargs): array = kwargs['container'] right_marker = array.create_marker("right", 0) left_marker = array.create_marker("left", 0) left_h_marker = array.create_marker("left+h", 0) array.sync() h = ...
array.sync()
Next line prediction: <|code_start|> logger = logging.getLogger(__name__) class Browser(ResourceFactory): @staticmethod def create(): return LocalBrowser() class LocalBrowser(Resource): <|code_end|> . Use current file imports: (import logging from alvi.tests.resources.base import Resource from alvi...
def __init__(self):
Based on the snippet: <|code_start|> logger = logging.getLogger(__name__) class Browser(ResourceFactory): @staticmethod def create(): return LocalBrowser() class LocalBrowser(Resource): def __init__(self): logger.info("setting up browser") #TODO config <|code_end|> , predict the ...
self._driver = webdriver.Firefox()